0.1.1 • Published 3 years ago

@21epub/dynamic-loader v0.1.1

Weekly downloads
28
License
MIT
Repository
github
Last release
3 years ago

@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

  • Easy-to-use
  • 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

0.1.1

3 years ago

0.1.0

3 years ago