wezom-module-loader
v2.0.4
Published
Async module loader
Downloads
18
Readme
wezom-module-loader
Usage example
entry.js
import ModuleLoader from 'wezom-module-loader';
const moduleLoader = new ModuleLoader({
debug: process.env.NODE_ENV !== 'production', // default false
importPromise: moduleName => import('./_loaders/' + moduleName),
initSelector: '.js-init', // default '.js-init'
initFunctionName: 'loaderInit', // default 'loaderInit'
loadingClass: '_module-loading', // default '_module-loading'
loadedClass: '_module-loaded', // default '_module-loaded'
list: {
'pluginA-loader': 'form',
'pluginB-loader': '[data-mfp]',
'pluginC': ['[data-lozad]', 'picture']
}
})
moduleLoader.init()
_loaders/pluginA-loader.js
import coreInitMethodForPluginA from '../_modules/coreA'
function loaderInit ($elements) {
coreInitMethodForPluginA($elements)
}
export {loaderInit}
_modules/coreA.js
import dependence1 from 'dependence-1'
import dependence2 from 'dependence-2'
import dependence3 from 'dependence-3'
function coreInitialize ($elements) {
// your code
}
export default coreInitialize