A babel plugin to strip '/jsnext' path from importing module names. Used to switch entry point in production.
Before:
import A from 'packageA/jsnext'
import B from 'packageB/jsnext.js'
import C from 'packageC/jsnext-foo-bar'
After:
import A from 'packageA'
import B from 'packageB/jsnext.js'
import C from 'packageC/jsnext-foo-bar'
It's similar to rollup.js's jsnext:main. It's designed for switching entry points of your microservices of babel / flow-typed npm modules.
└─┬ your-service1
├── your-module1 (ES module)
├── your-module2 (ES module)
You may want to use untranspiled codes of your modules1
and your modules2
in developing your service1
for type.
However, simply importing untranspiled codes will not go well in generating transpiled files.
babel src -d dist
It cannot transform node_modules/*
by default and fails.
Then, let's add jsnext
entry.
The skeleton of your module 1/2 will be like the following.
├── index.js (transpiled entry point)
├── jsnext.js (untranspiled entry point)
...
You can import the untranspiled code with /jsnext
import mod1 from 'your-module1/jsnext'
In the transpilation phase, the /jsnext
will be stripped by this transform.
$ npm install babel-plugin-transform-strip-jsnext
.babelrc
{
"plugins": ["transform-strip-jsnext"]
}
$ babel --plugins transform-strip-jsnext script.js
require('babel-core').transform('code', {
plugins: ['transform-strip-jsnext']
});
MIT