@21epub/dynamic-loader
v0.1.1
Published
Dynamic load module on demand
Downloads
73
Keywords
Readme
@21epub/dynamic-loader
Dynamic load module on demand for epub
Intro
Dynamic module loader to import module for webpack
TODO: Dynamic js or css loader
Feature
- [x] Easy-to-use
- [x] Loader for webapck module
- [ ] Loader for online js or css
Install
npm install --save @21epub/dynamic-loader
Usage
import { DynamicModuleLoader } from '@21epub/dynamic-loader'
const loaders = [
{
modules: ["module1", "module2"],
loader: async () => {
await import('url/to/module1');
await import('url/to/module2')
}
},
{
modules: 'module3',
loader: async () => {
await import('url/to/module3');
}
}
]
const dynamicLoader = new DynamicModuleLoader(loaders)
...
dynamicLoader.loadAll().then( callbacks => console.log(callbacks))
Documents
Developing and running on localhost
First install dependencies and then install peerDeps for parcel dev:
npm install
npm run install-peers
To run Example in hot module reloading mode:
npm start
To create a bundle library module build:
npm run build
Running
Open the file dist/index.html
in your browser
Testing
To run unit tests:
npm test
License
MIT © 21epub