简体   繁体   中英

Babel : turn off import directives transpilation

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 'component:component-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!

babel-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 }]
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM