-
Notifications
You must be signed in to change notification settings - Fork 835
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
vite-ts原nutui3升级4 指南中NutUIResolver无法支持报错 #2157
Comments
复现仓库 404 |
可以了 刚才用的是私有 |
临时解决方案: |
好的 谢谢 |
Icon: 建议先看下这个,有一些破坏性变更,先评估下是否可以升级 V3->V4升级指南 |
好的 谢谢 |
NutUI scenes(nutui 场景)
H5(@nutui/nutui)
NutUI-vue version(nutui-vue 版本)
4.0.2
Vue version(vue 版本)
3.2.47
Operating environment(运行环境)
dev:h5
Citation method(引用方式)
npm
Node version(node 版本)
16.18.0
Browser and its version(浏览器及其版本)
Microsoft Edge 版本 111.0.1661.27 (正式版本) dev (64 位)
System and its version(系统及其版本)
Windows 11 专业版 22H2
Reproduction link(重现链接)
github.com
Steps to reproduce(重现步骤)
升级最新版即重现
What is expected?(期望的结果是什么?)
能够正常打包和使用
What is actually happening?(实际的结果是什么?)
能够正常打包和使用
Remarks(补充说明)
vite.config.ts:
import NutUIResolver from "@nutui/nutui/dist/resolver";
// 组件 图标自动导入
Components({
resolvers: [VantResolver(), IconsResolver(), NaiveUiResolver(), NutUIResolver()]
}),
vite build后控制台报错
Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules@nutui\nutui\dist\resolver\index.mjs not supported.
Instead change the require of node_modules@nutui\nutui\dist\resolver\index.mjs to a dynamic import() which is available in all CommonJS modules.
at Object. (vite.config.ts:74:32)
vite、vue等版本与demo一致
但是没有使用demo中的
const NutUIResolver = () => {
return (name) => {
if (name.startsWith("Nut")) {
const partialName = name.slice(3);
return {
name: partialName,
from: "@nutui/nutui",
sideEffects:
@nutui/nutui/dist/packages/${partialName.toLowerCase()}/style
,};
}
};
};
还有你们这个最新版本的icon不能向下兼容吗?我更新后需要全部手动替换
import {showToast} from '@nutui/nutui';无法自动引入样式,有需要的页面必须引入@nutui/nutui/dist/packages/toast/style才能正常弹出,这也是个问题
The text was updated successfully, but these errors were encountered: