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

引入react的cdn会报如下错误 #17

Open
MateoLu opened this issue Apr 20, 2022 · 11 comments
Open

引入react的cdn会报如下错误 #17

MateoLu opened this issue Apr 20, 2022 · 11 comments

Comments

@MateoLu
Copy link

MateoLu commented Apr 20, 2022

image

@hemengke1997
Copy link

+1

1 similar comment
@cixing
Copy link

cixing commented May 25, 2022

+1

@cixing
Copy link

cixing commented May 25, 2022

image

老哥你解决了吗

@hans000
Copy link

hans000 commented Jun 17, 2022

应该是使用了最新的tsconfig配置造成的,把打包里的import语句去掉就可以了,本质还是依赖的rollup-plugin-external-globals没有解决eight04/rollup-plugin-external-globals#26

@chrisworkalx
Copy link

image

老哥你解决了吗

最近想把老项目移植到vite,react也报这个错,大佬解决没啊?

@cixing
Copy link

cixing commented Jul 1, 2022

image

老哥你解决了吗

最近想把老项目移植到vite,react也报这个错,大佬解决没啊?

import { viteExternalsPlugin } from 'vite-plugin-externals';

@cixing
Copy link

cixing commented Jul 1, 2022

解决了。
1、使用vite-plugin-externals ,本issue的插件没这样试过,应该也可以。
2、
image

@chrisworkalx
Copy link

解决了。 1、使用vite-plugin-externals ,本issue的插件没这样试过,应该也可以。 2、 image

image

好像还是不管用

@cixing
Copy link

cixing commented Jul 1, 2022 via email

@LiWeny16
Copy link

LiWeny16 commented May 5, 2024

import { viteExternalsPlugin } from 'vite-plugin-externals';

我去,有用!

@Zhaoyi-Flyhigher
Copy link

我用了这个插件​ vite-plugin-external解决了上述问题。

import createExternal from 'vite-plugin-external';
// ...
plugins: [
   createExternal({
       interop: 'auto', // 这个声明很重要
       externals: {
            react: 'React',
            'react-dom': 'ReactDOM',
       }
   })
]

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

7 participants