babel-plugin-transform-ensure-ignore

require.ensure ignore

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-transform-ensure-ignore
0.1.07 years ago7 years agoMinified + gzip package size for babel-plugin-transform-ensure-ignore in KB

Readme

babel-plugin-transform-ensure-ignore

Build Status NPM Dependencies License
require.ensure is cool, but we don't need it in Node env.
see more
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