Skip to content

fix: resolve absolute stack frame paths in the webpack compiler - #1446

Open
giaBaoJS wants to merge 1 commit into
callstack:mainfrom
giaBaoJS:fix/webpack-getsource-absolute-path
Open

fix: resolve absolute stack frame paths in the webpack compiler#1446
giaBaoJS wants to merge 1 commit into
callstack:mainfrom
giaBaoJS:fix/webpack-getsource-absolute-path

Conversation

@giaBaoJS

Copy link
Copy Markdown

Summary

  • guard the webpack compiler's getSource with path.isAbsolute, matching the Rspack compiler
  • add getSource unit tests covering both the absolute and the relative case

Why

start.ts runs every symbolicator request through resolveProjectPath before handing it to the compiler:

getSource: (url) => {
let { resourcePath, platform } = parseUrl(url, platforms);
resourcePath = resolveProjectPath(resourcePath, cliConfig.root);
return compiler.getSource(resourcePath, platform);
},

resolveProjectPath ends in path.resolve, so the compiler receives an absolute path. rspack/Compiler.ts:353 handles that:

const filePath = path.isAbsolute(filename)
  ? filename
  : path.join(this.rootDir, filename);

webpack/Compiler.ts:279 did not:

const filePath = path.join(this.rootDir, filename);

so the root was prepended a second time. With rootDir /project, a frame at /outside/project/file.js was read from /project/outside/project/file.js, which does not exist. getSource threw, and the redbox rendered the frame with no code frame.

This is not limited to files outside the project root. SourceMapPlugin emits [projectRoot]/... for every in-project module, resolveProjectPath turns that into an absolute path, and path.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:

b15b7d77 fix: sourcemaps handling in dev & prod (#1172)

That commit is the one that introduced resolveProjectPath and wired it into both start commands, including packages/repack/src/commands/webpack/start.ts. It added the path.isAbsolute guard only to rspack/Compiler.ts. The webpack producer was updated, the webpack consumer was not.

This is the getSource bullet 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 successful
  • pnpm typecheck: 11 tasks successful. biome check: 481 files, clean
  • counterfactual: reverting only Compiler.ts while keeping the tests turns reads an absolute filename as-is red on the assertion, Rejected to value: [CLIError: File /outside/project/file.js not found], not on an import or compile error. Instrumenting the spy shows readFile receiving /project/outside/project/file.js
  • non-vacuity in the other direction: replacing the change with const filePath = filename (dropping the join entirely) turns resolves a relative filename against the project root red, so neither test passes both ways

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-bot

changeset-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6ae4f65

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Patch
@callstack/repack-plugin-expo-modules Patch
@callstack/repack-plugin-nativewind Patch
@callstack/repack-plugin-reanimated Patch
@callstack/repack-dev-server Patch
@callstack/repack-init Patch

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

@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

@giaBaoJS is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant