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

子应用采用cdn加载库文件,报错,库文件全局未定义, #1362

Closed
shuixiaobin opened this issue Sep 13, 2024 · 5 comments
Closed
Assignees
Labels
Need Reproduction 需要复现步骤

Comments

@shuixiaobin
Copy link

shuixiaobin commented Sep 13, 2024

Is your feature request related to a problem? Please describe.
主应用: vue3+vite
子应用: vue3+vite

Describe the solution you'd like
A clear and concise description of what you want to happen.
5dcc97fc5e394caddf5a25022cc66c1
86df91f02d4f8eca91cd3dbbaf13afb
e48cf28ba0396b377f7fdc7cc77218b

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
请问怎么解决呢,子应用要改成npm包的形式引用是可以的,如果不改子应用主应用要怎么改下可以适配这种场景?多谢

@timhub66 timhub66 added the Need Reproduction 需要复现步骤 label Sep 14, 2024
Copy link

Hello @shuixiaobin. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository.
您好 @shuixiaobin, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。

@shuixiaobin
Copy link
Author

https://gitee.com/shuixiaobin/micro-app-demo.git

Hello @shuixiaobin. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository. 您好 @shuixiaobin, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。

@shuixiaobin
Copy link
Author

Hello @shuixiaobin. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository. 您好 @shuixiaobin, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。

仓库地址已补充,主应用子应用都在一个里面,多谢;https://gitee.com/shuixiaobin/micro-app-demo.git

@timhub66 timhub66 self-assigned this Sep 14, 2024
@timhub66
Copy link
Member

Hello @shuixiaobin. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository. 您好 @shuixiaobin, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。

仓库地址已补充,主应用子应用都在一个里面,多谢;https://gitee.com/shuixiaobin/micro-app-demo.git

@shuixiaobin 基座启动的时候,加一下 几个未定义变量的替换就行了

microApp.start({
    plugins: {
        modules: {
            "my-app": [{
                loader(code, url) {
                    // 按实际情况 加js文件判断
                    // VUE 
                    code = code.replace('var Vue', 'window.Vue')
                    // VUE-ROUTER
                    code = code.replace('var VueRouter', 'window.VueRouter')
                    // ElementPlusIconsVue
                    code = code.replace('var ElementPlusIconsVue', 'window.ElementPlusIconsVue')
                    return code
                }
            }]
        }
    }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Need Reproduction 需要复现步骤
Projects
None yet
Development

No branches or pull requests

2 participants