zhangHongEn / universal-module-federation-plugin

Versioned remote module manager based on npm and module-federation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't play well with UMD packages served by the webpack-cli dev server

jdthorpe opened this issue · comments

I was trying to work on a UMD package to import with this plugin and was using the usual webpack-cli serve to serve the package. Curiously, when I try and import the UMD package served from the webpack-cli every import is undefined. E.g:

import { something } from "MyUMDpackage"
console.log(typeof something) // always returns "undefined" when MyUMDpackage is served from the webpack-cli

However when I build my UMD package with npx webpack --watch in one process and serve it in another process with serve dist --cors -p $PORT, it seems to work just fine. Probably something to do with all the extra debugging code injected by the webpack-cli dev server. However, while this is still an issue, probably worth mentioning in the README.

commented

webpack-cli and webpack-dev-server must be available,
Can you send me the js content corresponding to MyUMDpackage in dev-server so I can troubleshoot
For example, app2 in this example is the dev-server started by webpack-cli

Sure. I'll get you a minimal reproducible example in a few hours.

Turns out I was using a pretty old version of the webpack-dev-server (3.11.2). Upgrading to the latest (4.11.1) fixed it for me.

commented

Thank you very much! Let me add a document to explain this