From 99a543f05d975e4e2b2f88fe9f8c8d0197a94ab8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 24 Nov 2024 13:18:01 +0800 Subject: [PATCH 1/5] chore: delete webpack.config.js --- webpack.config.js | 78 ----------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 webpack.config.js diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 763c7dfd..00000000 --- a/webpack.config.js +++ /dev/null @@ -1,78 +0,0 @@ -/* eslint no-param-reassign: 0 */ -// This config is for building dist files -const getWebpackConfig = require('@ant-design/tools/lib/getWebpackConfig'); -const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); -const { EsbuildPlugin } = require('esbuild-loader'); -const CircularDependencyPlugin = require('circular-dependency-plugin'); -const DuplicatePackageCheckerPlugin = require('@madccc/duplicate-package-checker-webpack-plugin'); -const path = require('path'); - -function externalDayjs(config) { - config.externals.dayjs = { - root: 'dayjs', - commonjs2: 'dayjs', - commonjs: 'dayjs', - amd: 'dayjs', - }; -} - -function externalCssinjs(config) { - config.resolve = config.resolve || {}; - config.resolve.alias = config.resolve.alias || {}; - - config.resolve.alias['@ant-design/cssinjs'] = path.resolve(__dirname, 'alias/cssinjs'); -} - -let webpackConfig = getWebpackConfig(false); - -// Used for `size-limit` ci which only need to check min files -if (process.env.PRODUCTION_ONLY) { - // eslint-disable-next-line no-console - console.log('🍐 Build production only'); - webpackConfig = webpackConfig.filter((config) => config.mode === 'production'); -} - -if (process.env.RUN_ENV === 'PRODUCTION') { - webpackConfig.forEach((config) => { - externalDayjs(config); - externalCssinjs(config); - - // Reduce non-minified dist files size - config.optimization.usedExports = true; - // use esbuild - if (process.env.ESBUILD || process.env.CSB_REPO) { - config.optimization.minimizer[0] = new EsbuildPlugin({ - target: 'es2020', - css: true, - }); - } - - if (!process.env.CI || process.env.ANALYZER) { - config.plugins.push( - new BundleAnalyzerPlugin({ - analyzerMode: 'static', - openAnalyzer: false, - reportFilename: '../report.html', - }), - ); - } - - if (!process.env.NO_DUP_CHECK) { - config.plugins.push( - new DuplicatePackageCheckerPlugin({ - verbose: true, - emitError: true, - }), - ); - } - - config.plugins.push( - new CircularDependencyPlugin({ - // add errors to webpack instead of warnings - failOnError: true, - }), - ); - }); -} - -module.exports = [...webpackConfig]; From 6cfd4465838370d69bfaa9d125f78f647f4ea859 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 25 Nov 2024 11:24:49 +0800 Subject: [PATCH 2/5] chore: remove legacy compile command --- .fatherrc.ts | 4 ++-- .github/workflows/site-deploy.yml | 2 +- .github/workflows/size-limit.yml | 2 +- package.json | 7 +------ 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.fatherrc.ts b/.fatherrc.ts index b7970af0..f83aa2ec 100644 --- a/.fatherrc.ts +++ b/.fatherrc.ts @@ -45,8 +45,8 @@ export default defineConfig({ '@ant-design/cssinjs': 'antdCssinjs', antd: 'antd', }, - chainWebpack: (memo) => { - if (process.env.NODE_ENV === 'production') { + chainWebpack: (memo, { env }) => { + if (env === 'production') { memo.plugin('codecov').use(CodecovWebpackPlugin, [ { enableBundleAnalysis: true, diff --git a/.github/workflows/site-deploy.yml b/.github/workflows/site-deploy.yml index 83e472bb..8878ce3d 100644 --- a/.github/workflows/site-deploy.yml +++ b/.github/workflows/site-deploy.yml @@ -28,7 +28,7 @@ jobs: NODE_OPTIONS: --max_old_space_size=4096 - name: build dist and bundle analyzer report - run: bun run compile + run: bun run dist env: ANALYZER: 1 NODE_OPTIONS: --max_old_space_size=4096 diff --git a/.github/workflows/size-limit.yml b/.github/workflows/size-limit.yml index 0b04a217..e54399e1 100644 --- a/.github/workflows/size-limit.yml +++ b/.github/workflows/size-limit.yml @@ -23,4 +23,4 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} package_manager: bun - build_script: compile + build_script: dist diff --git a/package.json b/package.json index 716440a9..568f839f 100644 --- a/package.json +++ b/package.json @@ -37,18 +37,13 @@ "scripts": { "api-collection": "antd-tools run api-collection", "authors": "tsx scripts/generate-authors.ts", - "legacy_build": "npm run compile && NODE_OPTIONS='--max-old-space-size=4096' npm run dist", "changelog": "npm run lint:changelog && tsx scripts/print-changelog.ts", "check-commit": "tsx scripts/check-commit.ts", "clean": "antd-tools run clean && rm -rf es lib coverage locale dist report.html artifacts.zip oss-artifacts.zip", - "precompile": "npm run prestart", - "compile": "father build", + "dist": "father build", "predeploy": "npm run site && cp CNAME _site", "deploy": "gh-pages -d _site -b gh-pages -f", "predist": "npm run version && npm run token:statistic && npm run token:meta", - "legacy_dist": "antd-tools run dist", - "legacy_dist:esbuild": "ESBUILD=true npm run dist", - "legacy_dist:esbuild-no-dup-check": "ESBUILD=true NO_DUP_CHECK=true npm run dist", "format": "biome format --write .", "prelint": "dumi setup", "lint": "npm run version && npm run tsc && npm run lint:script && npm run lint:md && npm run lint:style && npm run lint:changelog", From 0d4506dbd214963ae12b4aa089d1559b79a88fed Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 25 Nov 2024 11:28:28 +0800 Subject: [PATCH 3/5] chore: add circular-dependency-plugin and duplicate-package-checker-webpack-plugin --- .fatherrc.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.fatherrc.ts b/.fatherrc.ts index f83aa2ec..f26e8a2d 100644 --- a/.fatherrc.ts +++ b/.fatherrc.ts @@ -1,16 +1,12 @@ import { codecovWebpackPlugin } from '@codecov/webpack-plugin'; +import DuplicatePackageCheckerPlugin from '@madccc/duplicate-package-checker-webpack-plugin'; +import CircularDependencyPlugin from 'circular-dependency-plugin'; import { defineConfig } from 'father'; class CodecovWebpackPlugin { private options; constructor(options = {}) { - this.options = { - enableBundleAnalysis: true, - bundleName: 'webpack-bundle', - gitService: 'github', - disable: false, - ...options, - }; + this.options = options; } apply(compiler: any) { return codecovWebpackPlugin(this.options).apply(compiler); @@ -55,6 +51,17 @@ export default defineConfig({ gitService: 'github', }, ]); + memo.plugin('circular-dependency-checker').use(CircularDependencyPlugin, [ + { + failOnError: true, + }, + ]); + memo.plugin('duplicate-package-checker').use(DuplicatePackageCheckerPlugin, [ + { + verbose: true, + emitError: true, + }, + ]); } return memo; }, From 193743f2e68b87f38109a22a0309cd3dd32a4454 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 25 Nov 2024 11:38:43 +0800 Subject: [PATCH 4/5] compile => dist --- docs/react/contributing.en-US.md | 8 +------- docs/react/contributing.zh-CN.md | 8 +------- scripts/pre-publish.ts | 6 +++--- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/docs/react/contributing.en-US.md b/docs/react/contributing.en-US.md index 05faa630..fe62f7ce 100644 --- a/docs/react/contributing.en-US.md +++ b/docs/react/contributing.en-US.md @@ -88,15 +88,9 @@ runs the complete test suite. (Make sure the `NODE_ENV` environment variable is -### Compile - -compiles TypeScript code to the `lib` and `es` directory. - - - ### Build -creates UMD build of antd. +Build TypeScript code to the `lib` and `es` directory, creates UMD build of antdx. diff --git a/docs/react/contributing.zh-CN.md b/docs/react/contributing.zh-CN.md index f86f920f..56d17444 100644 --- a/docs/react/contributing.zh-CN.md +++ b/docs/react/contributing.zh-CN.md @@ -90,13 +90,7 @@ Ant Design 团队会关注所有的 pull request,我们会 review 以及合并 ### 编译 -编译 TypeScript 代码到 lib 和 es 目录。 - - - -### 构建 - -构建 antd 的 UMD 版本到 dist 目录。 +编译 TypeScript 代码到 lib 和 es 目录,UMD 版本到 dist 目录。 diff --git a/scripts/pre-publish.ts b/scripts/pre-publish.ts index 24a13d5a..bc608782 100644 --- a/scripts/pre-publish.ts +++ b/scripts/pre-publish.ts @@ -91,9 +91,9 @@ const runPrePublish = async () => { showMessage(`[CI] 正在执行 lint`, true); await runScript({ event: 'lint', path: '.', stdio: 'inherit' }); showMessage(`[CI] lint 执行成功`, 'succeed'); - showMessage(`[CI] 正在执行 compile`, true); - await runScript({ event: 'compile', path: '.', stdio: 'inherit' }); - showMessage(`[CI] compile 执行成功`, 'succeed'); + showMessage(`[CI] 正在执行 dist`, true); + await runScript({ event: 'dist', path: '.', stdio: 'inherit' }); + showMessage(`[CI] dist 执行成功`, 'succeed'); showMessage(`[CI] 正在执行 test`, true); await runScript({ event: 'test', path: '.', stdio: 'inherit' }); showMessage(`[CI] test 执行成功`, 'succeed'); From 02aed4eb237293eaf233d02932da8c2cafb1f9cc Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 25 Nov 2024 11:42:27 +0800 Subject: [PATCH 5/5] dist => compile --- .github/workflows/site-deploy.yml | 2 +- .github/workflows/size-limit.yml | 2 +- docs/react/contributing.en-US.md | 2 +- docs/react/contributing.zh-CN.md | 2 +- package.json | 3 ++- scripts/pre-publish.ts | 6 +++--- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/site-deploy.yml b/.github/workflows/site-deploy.yml index 8878ce3d..83e472bb 100644 --- a/.github/workflows/site-deploy.yml +++ b/.github/workflows/site-deploy.yml @@ -28,7 +28,7 @@ jobs: NODE_OPTIONS: --max_old_space_size=4096 - name: build dist and bundle analyzer report - run: bun run dist + run: bun run compile env: ANALYZER: 1 NODE_OPTIONS: --max_old_space_size=4096 diff --git a/.github/workflows/size-limit.yml b/.github/workflows/size-limit.yml index e54399e1..0b04a217 100644 --- a/.github/workflows/size-limit.yml +++ b/.github/workflows/size-limit.yml @@ -23,4 +23,4 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} package_manager: bun - build_script: dist + build_script: compile diff --git a/docs/react/contributing.en-US.md b/docs/react/contributing.en-US.md index fe62f7ce..87f7e612 100644 --- a/docs/react/contributing.en-US.md +++ b/docs/react/contributing.en-US.md @@ -92,7 +92,7 @@ runs the complete test suite. (Make sure the `NODE_ENV` environment variable is Build TypeScript code to the `lib` and `es` directory, creates UMD build of antdx. - + ## Development Tools diff --git a/docs/react/contributing.zh-CN.md b/docs/react/contributing.zh-CN.md index 56d17444..1260a9db 100644 --- a/docs/react/contributing.zh-CN.md +++ b/docs/react/contributing.zh-CN.md @@ -92,7 +92,7 @@ Ant Design 团队会关注所有的 pull request,我们会 review 以及合并 编译 TypeScript 代码到 lib 和 es 目录,UMD 版本到 dist 目录。 - + ## 配套开发工具 diff --git a/package.json b/package.json index 568f839f..18725d9f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "changelog": "npm run lint:changelog && tsx scripts/print-changelog.ts", "check-commit": "tsx scripts/check-commit.ts", "clean": "antd-tools run clean && rm -rf es lib coverage locale dist report.html artifacts.zip oss-artifacts.zip", - "dist": "father build", + "precompile": "npm run prestart", + "compile": "father build", "predeploy": "npm run site && cp CNAME _site", "deploy": "gh-pages -d _site -b gh-pages -f", "predist": "npm run version && npm run token:statistic && npm run token:meta", diff --git a/scripts/pre-publish.ts b/scripts/pre-publish.ts index bc608782..24a13d5a 100644 --- a/scripts/pre-publish.ts +++ b/scripts/pre-publish.ts @@ -91,9 +91,9 @@ const runPrePublish = async () => { showMessage(`[CI] 正在执行 lint`, true); await runScript({ event: 'lint', path: '.', stdio: 'inherit' }); showMessage(`[CI] lint 执行成功`, 'succeed'); - showMessage(`[CI] 正在执行 dist`, true); - await runScript({ event: 'dist', path: '.', stdio: 'inherit' }); - showMessage(`[CI] dist 执行成功`, 'succeed'); + showMessage(`[CI] 正在执行 compile`, true); + await runScript({ event: 'compile', path: '.', stdio: 'inherit' }); + showMessage(`[CI] compile 执行成功`, 'succeed'); showMessage(`[CI] 正在执行 test`, true); await runScript({ event: 'test', path: '.', stdio: 'inherit' }); showMessage(`[CI] test 执行成功`, 'succeed');