@21epub/dynamic-loader 中文文档教程
@21epub/dynamic-loader
epub 动态加载模块
Intro
导入模块的动态模块加载器
为 webpack TODO :动态 js 或 css 加载器
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
首先安装依赖项,然后为 parcel dev 安装 peerDeps:
npm install
npm run install-peers
在热模块重新加载模式下运行示例:
npm start
创建一个包库模块构建:
npm run build
Running
打开文件 dist/index.html
在你的浏览器
Testing
运行单元测试:
npm test
License
MIT © 21epub
@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