core icon indicating copy to clipboard operation
core copied to clipboard

`@module-federation/enhanced/webpack`: types could not be generated when using a shared webpack config

Open feedm3 opened this issue 10 months ago • 2 comments

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

feedm3 avatar Apr 08 '24 16:04 feedm3

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.

github-actions[bot] avatar Apr 09 '24 01:04 github-actions[bot]

@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

ScriptedAlchemy avatar Apr 09 '24 22:04 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar Jun 09 '24 15:06 github-actions[bot]

@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.

manvydas-tbol avatar Jul 21 '24 14:07 manvydas-tbol