Summary
The scripts under .github/scripts are CommonJS, pinned by a local package.json with "type": "commonjs", while every package in the repo and the root package.json are ESM. list_workspaces.js (#5638) is written as ESM and cannot run until the directory is converted. The remaining three JavaScript scripts should be converted at the same time so the directory has one module system:
release_patch_package_json.js, run as node …/release_patch_package_json.js . from each package's prepack script
post_release.js, loaded with require() inside an actions/github-script step in post-release.yml
report_e2e_sweep.js, loaded with require() in two actions/github-script steps in sweep-stale-e2e-stacks.yml
Why is this needed?
Two module systems in one small directory means two sets of idioms (require/module.exports/__dirname versus import/export/import.meta) and a per-directory package.json whose only job is to override the root. Converting removes that override, and #5638 depends on it.
Which area does this relate to?
Automation
Solution
- Flip
.github/scripts/package.json to "type": "module". File names stay .js, so the fifteen prepack entries pointing at the release patch script are untouched.
release_patch_package_json.js: replace the two require lines with import; nothing else changes.
post_release.js and report_e2e_sweep.js: replace module.exports with export default and named exports. actions/github-script evaluates its snippet as CommonJS, so the three call sites must switch from require('./.github/scripts/…') to await import() with an absolute or file:// path built from github.workspace.
- Verify by triggering the stale-stack sweep workflow manually before the next release, since
post-release.yml only runs after a release and a bad import path is only observable in a workflow run.
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Summary
The scripts under
.github/scriptsare CommonJS, pinned by a localpackage.jsonwith"type": "commonjs", while every package in the repo and the rootpackage.jsonare ESM.list_workspaces.js(#5638) is written as ESM and cannot run until the directory is converted. The remaining three JavaScript scripts should be converted at the same time so the directory has one module system:release_patch_package_json.js, run asnode …/release_patch_package_json.js .from each package'sprepackscriptpost_release.js, loaded withrequire()inside anactions/github-scriptstep inpost-release.ymlreport_e2e_sweep.js, loaded withrequire()in twoactions/github-scriptsteps insweep-stale-e2e-stacks.ymlWhy is this needed?
Two module systems in one small directory means two sets of idioms (
require/module.exports/__dirnameversusimport/export/import.meta) and a per-directorypackage.jsonwhose only job is to override the root. Converting removes that override, and #5638 depends on it.Which area does this relate to?
Automation
Solution
.github/scripts/package.jsonto"type": "module". File names stay.js, so the fifteenprepackentries pointing at the release patch script are untouched.release_patch_package_json.js: replace the tworequirelines withimport; nothing else changes.post_release.jsandreport_e2e_sweep.js: replacemodule.exportswithexport defaultand named exports.actions/github-scriptevaluates its snippet as CommonJS, so the three call sites must switch fromrequire('./.github/scripts/…')toawait import()with an absolute orfile://path built fromgithub.workspace.post-release.ymlonly runs after a release and a bad import path is only observable in a workflow run.Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.