JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q45307F

Package Exports

  • @hackbg/ganesha
  • @hackbg/ganesha/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hackbg/ganesha) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

"The very day I was born I made my first mistake,
and by that path have I sought wisdom ever since."
                                   - William Buck

Ganesha

Tools for modern literate programming with ECMAScript-based languages and Markdown

Made with ๐Ÿงก at Hack.bg.

File format

Ganesha extracts fenced code blocks from Markdown files. It also supports loading regular TypeScript without an intermediate compilation step (no more running tsc on every change!)

# My literate program

This text will be ignored
but this code will be executed:
  
```typescript
console.log("Hello world!")
```

Module loading

Use ganesha-node to run a Node.js process with Ganesha support.

  • This allows TypeScript files to be compiled on demand to the appropriate JavaScript module format.
  • Markdown files can be loaded as if they were regular source files. The embedded code blocks are compiled and the surrounding text is ignored.
npm install --save @hackbg/ganesha
ganesha-node my-typescript-program.ts
ganesha-node my-literate-program.ts.md

Frontend bundling

Ganesha currently provides a Rollup plugin that can be used in Rollup or Vite to compile literate modules for the browser.

index.html:

<script type="module" src="./script"></script>

script.ts.md:

This is an example literate frontend script:
```typescript
console.log('Hello, world!')
```

vite.config.js:

import { defineConfig } from 'vite'
import ganesha from '@ganesha/rollup'
export default defineConfig({ plugins: [ ganesha() ] })

IDE integration

Help wanted!

A language server is currently in development.

(LSP sounds is a great idea, but I found the implementation to be obfuscated beyond belief)

Comparison with alternatives

Feature Ganesha esmo/esno ts-esnode ts-node
Compile TypeScript on demand ๐ŸŸฉ yes ๐ŸŸฉ yes ๐ŸŸฉ yes ๐ŸŸฉ yes
Literate modules ๐ŸŸฉ yes โŒ no โŒ no โŒ no
Honors compilerOptions.paths ๐ŸŸฉ yes โŒ no ? ?
Single entrypoint for CJS and ESM ๐ŸŸฉ yes โŒ no โŒ no โŒ no
Depends on esbuild binary module ๐ŸŸฉ no โŒ yes ๐ŸŸฉ no ๐ŸŸฉ no
Built-in hot reloader โณ WIP โŒ no โŒ no โŒ no

Known issues

See doc/GRIPES.md