module-federation / FMR-issues

a place to file issues related to FMR plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webpack is not specified as a peer dependency

Indimeco opened this issue Β· comments

Hi, thanks for your work πŸ˜ƒ

I use Lerna in a monorepo.
Some of my subpackages use webpack 4, some of my subpackages use webpack 5.

When Lerna installs (bootstraps) my subprojects it uses node module resolution to determine where to hoist packages depending on their dependencies.

Right now, the fmr package does not specify that it needs any particular webpack version to work, so gets hoisted up to v4 webpack sometimes.
This results in failure to compile and a stack trace like:
[webpack cli] TypeError: Class extends value undefined is not a constructor or null at Object.<anonymous> (node_modules/@module-federation/fmr/src/index.js:40:39)

The solution is to specify the correct webpack dependency as a "peerDependency" in your package.json
I have tested this and confirmed it works with

"peerDependencies": {
    "webpack": "~5.39"
}