fix: resolve absolute stack frame paths in the webpack compiler - #1446
Open
giaBaoJS wants to merge 1 commit into
Open
fix: resolve absolute stack frame paths in the webpack compiler#1446giaBaoJS wants to merge 1 commit into
giaBaoJS wants to merge 1 commit into
Conversation
The dev server resolves symbolicated stack frames to absolute paths before handing them to the compiler. The Rspack compiler guards this with path.isAbsolute, but the webpack one joined them onto the project root a second time, so the file was never found and the redbox lost its code frame. Apply the same guard to the webpack compiler.
🦋 Changeset detectedLatest commit: 6ae4f65 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@giaBaoJS is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getSourcewithpath.isAbsolute, matching the Rspack compilergetSourceunit tests covering both the absolute and the relative caseWhy
start.tsruns every symbolicator request throughresolveProjectPathbefore handing it to the compiler:repack/packages/repack/src/commands/start.ts
Lines 210 to 214 in b7a8611
resolveProjectPathends inpath.resolve, so the compiler receives an absolute path.rspack/Compiler.ts:353handles that:webpack/Compiler.ts:279did not:so the root was prepended a second time. With
rootDir/project, a frame at/outside/project/file.jswas read from/project/outside/project/file.js, which does not exist.getSourcethrew, and the redbox rendered the frame with no code frame.This is not limited to files outside the project root.
SourceMapPluginemits[projectRoot]/...for every in-project module,resolveProjectPathturns that into an absolute path, andpath.join('/project', '/project/src/App.tsx')is/project/project/src/App.tsx. So on webpack every symbolicated frame lost its source, while Rspack was fine.It looks like an oversight rather than a deliberate difference.
git log -S "path.isAbsolute(filename)"returns exactly one commit:That commit is the one that introduced
resolveProjectPathand wired it into both start commands, includingpackages/repack/src/commands/webpack/start.ts. It added thepath.isAbsoluteguard only torspack/Compiler.ts. The webpack producer was updated, the webpack consumer was not.This is the
getSourcebullet from the v6 list in #1421. It is an independent v5 bug that stands on its own, so I am not marking #1421 as closed. Happy to have it folded into the unification work instead if you would rather handle it there.Validation
pnpm --filter @callstack/repack test: 33 suites, 301 tests passed (299 before)pnpm test: 10 tasks successfulpnpm typecheck: 11 tasks successful.biome check: 481 files, cleanCompiler.tswhile keeping the tests turnsreads an absolute filename as-isred on the assertion,Rejected to value: [CLIError: File /outside/project/file.js not found], not on an import or compile error. Instrumenting the spy showsreadFilereceiving/project/outside/project/file.jsconst filePath = filename(dropping the join entirely) turnsresolves a relative filename against the project rootred, so neither test passes both ways