fix: bundle prettier into dist by removing it from esbuild external list#543
Conversation
Agent-Logs-Url: https://github.com/bitflight-devops/github-action-readme-generator/sessions/de0b6202-b340-40b1-8fb5-36c1673786a8 Co-authored-by: Jamie-BitFlight <25075504+Jamie-BitFlight@users.noreply.github.com>
Coverage Report
File CoverageNo changed files found. |
|
@copilot did the validation tests test the failure path accurately. did you trigger the error without the fix first to identify how the failure occurred |
There was a problem hiding this comment.
Pull request overview
Fixes a runtime startup failure in the published GitHub Action by ensuring prettier is bundled into the generated dist/bin/index.js, so the action can run in user workflows where node_modules is not present.
Changes:
- Remove
prettierfrom the esbuildexternallist so it is included in the bundle.
Agent-Logs-Url: https://github.com/bitflight-devops/github-action-readme-generator/sessions/19b4f659-084d-4fc3-b608-5a96323df5ee Co-authored-by: Jamie-BitFlight <25075504+Jamie-BitFlight@users.noreply.github.com>
No, I didn't reproduce the failure path first in my initial fix. I've now done that explicitly in commit Here's what was done to validate the failure path:
|
|
@copilot your changes are failing the ci tests. please lint and format |
Agent-Logs-Url: https://github.com/bitflight-devops/github-action-readme-generator/sessions/e40b8c75-13d8-4459-bcfc-bee102114781 Co-authored-by: Jamie-BitFlight <25075504+Jamie-BitFlight@users.noreply.github.com>
Head branch was pushed to by a user without write access
Fixed in |
|
🎉 This PR is included in version 1.10.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The action fails immediately on startup with
ERR_MODULE_NOT_FOUND: Cannot find package 'prettier'because esbuild was configured to treatprettieras external, leaving it unbundled. At runtime in user workflows, onlydist/is present — nonode_modules— so the import resolves to nothing regardless of theprettyinput value.Changes
scripts/esbuild.mjs— removeprettierfrom theexternalarray:prettieris already adependency(notdevDependency) inpackage.json, so bundling it is correct. The resultingdist/bin/index.jsgrows to ~29MB but is fully self-contained.__tests__/integration-bundled-binary.test.ts— added a regression test that reproduces the original failure path:node_modulesanywhere in the directory hierarchy (mirroring the GitHub Actions runner environment where onlydist/is deployed)stderrcontains noERR_MODULE_NOT_FOUNDand that the binary exits successfully with a generated READMEThe test was validated to fail against a binary built with
external: ['prettier'](reproducing the exact error from the issue) and pass against the fixed binary.