JavaScript library example using Emscripten
dist/my-lib.js
is built for modern browsers and bundlers.
- APIs are exported as JavaScript modules (ESM)
- Library users use this with
import
syntax in JavaScript
- Library users use this with
- Uses WebAssembly for performance
dist/legacy/my-lib.js
is build for compatibility.
- APIs are exported in global scope
- Library users use this
<script>
tag before main programs
- Library users use this
- Doesn't use WebAssembly
- POSIX shell
- GNU Make 4.2.1
- Emscripten 3.1.8
- Node.js 14.18.2
- npm 6.14.15
npm install
npm run prepare
npm run build
npx serve
Then open demo.html
or demo-legacy.html
in your browsers and check DevTool
console output.
deno run demo-deno.js