From a14afae7c94247f40d1e7785bf5aaa823879878c Mon Sep 17 00:00:00 2001 From: zouhang Date: Wed, 30 Sep 2020 18:21:47 +0800 Subject: [PATCH] fix: fix some comp type erro & add rollup build --- build/rollup.config.js | 26 ++++ package.json | 9 ++ packages/badge/src/index.vue | 6 +- packages/collapse/src/collapse.vue | 6 +- packages/tooltip/src/index.ts | 6 +- packages/utils/util.ts | 6 +- tsconfig.json | 7 +- yarn.lock | 204 ++++++++++++++++++++++++++++- 8 files changed, 249 insertions(+), 21 deletions(-) create mode 100644 build/rollup.config.js diff --git a/build/rollup.config.js b/build/rollup.config.js new file mode 100644 index 0000000000..79b9d975e0 --- /dev/null +++ b/build/rollup.config.js @@ -0,0 +1,26 @@ +import vue from 'rollup-plugin-vue' +import typescript from 'rollup-plugin-typescript2' +import css from 'rollup-plugin-css-only' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import { terser } from 'rollup-plugin-terser' +import path from 'path' + +export default [ + // ESM + { + input: path.resolve(__dirname, '../packages/element-plus/index.ts'), + output: { + format: 'esm', + file: 'lib/library.esm.js', + }, + plugins: [ + terser(), + nodeResolve(), + commonjs(), + typescript(), + css(), + vue({ css: false }), + ], + }, +] diff --git a/package.json b/package.json index f4a4f2e261..f9c11e582a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "bootstrap": "yarn && npx lerna bootstrap", "build": "yarn bootstrap && yarn build:lib && yarn build:theme", "build:lib": "rimraf lib && webpack --config ./build/webpack.config.js", + "build:esm": "rollup --config ./build/rollup.config.js", "build:theme": "rimraf packages/theme-chalk/lib && gulp build --gulpfile packages/theme-chalk/gulpfile.js && cp-cli packages/theme-chalk/lib lib/theme-chalk", "lint": "eslint ./packages --ext .vue,.js,.ts", "website-build": "rimraf website-dist && cross-env NODE_ENV=production webpack --config ./website/webpack.config.js", @@ -24,6 +25,9 @@ "@babel/preset-typescript": "^7.10.4", "@commitlint/cli": "^9.1.2", "@commitlint/config-conventional": "^9.1.2", + "@rollup/plugin-commonjs": "^15.1.0", + "@rollup/plugin-node-resolve": "^9.0.0", + "@rollup/plugin-typescript": "^6.0.0", "@types/jest": "^26.0.10", "@types/lodash": "^4.14.161", "@typescript-eslint/eslint-plugin": "^3.10.1", @@ -55,6 +59,11 @@ "markdown-it-container": "^3.0.0", "mini-css-extract-plugin": "^0.11.2", "rimraf": "^3.0.2", + "rollup": "^2.28.2", + "rollup-plugin-css-only": "^2.1.0", + "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-typescript2": "^0.27.3", + "rollup-plugin-vue": "^6.0.0-beta.10", "sass": "^1.26.10", "sass-loader": "^10.0.1", "style-loader": "^1.2.1", diff --git a/packages/badge/src/index.vue b/packages/badge/src/index.vue index 8ace3617c6..44ede6e866 100644 --- a/packages/badge/src/index.vue +++ b/packages/badge/src/index.vue @@ -49,12 +49,12 @@ export default { type: { type: String, default: 'primary', - validator(val: string): boolean { - return ['primary', 'success', 'warning', 'info', 'danger'].indexOf(val) > -1 + validator: (val: string) => { + return ['primary', 'success', 'warning', 'info', 'danger'].includes(val) }, }, }, - setup(props: IBadgeProps): IBadgeSetups { + setup(props) { const content = computed(() => { if (props.isDot) { return diff --git a/packages/collapse/src/collapse.vue b/packages/collapse/src/collapse.vue index b1d258a309..70fd2be489 100644 --- a/packages/collapse/src/collapse.vue +++ b/packages/collapse/src/collapse.vue @@ -5,11 +5,11 @@