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
Add CLI flag to explicitly disable config file transpilation #4055
Comments
Maybe a positive flag might be less confusing as it avoids the double negation of |
I'm not familiar with Rollup's codebase. Could you provide suggestions on what files should I look at to add a CLI option? Also, do I need to write tests for CLI options? |
Yes please. CLI tests are found in
The entire CLI is in the Also, you should extend documentation in |
This issue has been resolved via #4574 as part of rollup@3.0.0-5. Note that this is a pre-release, so to test it, you need to install Rollup via |
This issue has been resolved via #4574 as part of rollup@3.0.0-6. Note that this is a pre-release, so to test it, you need to install Rollup via |
This issue has been resolved via #4574 as part of rollup@3.0.0-7. Note that this is a pre-release, so to test it, you need to install Rollup via |
This issue has been resolved via #4574 as part of rollup@3.0.0-8. Note that this is a pre-release, so to test it, you need to install Rollup via |
This issue has been resolved via #4574 as part of rollup@3.0.0. You can test it via |
Feature Use Case
Rollup gained support for native ESM configs in #3445. This feature enables Rollup to "give up" transpiling and let Node.js execute the raw ESM. However, support for ESM configs are still flaky at the moment:
Rollup requires Node.js >= 13 to support native ESM config. However, native ESM is well-supported in Node.js v12.x as well. In 12.17.0, the
--experimental-modules
flag was made redundant; in 12.22.0 native ESM was declared "stable".Node.js v12 is scheduled to be maintained until April 2022. In the meantime, many projects staying on v12 will be unable to use native ESM for their Rollup config file.
See:
rollup/cli/run/loadConfigFile.ts
Lines 15 to 17 in a4a3b8a
When
package.json
has"type": "module"
, Node.js treats all scripts with the.js
extension as native ESM. This behavior was introduced in Node.js 12+. However, Rollup does not respect this field when consumingrollup.config.js
: it still transpiles the config to CJS before passing it to Node.js.This becomes a problem if the config file imports a pure ES module: Because Rollup transpiles the
import
s torequire()
s, the build fails with "Node tried to require an ES module from a CommonJS file, which is not supported.".See:
rollup/cli/run/loadConfigFile.ts
Lines 115 to 123 in a4a3b8a
While these two issues can be resolved separately, we may expect further edge cases until the ecosystem adapts to native ESM. Rollup's "should I transpile the config?" detection method may not reflect the interests of its users. Furthermore, changes in the detection method would break existing code that relies on the current behavior. Therefore, it would be nice to give users an escape hatch that gives full control over whether Rollup should transpile its config file.
Feature Proposal
Add a
--[no--]skip-config-transpile
CLI flag.--skip-config-transpile
will force Rollup not to transpile the config, and--no-skip-config-transpile
will force Rollup to transpile the config. In both cases, Rollup leaves the decision up to the user; it forgoes checking the version of Node.js or the config file extension.Some notes:
The text was updated successfully, but these errors were encountered: