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
Initialization of sharing external failed: ScriptExternalLoadError: Loading script failed. #692
Comments
@ScriptedAlchemy Very sorry to bother you can you help with some config advice? or need some more config info ? |
then try manually adding the remoteEntry. That error says "it's not defined", meaning the remote entry was not loaded before webpack tried to access it. |
@jacob-ebey Sorry to interrupt you I tried your advice, emmm, the error above disappears; but, another error occurs, it say 'Uncaught (in promise) Error: Container missing may I have more advice ? manually adding the remoteEntry code:
|
Finally, it's not webpack config error. I create a demo here the problem related to vue-cli & vue.config.js, but I cannot find out the reason why it failed in vue-cli so far. For me, I will create a PR for vue3-demo, it doesn't contain how to use routes in remote repo. this issue closed |
兄弟,有发现问题吗?我现在也遇到同样的问题 |
我这边发现问题了,是qiannkun沙箱问题,暂时通过配置library: { type: 'window', name: 'xxx' } 来解决 |
I'm using vue-cli with vue3 and disabling splitChunks was the solution for me. |
how a u resolve it? |
Hello I am facing same issue module.exports = merge(common, {
}); Host Webpack config module.exports = { Uncaught ScriptExternalLoadError: Loading script failed. /src/bizLanding/bootstrap.js const BizLandingApp = () => ( Hello App From Another Application); export default BizLandingApp; |
Public path is probably incorrect |
请问你这边qiankun项目是如何使用MF,可以分享下一个demo吗 |
As mentioned by nrz2000 disabling splitChunks worked, but I didn't understand why, so I checked vue-cli code to see how they were configuring SplitChunks plugin. And here it is what I got so far: Comparing the config from vue-cli and the default webpack config from the official website we can get some answers. Code copied from vue-cli:https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/config/app.js#L41-L60 webpackConfig.optimization.splitChunks({
cacheGroups: {
defaultVendors: {
name: `chunk-vendors`,
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'initial'
},
common: {
name: `chunk-common`,
minChunks: 2,
priority: -20,
chunks: 'initial',
reuseExistingChunk: true
}
}
}) Code copied from webpack docs:https://webpack.js.org/plugins/split-chunks-plugin/#optimizationsplitchunks module.exports = {
//...
optimization: {
splitChunks: {
chunks: 'async',
minSize: 20000,
minRemainingSize: 0,
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
enforceSizeThreshold: 50000,
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
reuseExistingChunk: true,
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
},
},
},
}; So the main difference between the two configs is that webpack uses by default Note that it's the same configuration as vue-cli, but just changing the optimization: {
splitChunks: {
cacheGroups: {
defaultVendors: {
name: `chunk-vendors`,
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'async',
reuseExistingChunk: true
},
common: {
name: `chunk-common`,
minChunks: 2,
priority: -20,
chunks: 'async',
reuseExistingChunk: true
}
}
}
} Still, I don't know the specific reason, in this stackoverflow thread they explain the differences between the three possible split chunk values: |
Chunks also accepts function. So all, initial, async or function. Use function and test chunks to see if they contain remote-module or provide-module type, return false for those and true for any others. That lets you exclude MF manages chunks from split chunks algorithms |
|
based on @gabrielmaschke and @ScriptedAlchemy 's solution, the following worked for me common: {
name: `chunk-common`,
minChunks: 3,
enforce: true,
priority: -20,
chunks: 'async',
reuseExistingChunk: true,
test(module) {
if (
module.type === 'provide-module' ||
module.type === 'consume-shared-module' ||
module.type === 'remote-module'
) {
return false;
}
return true;
}
} I am not sure how to fix this in webpack. since all module types are derived classes of Module, they get sent to the SplitChunksPlugin. It does not make sense to add a condition in the SplitChunksPlugin to check for this but I cant find where else to fix it |
Not necessarily since I still want the option to be able to manipulate the chunking algorithm for federated module chunks too. So I don't want to skip it from split chunks. Maybe a default option can be added though. |
Manipulate only From my understanding, |
webpack version: 5.20.0
error message
warining: Initialization of sharing external failed: ScriptExternalLoadError: Loading script failed.
error: Uncaught (in promise) ScriptExternalLoadError: Loading script failed.
similar issue: (#307)
I already used syntax like
app2: "app2@http://localhost:3002/remoteEntry.js"
, but the browser still report the error.Here's my config:
app1
app2
other
I am sure I have read
shared-routes2
folder in this repo.The difference between my demo and
shared-routes
is this different framework.I use vue-cli in my demo.
I inspect the generated webpack config:
The text was updated successfully, but these errors were encountered: