New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support loading ESM plugins from the CLI via --plugin
#4265
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4265 +/- ##
=======================================
Coverage 98.39% 98.39%
=======================================
Files 204 204
Lines 7289 7294 +5
Branches 2081 2081
=======================================
+ Hits 7172 7177 +5
Misses 58 58
Partials 59 59
Continue to review full report at Codecov.
|
Interesting... the new ESM CLI plugin tests succeed on Node v12 here, but not on my local machine. The Node v12 version used by github CI must be more recent than my local version. The Node v10 failures for the new ESM CLI plugin tests were expected - both here and on my local machine. I will add a condition to skip the ESM CLI plugin tests on Node v10, as no old functionality is lost on that Node version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks a lot!
the |
I think |
Even if rollup v3 moves to an all ESM toolchain for the CLI, rollup v2 should support both ESM and CJS during the transition period. Although it's technically possible to mimic the semantics of |
yes, I agree. that was just a thought I had in mind since it touched the |
@kzc this is freakin awesome, thank you!! ❤️ |
Glad it's useful. It simplified my workflow. |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
n/a
Description
Rollup presently only supports CJS plugins from the CLI via
--plugin
. This PR adds seamless ESM plugin support to the CLI. To maintain backwards compatibility rollup will still attempt to resolve the plugin viarequire
first, and only upon error will it attempt to load the plugin via a dynamicimport()
. This is due to the different module resolution semantics of CJS and ESM modules in NodeJS.The use of dynamic import to load ESM plugins works with Node v12+. No rollup CLI functionality is lost on NodeJS versions that do not support loading ESM via dynamic
import
.