Current Behavior
I'm using NX-enhanced webpack plugins as per documentation to configure react and module federation, e.g.
import { withReact } from '@nx/react';
import { composePlugins, withNx } from '@nx/webpack';
import { withModuleFederation } from '@nx/react/module-federation';
export default composePlugins(
withNx(),
withReact(),
withModuleFederation(config)
}
I have noticed that the optimization options are lost when withModuleFederation is invoked, e.g. when I do this:
export default composePlugins(
withNx(),
withReact(),
(config) => {
console.log({ optimization: config.optimization });
return config;
},
withModuleFederation(config),
(config) => {
console.log({ optimization: config.optimization });
return config;
}
}
These are the config options before:
optimization: {
sideEffects: true,
minimize: false,
minimizer: [Array],
runtimeChunk: [Object],
concatenateModules: true,
emitOnErrors: false,
moduleIds: 'deterministic',
splitChunks: [Object]
}
and this is after:
optimization: {
runtimeChunk: false
},
This is causing problems for me later on:
ERROR in main.js
main.js from Terser plugin
"Import" statement may only appear at the top level [main.js:12,0]
at js_error (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:536:11)
at TreeWalker.visit (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:11818:13)
at TreeWalker._visit (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:6728:24)
at AST_Import._walk (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:5122:28)
at walk_body (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:3869:17)
at AST_Function.<anonymous> (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:4368:17)
at /Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:6729:21
at TreeWalker.visit (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:11720:13)
at TreeWalker._visit (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:6728:24)
at AST_Function._walk (/Users/xxxx/workspace/xxxx/node_modules/terser/dist/bundle.min.js:4362:28)
Expected Behavior
I was expecting optimization options to be unchanged when withModuleFederation plugin is used.
GitHub Repo
No response
Steps to Reproduce
- Enable
withNx, withReact, and withModuleFederation plugins
- Optimization options after
withModuleFederation will not have all of the default values
Nx Report
NX Report complete - copy this into the issue template
Node : 18.18.0
OS : darwin-x64
yarn : 1.22.22
nx : 19.5.3
@nx/js : 19.5.3
@nx/jest : 19.5.3
@nx/linter : 19.5.3
@nx/eslint : 19.5.3
@nx/workspace : 19.5.3
@nx/devkit : 19.5.3
@nx/eslint-plugin : 19.5.3
@nx/react : 19.5.3
@nrwl/tao : 19.5.3
@nx/web : 19.5.3
@nx/webpack : 19.5.3
typescript : 5.5.4
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin
Failure Logs
No response
Package Manager Version
1.22.22
Operating System
Additional Information
No response
Current Behavior
I'm using NX-enhanced webpack plugins as per documentation to configure react and module federation, e.g.
I have noticed that the
optimizationoptions are lost whenwithModuleFederationis invoked, e.g. when I do this:These are the config options before:
and this is after:
This is causing problems for me later on:
Expected Behavior
I was expecting
optimizationoptions to be unchanged whenwithModuleFederationplugin is used.GitHub Repo
No response
Steps to Reproduce
withNx,withReact, andwithModuleFederationpluginswithModuleFederationwill not have all of the default valuesNx Report
Failure Logs
No response
Package Manager Version
1.22.22
Operating System
Additional Information
No response