@21epub/dynamic-loader
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@21epub/dynamic-loader

Dynamic load module on demand for epub

NPM JavaScript Style Guide Build Status Codecov

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

Readme

Keywords

Package Sidebar

Install

npm i @21epub/dynamic-loader

Weekly Downloads

6

Version

0.1.1

License

MIT

Unpacked Size

34.6 kB

Total Files

13

Last publish

Collaborators

  • csj117
  • gary.guzy
  • zhangwei0126
  • dxsix
  • wagon1104
  • ongyuxing