https://github.com/morlay/babel-plugin-transform-ensure-ignore
https://github.com/morlay/babel-plugin-transform-ensure-ignore
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/morlay/babel-plugin-transform-ensure-ignore
- Owner: morlay
- Created: 2016-01-05T13:43:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-05T13:57:19.000Z (over 10 years ago)
- Last Synced: 2025-04-01T21:46:09.260Z (about 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## babel-plugin-transform-ensure-ignore
[](https://travis-ci.org/morlay/babel-plugin-transform-ensure-ignore)
[](https://npmjs.org/package/babel-plugin-transform-ensure-ignore)
[](https://david-dm.org/morlay/babel-plugin-transform-ensure-ignore)
[](https://npmjs.org/package/babel-plugin-transform-ensure-ignore)
`require.ensure` is cool, but we don't need it in Node env.
see more
this plugin will help to transform code below:
```js
require.ensure([], (require) => {
require.include('./some-module');
require('./some-module');
});
```
to
```js
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;
```js
{
"env": {
"node": {
"plugins": [
"babel-plugin-transform-ensure-ignore"
]
}
}
}
```
or use with `babel-register` in require-hooks
```js
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`