fix(rsbuild): infer build outputs from distPath.root directly#35707
Merged
Conversation
`getOutputs()` took `dirname()` of `output.distPath.root` when inferring the build target's `outputs`. But `distPath.root` is the directory Rsbuild emits the build into, so `dirname()` points one level too high - a project with `distPath.root` of `dist/apps/my-app` inferred `dist/apps` as its output, which captures sibling projects' build artifacts in the cache. Use `distPath.root` as-is.
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit e2e47c5
☁️ Nx Cloud last updated this comment at |
AgentEnder
approved these changes
May 19, 2026
FrozenPandaz
added a commit
that referenced
this pull request
May 19, 2026
## Current Behavior
The `@nx/rsbuild` inferred-plugin computes the build target's `outputs`
by taking `dirname()` of `output.distPath.root`:
```ts
const buildOutputPath = normalizeOutputPath(
rsbuildConfig?.output?.distPath?.root
? dirname(rsbuildConfig?.output.distPath.root)
: undefined,
...
);
```
But `distPath.root` *is* the directory Rsbuild emits the build into, so
`dirname()` points one level too high. A project whose `distPath.root`
resolves to `dist/apps/my-app` gets its `outputs` inferred as
`{workspaceRoot}/dist/apps` — the parent directory, which captures
sibling projects' build artifacts. Nx then caches/restores the whole
`dist/apps` tree as that one project's output.
## Expected Behavior
The inferred `outputs` should be `distPath.root` itself
(`{workspaceRoot}/dist/apps/my-app`).
This PR drops the `dirname()` call so `distPath.root` is used as-is, and
adds `getOutputs` coverage for an unset, a project-relative, and a
workspace-relative `distPath.root` (the existing tests only exercised an
empty config).
## Related Issue(s)
N/A
(cherry picked from commit f173650)
FrozenPandaz
added a commit
that referenced
this pull request
May 19, 2026
## Current Behavior
The `@nx/rsbuild` inferred-plugin computes the build target's `outputs`
by taking `dirname()` of `output.distPath.root`:
```ts
const buildOutputPath = normalizeOutputPath(
rsbuildConfig?.output?.distPath?.root
? dirname(rsbuildConfig?.output.distPath.root)
: undefined,
...
);
```
But `distPath.root` *is* the directory Rsbuild emits the build into, so
`dirname()` points one level too high. A project whose `distPath.root`
resolves to `dist/apps/my-app` gets its `outputs` inferred as
`{workspaceRoot}/dist/apps` — the parent directory, which captures
sibling projects' build artifacts. Nx then caches/restores the whole
`dist/apps` tree as that one project's output.
## Expected Behavior
The inferred `outputs` should be `distPath.root` itself
(`{workspaceRoot}/dist/apps/my-app`).
This PR drops the `dirname()` call so `distPath.root` is used as-is, and
adds `getOutputs` coverage for an unset, a project-relative, and a
workspace-relative `distPath.root` (the existing tests only exercised an
empty config).
## Related Issue(s)
N/A
(cherry picked from commit f173650)
polygraph-snapshot-app Bot
pushed a commit
that referenced
this pull request
May 20, 2026
## Current Behavior
The `@nx/rsbuild` inferred-plugin computes the build target's `outputs`
by taking `dirname()` of `output.distPath.root`:
```ts
const buildOutputPath = normalizeOutputPath(
rsbuildConfig?.output?.distPath?.root
? dirname(rsbuildConfig?.output.distPath.root)
: undefined,
...
);
```
But `distPath.root` *is* the directory Rsbuild emits the build into, so
`dirname()` points one level too high. A project whose `distPath.root`
resolves to `dist/apps/my-app` gets its `outputs` inferred as
`{workspaceRoot}/dist/apps` — the parent directory, which captures
sibling projects' build artifacts. Nx then caches/restores the whole
`dist/apps` tree as that one project's output.
## Expected Behavior
The inferred `outputs` should be `distPath.root` itself
(`{workspaceRoot}/dist/apps/my-app`).
This PR drops the `dirname()` call so `distPath.root` is used as-is, and
adds `getOutputs` coverage for an unset, a project-relative, and a
workspace-relative `distPath.root` (the existing tests only exercised an
empty config).
## Related Issue(s)
N/A
vrxj81
pushed a commit
to vrxj81/nx
that referenced
this pull request
May 20, 2026
…5707) ## Current Behavior The `@nx/rsbuild` inferred-plugin computes the build target's `outputs` by taking `dirname()` of `output.distPath.root`: ```ts const buildOutputPath = normalizeOutputPath( rsbuildConfig?.output?.distPath?.root ? dirname(rsbuildConfig?.output.distPath.root) : undefined, ... ); ``` But `distPath.root` *is* the directory Rsbuild emits the build into, so `dirname()` points one level too high. A project whose `distPath.root` resolves to `dist/apps/my-app` gets its `outputs` inferred as `{workspaceRoot}/dist/apps` — the parent directory, which captures sibling projects' build artifacts. Nx then caches/restores the whole `dist/apps` tree as that one project's output. ## Expected Behavior The inferred `outputs` should be `distPath.root` itself (`{workspaceRoot}/dist/apps/my-app`). This PR drops the `dirname()` call so `distPath.root` is used as-is, and adds `getOutputs` coverage for an unset, a project-relative, and a workspace-relative `distPath.root` (the existing tests only exercised an empty config). ## Related Issue(s) N/A
FrozenPandaz
added a commit
that referenced
this pull request
May 20, 2026
… after jest.resetModules The build-outputs tests added in #35707 (cherry-picked here) rely on mockResolvedValueOnce against the current @rsbuild/core mock between tests. A top-level import binds loadConfig once at module load, leaving the binding stale after the spec's jest.resetModules() in afterEach. Lazy-require matches master and lets the per-test mock take effect.
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.
Current Behavior
The
@nx/rsbuildinferred-plugin computes the build target'soutputsby takingdirname()ofoutput.distPath.root:But
distPath.rootis the directory Rsbuild emits the build into, sodirname()points one level too high. A project whosedistPath.rootresolves todist/apps/my-appgets itsoutputsinferred as{workspaceRoot}/dist/apps— the parent directory, which captures sibling projects' build artifacts. Nx then caches/restores the wholedist/appstree as that one project's output.Expected Behavior
The inferred
outputsshould bedistPath.rootitself ({workspaceRoot}/dist/apps/my-app).This PR drops the
dirname()call sodistPath.rootis used as-is, and addsgetOutputscoverage for an unset, a project-relative, and a workspace-relativedistPath.root(the existing tests only exercised an empty config).Related Issue(s)
N/A