0.1.3 • Published 7 years ago
cerebral-module-loader v0.1.3
this webpack pre-loader will import signals and actions once they are referenced (cerebral v2)
how-to
yarn add cerebral-module-loader
at webpack.config.js
[ ... ]
module: {
rules: [
{
enforce: 'pre', // < this must be set, or it will not work
test: /\.js$/,
exclude: /node_modules/,
loader: 'cerebral-module-loader',
options: { // < these are defaults to be used, provide an override if needed
productivityWarning: false, // will emit warning if this loader finds module attribtes that could be autoloaded instead
dirnames: {
modules: 'modules',
signals: 'signals',
actions: 'actions',
factories: 'factories',
},
}
},
{
test: /\.js$/,
exclude: /node_modules/,
loaders: 'babel-loader'
},
[ ... ]
why this exists
To speed up dev process
Todo:
- ?
How it does what it does?
if webpacks loaded file is determined to be a part of cerebral module if this module has signals or actions (based on commonly used cerebral module folder structure (see example-project)) then file is parsed into AST and this loader looks into arrays and objects for unreferenced identifiers, that could be auto-included from signals or actions or..
Bugs
webpacks define plugin plugin defined are also "unreferenced identifiers"