Minimal reproduction example to demonstrate error for this issue when loading a module federation remote from a webworker script that's
built using a target: 'webworker'
webpack configuration.
NOTE: This project uses patch-package
to apply the publicPath
fix for this issue.
- Run
yarn
to install dependencies. - Run
yarn serve
to serve prebuilt dist (oryarn start
to serve from source). - Load http://localhost:3001, the console should show the error
Uncaught (in promise) DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:3001/webpack_container_remote_remote_remote-logger.js' failed to load.
- Using the workaround below, the message
Hello from the remote logger
should appear on the page.
Comment out this line, so that the main webworker script is not compiled using the
webworker
target. While this resolves the remote loading issue, presumably it would prevent chunk splitting from
working, as the importScripts
is replaced with a JSONP
chunk loader.