alibaba / react-intl-universal

Internationalize React apps. Not only for Component but also for Vanilla JS.
1.34k stars 154 forks source link

vite: global is undefined #154

Closed xiaosenzhang closed 3 years ago

xiaosenzhang commented 3 years ago

vite创建的项目,用此插件会报错

cwtuan commented 3 years ago

please provide more message

xiaosenzhang commented 3 years ago

please provide more message

vite创建react项目
在App.jsx中 import intl from 'react-intl-universal' 后 image image

cheerylong commented 3 years ago

please provide more message

vite创建react项目 在App.jsx中 import intl from 'react-intl-universal' 后 image image

请问解决了吗?也遇到了同样的问题

xiaosenzhang commented 3 years ago

please provide more message

vite创建react项目 在App.jsx中 import intl from 'react-intl-universal' 后 image image

请问解决了吗?也遇到了同样的问题

我找到了两种解决方法:

  1. 直接改node_modules中的源码,把global 换成 var
  2. image 如图,直接在项目index.html中添加script 把global挂载到window下即可

推荐使用第二中方法

cheerylong commented 2 years ago

我也是采用了window.global = window解决。

cwtuan commented 9 months ago

please use the last version react-intl-universal@2.10.1