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

[Bug]qiankun好像不支持esmodule的语法 #2956

Open
waltbest2 opened this issue May 9, 2024 · 1 comment
Open

[Bug]qiankun好像不支持esmodule的语法 #2956

waltbest2 opened this issue May 9, 2024 · 1 comment

Comments

@waltbest2
Copy link

waltbest2 commented May 9, 2024

提问之前强烈建立您能先阅读一下《如何正确的提出一个 Issue》

What happens?

如果子应用中js使用了esmodule的语法,例如import {} from 'xxx',或者import.meta ,或者export const aa = 3;
都会提示Cannot use xxxxx outside a module
例如 Cannot use 'import.meta' outside a module

感觉和底层用eval执行有关系。

最小可复现仓库

为节约大家的时间,无复现步骤的 ISSUE 会被关闭,提供之后再 REOPEN

复现步骤,错误日志以及相关配置

相关环境信息

  • qiankun 版本 2.10.16
  • 浏览器版本:chrome 100+
  • 操作系统:windows 10
@daiwanxing
Copy link

daiwanxing commented Jun 26, 2024

是的,因为 eval 无法加载 es module,但是你配置了 libraryTarget: umd 的话,import 的脚本应该会正确编译成了 umd 脚本。 如果构建工具是用的 vite,可以用 vite-plugin-qiankun 解决这个问题。它本质上是在 eval 函数内用 dynamic import 加载 es module

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

No branches or pull requests

2 participants