2.0.4 • Published 6 years ago

wezom-module-loader v2.0.4

Weekly downloads
18
License
ISC
Repository
bitbucket
Last release
6 years ago

wezom-module-loader

JavaScript Style Guide

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
2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago