microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.95k stars 602 forks source link

[rush] Rush plugin architecture doesn't support ESM? #4869

Open kaiyoma opened 3 months ago

kaiyoma commented 3 months ago

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\@arista+rush-buildpack-cache-plugin@0.1.0\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
iclanton commented 3 months ago

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.

NovaAstra commented 1 week ago

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?