Repository navigation
fix(scripts): use file URL for ESM sourcemap preload - #6044
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe start command now passes a file URL to Node’s ESM ChangesStartup preload and Windows regression coverage
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The Windows preload fix is ready for normal merge checks; no actionable risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #6044 +/- ##
==========================================
+ Coverage 83.00% 83.34% +0.34%
==========================================
Files 732 732
Lines 22546 22546
Branches 4539 4539
==========================================
+ Hits 18714 18792 +78
+ Misses 3319 3252 -67
+ Partials 513 502 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes Windows production startup for ESM apps when egg.typescript enables sourcemaps by ensuring the source-map-support/register.js preload passed to Node’s --import is a file:// URL (avoiding drive-letter paths being parsed as an unsupported URL scheme).
Changes:
- Convert the resolved
source-map-support/register.jspath to afile://URL when using--importfor ESM apps. - Keep the CommonJS preload path unchanged via
--require. - Add a regression unit test covering an ESM app (
"type": "module") withegg.typescript: true.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/scripts/src/commands/start.ts | Uses pathToFileURL(...).href when pushing the ESM --import preload for source-map-support. |
| tools/scripts/test/start-unit.test.ts | Adds a regression test asserting ESM startup uses --import file: and adjusts the stubbed server bin to return .mjs for ESM. |
2674193 to
d231d0b
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
d231d0b to
8cbfc88
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tools/scripts/test/start-unit.test.ts (1)
23-23: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExercise
Start.getServerBin()for ESM resolution.
TestStart.getServerBin()overridesStart.getServerBin()and returns themjs/cjsextension from the override. The ESM test attools/scripts/test/start-unit.test.ts:92only checks that double. Delegate tosuper.getServerBin()here or add a direct test onStart.getServerBin().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/scripts/test/start-unit.test.ts` at line 23, Update TestStart.getServerBin() so the ESM test exercises Start.getServerBin() rather than bypassing it with a hardcoded extension; delegate to the superclass implementation while preserving the test fixture’s fake script path behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tools/scripts/test/start-unit.test.ts`:
- Around line 72-99: Extend the ESM preload test around TestStart.run to
explicitly exercise a Windows drive-style esmBaseDir, independent of the host
platform. Verify that the generated --import argument is a file URL with the
Windows path correctly converted, while preserving the existing POSIX-platform
coverage.
---
Nitpick comments:
In `@tools/scripts/test/start-unit.test.ts`:
- Line 23: Update TestStart.getServerBin() so the ESM test exercises
Start.getServerBin() rather than bypassing it with a hardcoded extension;
delegate to the superclass implementation while preserving the test fixture’s
fake script path behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3a8de3ba-9689-46a3-b5af-b0f2880dea93
📒 Files selected for processing (2)
tools/scripts/src/commands/start.tstools/scripts/test/start-unit.test.ts
8cbfc88 to
0cf8ac6
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Motivation
On Windows, egg-scripts passes the resolved source-map-support path directly to Node.js --import for ESM applications. A drive-letter path such as D:\app\node_modules\source-map-support\register.js is parsed as the unsupported d: URL scheme, causing ERR_UNSUPPORTED_ESM_URL_SCHEME during production startup.
Fixes #6041.
Changes
Testing
Summary by CodeRabbit