Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Using external helpers plugin rather than preset #16

Closed
madeleineostoja opened this issue Nov 26, 2015 · 5 comments
Closed

Using external helpers plugin rather than preset #16

madeleineostoja opened this issue Nov 26, 2015 · 5 comments

Comments

@madeleineostoja
Copy link

Because of situations like #12 and #3 I'm trying to use the es2015 preset with the external-helpers-2 plugin in my .babelrc, as suggested in the README. But rollup-plugin-babel still complains about using es2015 rather than es2015-rollup. Is it possible to use es2015 + external-helpers?

@Rich-Harris
Copy link
Contributor

es2015 includes the CommonJS transformer, which makes Rollup's job impossible (no ES6 modules). Because of that, the first .babelrc file Babel finds (it stops looking once it's found the nearest one) can't have the es2015 preset.

The best bet is probably to have a .babelrc in the root of your project with es2015, and another src/.babelrc (or whatever) that uses es2015-rollup. Your test runner/Gulp/whatever won't see src/.babelrc, and Rollup won't see the root .babelrc. Let me know if that works, I haven't tried it yet!

@madeleineostoja
Copy link
Author

No luck, getting

Error: External helpers are not enabled. Please add the "external-helpers-2" plugin or use the "es2015-rollup" preset. See https://github.com/rollup/rollup-plugin-babel#TK for more information

with es2015-rollup specified in a local .babelrc (in src dir). And if I specify the preset in the plugin directly as well as have a local .babelrc it complains about the root .babelrc

Rich-Harris added a commit that referenced this issue Nov 28, 2015
@Rich-Harris
Copy link
Contributor

Ah, I figured out what's going on here – it runs the 'preflight checks' (ensuring module transformation is disabled and external helpers are enabled) in the cwd, which means it picks up the root .babelrc. Changed so that it runs preflight checks for each file before transpilation. Slight overhead but only way to ensure correct configuration throughout.

@Rich-Harris
Copy link
Contributor

Meant to add – released 2.2.0 with a fix

@madeleineostoja
Copy link
Author

Awesome, thanks! Might be worth explicitly documenting this pattern in the readme? I feel it's a reasonably common use-case, needing to use es2015 for some things in a codebase and rollup for others.

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

No branches or pull requests

2 participants