From 395d7c32c5608c6b50d12afa8fce6486303663fe Mon Sep 17 00:00:00 2001 From: kkxxkk2019 Date: Mon, 21 Aug 2023 22:25:05 +0800 Subject: [PATCH] chore: reduce postinstall build content and improve rush update speed --- common/config/rush/pnpm-lock.yaml | 6 +++--- packages/vchart/bundler.config.js | 6 +++--- packages/vchart/package.json | 2 +- tools/bundler/README.md | 1 + tools/bundler/src/bootstrap.ts | 3 ++- tools/bundler/src/logic/config.ts | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 15a88f9a2b..9f677ffa3d 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -18918,8 +18918,8 @@ packages: engines: {node: '>= 0.8'} dev: true - /std-env/3.4.1: - resolution: {integrity: sha512-8ff1ZsX3NZMNEmDZmINWcFb7CIhPGKZO+TSVytJxJmFzZjAHtAHOR2GuIur7QXlgwY9Md7wNlu4Q7TtSvbu/SA==} + /std-env/3.4.2: + resolution: {integrity: sha512-Cw6eJDX9AxEEL0g5pYj8Zx9KXtDf60rxwS2ze0HBanS0aKhj1sBlzcsmg+R0qYy8byFa854/yR2X5ZmBSClVmg==} dev: true /stealthy-require/1.1.1: @@ -21004,7 +21004,7 @@ packages: pathe: 1.1.1 picocolors: 1.0.0 source-map: 0.6.1 - std-env: 3.4.1 + std-env: 3.4.2 strip-literal: 1.3.0 tinybench: 2.5.0 tinypool: 0.4.0 diff --git a/packages/vchart/bundler.config.js b/packages/vchart/bundler.config.js index ebe3893150..3ac57de376 100644 --- a/packages/vchart/bundler.config.js +++ b/packages/vchart/bundler.config.js @@ -1,6 +1,3 @@ -/** - * @type {import('@internal/bundler').Config} - */ const fs = require('fs'); const path = require('path'); @@ -19,6 +16,9 @@ function copyStart(source, destinations) { }); } +/** + * @type {import('@internal/bundler').Config} + */ module.exports = { name: 'VChart', formats: ['es', 'cjs', 'umd'], diff --git a/packages/vchart/package.json b/packages/vchart/package.json index a538737566..602c018f0f 100644 --- a/packages/vchart/package.json +++ b/packages/vchart/package.json @@ -26,7 +26,7 @@ "test-live": "npm run test-watch __tests__/unit/", "test-watch": "DEBUG_MODE=1 jest --watch", "ci": "ts-node --transpileOnly --skipProject ./scripts/trigger-test.ts", - "postinstall": "npm run build" + "postinstall": "bundle --clean -f es --ignorePostTasks" }, "files": [ "esm", diff --git a/tools/bundler/README.md b/tools/bundler/README.md index e8645a5f3e..3731cb9eca 100644 --- a/tools/bundler/README.md +++ b/tools/bundler/README.md @@ -27,6 +27,7 @@ bundle -f es -w dev --env __DEV__=true --env __ID__="'my_id'" --minify 是否输出压缩后的 UMD 产物文件 -w, --watch 监听文件变化重新构建 -s, --sourcemap 是否生成 sourcemap +--ignorePostTasks, 不执行 postTasks ``` # 配置文件 diff --git a/tools/bundler/src/bootstrap.ts b/tools/bundler/src/bootstrap.ts index af0849ad40..449af6f65d 100644 --- a/tools/bundler/src/bootstrap.ts +++ b/tools/bundler/src/bootstrap.ts @@ -132,7 +132,8 @@ async function bootstrap() { _task(Tasks.COPY_FILES, () => copyFiles(PROJECT_ROOT, config)); taskList.push(Tasks.COPY_FILES); } - if (config.postTasks) { + + if (!args.ignorePostTasks && config.postTasks) { const tasksKey = Object.keys(config.postTasks); if (tasksKey.length) { tasksKey.forEach(name => { diff --git a/tools/bundler/src/logic/config.ts b/tools/bundler/src/logic/config.ts index 4cafe610a0..3f19303265 100644 --- a/tools/bundler/src/logic/config.ts +++ b/tools/bundler/src/logic/config.ts @@ -47,7 +47,7 @@ export function parserCLIArgs(argv: string | string[]): Partial { }, array: ['formats', 'envs', 'copy'], string: ['config'], - boolean: ['watch', 'less', 'clean', 'minify', 'sourcemap'], + boolean: ['watch', 'less', 'clean', 'minify', 'sourcemap', 'ignorePostTasks'], coerce: getCoerce(stringKeys) }); }