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

Does not work with web workers

jdthorpe opened this issue · comments

I've created a minimal reproducible example here with this error. In short, when trying to import a UMD module in a web worker, this error is raised:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'containerImportMap')

because the following line is run in the web worker:

var containerImportMap = _global.__umfplugin__.containerImportMap

but the __umfplugin__ is only instatntiated in the main thread (dist/main.js in the compiled package) by the inject Plugin.

PS. Sorry for all the issues. I hope they are helpful (and I wouldn't bother if I didn't think this package was so useful!)

commented

Certainly helpful, thanks a lot
I manually introduced inject-code in worker.js, I have completed the demo, and then I want to automatically inject the code into the worker

commented

I can't judge which files will run on the worker thread, you can manually set the regexp support worker file to use remote,,
Need to update universal-module-federation-plugin@^1.0.5
demo here

Wow! I'm impressed at how quickly you were able to implement this. Thanks so much! Feel free to close this (and my other issues) at your leisure.

commented

I will close the issues after solving the various deficiencies and optimization points you raised