Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babel natively supports this now #8

Closed
avindra opened this issue Aug 5, 2016 · 9 comments
Closed

Babel natively supports this now #8

avindra opened this issue Aug 5, 2016 · 9 comments

Comments

@avindra
Copy link
Contributor

avindra commented Aug 5, 2016

Check this most recent change:

https://github.com/babel/babel/blob/master/CHANGELOG.md#loose-and-modules-options-for-babel-preset-es2015-3331-3627

I think you should updated this package to use :

{
  presets: [
    ["es2015", { "modules": false }]
  ]
}

And encourage other users to do the same on the readme. What do you say?

@bartekus
Copy link
Member

bartekus commented Aug 5, 2016

That's pretty interesting, perhaps this would be the perfect solution:

// for loose and native modules
{
  presets: [
    ["es2015", { "loose": true, "modules": false }]
  ]
}

@avindra
Copy link
Contributor Author

avindra commented Aug 6, 2016

I'm honestly not sure if turning on loose mode would be a good idea, even after reading this article:

http://www.2ality.com/2015/12/babel6-loose-mode.html

@bartekus
Copy link
Member

bartekus commented Aug 6, 2016

Yeah after looking at what Alex had to say about loose mode I agree with you about it not being a good idea at all here. That being said, I'll roll-out the new version with:

{
  presets: [
    ["es2015", { "modules": false }]
  ]
}

implemented.

@taion
Copy link

taion commented Aug 9, 2016

You should deprecate this package actually – the recommended approach now is for users to directly use the preset with options, to have more flexibility in e.g. not having to pull down yet another npm dependency just to add loose mode.

@ghost
Copy link

ghost commented Aug 17, 2016

Wouldn't the above configuration also break ES2015 modules for stuff that currently still needs to transpile modules? E.g. consider gulpfile.babel.js, webpack.config.babel.js, …

@bartekus
Copy link
Member

@avindra & @taion thank you gentlemen for the heads up and recommendation as per which I've deprecated this package in favour of the proper implementation.
This package will now return

{
  presets: [
    ["es2015", { "modules": false }]
  ]
}

while also advising users to abandon it.

@Kdex After a week of testing I'm fairly confident that the replacement implementation is producing exactly the same results as the old way did and as such there should not be any differences being experianced by the end user.

I will now close this issue but please feel free to reopen it should you still find a need to do so.
Cheers!

@ghost
Copy link

ghost commented Aug 17, 2016

@bartekus I've tested this, too. If your build pipeline doesn't contain any processes whose configurations need to be transpiled themselves, you're fine.

But as soon as you instruct babel not to transpile any modules, such processes will fail, since import isn't natively supported by node yet.

Give it a try; disable module transpilation in your .babelrc and watch your ES2015+ gulpfiles or ES2015+ webpack configuration files break.

@amir20
Copy link

amir20 commented Aug 17, 2016

@Kdex I had the same problem with my tests via jest. I was able to get it to work by changing the configuration for env=test.

.babelrc

{
  "presets": [
    "react",
    ["es2015", {"modules": false}]
  ],
  "env": {
    "test": {
      "plugins": ["transform-es2015-modules-commonjs"]
    }
  }
}

Maybe you can do something similar for gulp.

@tamlyn
Copy link

tamlyn commented Sep 13, 2017

What about CLI usage?

I want to compile both a version with plan ES5 and one with ES5 + ES modules. It doesn't appear that you can pass options to a preset via the CLI interface (please say I'm wrong).

So the next best option is:

babel-cli src/ --preset es2015 --out-dir dist/
babel-cli src/ --preset es2015-native-modules --out-dir esm/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants