Skip to content

fix(rsbuild): infer build outputs from distPath.root directly#35707

Merged
FrozenPandaz merged 1 commit into
masterfrom
fix/rsbuild-plugin-build-outputs
May 19, 2026
Merged

fix(rsbuild): infer build outputs from distPath.root directly#35707
FrozenPandaz merged 1 commit into
masterfrom
fix/rsbuild-plugin-build-outputs

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

Current Behavior

The @nx/rsbuild inferred-plugin computes the build target's outputs by taking dirname() of output.distPath.root:

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

`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.
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner May 15, 2026 21:04
@FrozenPandaz FrozenPandaz requested a review from MaxKless May 15, 2026 21:04
@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit e2e47c5
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a078a4d170f670008ad10e7
😎 Deploy Preview https://deploy-preview-35707--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit e2e47c5
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a078a4d170f670008ad10e3
😎 Deploy Preview https://deploy-preview-35707--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 15, 2026

View your CI Pipeline Execution ↗ for commit e2e47c5

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 40m 2s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 15s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 19s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-15 21:47:44 UTC

@FrozenPandaz FrozenPandaz merged commit f173650 into master May 19, 2026
26 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/rsbuild-plugin-build-outputs branch May 19, 2026 19:32
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.
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.

2 participants