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

Babel helpers are bundled into the output file.

zhangshme opened this issue · comments

rollup.config.js
image

If I add @babel/runtime-corejs3 as a dependency. Babel helpers are bundled in, without any import.
image

But when I remove @babel/runtime-corejs3 from the dependencies, output file looks like this
image

Same config, different outputs. I tried to add @babel/runtime-corejs3 to the rollup external field, but had no difference.

Could someone explain this? Thanks!

Same config, different outputs.

I suspect that you could see some warnings about rollup's inability to resolve @babel/runtime-corejs3 when you hadn't it installed.

I tried to add @babel/runtime-corejs3 to the rollup external field, but had no difference.

That's because those imports are using "deep paths". With @babel/runtime-corejs3 added to external you have only added literally @babel/runtime-corejs3 to externals, not its subdirectories etc. I personally deal with this problem like this.

Also - runtimeHelpers & externalHelpers arent supposed to be used together. You should use only one of them.

Appreciate to your reply.

I suspect that you could see some warnings about rollup's inability to resolve @babel/runtime-corejs3 when you hadn't it installed.

Yes, there are some warnings actually. So, can I say that missing the corejs3 dependency cause the output difference?

I personally deal with this problem like this.
Also - runtimeHelpers & externalHelpers arent supposed to be used together.

Thanks. I've updated my rollup config like this, and worked as I expected.

But there comes another problem. When I import my bundled iife-format file to one project, it throws an error while executing.
image

rollup.config.js
image

Could you please give me some hints?

image

_export is used before it is declared. But how could this happen?

I dont actually see where is used before its value is assigned. To get more help regarding this you'd have to share a repository with the issue reproduced in it - without this it's guesswork.

Very appreciate to your patience. I've created a repo. Hope this will not take you too much time. Thanks!

The problem for sure is not in this plugin because it's sole responsibility is to transform single files with Babel. The issue ain't that easy to track down BUT my best guess is that rollup-plugin-commonjs fails to convert core-js properly (or rather it doesn't handle circular dependencies well, as core-js seems to have a TON of them). I would suggest reporting it over there.

Got it. Thanks a lot!

@Andarist Thanks for you help. I modified my rollup.config.js like #254 mentioned, and the problem solved.