-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
在使用antdesign-vue1.7.8的date-picker组件,通过moment库设置日期组件的default-value,使用webpack编译运行没有问题,改为vite编译运行后会报错 #12969
Comments
Start a new pull request in StackBlitz Codeflow. |
Updated the issue description with the error log, it seems to be caused by (the // node_modules/ant-design-vue/es/_util/moment-util.js
var import_isNil = __toESM(require_isNil());
var TimeType = {
validator: function validator6(value27) {
return typeof value27 === "string" || (0, import_isNil.default)(value27) || (void 0)(value27);
}
}; Source code at https://github.com/vueComponent/ant-design-vue/blob/1.x/components/_util/moment-util.js: import interopDefault from './interopDefault';
import * as moment from 'moment';
import warning from './warning';
import isNil from 'lodash/isNil';
export const TimeType = {
validator(value) {
return typeof value === 'string' || isNil(value) || moment.isMoment(value);
},
}; I'm not sure why esbuild bundles |
I tried it, it seems to need |
I think this is a limitation of // ...
var moment_default = hooks;
export {
moment_default as default
}; which will cause import * as moment from 'moment'
console.log(moment.isMoment) // undefined
console.log(moment.default.isMoment) // isMoment |
Using patch-package or pnpm patch to remove the "jsnext:main" field from the package.json file of moment can temporarily resolve this issue. diff --git a/package.json b/package.json
index 6c1205c9334a15c11757d283b804b027de52314d..3eb02b5955811cbe78af224e3a41ecc34497efa6 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,6 @@
"ender"
],
"main": "./moment.js",
- "jsnext:main": "./dist/moment.js",
"typings": "./moment.d.ts",
"typesVersions": {
">=3.1": { |
use alias can solve
|
use this can resove
|
It works! |
Describe the bug
我的环境是:[email protected][email protected][email protected]
在模板中使用antdesign-vue的date-picker组件,通过moment库设置日期组件的default-value,在webpack编译运行是不会报错的,我想体验下vite,就换成了vite,发现就会报错,具体报错来源是moment库报的。
Reproduction
https://stackblitz.com/edit/vitejs-vite-vwzkll?file=App.vue
Steps to reproduce
npm i
npm run dev
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: