ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.14k stars 14.64k forks source link

[Bug Report] '$isServer' error in vite 2.3.2 #21005

Closed qwfy5287 closed 3 years ago

qwfy5287 commented 3 years ago

Element UI version

2.15.1

OS/Browsers version

mac,chrome

Vue version

2.6.12

Reproduction Link

https://github.com/qwfy5287/vue-admin-template-vite

Steps to reproduce

yarn dev

What is Expected?

not error

What is actually happening?

Uncaught TypeError: Cannot read property '$isServer' of undefined

LauJon commented 3 years ago

我也遇到了这个问题 ,应该是vite不支持require方式,应该用vue3版本 element-plus ,目前不想换element-plus改动太大。不知道官方有没有解决办法,兼容

qwfy5287 commented 3 years ago

@LauJon vite v2.1.5 是可以的,不清楚改了的什么。

pasBone commented 3 years ago

有解決办法请踢我一下

Rainmen-xia commented 3 years ago

element-ui官方出一个es版本大家就不会这么难受了

Yuliang-Lee commented 3 years ago

应该是因为 https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#breaking-changes

qwfy5287 commented 3 years ago

@LauJon @pasBone @Rainmen-xia @Yuliang-Lee

找到方法解决了

插件

https://github.com/dravenww/esbuild-plugin-vite-element-ui

示例

https://github.com/qwfy5287/vite-element-ui-example

LauJon commented 3 years ago

@LauJon @pasBone @Rainmen-xia @Yuliang-Lee

找到方法解决了

插件

https://github.com/dravenww/esbuild-plugin-vite-element-ui

示例

https://github.com/qwfy5287/vite-element-ui-example

没有起作用 更新了最新的Vite 2.3.5也不行

qwfy5287 commented 3 years ago

@LauJon

我把 vite 锁定在 2.2.4, 大于 2.3.0 的可以用 element-ui-es,看下这边

https://github.com/dravenww/esbuild-plugin-vite-element-ui/issues/1

lovetingyuan commented 3 years ago

element-ui官方出一个es版本大家就不会这么难受了

属实拉垮 没人维护了吧

qwfy5287 commented 3 years ago

新版的vite解决问题了

fix: 升级到 vite v2.3.7, esbuild v0.12.7 for esm compatibility; 去掉 esbuild-plugin-vite-element-ui

示例 https://github.com/qwfy5287/vue-admin-template-vite

LauJon commented 3 years ago

@qwfy5287 谢谢分享