From dcb34b08e9992881d29aef882043f10ea76f7721 Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Wed, 12 May 2021 13:10:07 +0800 Subject: [PATCH 1/2] fix: ssr error #3983 #3997 --- CHANGELOG.en-US.md | 6 ++++++ CHANGELOG.zh-CN.md | 6 ++++++ antd-tools/gulpfile.js | 12 +++++++++--- components/_util/component-classes.ts | 2 +- components/carousel/index.tsx | 1 + components/vc-image/src/Image.tsx | 2 +- components/vc-menu/Menu.jsx | 2 +- package.json | 3 ++- v2-doc | 2 +- 9 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index df7b8b026..07e47c660 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -10,6 +10,12 @@ --- +## 2.1.5 + +`2021-05-12` + +- 🐞 Fix SSR time reporting error [#3983](https://github.com/vueComponent/ant-design-vue/issues/3983) + ## 2.1.4 `2021-05-09` diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index c3ddae7bf..c48c810d6 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -10,6 +10,12 @@ --- +## 2.1.5 + +`2021-05-12` + +- 🐞 修复 SSR 时报错问题 [#3983](https://github.com/vueComponent/ant-design-vue/issues/3983) + ## 2.1.4 `2021-05-09` diff --git a/antd-tools/gulpfile.js b/antd-tools/gulpfile.js index c87d62fd3..77e94370b 100644 --- a/antd-tools/gulpfile.js +++ b/antd-tools/gulpfile.js @@ -118,10 +118,16 @@ function babelify(js, modules) { ); file.path = file.path.replace(/index\.(js|jsx|ts|tsx)$/, 'css.js'); this.push(file); - next(); - } else { - next(); + } else if (modules !== false) { + const content = file.contents.toString(encoding); + file.contents = Buffer.from( + content + .replace(/lodash-es/g, 'lodash') + .replace(/@ant-design\/icons-vue/g, '@ant-design/icons-vue/lib/icons'), + ); + this.push(file); } + next(); }), ); if (modules === false) { diff --git a/components/_util/component-classes.ts b/components/_util/component-classes.ts index cfbb9cf66..4682d9693 100644 --- a/components/_util/component-classes.ts +++ b/components/_util/component-classes.ts @@ -3,7 +3,7 @@ * https://github.com/component/classes.git */ -import { indexOf } from 'lodash-es'; +import indexOf from 'lodash-es/indexOf'; /** * Whitespace regexp. diff --git a/components/carousel/index.tsx b/components/carousel/index.tsx index a0bd8f88a..ef4e228e1 100644 --- a/components/carousel/index.tsx +++ b/components/carousel/index.tsx @@ -51,6 +51,7 @@ export const CarouselProps = { slickGoTo: PropTypes.number, responsive: PropTypes.array, dotPosition: PropTypes.oneOf(tuple('top', 'bottom', 'left', 'right')), + verticalSwiping: PropTypes.looseBool.def(false), }; const Carousel = defineComponent({ diff --git a/components/vc-image/src/Image.tsx b/components/vc-image/src/Image.tsx index 8e99b5f31..3a5020aee 100644 --- a/components/vc-image/src/Image.tsx +++ b/components/vc-image/src/Image.tsx @@ -7,7 +7,7 @@ import { computed, onMounted, } from 'vue'; -import { isNumber } from 'lodash-es'; +import isNumber from 'lodash-es/isNumber'; import BaseMixin from '../../_util/BaseMixin'; import cn from '../../_util/classNames'; diff --git a/components/vc-menu/Menu.jsx b/components/vc-menu/Menu.jsx index ae559e937..03cd11115 100644 --- a/components/vc-menu/Menu.jsx +++ b/components/vc-menu/Menu.jsx @@ -13,7 +13,7 @@ import { toRaw, watch, } from 'vue'; -import { isEqual } from 'lodash-es'; +import isEqual from 'lodash-es/isEqual'; const Menu = { name: 'Menu', diff --git a/package.json b/package.json index 7df3bb417..7c8b2dabb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ant-design-vue", - "version": "2.1.4", + "version": "2.1.5", "title": "Ant Design Vue", "description": "An enterprise-class UI design language and Vue-based implementation", "keywords": [ @@ -209,6 +209,7 @@ "async-validator": "^3.3.0", "dom-align": "^1.10.4", "dom-scroll-into-view": "^2.0.0", + "lodash": "^4.17.21", "lodash-es": "^4.17.15", "moment": "^2.27.0", "omit.js": "^2.0.0", diff --git a/v2-doc b/v2-doc index 4da56dac8..d19705328 160000 --- a/v2-doc +++ b/v2-doc @@ -1 +1 @@ -Subproject commit 4da56dac85f43ad7a288951cbf09d860ecf93bb4 +Subproject commit d197053285b81e77718621c0b5b94cb3b21831a2 From b51f25fff70e75e192e0435e6929171af703ea68 Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Wed, 12 May 2021 14:32:20 +0800 Subject: [PATCH 2/2] chore: update webpack config --- antd-tools/getWebpackConfig.js | 26 ++++++------- antd-tools/gulpfile.js | 69 +++++++++++++++------------------- package.json | 5 ++- 3 files changed, 47 insertions(+), 53 deletions(-) diff --git a/antd-tools/getWebpackConfig.js b/antd-tools/getWebpackConfig.js index 3ca2b4d8d..8b4deef31 100644 --- a/antd-tools/getWebpackConfig.js +++ b/antd-tools/getWebpackConfig.js @@ -4,8 +4,9 @@ const path = require('path'); const webpack = require('webpack'); const WebpackBar = require('webpackbar'); const { merge } = require('webpack-merge'); +const TerserPlugin = require('terser-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); +const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const CleanUpStatsPlugin = require('./utils/CleanUpStatsPlugin'); // const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; @@ -207,6 +208,9 @@ All rights reserved. }), new CleanUpStatsPlugin(), ], + performance: { + hints: false, + }, }; if (process.env.RUN_ENV === 'PRODUCTION') { @@ -223,17 +227,12 @@ All rights reserved. config.output.libraryTarget = 'umd'; config.optimization = { minimizer: [ - // eslint-disable-next-line no-unused-vars - compiler => { - return () => { - return { - parallel: true, - terserOptions: { - warnings: false, - }, - }; - }; - }, + new TerserPlugin({ + parallel: true, + terserOptions: { + warnings: false, + }, + }), ], }; @@ -266,7 +265,8 @@ All rights reserved. }), ], optimization: { - minimizer: [new OptimizeCSSAssetsPlugin({})], + minimize: true, + minimizer: [new CssMinimizerPlugin({})], }, }); diff --git a/antd-tools/gulpfile.js b/antd-tools/gulpfile.js index 77e94370b..3b4d8c6b1 100644 --- a/antd-tools/gulpfile.js +++ b/antd-tools/gulpfile.js @@ -308,61 +308,54 @@ function publish(tagString, done) { } function pub(done) { - dist(code => { - if (code) { - done(code); - return; - } - const notOk = !packageJson.version.match(/^\d+\.\d+\.\d+$/); - let tagString; - if (argv['npm-tag']) { - tagString = argv['npm-tag']; - } - if (!tagString && notOk) { - tagString = 'next'; - } - if (packageJson.scripts['pre-publish']) { - runCmd('npm', ['run', 'pre-publish'], code2 => { - if (code2) { - done(code2); - return; - } - publish(tagString, done); - }); - } else { + const notOk = !packageJson.version.match(/^\d+\.\d+\.\d+$/); + let tagString; + if (argv['npm-tag']) { + tagString = argv['npm-tag']; + } + if (!tagString && notOk) { + tagString = 'next'; + } + if (packageJson.scripts['pre-publish']) { + runCmd('npm', ['run', 'pre-publish'], code2 => { + if (code2) { + done(code2); + return; + } publish(tagString, done); - } - }); + }); + } else { + publish(tagString, done); + } } -gulp.task( - 'compile-with-es', - gulp.series(done => { - compile(false).on('finish', function() { - done(); - }); - }), -); +gulp.task('compile-with-es', done => { + console.log('[Parallel] Compile to es...'); + compile(false).on('finish', done); +}); + +gulp.task('compile-with-lib', done => { + console.log('[Parallel] Compile to js...'); + compile().on('finish', done); +}); gulp.task( 'compile', - gulp.series('compile-with-es', done => { - compile().on('finish', function() { - done(); - }); + gulp.series(gulp.parallel('compile-with-es', 'compile-with-lib'), done => { + done(); }), ); gulp.task( 'dist', - gulp.series('compile', done => { + gulp.series(done => { dist(done); }), ); gulp.task( 'pub', - gulp.series('check-git', 'compile', done => { + gulp.series('check-git', 'compile', 'dist', done => { // if (!process.env.GITHUB_TOKEN) { // console.log('no GitHub token found, skip'); // } else { diff --git a/package.json b/package.json index 7c8b2dabb..0799926f5 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "test:dev": "cross-env NODE_ENV=test jest --config .jest.js", "compile": "node antd-tools/cli/run.js compile", "generator-webtypes": "tsc -p antd-tools/generator-types/tsconfig.json && node antd-tools/generator-types/index.js", - "pub": "node antd-tools/cli/run.js pub", + "pub": "node --max_old_space_size=8192 antd-tools/cli/run.js pub", "pub-with-ci": "node antd-tools/cli/run.js pub-with-ci", "prepublish": "node antd-tools/cli/run.js guard", "pre-publish": "node ./scripts/prepub && npm run generator-webtypes", @@ -112,6 +112,7 @@ "compare-versions": "^3.3.0", "cross-env": "^7.0.0", "css-loader": "^5.0.0", + "css-minimizer-webpack-plugin": "^2.0.0", "deep-assign": "^3.0.0", "docsearch.js": "^2.6.3", "enquire-js": "^0.2.1", @@ -151,7 +152,6 @@ "mkdirp": "^0.5.1", "mockdate": "^2.0.2", "nprogress": "^0.2.0", - "optimize-css-assets-webpack-plugin": "^5.0.1", "postcss": "^8.2.12", "postcss-loader": "^5.0.0", "prettier": "^1.18.2", @@ -171,6 +171,7 @@ "stylelint-config-standard": "^22.0.0", "stylelint-declaration-block-no-ignored-properties": "^2.1.0", "stylelint-order": "^4.0.0", + "terser-webpack-plugin": "^5.1.1", "through2": "^3.0.0", "ts-jest": "^26.4.1", "ts-loader": "^9.1.0",