[rush] Rush plugin architecture doesn't support ESM?
Summary
I'm working on a custom cloud storage cache plugin, as per the docs here:
https://rushjs.io/pages/maintainer/build_cache/#enabling-cloud-storage https://rushjs.io/pages/maintainer/using_rush_plugins/ https://rushjs.io/pages/extensibility/creating_plugins/
However, when I try to use the plugin in Rush, I get an error message about ES modules not being supported.
Repro steps
Write a plugin in ESM and try to use it.
Expected result:
It works.
Actual result:
Apparently the Rush architecture is not using ES modules, and tries to require the plugin:
ERROR: Internal Error: Error loading rush plugin from
"...\common\autoinstallers\rush-plugins\node_modules\@arista\rush-buildpack-cache-plugin\dist\index.js":
Error [ERR_REQUIRE_ESM]: require() of ES Module
...\common\autoinstallers\rush-plugins\node_modules\.pnpm\@[email protected]\node_modules\@arista\rush-buildpack-cache-plugin\dist\index.js
from ...\.rush\node-v20.11.1\rush-5.117.9\node_modules\@microsoft\rush-lib\dist\commons.js
not supported.
Instead change the require of index.js in
...\.rush\node-v20.11.1\rush-5.117.9\node_modules\@microsoft\rush-lib\dist\commons.js to
a dynamic import() which is available in all CommonJS modules.
You have encountered a software defect. Please consider reporting the issue to the maintainers of
this application.
Details
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question | Answer |
|---|---|
@microsoft/rush globally installed version? |
5.117.9 |
rushVersion from rush.json? |
5.117.9 |
useWorkspaces from rush.json? |
N/A |
| Operating system? | Windows 11, Linux |
| Would you consider contributing a PR? | No |
Node.js version (node -v)? |
20.11.1 |
Yeah, Rush (and actually all of the rushstack projects) currently use the CommonJS module format. Moving to ESM would be a pretty major breaking change, although it may be time to do that. This is something that we'd do with the release of Rush v6, along with other breaking changes and removal of deprecated APIs.
Yeah, Rush (and actually all of the rushstack projects) currently use the CommonJS module format. Moving to ESM would be a pretty major breaking change, although it may be time to do that. This is something that we'd do with the release of Rush v6, along with other breaking changes and removal of deprecated APIs.
When is Rush v6 expected to be released?