babel-plugin-transform-ensure-ignore
v0.1.0
Published
require.ensure ignore
Downloads
2,764
Readme
babel-plugin-transform-ensure-ignore
require.ensure
is cool, but we don't need it in Node env.
see more https://webpack.github.io/docs/code-splitting.html#defining-a-split-point
this plugin will help to transform code below:
require.ensure([], (require) => {
require.include('./some-module');
require('./some-module');
});
to
require('./some-module');
Configure it in .babelrc
for node, we could ignore the requirement when run test in node or build server render app.
Then we run babel with BABEL_ENV=node
will active this plugin;
{
"env": {
"node": {
"plugins": [
"babel-plugin-transform-ensure-ignore"
]
}
}
}
or use with babel-register
in require-hooks
require('babel-register')({
'plugins': [
'babel-plugin-transform-ensure-ignore'
]
});
Or with cli like other plugin used.
Notice:
- Don't use this in webpack system
- make sure the correct usage of
require.ensure