gwenp
gwenp

Reputation: 23

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!

Upvotes: 2

Views: 2573

Answers (1)

Michael Jungo
Michael Jungo

Reputation: 32982

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

Upvotes: 8

Related Questions