#36946·nx

@nx/rspack NestJS 12 esm build

Author: ForceresCreated Sep 7, 2026Updated Sep 28, 2026
Labelstype: bugblocked: repro neededstalescope: bundlerspriority: medium

Current Behavior

2 issues detected:

  1. @rspack/core: 2.2.2 gives an error independently of the config (immutablePaths is undefined)
  2. @rspack/core: 2.2.1 doesn't have this error, but the option for NxAppRspackPlugin:
json
optimization: true

gives an error:

typescript
ERROR in main.js
  × Chunk minification failed:
  ╰─▶   × JavaScript parse error: 'import', and 'export' cannot be used outside of module code

when we pass optimization: false, it builds without errors (overriding optimization options in legacyPlugin doesn't have any influence. btw, serve target works with both options, so the build output is correct in both cases.

Expected Behavior

It should successfully build the esm project with both @rspack/core versions and respect options overriding.

GitHub Repo

.

Steps to Reproduce

  1. Create NestJS 12 project with several esm libs
  2. Try to build it with rspack

Nx Report

bash
NX   Report complete - copy this into the issue template

Node           : 24.18.0
OS             : darwin-arm64
Native Target  : aarch64-macos
bun            : 1.4.0
daemon         : Available

nx                     : 23.2.0
@nx/js                 : 23.2.0
@nx/linter             : 16.0.0-beta.1
@nx/eslint             : 23.2.0
@nx/workspace          : 23.2.0
@nx/jest               : 23.2.0
@nx/devkit             : 23.2.0
@nx/eslint-plugin      : 23.2.0
@nx/module-federation  : 23.2.0
@nx/nest               : 23.2.0
@nx/node               : 23.2.0
@nx/nuxt               : 23.2.0
@nx/oxlint             : 23.2.0
@nx/playwright         : 23.2.0
@nx/plugin             : 23.2.0
@nx/rspack             : 23.2.0
@nx/vite               : 23.2.0
@nx/vitest             : 23.2.0
@nx/vue                : 23.2.0
@nx/web                : 23.2.0
@nx/webpack            : 23.2.0
@nx/docker             : 23.2.0
typescript             : 6.0.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/eslint/plugin
@org/biome
@nx/jest/plugin
@nx/vite/plugin
@nx/rspack/plugin
@nx/vitest
@nx/vitest
@nx/playwright/plugin
@nx/nuxt/plugin
@nx/oxlint
---------------------------------------
Community plugins:
@nx/nx-plugin : 16.0.0-beta.1
---------------------------------------
Local workspace plugins:
@org/biome
---------------------------------------
Cache Usage: 2.34 MB / 92.63 GB

Failure Logs

bash
@rspack/core: 2.2.1

> rspack build --node-env=production

●  ━━━━━━━━━━━━━━━━━━━━━━━━━ (87%) process assets                                                      
 NX   Bun lockfile generation is not supported

Only the package.json is generated. Run `bun install` in the output directory if needed.

●  ━━━━━━━━━━━━━━━━━━━━━━━━━ (100%) done                                                               chunk (runtime: main) main.js (main) 1.16 MiB [entry] [rendered]

ERROR in main.js
  × Chunk minification failed:
  ╰─▶   × JavaScript parse error: 'import', and 'export' cannot be used outside of module code
         ╭─[1:0]


@rspack/core: 2.2.2

TypeError: immutablePaths is undefined

Package Manager Version

[email protected]

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response