GETTING STARTED

No build step

Everything in @amojs.dev/core is plain JavaScript with JSDoc types, shipped raw. A browser can load it directly — no bundler, no transform, no configuration. The compiler only makes the same code smaller and faster.

An import map and a module

Map the bare specifier to a url and import as usual. From a CDN:

index.html
<script type="importmap">
  { "imports": { "@amojs.dev/core": "https://esm.sh/@amojs.dev/core" } }
</script>
<script type="module" src="./app.js"></script>

Or from your own node_modules, served statically:

index.html
<script type="importmap">
  {
    "imports": {
      "@amojs.dev/core": "/node_modules/@amojs.dev/core/dist/browser.js"
    }
  }
</script>

One request instead of seven

Raw ESM has no bundler, so an import chain is the network cost: loading the source files one by one costs seven requests, three levels deep. The package therefore ships prebuilt single-file twins — same code, a different url:

FILEREPLACESMIN + GZIP
dist/browser.js@amojs.dev/core3.3 KB — parser included, for uncompiled apps
dist/browser-runtime.js/runtime, /compiled2.5 KB — no parser, for compiled output

One url for core

Core keeps module-level state — the scheduler, the current owner — so two copies on one page do not interoperate. A compiled app maps both subpaths to the same file:

index.html
<script type="importmap">
  {
    "imports": {
      "@amojs.dev/core/runtime":  "/node_modules/@amojs.dev/core/dist/browser-runtime.js",
      "@amojs.dev/core/compiled": "/node_modules/@amojs.dev/core/dist/browser-runtime.js"
    }
  }
</script>

You rarely write this by hand: amo build vendors core next to your output and rewrites the imports, so a built site needs no import map at all.

When to compile

Development, demos, teaching, a page that will never grow: no build is the honest default. Production: amo build, for the 1.98 KB all-in figure and the parser gone from the bundle. The source is identical either way, and the test suite runs every fixture in both modes.