1.0.0 • Published 6 years ago

anonmd v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

anonmd

Simple AMD require and define implementation designed to load from <script> tags that already exist on the page.

Why?

Rollup's experimentalCodeSplitting option supports chunking and AMD output, but outputs anonymous modules using filenames for dependencies. I couldn't find an AMD loader that handled that for the case where all the files are manually included in the right order using <script> tags, so here we are.

Example

<script src="anonmd.js"></script>
<script src="./common.js"></script>
<script src="./app.js"></script>
<script>
    require("./app.js");
</script>

Usage w/ rollup

  1. Set experimentalCodeSplitting to true.
  2. Provide an array of files for input.
  3. Set output.format to "amd" and let 'er rip.

For ease of writing your HTML & <script> includes you'll probably also want to set output.chunkFileNames to something like "[name].js" so they don't include a hash and keep changing.

Prior Art

License

MIT