isomorphic (browser/node) TypeScript / JavaScript loader
- ESM, TypeScript 4.4, JavaScript (ES2021)
- Single file, zero dependencies, 321K of readable JS
- Stack traces
- Module packaging/publishing (incomplete)
- CommonJS, JSX, TSX
- Import cycles (use madge to get rid of them, it makes the code cleaner anyway)
- Type checking (use the full
tsc
for that) - see TODO
- Copy t348.mjs to your project
- Use
node --experimental-loader=./t348.mjs your-app.ts [args]
to launch your application
- Add the following to your HTML:
<head>
<script src="t348.mjs" type="module" data-global-repo="./t348repo/t0$HASH.ts"></script>
<script src="app.js" type="text/typescript"> (OR CODE WITH NEWLINES HERE) </script>
</head>
TODO document this
(yes it includes incomplete package manager-like functionality)
TODO document this
(TLDR: if you import files by hash, you don't need versions. for public use I need to make hashes longer though, lol)
export T348_GLOBAL_REPO='https://repo.website/t0$HASH.js'
export T348_GLOBAL_REPO_PUBLISH='https://repo.website/?name=t0$HASH.js'
node t348.mjs t348pack yourModule.js
> t0aAa1bBb2.js
import { yourFunction } from 't0aAa1bBb2.js' // will try to resolve from FS first, then from global repo
Transpiling: manually stripped down sucrase@3.21.0
- more docs/examples
- automate sucrase feature removal, update to latest version
- bring JSX back? (I don't need it. Use naked-preact instead)
- publish module repo and make it more web-scale lol
- more tests
madge --warning --circular --extensions ts,js --image deps-circular.svg <ENTRYPOINT/FOLDER>