element-plus / element-plus-vite-starter

🌰 A starter kit for Element Plus with Vite
https://vite-starter.element-plus.org
1.1k stars 362 forks source link

build Error: Unexpected token #2

Closed em2046 closed 3 years ago

em2046 commented 3 years ago

system: windows10 element-plus version: latest

error log: "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" run build --scripts-prepend-node-path=auto

element-plus-vite-starter@0.0.0 build D:\GitHub\element-plus-vite-starter-master vite build

vite v1.0.0-rc.9

Error: Unexpected token at error (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:5252:30) at Module.error (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:9820:16) at tryParse (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:9701:23) at Module.setSource (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:10127:19) at ModuleLoader.addModuleSource (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:18288:20) at async ModuleLoader.fetchModule (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:18344:9) at async Promise.all (index 0) at async ModuleLoader.fetchStaticDependencies (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:18369:34) at async Promise.all (index 0) at async ModuleLoader.fetchModule (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:18346:9) { code: 'PARSE_ERROR', parserError: SyntaxError: Unexpected token (928:3225) at Object.pp$4.raise (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:15542:13) at Object.pp.unexpected (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:13234:8) at Object.pp.expect (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:13228:26) at Object.pp$3.parseExprList (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:15433:12) at Object.pp$3.parseSubscript (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:14799:25) at Object.parseSubscript (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:19112:37) at Object.pp$3.parseSubscripts (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:14762:24) at Object.pp$3.parseExprSubscripts (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:14747:21) at Object.pp$3.parseMaybeUnary (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:14721:17) at Object.parseMaybeUnary (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:19144:29) { pos: 534953, loc: Position { line: 928, column: 3225 }, raisedAt: 534961 }, id: 'D:\GitHub\element-plus-vite-starter-master\node_modules\element-plus\lib\index.js', pos: 534953, loc: { file: 'D:\GitHub\element-plus-vite-starter-master\node_modules\element-plus\lib\index.js', line: 923, column: 40252 }, frame: '921: \n' + '922: "use strict";\n' + '923: eval("webpack_require.r(webpack_exports);\n/ WEBPACK VAR INJECTION /(function(process) {function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.len gth; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n \n return target;\n };\n\n return _extends.apply(this, arguments);\n}\n\nfunction _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.cons tructor = subClass;\n subClass.proto = superClass;\n}\n\nfunction _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.proto | | Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}\n\nfunction _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.proto = p;\n retur n o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nfunction _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false; \n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nf unction _construct(Parent, args, Class) {\n if (_isNativeReflectConstruct()) {\n _construct = Reflect.construct;\n } else {\n _construct = function _construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) _setPrototypeOf(instance, Class.prototype);\n return instance;\n } ;\n }\n\n return _construct.apply(null, arguments);\n}\n\nfunction _isNativeFunction(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\n\nfunction _wrapNativeSuper(Class) {\n var _cache = typeof Map === \"function\" ? new Map() : undefined;\n\n _wrapNativeSuper = function _wrapNativeSuper(Class) {\n if (Class === null || !_isNativeFunction(Class)) return Class;\n\n if (typeof Clas s !== \"function\") {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class)) return _cache.get(Clas s);\n\n _cache.set(Class, Wrapper);\n }\n\n function Wrapper() {\n return _construct(Class, arguments, _getPrototypeOf(this).constructor);\n }\n\n Wrapper.prototype = Object.create(Class.prot otype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return _setPrototypeOf(Wrapper, Class);\n };\n\n return _wrapNativeSuper(Class);\n}\n\n/ eslint no-console:0 /\nvar formatRegExp = /%[sdj%]/g;\nvar warning = function warning() {}; // don\'t print warning message when in production env or node runtime\n\nif (typ eof process !== \'undefined\' && process.env && \"development\" !== \'production\' && typeof window !== \'undefined\' && typeof document !== \'undefined\') {\n warning = function warning(type, errors) {\n if (typeo f console !== \'undefined\' && console.warn) {\n if (errors.every(function (e) {\n return typeof e === \'string\';\n })) {\n console.warn(type, errors);\n }\n }\n };\n}\n\nfunctio n convertFieldsError(errors) {\n if (!errors || !errors.length) return null;\n var fields = {};\n errors.forEach(function (error) {\n var field = error.field;\n fields[field] = fields[field] || [];\n fiel ds[field].push(error);\n });\n return fields;\n}\nfunction format() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[key];\n }\n\n va r i = 1;\n var f = args[0];\n var len = args.length;\n\n if (typeof f === \'function\') {\n return f.apply(null, args.slice(1));\n }\n\n if (typeof f === \'string\') {\n var str = String(f).replace(form atRegExp, function (x) {\n if (x === \'%%\') {\n return \'%\';\n }\n\n if (i >= len) {\n return x;\n }\n\n switch (x) {\n case \'%s\':\n return String(args[ i++]);\n\n case \'%d\':\n return Number(args[i++]);\n\n case \'%j\':\n try {\n return JSON.stringify(args[i++]);\n } catch () {\n return \'[Circular] \';\n }\n\n break;\n\n default:\n return x;\n }\n });\n return str;\n }\n\n return f;\n}\n\nfunction isNativeStringType(type) {\n return type === \'string\' | | type === \'url\' || type === \'hex\' || type === \'email\' || type === \'date\' || type === \'pattern\';\n}\n\nfunction isEmptyValue(value, type) {\n if (value === undefined || value === null) {\n return true;\ n }\n\n if (type === \'array\' && Array.isArray(value) && !value.length) {\n return true;\n }\n\n if (isNativeStringType(type) && typeof value === \'string\' && !value) {\n return true;\n }\n\n return false;\n}\n\nfunction asyncParallelArray(arr, func, callback) {\n var results = [];\n var total = 0;\n var arrLength = arr.length;\n\n function count(errors) {\n results.push.apply(results, errors);\n total++;\n\n if (total === arrLength) {\n callback(results);\n }\n }\n\n arr.forEach(function (a) {\n func(a, count);\n });\n}\n\nfunction asyncSerialArray(arr, func, callback) {\n var index = 0;\n var arrLength = arr.length;\n\n function next(errors) {\n if (errors && errors.length) {\n callback(errors);\n return;\n }\n\n var original = index;\n index = index + 1;\n\n if (original < arrLength) {\n func(arr[original], next);\n } else {\n callback([]);\n }\n }\n\n next([]);\n}\n\nfunction flattenObjArr(objArr) {\n var ret = [];\n Object.keys(objArr).forEach(f unction (k) {\n ret.push.apply(ret, objArr[k]);\n });\n return ret;\n}\n\nvar AsyncValidationError = /#PURE/function (_Error) {\n _inheritsLoose(AsyncValidationError, _Error);\n\n function AsyncValida tionError(errors, fields) {\n var _this;\n\n _this = _Error.call(this, \'Async Validation Error\') || this;\n _this.errors = errors;\n _this.fields = fields;\n return _this;\n }\n\n return AsyncVa lidationError;\n}( /#PURE/_wrapNativeSuper(Error));\nfunction asyncMap(objArr, option, func, callback) {\n if (option.first) {\n var _pending = new Promise(function (resolve, reject) {\n var next = func tr );\n asyncSerialArray(flattenArr, func, next);\n });\n\n _pending[\"catch\"](function (e) {\n return e;\n });\n\n return _pending;\n }\n\n var firstFields = option.firstFields || [];\n \n if (firstFields === true) {\n firstFields = Object.keys(objArr);\n }\n\n var objArrKeys = Object.keys(objArr);\n var objArrLength = objArrKeys.length;\n var total = 0;\n var results = [];\n var pendin g = new Promise(function (resolve, reject) {\n var next = function next(errors) {\n results.push.apply(results, errors);\n total++;\n\n if (total === objArrLength) {\n callback(results);\n return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve();\n }\n };\n\n if (!objArrKeys.length) {\n callback(results);\n resolve();\n }\ \n\n objArrKeys.forEach(function (key) {\n var arr = objArr[key];\n\n if (firstFields.indexOf(key) !== -1) {\n asyncSerialArray(arr, func, next);\n } else {\n asyncParallelArray(arr, func, next);\n }\n });\n });\n pending[\"catch\"](function (e) {\n return e;\n });\n return pending;\n}\nfunction complementError(rule) {\n return function (oe) {\n if (oe && oe.message) {\ n oe.field = oe.field || rule.fullField;\n return oe;\n }\n\n return {\n message: typeof oe === \'function\' ? oe() : oe,\n field: oe.field || rule.fullField\n };\n };\n}\nfunction d eepMerge(target, source) {\n if (source) {\n for (var s in source) {\n if (source.hasOwnProperty(s)) {\n var value = source[s];\n\n if (typeof value === \'object\' && typeof target[s] === \'obj ect\') {\n target[s] = _extends(extends({}, target[s]), value);\n } else {\n target[s] = value;\n }\n }\n }\n }\n\n return target;\n}\n\n/\n Rule for validating required fields.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param source The source object being validated.\n @param errors An array of errors tha t this rule may add\n validation errors to.\n @param options The validation options.\n @param options.messages The validation messages.\n /\n\nfunction required(rule, value, source, errors, options, type) { \n if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type || rule.type))) {\n errors.push(format(options.messages.required, rule.fullField));\n }\n}\n\n/\n Rule for validating whitespace.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param source The source object being validated.\n @param errors An array of errors that th is rule may add\n validation errors to.\n @param options The validation options.\n @param options.messages The validation messages.\n /\n\nfunction whitespace(rule, value, source, errors, options) {\n if (/^\\s+$/.test(value) || value === \'\') {\n errors.push(format(options.messages.whitespace, rule.fullField));\n }\n}\n\n/ eslint max-len:0 /\n\nvar pattern = {\n // http://emailregex.com/\\n email: /^(([ ^>()\\\\[\\\\]\\\\\\\\.,;:\\\\s@\\"]+(\\\\.[^<()\\[\\]\\\\.,;:\\s@\"]+))|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n url: new R egExp(\"^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\\\S+(?::\\\\S)?@)?(?:(?:(?:[1-9]\\\\d?|1\\\\d\\\\d|2[01]\\\\d|22[0-3])(?:\\\\.(?:1?\\\\d{1,2}|2[0-4]\\\\d|25[0-5])){2}(?:\\\\.( ?:[0-9]\\\\d?|1\\\\d\\\\d|2[0-4]\\\\d|25[0-4]))|(?:(?:[a-z\\\\u00a1-\\\\uffff0-9]+-)[a-z\\\\u00a1-\\\\uffff0-9]+)(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff0-9]+-)[a-z\\\\u00a1-\ \\\uffff0-9]+)(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff]{2,})))|localhost)(?::\\\\d{2,5})?(?:(/|\\\\?|#)[^\\\\s])?$\", \'i\'),\n hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i\n};\nvar types = {\n integ er: function integer(value) {\n return types.number(value) && parseInt(value, 10) === value;\n },\n \"float\": function float(value) {\n return types.number(value) && !types.integer(value);\n },\n array: function array(value) {\n return Array.isArray(value);\n },\n regexp: function regexp(value) {\n if (value instanceof RegExp) {\n return true;\n }\n\n try {\n return !!new RegExp(value);\n } catch (e) {\n return false;\n }\n },\n date: function date(value) {\n return typeof value.getTime === \'function\' && typeof value.getMonth === \'function\' && typeof value.getYear === \'function\' && !isNaN(value.getTime());\n },\n number: function number(value) {\n if (isNaN(value)) {\n return false;\n }\n\n return typeof value === \'number\';\n },\n object: function object(value) {\n return typeof value === \'object\' && !types.array(value);\n },\n method: function method(value) {\n return typeof value === \'function\';\n },\n email: function email(value) {\n return typeof value === \' string\' && !!value.match(pattern.email) && value.length < 255;\n },\n url: function url(value) {\n return typeof value === \'string\' && !!value.match(pattern.url);\n },\n hex: function hex(value) {\n retu rn typeof value === \'string\' && !!value.match(pattern.hex);\n }\n};\n/\n Rule for validating the type of a value.\n \n @param rule The validation rule.\n @param value The value of the field on the sou rce object.\n @param source The source object being validated.\n @param errors An array of errors that this rule may add\n validation errors to.\n @param options The validation options.\n @param options .messages The validation messages.\n /\n\nfunction type(rule, value, source, errors, options) {\n if (rule.required && value === undefined) {\n required(rule, value, source, errors, options);\n return;\n }\ \n\n var custom = [\'integer\', \'float\', \'array\', \'regexp\', \'object\', \'method\', \'email\', \'number\', \'date\', \'url\', \'hex\'];\n var ruleType = rule.type;\n\n if (custom.indexOf(ruleType) > -1) {\n if (!typesruleType) {\n errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));\n } // straight typeof check\n\n } else if (ruleType && typeof value !== rule.type) {\n errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));\n }\n}\n\n/\n Rule for validating minimum and maximum allowed values.\n \n @param rule The validation rule.\n @param va lue The value of the field on the source object.\n @param source The source object being validated.\n @param errors An array of errors that this rule may add\n validation errors to.\n @param options The val idation options.\n @param options.messages The validation messages.\n /\n\nfunction range(rule, value, source, errors, options) {\n var len = typeof rule.len === \'number\';\n var min = typeof rule.min === \'nu mber\';\n var max = typeof rule.max === \'number\'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)\n\n var spRegexp = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n var val = valu e;\n var key = null;\n var num = typeof value === \'number\';\n var str = typeof value === \'string\';\n var arr = Array.isArray(value);\n\n if (num) {\n key = \'number\';\n } else if (str) {\n key = \ 'string\';\n } else if (arr) {\n key = \'array\';\n } // if the value is not of a supported type for range validation\n // the validation rule rule should use the\n // type property to also test for a particula r type\n\n\n if (!key) {\n return false;\n }\n\n if (arr) {\n val = value.length;\n }\n\n if (str) {\n // 处理码点大于U+010000的文字length属性不准确的bug,如\"���\".lenght !== 3\n val = v alue.replace(spRegexp, \'\').length;\n }\n\n if (len) {\n if (val !== rule.len) {\n errors.push(format(options.messages[key].len, rule.fullField, rule.len));\n }\n } else if (min && !max && val < rule .min) {\n errors.push(format(options.messages[key].min, rule.fullField, rule.min));\n } else if (max && !min && val > rule.max) {\n errors.push(format(options.messages[key].max, rule.fullField, rule.max));\n } else if (min && max && (val < rule.min || val > rule.max)) {\n errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));\n }\n}\n\nvar ENUM = \'enum\';\n/\n Rule for validating a value exists in an enumerable list.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param source The source object being validated.\n @param errors An array of errors that this rule may add\n validation errors to.\n @param options The validation options.\n @param options.messages The validation messages.\n /\n\nfunction enumerable(rule, value, source, er rors, options) {\n rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];\n\n if (rule[ENUM].indexOf(value) === -1) {\n errors.push(format(options.messages[ENUM], rule.fullField, rule[ENUM].join(\', \')));\n }\n}\n\n/\n Rule for validating a regular expression pattern.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param source The source object being validated.\n @param errors An array of errors that this rule may add\n validation errors to.\n @param options The validation options.\n @param options.messages The validation messages.\n /\n\nfunction pattern$1(rule, value, source, errors, options) {\n if (rule.pattern) {\n if (rule.pattern instanceof RegExp) {\n // if a RegExp instance is passed, reset lastIndex in case its global\n // flag is acc identally set to true, which in a validation scenario\n // is not necessary and the result might be misleading\n rule.pattern.lastIndex = 0;\n\n if (!rule.pattern.test(value)) {\n errors.push(f ormat(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));\n }\n } else if (typeof rule.pattern === \'string\') {\n var _pattern = new RegExp(rule.pattern);\n\n if (!_pattern.tes t(value)) {\n errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));\n }\n }\n }\n}\n\nvar rules = {\n required: required,\n whitespace: whitespace,\n type : type,\n range: range,\n \"enum\": enumerable,\n pattern: pattern$1\n};\n\n/\n Performs validation for string types.\n \n @param rule The validation rule.\n @param value The value of the field o n the source object.\n @param callback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\ n */\n\nfunction string(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValu e(value, \'string\') && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options, \'string\');\n\n if (!isEmptyValue(value, \'string\')) {\n rules.type(ru le, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n rules.pattern(rule, value, source, errors, options);\n\n if (rule.whitespace === true) {\n rules.whites pace(rule, value, source, errors, options);\n }\n }\n }\n\n callback(errors);\n}\n\n/*\n Validates a function.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n /\n\nfunction method(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue (value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\ n }\n }\n\n callback(errors);\n}\n\n/\n Validates a number.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback fu nction.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n */\n\nfunction number(rule, value, callback, source, o ptions) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (value === \'\') {\n value = undefined;\n }\n\n if (isE mptyValue(value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, op tions);\n rules.range(rule, value, source, errors, options);\n }\n }\n\n callback(errors);\n}\n\n/\n Validates a boolean.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n */\n\nfunction _boolean(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, error s, options);\n }\n }\n\n callback(errors);\n}\n\n/*\n Validates the regular expression type.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n /\n\nfunction regexp (rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.require d) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (!isEmptyValue(value)) {\n rules.type(rule, value, source, errors, options);\n }\n }\n\n cal lback(errors);\n}\n\n/\n Validates a number is an integer.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback function.\ n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n */\n\nfunction integer(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\ n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n } \n }\n\n callback(errors);\n}\n\n/\n Validates a number is a floating point number.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param cal lback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n */\n\nfunction floatFn(rule, valu e, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, sou rce, errors, options);\n }\n }\n\n callback(errors);\n}\n\n/*\n Validates an array.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n /\n\nfunction array(rule, val ue, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value, \'array\') && !rule.requir ed) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options, \'array\');\n\n if (!isEmptyValue(value, \'array\')) {\n rules.type(rule, value, source, errors, options);\ n rules.range(rule, value, source, errors, options);\n }\n }\n\n callback(errors);\n}\n\n/\n Validates an object.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages. \n */\n\nfunction object(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyVa lue(value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options) ;\n }\n }\n\n callback(errors);\n}\n\nvar ENUM$1 = \'enum\';\n/\n Validates an enumerable list.\n \n @param rule The validation rule.\n @param value The value of the field on the source object. \n @param callback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n */\n\nfunction e numerable$1(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !r ule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules[ENUM$1](rule, value, source, errors, options);\n }\n }\n\n callback(errors);\n}\n\n/\n Validates a regular expression pattern.\n \n Performs validation when a rule only contains\n a pattern property but is not declared as a string type.\n \n @par am rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback function.\n @param source The source object being validated.\n @param options The vali dation options.\n @param options.messages The validation messages.\n /\n\nfunction pattern$2(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && sour ce.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value, \'string\') && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (!isEmptyValue(value, \'string\')) {\n rules.pattern(rule, value, source, errors, options);\n }\n }\n\n callback(errors);\n}\n\nfunction date(rule, value, callback, source, options) {\n // console. log(\'integer rule called %j\', rule);\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); // console.log(\'validate on %s value\', value);\n\n if (validate) {\ n if (isEmptyValue(value, \'date\') && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (!isEmptyValue(value, \'date\')) {\n var dateO bject;\n\n if (value instanceof Date) {\n dateObject = value;\n } else {\n dateObject = new Date(value);\n }\n\n rules.type(rule, dateObject, source, errors, options);\n\n i f (dateObject) {\n rules.range(rule, dateObject.getTime(), source, errors, options);\n }\n }\n }\n\n callback(errors);\n}\n\nfunction required$1(rule, value, callback, source, options) {\n var e rrors = [];\n var type = Array.isArray(value) ? \'array\' : typeof value;\n rules.required(rule, value, source, errors, options, type);\n callback(errors);\n}\n\nfunction type$1(rule, value, callback, source, opti ons) {\n var ruleType = rule.type;\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value, ruleType) && !rule.req uired) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options, ruleType);\n\n if (!isEmptyValue(value, ruleType)) {\n rules.type(rule, value, source, errors, options);\ \n }\n }\n\n callback(errors);\n}\n\n/\n Performs validation for any type.\n \n @param rule The validation rule.\n @param value The value of the field on the source object.\n @param callback The callback function.\n @param source The source object being validated.\n @param options The validation options.\n @param options.messages The validation messages.\n */\n\nfunction any(rule, value, callbac k, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return c allback();\n }\n\n rules.required(rule, value, source, errors, options);\n }\n\n callback(errors);\n}\n\nvar validators = {\n string: string,\n method: method,\n number: number,\n \"boolean\": _b oolean,\n regexp: regexp,\n integer: integer,\n \"float\": floatFn,\n array: array,\n object: object,\n \"enum\": enumerable$1,\n pattern: pattern$2,\n date: date,\n url: type$1,\n hex: type$1,\n email: type$1,\n required: required$1,\n any: any\n};\n\nfunction newMessages() {\n return {\n \"default\": \'Validation error on field %s\',\n required: \'%s is required\',\n \"enum\": \'%s must b e one of %s\',\n whitespace: \'%s cannot be empty\',\n date: {\n format: \'%s date %s is invalid for format %s\',\n parse: \'%s date could not be parsed, %s is invalid \',\n invalid: \'%s date %s is invalid\'\n },\n types: {\n string: \'%s is not a %s\',\n method: \'%s is not a %s (function)\',\n array: \'%s is not an %s\',\n object: \'%s is not an %s\',\n number: \'%s is not a %s\',\n date: \'%s is not a %s\',\n \"boolean\": \'%s is not a %s\',\n integer: \'%s is not an %s\',\n \"float\": \'%s is not a %s\',\n regexp: \'%s is not a valid %s\',\n email: \' %s is not a valid %s\',\n url: \'%s is not a valid %s\',\n hex: \'%s is not a valid %s\'\n },\n string: {\n len: \'%s must be exactly %s characters\',\n min: \'%s must be at least %s charact ers\',\n max: \'%s cannot be longer than %s characters\',\n range: \'%s must be between %s and %s characters\'\n },\n number: {\n len: \'%s must equal %s\',\n min: \'%s cannot be less than % s\',\n max: \'%s cannot be greater than %s\',\n range: \'%s must be between %s and %s\'\n },\n array: {\n len: \'%s must be exactly %s in length\',\n min: \'%s cannot be less than %s in leng th\',\n max: \'%s cannot be greater than %s in length\',\n range: \'%s must be between %s and %s in length\'\n },\n pattern: {\n mismatch: \'%s value %s does not match pattern %s\'\n },\n clone: function clone() {\n var cloned = JSON.parse(JSON.stringify(this));\n cloned.clone = this.clone;\n return cloned;\n }\n };\n}\nvar messages = newMessages();\n\n/\n Encapsulates a va lidation schema.\n \n @param descriptor An object declaring validation rules\n for this schema.\n */\n\nfunction Schema(descriptor) {\n this.rules = null;\n this._messages = messages;\n this.define(descr iptor);\n}\n\nSchema.prototype = {\n messages: function messages(_messages) {\n if (_messages) {\n this._messages = deepMerge(newMessages(), _messages);\n }\n\n return this.messages;\n },\n def ine: function define(rules) {\n if (!rules) {\n throw new Error(\'Cannot configure a schema with no rules\');\n }\n\n if (typeof rules !== \'object\' || Array.isArray(rules)) {\n throw new Error(\' Rules must be an object\');\n }\n\n this.rules = {};\n var z;\n var item;\n\n for (z in rules) {\n if (rules.hasOwnProperty(z)) {\n item = rules[z];\n this.rules[z] = Array.isArr ay(item) ? item : [item];\n }\n }\n },\n validate: function validate(source, o, oc) {\n var _this = this;\n\n if (o === void 0) {\n o = {};\n }\n\n if (oc === void 0) {\n oc = f

(!this.rules || Object.keys(this.rules).length === 0) {\n if (callback) {\n callback();\n }\n\n return Promise.resolve();\n }\n\n function complete(results) {\n var i;\n var errors = [];\n var fields = {};\n\n function add(e) {\n if (Array.isArray(e)) {\n var _errors;\n\n errors = (_errors = errors).concat.apply(_errors, e);\n } else {\n errors.push(e);\n }\n }\n\n for (i = 0; i < results.length; i++) {\n add(results[i]);\n }\n\n if (!errors.length) {\n errors = null;\n fields = null;\n } else {\n fields = convertFieldsError(errors);\n }\n\n callback(errors, fields);\n }\n\n if (options.messages) {\n var messages$1 = this.messages();\n\n if (messages$1 === messages ) {\n messages$1 = newMessages();\n }\n\n deepMerge(messages$1, options.messages);\n options.messages = messages$1;\n } else {\n options.messages = this.messages();\n }\n\n var arr;\n var value;\n var series = {};\n var keys = options.keys || Object.keys(this.rules);\n keys.forEach(function (z) {\n arr = this.rules[z];\n value = source[z];\n arr.forEach(functio n (r) {\n var rule = r;\n\n if (typeof rule.transform === \'function\') {\n if (source === source) {\n source = _extends({}, source);\n }\n\n value = source[z] = rule.transform(value);\n }\n\n if (typeof rule === \'function\') {\n rule = {\n validator: rule\n };\n } else {\n rule = _extends({}, rule);\n }\ n\n rule.validator = _this.getValidationMethod(rule);\n rule.field = z;\n rule.fullField = rule.fullField || z;\n rule.type = _this.getType(rule);\n\n if (!rule.validator) {\n return;\n }\n\n series[z] = series[z] || [];\n series[z].push({\n rule: rule,\n value: value,\n source: source,\n field: z\n });\n });\n });\n var errorFields = {};\n return asyncMap(series, options, function (data, doIt) {\n var rule = data.rule;\n var deep = (rule.type === \'object\' || rule.type === \'array\') && (typeof rule.field s === \'object\' || typeof rule.defaultField === \'object\');\n deep = deep && (rule.required || !rule.required && data.value);\n rule.field = data.field;\n\n function addFullfield(key, schema) {\n return _extends(_extends({}, schema), {}, {\n fullField: rule.fullField + \".\" + key\n });\n }\n\n function cb(e) {\n if (e === void 0) {\n e = [];\n }\n\n var errors = e;\n\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n\n if (!options.suppressWarning && errors.length) {\n Schema.warning(\'async-validator:\', err ors);\n }\n\n if (errors.length && rule.message) {\n errors = [].concat(rule.message);\n }\n\n errors = errors.map(complementError(rule));\n\n if (options.first && error s.length) {\n errorFields[rule.field] = 1;\n return doIt(errors);\n }\n\n if (!deep) {\n doIt(errors);\n } else {\n // if rule is required but the target obj ect\n // does not exist fail at the rule level and don\'t\n // go deeper\n if (rule.required && !data.value) {\n if (rule.message) {\n errors = [].concat(rule.message ).map(complementError(rule));\n } else if (options.error) {\n errors = [options.error(rule, format(options.messages.required, rule.field))];\n }\n\n return doIt(errors);\ n }\n\n var fieldsSchema = {};\n\n if (rule.defaultField) {\n for (var k in data.value) {\n if (data.value.hasOwnProperty(k)) {\n fieldsSchema[k] = r ule.defaultField;\n }\n }\n }\n\n fieldsSchema = _extends(_extends({}, fieldsSchema), data.rule.fields);\n\n for (var f in fieldsSchema) {\n if (fieldsS chema.hasOwnProperty(f)) {\n var fieldSchema = Array.isArray(fieldsSchema[f]) ? fieldsSchema[f] : [fieldsSchema[f]];\n fieldsSchema[f] = fieldSchema.map(addFullfield.bind(null, f));\n }\n }\n\n var schema = new Schema(fieldsSchema);\n schema.messages(options.messages);\n\n if (data.rule.options) {\n data.rule.options.messages = options.messages;\n data.rule.options.error = options.error;\n }\n\n schema.validate(data.value, data.rule.options || options, function (errs) {\n var finalErrors = [];\n\n if (errors && errors.length) {\n finalErrors.push.apply(finalErrors, errors);\n }\n\n if (errs && errs.length) {\n finalErrors.push.apply(finalErrors, errs);\n }\n\n doIt(finalErrors.length ? finalErrors : null);\n });\n }\n }\n\n var res;\n\n if (rule.asyncValidator) {\n res = rule.asyncValidator(rule, data.value, cb, data.sourc e, options);\n } else if (rule.validator) {\n res = rule.validator(rule, data.value, cb, data.source, options);\n\n if (res === true) {\n cb();\n } else if (res === false) {\n cb(rule.message || rule.field + \" fails\");\n } else if (res instanceof Array) {\n cb(res);\n } else if (res instanceof Error) {\n cb(res.message);\n }\n }\n\n if (res && res.then) {\n res.then(function () {\n return cb();\n }, function (e) {\n return cb(e);\n });\n }\n }, function (results) {\n complete(results);\n });\n },\n getType: function getType(rule) {\n if (rule.type === undefined && rule.pattern instanceof RegExp) {\n rule.type = \'pattern\';\n }\n\n if (typeof rule.validator !== \'function\' && rul e.type && !validators.hasOwnProperty(rule.type)) {\n throw new Error(format(\'Unknown rule type %s\', rule.type));\n }\n\n return rule.type || \'string\';\n },\n getValidationMethod: function getValidati onMethod(rule) {\n if (typeof rule.validator === \'function\') {\n return rule.validator;\n }\n\n var keys = Object.keys(rule);\n var messageIndex = keys.indexOf(\'message\');\n\n if (messageInd ex !== -1) {\n keys.splice(messageIndex, 1);\n }\n\n if (keys.length === 1 && keys[0] === \'required\') {\n return validators.required;\n }\n\n return validators[this.getType(rule)] || false;\ \n }\n};\n\nSchema.register = function register(type, validator) {\n if (typeof validator !== \'function\') {\n throw new Error(\'Cannot register a validator by type, validator is not a function\');\n }\n\n validators[type] = validator;\n};\n\nSchema.warning = warning;\nSchema.messages = messages;\nSchema.validators = validators;\n\n/ harmony default export / webpack_exports[\"default\"] = (Schema);\n//# sourc eMappingURL=index.js.map\n\n/ WEBPACK VAR INJECTION /}.call(this, webpack_require(/! ./../../process/browser.js / \"./node_modules/process/browser.js\")))\n\n//# sourceURL=webpack://ElementPlus/./node_modules /async-validator/dist-web/index.js?");\n' + '

                                                                            ^\n' +
'924: \n' +
'925: /***/ }),',

watchFiles: [ 'D:\GitHub\element-plus-vite-starter-master\index.html', 'D:\GitHub\element-plus-vite-starter-master\src\main.js', 'D:\GitHub\element-plus-vite-starter-master\node_modules\@vue\runtime-dom\dist\runtime-dom.esm-bundler.js', 'D:\GitHub\element-plus-vite-starter-master\node_modules\@vue\runtime-core\dist\runtime-core.esm-bundler.js', 'D:\GitHub\element-plus-vite-starter-master\node_modules\@vue\shared\dist\shared.esm-bundler.js', 'D:\GitHub\element-plus-vite-starter-master\node_modules\@vue\reactivity\dist\reactivity.esm-bundler.js', 'D:\GitHub\element-plus-vite-starter-master\src\App.vue', 'D:\GitHub\element-plus-vite-starter-master\src\index.css', 'D:\GitHub\element-plus-vite-starter-master\src\App.vue?vue&type=script&lang.js', 'D:\GitHub\element-plus-vite-starter-master\src\App.vue?vue&type=template&id=7ddbb86d&scoped=true&lang.js', 'D:\GitHub\element-plus-vite-starter-master\src\App.vue?vue&type=style&index=0&id=7ddbb86d&scoped=true&lang.css', 'D:\GitHub\element-plus-vite-starter-master\node_modules\element-plus\lib\index.js', 'D:\GitHub\element-plus-vite-starter-master\node_modules\element-plus\lib\theme-chalk\index.css', 'D:\GitHub\element-plus-vite-starter-master\src\assets\logo.png', 'D:\GitHub\element-plus-vite-starter-master\src\components\HelloWorld.vue', 'D:\GitHub\element-plus-vite-starter-master\src\components\HelloWorld.vue?vue&type=script&lang.js', 'D:\GitHub\element-plus-vite-starter-master\src\components\HelloWorld.vue?vue&type=template&id=bd4c1bf6&lang.js' ] } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! element-plus-vite-starter@0.0.0 build: vite build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the element-plus-vite-starter@0.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\twili\AppData\Roaming\npm-cache_logs\2020-11-17T01_35_38_743Z-debug.log

Process finished with exit code 1

LoveofRedMoon commented 3 years ago

find a way to solve this(element-plus dev branch already fix)

find element-plus/package.json in node_modules

add "module":"lib/index.esm.js" and rebuild the project

zazzaz commented 3 years ago

interesting bug. I think Vite should support umd bundle by default and we don't need to use the esm bundle.

em2046 commented 3 years ago

Duplicate of https://github.com/element-plus/element-plus/issues/625

zazzaz commented 3 years ago

I'll close this issue and we can track it on https://github.com/element-plus/element-plus/issues/625