rollup / rollup-plugin-babel

This package has moved and is now available at @rollup/plugin-babel / https://github.com/rollup/plugins/tree/master/packages/babel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Helpers are inlined when using 'externalHelpers'

aparajita opened this issue · comments

The bug reported in #245 remains. Using a global babelHelpers (as documented in this plugin's README) is currently not possible, and of course should be.

Here's the problem:

if (helpers !== RUNTIME) {
transformOptions = addBabelPlugin(transformOptions, helperPlugin);
}

Line 108 seems wrong.

  • If I run the code through babel, it's doing the right thing: generating babelHelpers.classCallCheck, etc.
  • I've got externalHelpers set to true in the rollup config.
  • I've checked the result of preflightCheck and it's correctly returning EXTERNAL.

But because line 108 does not check if helpers is EXTERNAL, an import is being added to the generated code that results in the helpers being inserted at the top of the generated code. If I change line 108 to:

if (helpers === INLINE) {

then the code is correct, the calls to the external babelHelpers remain.

Could u prepare a sample repo showcasing the problem? It would help tremendously as I could get into fixing this quicker.

Sure, I'll put something together today.

I noticed this too, and it seems to have started when I upgraded to babel7 and rollup-plugin-babel 4.0.3 from v3.0.7.

Yes, it's a regression that appeared somewhere during that upgrade.

Here's a reduction.

npm i
gulp compile
gulp compile-fixed

Notice that gulp compile generates the inlined helpers, whereas gulp compile-fixed uses the global babelHelpers. The only difference between them is I'm using a fixed rollup-plugin-babel that changes the line I mentioned.
issue-295.zip

Fixed in 4.3.2, could you confirm it?

Fixed, thank you!