-
-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
It should be clarified that plugin-commonjs should be placed before plugin-babel #622
Comments
Thanks for the issue. Happy to review a PR which adds this to the README. |
I came across this issue while running into problems with commonjs & babel - I was actually running into a similar issue but I found that often it doesn't work whichever way around you have the plugins. For example, if you have syntax like JSX (which the commonjs plugin can't parse), you have to put babel before commonjs. But if your commonjs code requires things like the typeof helper reported above, then commonjs has to come before babel. I've ended up having to include the babel plugin twice in my config (once before commonjs, once after) to make this work, which feels hacky. Perhaps the circular-dependency between the two plugins is a bigger thing that needs addressing, I'm happy to try and summarise that in a new issue. But based on my experience it doesn't seem as simple as saying one plugin or the other ought to be placed first |
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ |
resolved in 6b4b7b6 |
IMHO the recommandation should be further contextualized and more nuanced as pointed out by @jbt above and @Andarist in #805. The order suggested is simply wrong in the case of |
@teehemkay feel free to prepare a PR that would clarify this further |
Would you please consider creating this issue? You seem to have explored it further than I have since I only dealt with the specific issue of |
I stumbled on the same problem just now it seems that there are many things at play here.
So that brings me to a few possible solutions
I'm no Rollup/babel expert though and have no good idea on the feasability of each of these ideas |
plugin-commonjs
/plugin-babel
Documentation Is:
Please Explain in Detail...
Since how
@rollup/plugin-commonjs
and@rollup/plugin-babel
are implemented. It's better to hint user that when specify rollup plugins, they'd better place@rollup/plugin-commonjs
before@rollup/plugin-babel
.Reason
Given a module in CommonJS format and its code needs to be processed by babel. For example:
@rollup/plugin-babel
will inject helper codes:then, the transformed source will be passed to
@rollup/plugin-commonjs
. The CommonJS plugin then treat the source as ES6 module(because of theimport
syntax@rollup/plugin-babel
inserted) and does not process further and leads to*** is not exported by ***
.Your Proposal for Changes
Document the order issue in plugin section.
The text was updated successfully, but these errors were encountered: