Skip to content

fix(webpack): resolve tsconfig absolute path - #3595

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
fadiroot:fix/webpack-tsconfig-absolute-path
Sep 25, 2026
Merged

kamilmysliwiec merged 1 commit into
nestjs:masterfrom
fadiroot:fix/webpack-tsconfig-absolute-path

Conversation

@fadiroot

Copy link
Copy Markdown

PR Checklist

PR Type

  • Bugfix

What is the current behavior?

Issue Number: N/A

The webpack compiler builds the tsconfig path with path.join(cwd, tsConfigPath). For an absolute path, join does not short-circuit, so

nest build --builder webpack -p /home/me/app/tsconfig.build.json

looks for <cwd>/home/me/app/tsconfig.build.json and fails with Could not find TypeScript configuration file. The same happens with an absolute compilerOptions.tsConfigPath.

The rspack compiler had exactly this bug and was fixed in #3542 (fix(rspack): resolve tsconfig absolute path) by using path.resolve and passing the resolved path on to its defaults factory. The webpack compiler was left unchanged.

What is the new behavior?

The webpack compiler resolves the path the same way and passes the resolved path to webpackDefaultsFactory, matching rspack. Relative paths behave as before.

Tests: the existing factory-arguments test now expects the resolved path, and a new case passes an absolute tsconfig path through unchanged (mirroring the rspack spec). Both fail on master and pass with this change.

Does this PR introduce a breaking change?

  • No

The webpack compiler built the tsconfig path with `path.join(cwd, tsConfigPath)`,
so an absolute path such as `-p /home/me/app/tsconfig.build.json` became
`<cwd>/home/me/app/tsconfig.build.json` and the build failed with "Could not
find TypeScript configuration file". The rspack compiler was fixed for this
in nestjs#3542 by resolving the path instead and passing the resolved path on to
its defaults factory; the webpack compiler was left unchanged.

Apply the same change to the webpack compiler.
@kamilmysliwiec
kamilmysliwiec merged commit 6344c7d into nestjs:master Sep 25, 2026
1 check passed
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.

3 participants