Using external helpers plugin rather than preset
Closed this issue · 5 comments
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!
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
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.
Meant to add – released 2.2.0 with a fix
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.