0.0.3 • Published 9 years ago
babel-plugin-remove-import-js-extension v0.0.3
babel-plugin-remove-import-js-extension
This Babel plugin allows you to remove .js and .jsx extensions from JavaScript import statements.
Why this plugin ?
If you too are using the Google Closure Compiler to transpile ES5 to ES6, you should have noticed that it requires you to leave off the .js entension for modules. (Sources: Here). For instance,
$ java -jar closure-compiler-v20160822.jar --language_in=ECMASCRIPT6 --js main.js --language_out=ES5import Mylib from './myLib.js' // Will throw "ERROR - namespace never provided"
import Mylib from './myLib' // Won't throw 🕶Installation
$ npm install babel-plugin-remove-import-js-extensionExample
Input
import Mylib from './myLib.js'
import MyFancyComponent from './MyFancyComponent.jsx'Out
import Mylib from './myLib'
import MyFancyComponent from './MyFancyComponent'Usage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["babel-plugin-remove-import-js-extension"]
}Via CLI
$ babel --plugins babel-plugin-remove-import-js-extension script.jsVia Node API
require("babel-core").transform("code", {
plugins: ["babel-plugin-remove-import-js-extension"]
});0.0.3
9 years ago