amd-script
v1.1.0
Published
Load anonymous AMD modules, reasonably
Downloads
4
Readme
amd-script
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="amd-script.js"></script>
<script src="./common.js"></script>
<script src="./app.js"></script>
<script>
require("./app.js");
</script>
Usage w/ rollup
- Set
experimentalCodeSplitting
to true. - Provide an array of files for
input
. - 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