Skip to content
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

Webpack5生成的项目有时候无法获取导出内容 #2802

Closed
qiYuei opened this issue Nov 9, 2023 · 2 comments · Fixed by #2811
Closed

Webpack5生成的项目有时候无法获取导出内容 #2802

qiYuei opened this issue Nov 9, 2023 · 2 comments · Fixed by #2811

Comments

@qiYuei
Copy link
Contributor

qiYuei commented Nov 9, 2023

问题描述

  1. Vuecli 生成的项目自带 webpack5 生成的文件会统一加上 defer 标识,qiankun-webpack-plugin 对此标识过滤了。调试的时候还需小改下 webpack-plugin 的代码

  2. 带有 defer 标识的 scriptloadEntry 方法中会先执行 .then() 回调在执行 script.onload 导致 qiankun 获取不到应用生命周期

  3. webpack5output 设置成 libraryTarget 或者 library.type 设置成 window| umd 都有可能导致 代码内的 export 获取不到,导致 qiankun 获取不到应用生命周期

现象

d55fce89ead2b9741d3438e881ec8f3

ad24d4592e0ae195b74fcbe41aa2912

最小复现库

仓库地址

步骤

  1. 安装依赖
  2. 启动主应用 vue3-main
  3. 启动子应用 (因为 qiankun-plugin 还未发布,所以先用 fork 的版本对 defer的 script 也加上 entry ,方便调试)
  4. 点击加载 子应用
  5. 在 子应用的 app.js 断点可以看是否获取到 export 内容

多试几次,有时候加载成功,有时候加载失败

@kuitos
Copy link
Member

kuitos commented Nov 15, 2023

@qiYuei next 分支拉最新代码再看下

@qiYuei
Copy link
Contributor Author

qiYuei commented Nov 16, 2023

@qiYuei next 分支拉最新代码再看下

我一会验证下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants