@21epub/dynamic-loader

Dynamic load module on demand

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@21epub/dynamic-loader
000.1.12 years ago2 years agoMinified + gzip package size for @21epub/dynamic-loader in KB

Readme

@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