I am trying to use the babel transpiler to use ES6 in a project, but i'm struggling with something quite unusual : I'm working with an enhanced ES5 js codebase that contains imports and export directives.
Here is an example :
import Widget from 'ponent:ponent-widget';
//ES5 code here
export default "something"
I would like to keep those imports, but transpile the rest of detected ES6 features.
I did not find a way to do it so far... :/
Do you know if something like that could be possible?
Thanks in advance!
I am trying to use the babel transpiler to use ES6 in a project, but i'm struggling with something quite unusual : I'm working with an enhanced ES5 js codebase that contains imports and export directives.
Here is an example :
import Widget from 'ponent:ponent-widget';
//ES5 code here
export default "something"
I would like to keep those imports, but transpile the rest of detected ES6 features.
I did not find a way to do it so far... :/
Do you know if something like that could be possible?
Thanks in advance!
Share Improve this question asked Mar 18, 2017 at 22:10 gwenpgwenp 231 silver badge6 bronze badges 2- 2 Don't include module transpilation if you don't need it. Have a look at the documentation for how to configure Babel: babeljs.io/docs/plugins . – Felix Kling Commented Mar 18, 2017 at 22:18
- Ok I got it. I was using the "env" preset, but I did not find a way to use this preset without module transpilation, so I configured my babelrc with hand picked plugins. Thank you very much! – gwenp Commented Mar 18, 2017 at 23:44
1 Answer
Reset to default 8babel-preset-env
has the option modules
. Setting it to false
disables transformation of modules (import/export etc.).
The .babelrc
would look like this:
{
"presets": [
["env", { "modules": false }]
]
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745308428a4621854.html
评论列表(0条)