Hello! Ran into an issue generating a basic Angular + RSPack + Module Federation example.
Current Behavior
When generating an Angular Module Federation host + remote with --bundler=rspack, the remote's remoteEntry.js is emitted as ESM (with export statements) because NxModuleFederationPlugin sets library: { type: 'module' }. However, the generated rspack.config.ts does not set experiments.outputModule or output.module on the compiler, so the MF runtime loads the remote entry as a classic script, resulting in:
Uncaught SyntaxError: Unexpected token 'export' (at remoteEntry.js:48774:1)
Expected Behavior
The generated config should produce working Module Federation out of the box. Either:
NxModuleFederationPlugin should set experiments.outputModule = true and output.module = true on the compiler when it applies library: { type: 'module' }, or
- The
@nx/angular:host and @nx/angular:remote generators should include these settings in the generated rspack.config.ts
GitHub Repo
https://github.com/jdgarvey/nx-angular-rspack-mf-esm-repro
Steps to Reproduce
npx create-nx-workspace@22.4.0 rspack-mf-repro --preset=angular-monorepo --style=scss --e2eTestRunner=none --bundler=rspack --ssr=false --interactive=false
cd rspack-mf-repro
npx nx g @nx/angular:host --directory=apps/shell --name=shell --bundler=rspack --dynamic=true --e2eTestRunner=none --ssr=false --skipTests=true --interactive=false
npx nx g @nx/angular:remote --directory=apps/remote --name=remote --bundler=rspack --host=shell --e2eTestRunner=none --ssr=false --skipTests=true --interactive=false
npx nx serve remote
# Open http://localhost:4200 → console shows "Unexpected token 'export'"
Workaround
Add the following to the webpackMerge call in both host and remote rspack.config.ts:
return webpackMerge(baseConfig[0], baseWebpackConfig, {
experiments: { outputModule: true },
output: { module: true, scriptType: 'module' },
});
Nx Report
- Nx: 22.4.0
- @nx/angular-rspack: 22.4.0
- @nx/module-federation: 22.4.0
- @rspack/core: 1.6.8
- Angular: ~21.1.0 (resolved 21.1.5)
- Node: 22.x
- OS: macOS (arm64)
Thank you!
Hello! Ran into an issue generating a basic Angular + RSPack + Module Federation example.
Current Behavior
When generating an Angular Module Federation host + remote with
--bundler=rspack, the remote'sremoteEntry.jsis emitted as ESM (withexportstatements) becauseNxModuleFederationPluginsetslibrary: { type: 'module' }. However, the generatedrspack.config.tsdoes not setexperiments.outputModuleoroutput.moduleon the compiler, so the MF runtime loads the remote entry as a classic script, resulting in:Expected Behavior
The generated config should produce working Module Federation out of the box. Either:
NxModuleFederationPluginshould setexperiments.outputModule = trueandoutput.module = trueon the compiler when it applieslibrary: { type: 'module' }, or@nx/angular:hostand@nx/angular:remotegenerators should include these settings in the generatedrspack.config.tsGitHub Repo
https://github.com/jdgarvey/nx-angular-rspack-mf-esm-repro
Steps to Reproduce
Workaround
Add the following to the
webpackMergecall in both host and remoterspack.config.ts:Nx Report
Thank you!