Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks done
feedm3 opened this issue Apr 8, 2024 · 2 comments
Labels
🐞 bug Something isn't working

Comments

@feedm3
Copy link

feedm3 commented Apr 8, 2024

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

Copy link
Contributor

github-actions bot commented Apr 9, 2024

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.

@ScriptedAlchemy
Copy link
Member

@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 ScriptedAlchemy added 🐞 bug Something isn't working and removed need reproduction labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants