core
core copied to clipboard
`@module-federation/enhanced/webpack`: types could not be generated when using a shared webpack config
Describe the bug
We have a monorepo setup with a shared webpack configuration package. The setup look kinda like this:
packages
- configs
- webpack-shared.config.js # all setup is in here, including module federation setup
- app
- webpack.config.js # imports the shared config and overwrites some values, like the exposed federated modules
- tsconfig.js
In this setup, the configs
package contains the webpack-shared.config.js
, which setups everything including the @module-federation/enhanced/webpack
plugin. The app imports the config object and overwrites some values.
When I start the app with the OLD plugin const ModuleFederationPlugin = webpack.container.ModuleFederationPlugin;
, everything works. But with the new plugin, the variables created from the DefinePlugin
are not available as typescript types, hence I get an error in the console: TS Error 2304':' Cannot find name 'MODULE_NAME'
. This breaks the build, but if I set dts: false,
the error still gets logged but the build works.
My guess: The new @module-federation/enhanced/webpack
plugin doesn't read the tsconfig.json
from the app
package, but from the configs
package. As there is none, it uses some defaults.
Used Package Manager
pnpm
Validations
- [X] Read the docs.
- [X] Read the common issues list.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Module federation issue and not a framework-specific issue.
- [X] The provided reproduction is a minimal reproducible example of the bug.
Hello @feedm3. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction
will be closed if they have no activity within 5 days.
@2heal1 there is a bug in DTS plugin. If user doesnt use TS it will crash build. https://github.com/module-federation/module-federation-examples/actions/runs/8622719151/job/23634523849?pr=3802
Stale issue message
@ScriptedAlchemy
I'm seeing similar issues after switching webpack's built in ModuleFederationPlugin
with @module-federation/enhanced/webpack
one
Error:
...cannot be named without a reference to '.pnpm/[email protected]/node_modules/reselect'. This is likely not portable. A type annotation is necessary.