From a010c69c112a211b921f4bd33f9b0623e79a9795 Mon Sep 17 00:00:00 2001 From: "taojiahang.tjh" Date: Fri, 15 Mar 2024 15:00:05 +0800 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81ts-checker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/config.md | 7 ++ examples/with-dynamic-import/build.js | 17 ++++ packages/bundler-okam/index.js | 9 ++ packages/bundler-okam/package.json | 1 + .../plugins/fork-ts-checker/index.js | 97 +++++++++++++++++++ pnpm-lock.yaml | 10 ++ 6 files changed, 141 insertions(+) create mode 100644 examples/with-dynamic-import/build.js create mode 100644 packages/bundler-okam/plugins/fork-ts-checker/index.js diff --git a/docs/config.md b/docs/config.md index 6d25223a1..4aba3f379 100644 --- a/docs/config.md +++ b/docs/config.md @@ -444,3 +444,10 @@ function App() { - 默认值:`true` 是否在 mode 为 development 时将构建结果写入磁盘。 + +## tsChecker + +- 类型:`boolean` +- 默认值:`false` + +是否开启构建ts校验 diff --git a/examples/with-dynamic-import/build.js b/examples/with-dynamic-import/build.js new file mode 100644 index 000000000..e3b95b769 --- /dev/null +++ b/examples/with-dynamic-import/build.js @@ -0,0 +1,17 @@ +const { build } = require('@alipay/umi-bundler-okam'); + +build({ + cwd: __dirname, + entry: { + index: './index.tsx', + }, + chainWebpack: () => {}, + config: { + alias: {}, + externals: {}, + tsChecker: true, + }, + onBuildComplete() { + console.log('build finished'); + }, +}); diff --git a/packages/bundler-okam/index.js b/packages/bundler-okam/index.js index 09b34d2b0..26fb93907 100644 --- a/packages/bundler-okam/index.js +++ b/packages/bundler-okam/index.js @@ -5,6 +5,7 @@ const assert = require('assert'); const { createProxy, createHttpsServer } = require('@umijs/bundler-utils'); const lodash = require('lodash'); const chalk = require('chalk'); +const { TypeChecker } = require('./plugins/fork-ts-checker/index'); const { createProxyMiddleware, } = require('@umijs/bundler-utils/compiled/http-proxy-middleware'); @@ -99,6 +100,12 @@ exports.build = async function (opts) { throw err; } + // 后置ts校验,不影响打包速度 + if (!!okamConfig.tsChecker) { + const typeChecker = new TypeChecker(cwd); + typeChecker.check(); + } + const statsJsonPath = path.join(cwd, 'dist', 'stats.json'); const statsJson = JSON.parse(fs.readFileSync(statsJsonPath, 'utf-8')); @@ -467,6 +474,7 @@ async function getOkamConfig(opts) { externals, copy = [], clean, + tsChecker, } = opts.config; const outputPath = path.join(opts.cwd, 'dist'); // TODO: @@ -595,6 +603,7 @@ async function getOkamConfig(opts) { flexBugs: true, react: opts.react || {}, emotion, + tsChecker, ...(opts.disableCopy ? { copy: [] } : { copy: ['public'].concat(copy) }), }; diff --git a/packages/bundler-okam/package.json b/packages/bundler-okam/package.json index 5f1b2e6d7..4015cf365 100644 --- a/packages/bundler-okam/package.json +++ b/packages/bundler-okam/package.json @@ -16,6 +16,7 @@ "react-error-overlay": "6.0.9", "react-refresh": "^0.14.0", "rimraf": "5.0.1", + "typescript": "^5.4.2", "webpack-5-chain": "8.0.1" }, "scripts": { diff --git a/packages/bundler-okam/plugins/fork-ts-checker/index.js b/packages/bundler-okam/plugins/fork-ts-checker/index.js new file mode 100644 index 000000000..ba1484f03 --- /dev/null +++ b/packages/bundler-okam/plugins/fork-ts-checker/index.js @@ -0,0 +1,97 @@ +const ts = require('typescript'); +const path = require('path'); +const fs = require('fs').promises; + +class TypeChecker { + constructor(projectRoot) { + this.projectRoot = projectRoot; + } + + async check() { + try { + const configPath = ts.findConfigFile( + this.projectRoot, + ts.sys.fileExists, + 'tsconfig.json', + ); + if (!configPath) { + console.error( + 'Could not find a valid "tsconfig.json" file in the project root:', + this.projectRoot, + ); + return; + } + let configFileText = ''; + try { + configFileText = await fs.readFile(configPath, 'utf8'); + } catch (readError) { + console.error( + `Error reading the "tsconfig.json" file at ${configPath}:`, + readError, + ); + return; + } + const configFile = ts.parseConfigFileTextToJson( + configPath, + configFileText, + ); + if (configFile.error) { + console.error('Error parsing "tsconfig.json" file:', configFile.error); + return; + } + let parsedCommandLine; + try { + parsedCommandLine = ts.parseJsonConfigFileContent( + configFile.config, + ts.sys, + path.dirname(configPath), + ); + } catch (parseError) { + console.error( + 'Error parsing the configuration from "tsconfig.json":', + parseError, + ); + return; + } + let program; + try { + program = ts.createProgram({ + rootNames: parsedCommandLine.fileNames, + options: { ...parsedCommandLine.options, noEmit: true }, + }); + } catch (programError) { + console.error('Error creating the TypeScript program:', programError); + return; + } + const diagnostics = ts.getPreEmitDiagnostics(program); + if (diagnostics.length > 0) { + diagnostics.forEach((diagnostic) => { + const message = ts.flattenDiagnosticMessageText( + diagnostic.messageText, + '\n', + ); + if (diagnostic.file && typeof diagnostic.start === 'number') { + const { line, character } = + diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); + console.error( + `${diagnostic.file.fileName} (${line + 1}, ${ + character + 1 + }): ${message}`, + ); + } else { + console.error(message); + } + }); + } else { + console.log('No type errors found.'); + } + } catch (error) { + console.error( + 'An unexpected error occurred during type checking:', + error, + ); + } + } +} + +module.exports = { TypeChecker }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 227baeba9..0a4566285 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -383,6 +383,9 @@ importers: rimraf: specifier: 5.0.1 version: 5.0.1 + typescript: + specifier: ^5.4.2 + version: 5.4.2 webpack-5-chain: specifier: 8.0.1 version: 8.0.1 @@ -12301,6 +12304,7 @@ packages: object-assign: 4.1.1 prop-types: 15.8.1 dev: false + bundledDependencies: false /react@18.1.0: resolution: {integrity: sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ==} @@ -13594,6 +13598,12 @@ packages: hasBin: true dev: true + /typescript@5.4.2: + resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} + engines: {node: '>=14.17'} + hasBin: true + dev: false + /umi@4.0.70(@babel/core@7.22.1)(@types/node@20.4.2)(@types/react@18.2.7)(eslint@8.41.0)(postcss@8.4.24)(prettier@2.8.8)(react-dom@18.2.0)(react@18.2.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.0.4)(webpack@5.84.1): resolution: {integrity: sha512-e6GwzZXC1U+XPJhLaOMIr6IBWpi8mGap6ExRkApidfbYZ8HxilvrVHnaLUYSykp206RhZBnJWI7r99mYu3e5eQ==} engines: {node: '>=14'} From 2e1ec7993cf8c7a4d9b69a12259837d32f1cef7b Mon Sep 17 00:00:00 2001 From: ctts Date: Thu, 21 Mar 2024 14:29:20 +0800 Subject: [PATCH 02/10] Update packages/bundler-okam/index.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: chencheng (云谦) --- packages/bundler-okam/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bundler-okam/index.js b/packages/bundler-okam/index.js index 26fb93907..48afbb9f7 100644 --- a/packages/bundler-okam/index.js +++ b/packages/bundler-okam/index.js @@ -100,7 +100,7 @@ exports.build = async function (opts) { throw err; } - // 后置ts校验,不影响打包速度 + // 后置 ts 校验,不影响打包速度 if (!!okamConfig.tsChecker) { const typeChecker = new TypeChecker(cwd); typeChecker.check(); From e035da93dc91fb0a5a97f77098c0251e913375cf Mon Sep 17 00:00:00 2001 From: "taojiahang.tjh" Date: Thu, 21 Mar 2024 19:33:18 +0800 Subject: [PATCH 03/10] =?UTF-8?q?feat:=20=E5=9C=A8=E5=AD=90=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/config.md | 13 ++- examples/with-dynamic-import/build.js | 17 --- packages/bundler-okam/index.js | 12 +- packages/bundler-okam/package.json | 1 - .../plugins/fork-ts-checker/index.js | 105 ++++-------------- .../plugins/fork-ts-checker/ts-checker.js | 97 ++++++++++++++++ 6 files changed, 129 insertions(+), 116 deletions(-) delete mode 100644 examples/with-dynamic-import/build.js create mode 100644 packages/bundler-okam/plugins/fork-ts-checker/ts-checker.js diff --git a/docs/config.md b/docs/config.md index 4aba3f379..bcf3de515 100644 --- a/docs/config.md +++ b/docs/config.md @@ -429,6 +429,13 @@ function App() { } ``` +## forkTsChecker + +- 类型:`boolean` +- 默认值:`false` + +是否开启构建时 ts 校验。 + ## umd - 类型:`false | string` @@ -445,9 +452,3 @@ function App() { 是否在 mode 为 development 时将构建结果写入磁盘。 -## tsChecker - -- 类型:`boolean` -- 默认值:`false` - -是否开启构建ts校验 diff --git a/examples/with-dynamic-import/build.js b/examples/with-dynamic-import/build.js deleted file mode 100644 index e3b95b769..000000000 --- a/examples/with-dynamic-import/build.js +++ /dev/null @@ -1,17 +0,0 @@ -const { build } = require('@alipay/umi-bundler-okam'); - -build({ - cwd: __dirname, - entry: { - index: './index.tsx', - }, - chainWebpack: () => {}, - config: { - alias: {}, - externals: {}, - tsChecker: true, - }, - onBuildComplete() { - console.log('build finished'); - }, -}); diff --git a/packages/bundler-okam/index.js b/packages/bundler-okam/index.js index 48afbb9f7..f1aabe430 100644 --- a/packages/bundler-okam/index.js +++ b/packages/bundler-okam/index.js @@ -5,7 +5,7 @@ const assert = require('assert'); const { createProxy, createHttpsServer } = require('@umijs/bundler-utils'); const lodash = require('lodash'); const chalk = require('chalk'); -const { TypeChecker } = require('./plugins/fork-ts-checker/index'); +const { ForkTsChecker } = require('./plugins/fork-ts-checker/index'); const { createProxyMiddleware, } = require('@umijs/bundler-utils/compiled/http-proxy-middleware'); @@ -101,9 +101,9 @@ exports.build = async function (opts) { } // 后置 ts 校验,不影响打包速度 - if (!!okamConfig.tsChecker) { - const typeChecker = new TypeChecker(cwd); - typeChecker.check(); + if (!!okamConfig.forkTsChecker) { + const forkTypeChecker = new ForkTsChecker(cwd); + forkTypeChecker.runTypeCheck(); } const statsJsonPath = path.join(cwd, 'dist', 'stats.json'); @@ -474,7 +474,7 @@ async function getOkamConfig(opts) { externals, copy = [], clean, - tsChecker, + forkTsChecker, } = opts.config; const outputPath = path.join(opts.cwd, 'dist'); // TODO: @@ -603,7 +603,7 @@ async function getOkamConfig(opts) { flexBugs: true, react: opts.react || {}, emotion, - tsChecker, + forkTsChecker, ...(opts.disableCopy ? { copy: [] } : { copy: ['public'].concat(copy) }), }; diff --git a/packages/bundler-okam/package.json b/packages/bundler-okam/package.json index 4015cf365..5f1b2e6d7 100644 --- a/packages/bundler-okam/package.json +++ b/packages/bundler-okam/package.json @@ -16,7 +16,6 @@ "react-error-overlay": "6.0.9", "react-refresh": "^0.14.0", "rimraf": "5.0.1", - "typescript": "^5.4.2", "webpack-5-chain": "8.0.1" }, "scripts": { diff --git a/packages/bundler-okam/plugins/fork-ts-checker/index.js b/packages/bundler-okam/plugins/fork-ts-checker/index.js index ba1484f03..39c14135c 100644 --- a/packages/bundler-okam/plugins/fork-ts-checker/index.js +++ b/packages/bundler-okam/plugins/fork-ts-checker/index.js @@ -1,97 +1,30 @@ -const ts = require('typescript'); +const { fork } = require('child_process'); const path = require('path'); -const fs = require('fs').promises; +const { TypeChecker } = require('./ts-checker'); -class TypeChecker { +class ForkTsChecker { constructor(projectRoot) { this.projectRoot = projectRoot; } + async runTypeCheck() { + const typeChecker = new TypeChecker(projectRoot); + await typeChecker.check(); + } - async check() { - try { - const configPath = ts.findConfigFile( - this.projectRoot, - ts.sys.fileExists, - 'tsconfig.json', - ); - if (!configPath) { - console.error( - 'Could not find a valid "tsconfig.json" file in the project root:', - this.projectRoot, - ); - return; - } - let configFileText = ''; - try { - configFileText = await fs.readFile(configPath, 'utf8'); - } catch (readError) { - console.error( - `Error reading the "tsconfig.json" file at ${configPath}:`, - readError, - ); - return; - } - const configFile = ts.parseConfigFileTextToJson( - configPath, - configFileText, - ); - if (configFile.error) { - console.error('Error parsing "tsconfig.json" file:', configFile.error); - return; - } - let parsedCommandLine; - try { - parsedCommandLine = ts.parseJsonConfigFileContent( - configFile.config, - ts.sys, - path.dirname(configPath), - ); - } catch (parseError) { - console.error( - 'Error parsing the configuration from "tsconfig.json":', - parseError, - ); - return; - } - let program; - try { - program = ts.createProgram({ - rootNames: parsedCommandLine.fileNames, - options: { ...parsedCommandLine.options, noEmit: true }, - }); - } catch (programError) { - console.error('Error creating the TypeScript program:', programError); - return; - } - const diagnostics = ts.getPreEmitDiagnostics(program); - if (diagnostics.length > 0) { - diagnostics.forEach((diagnostic) => { - const message = ts.flattenDiagnosticMessageText( - diagnostic.messageText, - '\n', - ); - if (diagnostic.file && typeof diagnostic.start === 'number') { - const { line, character } = - diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); - console.error( - `${diagnostic.file.fileName} (${line + 1}, ${ - character + 1 - }): ${message}`, - ); - } else { - console.error(message); - } - }); + runTypeCheckInChildProcess() { + const workerScript = path.join(__dirname, 'child_process_fork.js'); + const child = fork(workerScript, [projectRoot], { + stdio: 'inherit', + }); + + child.on('exit', (code) => { + if (code === 0) { + console.log('Type checking completed successfully.'); } else { - console.log('No type errors found.'); + console.error('Type checking failed.'); } - } catch (error) { - console.error( - 'An unexpected error occurred during type checking:', - error, - ); - } + }); } } -module.exports = { TypeChecker }; +module.exports = { ForkTsChecker }; diff --git a/packages/bundler-okam/plugins/fork-ts-checker/ts-checker.js b/packages/bundler-okam/plugins/fork-ts-checker/ts-checker.js new file mode 100644 index 000000000..ba1484f03 --- /dev/null +++ b/packages/bundler-okam/plugins/fork-ts-checker/ts-checker.js @@ -0,0 +1,97 @@ +const ts = require('typescript'); +const path = require('path'); +const fs = require('fs').promises; + +class TypeChecker { + constructor(projectRoot) { + this.projectRoot = projectRoot; + } + + async check() { + try { + const configPath = ts.findConfigFile( + this.projectRoot, + ts.sys.fileExists, + 'tsconfig.json', + ); + if (!configPath) { + console.error( + 'Could not find a valid "tsconfig.json" file in the project root:', + this.projectRoot, + ); + return; + } + let configFileText = ''; + try { + configFileText = await fs.readFile(configPath, 'utf8'); + } catch (readError) { + console.error( + `Error reading the "tsconfig.json" file at ${configPath}:`, + readError, + ); + return; + } + const configFile = ts.parseConfigFileTextToJson( + configPath, + configFileText, + ); + if (configFile.error) { + console.error('Error parsing "tsconfig.json" file:', configFile.error); + return; + } + let parsedCommandLine; + try { + parsedCommandLine = ts.parseJsonConfigFileContent( + configFile.config, + ts.sys, + path.dirname(configPath), + ); + } catch (parseError) { + console.error( + 'Error parsing the configuration from "tsconfig.json":', + parseError, + ); + return; + } + let program; + try { + program = ts.createProgram({ + rootNames: parsedCommandLine.fileNames, + options: { ...parsedCommandLine.options, noEmit: true }, + }); + } catch (programError) { + console.error('Error creating the TypeScript program:', programError); + return; + } + const diagnostics = ts.getPreEmitDiagnostics(program); + if (diagnostics.length > 0) { + diagnostics.forEach((diagnostic) => { + const message = ts.flattenDiagnosticMessageText( + diagnostic.messageText, + '\n', + ); + if (diagnostic.file && typeof diagnostic.start === 'number') { + const { line, character } = + diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); + console.error( + `${diagnostic.file.fileName} (${line + 1}, ${ + character + 1 + }): ${message}`, + ); + } else { + console.error(message); + } + }); + } else { + console.log('No type errors found.'); + } + } catch (error) { + console.error( + 'An unexpected error occurred during type checking:', + error, + ); + } + } +} + +module.exports = { TypeChecker }; From 03c56d810e1a3a735e816f66731035d4c37a4796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E5=AE=B6=E8=A1=8C?= Date: Tue, 26 Mar 2024 14:25:06 +0800 Subject: [PATCH 04/10] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AD=90?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E4=BB=A3=E7=A0=81=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/config.md | 14 +- .../fork-ts-checker/child_process_fork.js | 17 +++ .../{plugins => }/fork-ts-checker/index.js | 11 +- .../fork-ts-checker/ts-checker.js | 0 packages/bundler-okam/index.js | 6 +- packages/bundler-okam/package.json | 5 +- pnpm-lock.yaml | 120 +++++++++--------- 7 files changed, 91 insertions(+), 82 deletions(-) create mode 100644 packages/bundler-okam/fork-ts-checker/child_process_fork.js rename packages/bundler-okam/{plugins => }/fork-ts-checker/index.js (60%) rename packages/bundler-okam/{plugins => }/fork-ts-checker/ts-checker.js (100%) diff --git a/docs/config.md b/docs/config.md index bcf3de515..0a767bbd8 100644 --- a/docs/config.md +++ b/docs/config.md @@ -173,6 +173,13 @@ import("./a.js") 是否修复 flexbugs。 +## forkTsChecker + +- 类型:`boolean` +- 默认值:`false` + +是否开启构建时 ts 校验。 + ## hash - 类型:`boolean` @@ -429,13 +436,6 @@ function App() { } ``` -## forkTsChecker - -- 类型:`boolean` -- 默认值:`false` - -是否开启构建时 ts 校验。 - ## umd - 类型:`false | string` diff --git a/packages/bundler-okam/fork-ts-checker/child_process_fork.js b/packages/bundler-okam/fork-ts-checker/child_process_fork.js new file mode 100644 index 000000000..83e31a272 --- /dev/null +++ b/packages/bundler-okam/fork-ts-checker/child_process_fork.js @@ -0,0 +1,17 @@ +const { TypeChecker } = require('./ts-checker'); + +const projectRoot = process.argv[2]; + +async function runTypeCheck() { + const typeChecker = new TypeChecker(projectRoot); + return await typeChecker.check(); +} + +runTypeCheck() + .then(() => { + process.exit(1); + }) + .catch((error) => { + console.error(error); + process.exit(0); + }); diff --git a/packages/bundler-okam/plugins/fork-ts-checker/index.js b/packages/bundler-okam/fork-ts-checker/index.js similarity index 60% rename from packages/bundler-okam/plugins/fork-ts-checker/index.js rename to packages/bundler-okam/fork-ts-checker/index.js index 39c14135c..9d0f7354f 100644 --- a/packages/bundler-okam/plugins/fork-ts-checker/index.js +++ b/packages/bundler-okam/fork-ts-checker/index.js @@ -1,25 +1,20 @@ const { fork } = require('child_process'); const path = require('path'); -const { TypeChecker } = require('./ts-checker'); class ForkTsChecker { constructor(projectRoot) { this.projectRoot = projectRoot; } - async runTypeCheck() { - const typeChecker = new TypeChecker(projectRoot); - await typeChecker.check(); - } runTypeCheckInChildProcess() { const workerScript = path.join(__dirname, 'child_process_fork.js'); - const child = fork(workerScript, [projectRoot], { + const child = fork(workerScript, [this.projectRoot], { stdio: 'inherit', }); child.on('exit', (code) => { - if (code === 0) { - console.log('Type checking completed successfully.'); + if (code === 1) { + console.log('Type checking completed.'); } else { console.error('Type checking failed.'); } diff --git a/packages/bundler-okam/plugins/fork-ts-checker/ts-checker.js b/packages/bundler-okam/fork-ts-checker/ts-checker.js similarity index 100% rename from packages/bundler-okam/plugins/fork-ts-checker/ts-checker.js rename to packages/bundler-okam/fork-ts-checker/ts-checker.js diff --git a/packages/bundler-okam/index.js b/packages/bundler-okam/index.js index f1aabe430..a8749c601 100644 --- a/packages/bundler-okam/index.js +++ b/packages/bundler-okam/index.js @@ -5,7 +5,7 @@ const assert = require('assert'); const { createProxy, createHttpsServer } = require('@umijs/bundler-utils'); const lodash = require('lodash'); const chalk = require('chalk'); -const { ForkTsChecker } = require('./plugins/fork-ts-checker/index'); +const { ForkTsChecker } = require('./fork-ts-checker/index'); const { createProxyMiddleware, } = require('@umijs/bundler-utils/compiled/http-proxy-middleware'); @@ -101,9 +101,9 @@ exports.build = async function (opts) { } // 后置 ts 校验,不影响打包速度 - if (!!okamConfig.forkTsChecker) { + if (okamConfig.forkTsChecker) { const forkTypeChecker = new ForkTsChecker(cwd); - forkTypeChecker.runTypeCheck(); + forkTypeChecker.runTypeCheckInChildProcess(); } const statsJsonPath = path.join(cwd, 'dist', 'stats.json'); diff --git a/packages/bundler-okam/package.json b/packages/bundler-okam/package.json index 5f1b2e6d7..2db2dba13 100644 --- a/packages/bundler-okam/package.json +++ b/packages/bundler-okam/package.json @@ -25,5 +25,8 @@ "publishConfig": { "registry": "https://registry.antgroup-inc.cn" }, - "repository": "git@github.com:umijs/mako.git" + "repository": "git@github.com:umijs/mako.git", + "devDependencies": { + "typescript": "^5.4.3" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0a4566285..58544f4a2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -231,7 +231,7 @@ importers: version: 5.0.0-alpha.21(react-dom@18.2.0)(react@18.2.0) '@umijs/bundler-webpack': specifier: ^4.0.80 - version: 4.0.80(styled-components@5.3.10)(typescript@5.0.4)(webpack@5.84.1) + version: 4.0.80(styled-components@5.3.10)(typescript@5.4.3)(webpack@5.84.1) antd: specifier: ^5.12.2 version: 5.12.2(react-dom@18.2.0)(react@18.2.0) @@ -337,7 +337,7 @@ importers: version: 18.2.0(react@18.2.0) umi: specifier: ^4.0.70 - version: 4.0.70(@babel/core@7.22.1)(@types/node@20.4.2)(@types/react@18.2.7)(eslint@8.41.0)(postcss@8.4.24)(prettier@2.8.8)(react-dom@18.2.0)(react@18.2.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.0.4)(webpack@5.84.1) + version: 4.0.70(@babel/core@7.22.1)(@types/node@20.4.2)(@types/react@18.2.7)(eslint@8.41.0)(postcss@8.4.24)(prettier@2.8.8)(react-dom@18.2.0)(react@18.2.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.4.3)(webpack@5.84.1) packages/bundler-okam: dependencies: @@ -383,12 +383,13 @@ importers: rimraf: specifier: 5.0.1 version: 5.0.1 - typescript: - specifier: ^5.4.2 - version: 5.4.2 webpack-5-chain: specifier: 8.0.1 version: 8.0.1 + devDependencies: + typescript: + specifier: ^5.4.3 + version: 5.4.3 packages: @@ -4296,7 +4297,7 @@ packages: '@types/yargs-parser': 21.0.0 dev: true - /@typescript-eslint/eslint-plugin@5.48.1(@typescript-eslint/parser@5.48.1)(eslint@8.41.0)(typescript@5.0.4): + /@typescript-eslint/eslint-plugin@5.48.1(@typescript-eslint/parser@5.48.1)(eslint@8.41.0)(typescript@5.4.3): resolution: {integrity: sha512-9nY5K1Rp2ppmpb9s9S2aBiF3xo5uExCehMDmYmmFqqyxgenbHJ3qbarcLt4ITgaD6r/2ypdlcFRdcuVPnks+fQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -4307,23 +4308,23 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.48.1(eslint@8.41.0)(typescript@5.0.4) + '@typescript-eslint/parser': 5.48.1(eslint@8.41.0)(typescript@5.4.3) '@typescript-eslint/scope-manager': 5.48.1 - '@typescript-eslint/type-utils': 5.48.1(eslint@8.41.0)(typescript@5.0.4) - '@typescript-eslint/utils': 5.48.1(eslint@8.41.0)(typescript@5.0.4) + '@typescript-eslint/type-utils': 5.48.1(eslint@8.41.0)(typescript@5.4.3) + '@typescript-eslint/utils': 5.48.1(eslint@8.41.0)(typescript@5.4.3) debug: 4.3.4(supports-color@5.5.0) eslint: 8.41.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 regexpp: 3.2.0 semver: 7.5.4 - tsutils: 3.21.0(typescript@5.0.4) - typescript: 5.0.4 + tsutils: 3.21.0(typescript@5.4.3) + typescript: 5.4.3 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@5.48.1(eslint@8.41.0)(typescript@5.0.4): + /@typescript-eslint/parser@5.48.1(eslint@8.41.0)(typescript@5.4.3): resolution: {integrity: sha512-4yg+FJR/V1M9Xoq56SF9Iygqm+r5LMXvheo6DQ7/yUWynQ4YfCRnsKuRgqH4EQ5Ya76rVwlEpw4Xu+TgWQUcdA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -4335,10 +4336,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.48.1 '@typescript-eslint/types': 5.48.1 - '@typescript-eslint/typescript-estree': 5.48.1(typescript@5.0.4) + '@typescript-eslint/typescript-estree': 5.48.1(typescript@5.4.3) debug: 4.3.4(supports-color@5.5.0) eslint: 8.41.0 - typescript: 5.0.4 + typescript: 5.4.3 transitivePeerDependencies: - supports-color dev: true @@ -4359,7 +4360,7 @@ packages: '@typescript-eslint/visitor-keys': 5.59.8 dev: true - /@typescript-eslint/type-utils@5.48.1(eslint@8.41.0)(typescript@5.0.4): + /@typescript-eslint/type-utils@5.48.1(eslint@8.41.0)(typescript@5.4.3): resolution: {integrity: sha512-Hyr8HU8Alcuva1ppmqSYtM/Gp0q4JOp1F+/JH5D1IZm/bUBrV0edoewQZiEc1r6I8L4JL21broddxK8HAcZiqQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -4369,12 +4370,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.48.1(typescript@5.0.4) - '@typescript-eslint/utils': 5.48.1(eslint@8.41.0)(typescript@5.0.4) + '@typescript-eslint/typescript-estree': 5.48.1(typescript@5.4.3) + '@typescript-eslint/utils': 5.48.1(eslint@8.41.0)(typescript@5.4.3) debug: 4.3.4(supports-color@5.5.0) eslint: 8.41.0 - tsutils: 3.21.0(typescript@5.0.4) - typescript: 5.0.4 + tsutils: 3.21.0(typescript@5.4.3) + typescript: 5.4.3 transitivePeerDependencies: - supports-color dev: true @@ -4389,7 +4390,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree@5.48.1(typescript@5.0.4): + /@typescript-eslint/typescript-estree@5.48.1(typescript@5.4.3): resolution: {integrity: sha512-Hut+Osk5FYr+sgFh8J/FHjqX6HFcDzTlWLrFqGoK5kVUN3VBHF/QzZmAsIXCQ8T/W9nQNBTqalxi1P3LSqWnRA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -4404,13 +4405,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 - tsutils: 3.21.0(typescript@5.0.4) - typescript: 5.0.4 + tsutils: 3.21.0(typescript@5.4.3) + typescript: 5.4.3 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/typescript-estree@5.59.8(typescript@5.0.4): + /@typescript-eslint/typescript-estree@5.59.8(typescript@5.4.3): resolution: {integrity: sha512-Jy/lPSDJGNow14vYu6IrW790p7HIf/SOV1Bb6lZ7NUkLc2iB2Z9elESmsaUtLw8kVqogSbtLH9tut5GCX1RLDg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -4425,13 +4426,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 - tsutils: 3.21.0(typescript@5.0.4) - typescript: 5.0.4 + tsutils: 3.21.0(typescript@5.4.3) + typescript: 5.4.3 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.48.1(eslint@8.41.0)(typescript@5.0.4): + /@typescript-eslint/utils@5.48.1(eslint@8.41.0)(typescript@5.4.3): resolution: {integrity: sha512-SmQuSrCGUOdmGMwivW14Z0Lj8dxG1mOFZ7soeJ0TQZEJcs3n5Ndgkg0A4bcMFzBELqLJ6GTHnEU+iIoaD6hFGA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -4441,7 +4442,7 @@ packages: '@types/semver': 7.5.0 '@typescript-eslint/scope-manager': 5.48.1 '@typescript-eslint/types': 5.48.1 - '@typescript-eslint/typescript-estree': 5.48.1(typescript@5.0.4) + '@typescript-eslint/typescript-estree': 5.48.1(typescript@5.4.3) eslint: 8.41.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0(eslint@8.41.0) @@ -4451,7 +4452,7 @@ packages: - typescript dev: true - /@typescript-eslint/utils@5.59.8(eslint@8.41.0)(typescript@5.0.4): + /@typescript-eslint/utils@5.59.8(eslint@8.41.0)(typescript@5.4.3): resolution: {integrity: sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -4462,7 +4463,7 @@ packages: '@types/semver': 7.5.0 '@typescript-eslint/scope-manager': 5.59.8 '@typescript-eslint/types': 5.59.8 - '@typescript-eslint/typescript-estree': 5.59.8(typescript@5.0.4) + '@typescript-eslint/typescript-estree': 5.59.8(typescript@5.4.3) eslint: 8.41.0 eslint-scope: 5.1.1 semver: 7.5.4 @@ -4610,7 +4611,7 @@ packages: - terser dev: true - /@umijs/bundler-webpack@4.0.70(styled-components@5.3.10)(typescript@5.0.4)(webpack@5.84.1): + /@umijs/bundler-webpack@4.0.70(styled-components@5.3.10)(typescript@5.4.3)(webpack@5.84.1): resolution: {integrity: sha512-QHaIEFesPzFSHnIMhHui9Ru54VYwNdnO683CzSoIoBjYAIcpDsGM7Tl3hIesujbfhrZl2eCJQVc//ZJ0SEFiTw==} hasBin: true dependencies: @@ -4627,7 +4628,7 @@ packages: cors: 2.8.5 css-loader: 6.7.1(webpack@5.84.1) es5-imcompatible-versions: 0.1.82 - fork-ts-checker-webpack-plugin: 8.0.0(typescript@5.0.4)(webpack@5.84.1) + fork-ts-checker-webpack-plugin: 8.0.0(typescript@5.4.3)(webpack@5.84.1) jest-worker: 29.4.3 lightningcss: 1.19.0 node-libs-browser: 2.2.1 @@ -4648,7 +4649,7 @@ packages: - webpack-plugin-serve dev: true - /@umijs/bundler-webpack@4.0.80(styled-components@5.3.10)(typescript@5.0.4)(webpack@5.84.1): + /@umijs/bundler-webpack@4.0.80(styled-components@5.3.10)(typescript@5.4.3)(webpack@5.84.1): resolution: {integrity: sha512-EdkEQpVx/fSrI0jmD6RbvPuSXiXW/1HXSA0OB9MJoKOBbndVTvjKL82CNgoUo8Ahytr2bZ0zjbgoV/lHadFLkA==} hasBin: true dependencies: @@ -4665,7 +4666,7 @@ packages: cors: 2.8.5 css-loader: 6.7.1(webpack@5.84.1) es5-imcompatible-versions: 0.1.82 - fork-ts-checker-webpack-plugin: 8.0.0(typescript@5.0.4)(webpack@5.84.1) + fork-ts-checker-webpack-plugin: 8.0.0(typescript@5.4.3)(webpack@5.84.1) jest-worker: 29.4.3 lightningcss: 1.19.0 node-libs-browser: 2.2.1 @@ -4810,16 +4811,16 @@ packages: query-string: 6.14.1 dev: true - /@umijs/lint@4.0.70(eslint@8.41.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.0.4): + /@umijs/lint@4.0.70(eslint@8.41.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.4.3): resolution: {integrity: sha512-89+1BC/taDfEcubrWGXI6Yzk6hVb3br21jx+7eYYOwJjOXDMULy3+8GCFqZN+TxIz9WXOG3NFHehcFehx9YPwg==} dependencies: '@babel/core': 7.21.0 '@babel/eslint-parser': 7.19.1(@babel/core@7.21.0)(eslint@8.41.0) '@stylelint/postcss-css-in-js': 0.38.0(postcss-syntax@0.36.2)(postcss@8.4.24) - '@typescript-eslint/eslint-plugin': 5.48.1(@typescript-eslint/parser@5.48.1)(eslint@8.41.0)(typescript@5.0.4) - '@typescript-eslint/parser': 5.48.1(eslint@8.41.0)(typescript@5.0.4) + '@typescript-eslint/eslint-plugin': 5.48.1(@typescript-eslint/parser@5.48.1)(eslint@8.41.0)(typescript@5.4.3) + '@typescript-eslint/parser': 5.48.1(eslint@8.41.0)(typescript@5.4.3) '@umijs/babel-preset-umi': 4.0.70(styled-components@5.3.10) - eslint-plugin-jest: 27.2.1(@typescript-eslint/eslint-plugin@5.48.1)(eslint@8.41.0)(typescript@5.0.4) + eslint-plugin-jest: 27.2.1(@typescript-eslint/eslint-plugin@5.48.1)(eslint@8.41.0)(typescript@5.4.3) eslint-plugin-react: 7.32.2(eslint@8.41.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.41.0) postcss: 8.4.24 @@ -4918,7 +4919,7 @@ packages: - supports-color dev: true - /@umijs/preset-umi@4.0.70(@types/node@20.4.2)(@types/react@18.2.7)(postcss@8.4.24)(styled-components@5.3.10)(typescript@5.0.4)(webpack@5.84.1): + /@umijs/preset-umi@4.0.70(@types/node@20.4.2)(@types/react@18.2.7)(postcss@8.4.24)(styled-components@5.3.10)(typescript@5.4.3)(webpack@5.84.1): resolution: {integrity: sha512-N9TQbuaZNz+3HTtXm1QG+LpALJx/XLEJk1CYfff8Ey3hgQVRtvR/hTo6EhsUtovoqdcfBClxidHAfy9dvJ9Ebw==} dependencies: '@iconify/utils': 2.1.1 @@ -4928,7 +4929,7 @@ packages: '@umijs/bundler-esbuild': 4.0.70 '@umijs/bundler-utils': 4.0.70 '@umijs/bundler-vite': 4.0.70(@types/node@20.4.2)(postcss@8.4.24) - '@umijs/bundler-webpack': 4.0.70(styled-components@5.3.10)(typescript@5.0.4)(webpack@5.84.1) + '@umijs/bundler-webpack': 4.0.70(styled-components@5.3.10)(typescript@5.4.3)(webpack@5.84.1) '@umijs/core': 4.0.70 '@umijs/did-you-know': 1.0.3 '@umijs/es-module-parser': 0.0.7 @@ -7257,7 +7258,7 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - /eslint-plugin-jest@27.2.1(@typescript-eslint/eslint-plugin@5.48.1)(eslint@8.41.0)(typescript@5.0.4): + /eslint-plugin-jest@27.2.1(@typescript-eslint/eslint-plugin@5.48.1)(eslint@8.41.0)(typescript@5.4.3): resolution: {integrity: sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: @@ -7270,8 +7271,8 @@ packages: jest: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 5.48.1(@typescript-eslint/parser@5.48.1)(eslint@8.41.0)(typescript@5.0.4) - '@typescript-eslint/utils': 5.59.8(eslint@8.41.0)(typescript@5.0.4) + '@typescript-eslint/eslint-plugin': 5.48.1(@typescript-eslint/parser@5.48.1)(eslint@8.41.0)(typescript@5.4.3) + '@typescript-eslint/utils': 5.59.8(eslint@8.41.0)(typescript@5.4.3) eslint: 8.41.0 transitivePeerDependencies: - supports-color @@ -7748,7 +7749,7 @@ packages: signal-exit: 4.0.2 dev: false - /fork-ts-checker-webpack-plugin@8.0.0(typescript@5.0.4)(webpack@5.84.1): + /fork-ts-checker-webpack-plugin@8.0.0(typescript@5.4.3)(webpack@5.84.1): resolution: {integrity: sha512-mX3qW3idpueT2klaQXBzrIM/pHw+T0B/V9KHEvNrqijTq9NFnMZU6oreVxDYcf33P8a5cW+67PjodNHthGnNVg==} engines: {node: '>=12.13.0', yarn: '>=1.0.0'} peerDependencies: @@ -7767,7 +7768,7 @@ packages: schema-utils: 3.1.2 semver: 7.5.4 tapable: 2.2.1 - typescript: 5.0.4 + typescript: 5.4.3 webpack: 5.84.1(webpack-cli@4.7.2) dev: true @@ -10708,7 +10709,7 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier-plugin-organize-imports@3.2.2(prettier@2.8.8)(typescript@5.0.4): + /prettier-plugin-organize-imports@3.2.2(prettier@2.8.8)(typescript@5.4.3): resolution: {integrity: sha512-e97lE6odGSiHonHJMTYC0q0iLXQyw0u5z/PJpvP/3vRy6/Zi9kLBwFAbEGjDzIowpjQv8b+J04PDamoUSQbzGA==} peerDependencies: '@volar/vue-language-plugin-pug': ^1.0.4 @@ -10722,7 +10723,7 @@ packages: optional: true dependencies: prettier: 2.8.8 - typescript: 5.0.4 + typescript: 5.4.3 dev: true /prettier-plugin-packagejson@2.4.3(prettier@2.8.8): @@ -12304,7 +12305,6 @@ packages: object-assign: 4.1.1 prop-types: 15.8.1 dev: false - bundledDependencies: false /react@18.1.0: resolution: {integrity: sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ==} @@ -13507,14 +13507,14 @@ packages: /tslib@2.5.2: resolution: {integrity: sha512-5svOrSA2w3iGFDs1HibEVBGbDrAY82bFQ3HZ3ixB+88nsbsWQoKqDRb5UBYAUPEzbBn6dAp5gRNXglySbx1MlA==} - /tsutils@3.21.0(typescript@5.0.4): + /tsutils@3.21.0(typescript@5.4.3): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 5.0.4 + typescript: 5.4.3 dev: true /tsx@3.12.7: @@ -13592,34 +13592,28 @@ packages: is-typed-array: 1.1.10 dev: true - /typescript@5.0.4: - resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} - engines: {node: '>=12.20'} - hasBin: true - dev: true - - /typescript@5.4.2: - resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} + /typescript@5.4.3: + resolution: {integrity: sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==} engines: {node: '>=14.17'} hasBin: true - dev: false + dev: true - /umi@4.0.70(@babel/core@7.22.1)(@types/node@20.4.2)(@types/react@18.2.7)(eslint@8.41.0)(postcss@8.4.24)(prettier@2.8.8)(react-dom@18.2.0)(react@18.2.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.0.4)(webpack@5.84.1): + /umi@4.0.70(@babel/core@7.22.1)(@types/node@20.4.2)(@types/react@18.2.7)(eslint@8.41.0)(postcss@8.4.24)(prettier@2.8.8)(react-dom@18.2.0)(react@18.2.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.4.3)(webpack@5.84.1): resolution: {integrity: sha512-e6GwzZXC1U+XPJhLaOMIr6IBWpi8mGap6ExRkApidfbYZ8HxilvrVHnaLUYSykp206RhZBnJWI7r99mYu3e5eQ==} engines: {node: '>=14'} hasBin: true dependencies: '@babel/runtime': 7.21.0 '@umijs/bundler-utils': 4.0.70 - '@umijs/bundler-webpack': 4.0.70(styled-components@5.3.10)(typescript@5.0.4)(webpack@5.84.1) + '@umijs/bundler-webpack': 4.0.70(styled-components@5.3.10)(typescript@5.4.3)(webpack@5.84.1) '@umijs/core': 4.0.70 - '@umijs/lint': 4.0.70(eslint@8.41.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.0.4) - '@umijs/preset-umi': 4.0.70(@types/node@20.4.2)(@types/react@18.2.7)(postcss@8.4.24)(styled-components@5.3.10)(typescript@5.0.4)(webpack@5.84.1) + '@umijs/lint': 4.0.70(eslint@8.41.0)(styled-components@5.3.10)(stylelint@14.16.1)(typescript@5.4.3) + '@umijs/preset-umi': 4.0.70(@types/node@20.4.2)(@types/react@18.2.7)(postcss@8.4.24)(styled-components@5.3.10)(typescript@5.4.3)(webpack@5.84.1) '@umijs/renderer-react': 4.0.70(react-dom@18.2.0)(react@18.2.0) '@umijs/server': 4.0.70 '@umijs/test': 4.0.70(@babel/core@7.22.1) '@umijs/utils': 4.0.70 - prettier-plugin-organize-imports: 3.2.2(prettier@2.8.8)(typescript@5.0.4) + prettier-plugin-organize-imports: 3.2.2(prettier@2.8.8)(typescript@5.4.3) prettier-plugin-packagejson: 2.4.3(prettier@2.8.8) transitivePeerDependencies: - '@babel/core' From d5fe76f82c260d6052b71ab73efee81960c13f6d Mon Sep 17 00:00:00 2001 From: sorrycc Date: Tue, 16 Apr 2024 11:06:32 +0800 Subject: [PATCH 05/10] chore: update pnpm-lock.yaml --- pnpm-lock.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a140161e..864f0da26 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -370,6 +370,10 @@ importers: webpack-5-chain: specifier: 8.0.1 version: 8.0.1 + devDependencies: + typescript: + specifier: ^5.4.3 + version: 5.4.3 packages/mako: dependencies: From 68043c60365b17338b9effe2a92bc69d140cfcbb Mon Sep 17 00:00:00 2001 From: sorrycc Date: Tue, 16 Apr 2024 11:28:57 +0800 Subject: [PATCH 06/10] chore: improve --- docs/config.md | 3 +-- .../bundler-okam/fork-ts-checker/index.js | 25 ------------------- packages/bundler-okam/index.js | 6 ----- packages/bundler-okam/package.json | 5 +--- packages/mako/package.json | 3 ++- .../src/forkTSChecker/childProcessFork.ts} | 2 +- packages/mako/src/forkTSChecker/index.ts | 23 +++++++++++++++++ .../src/forkTSChecker/tsChecker.ts} | 20 +++++++-------- packages/mako/src/index.ts | 7 ++++++ 9 files changed, 45 insertions(+), 49 deletions(-) delete mode 100644 packages/bundler-okam/fork-ts-checker/index.js rename packages/{bundler-okam/fork-ts-checker/child_process_fork.js => mako/src/forkTSChecker/childProcessFork.ts} (85%) create mode 100644 packages/mako/src/forkTSChecker/index.ts rename packages/{bundler-okam/fork-ts-checker/ts-checker.js => mako/src/forkTSChecker/tsChecker.ts} (86%) diff --git a/docs/config.md b/docs/config.md index d11a0f9fc..9d0c9672c 100644 --- a/docs/config.md +++ b/docs/config.md @@ -178,7 +178,7 @@ import("./a.js") - 类型:`boolean` - 默认值:`false` -是否开启构建时 ts 校验。 +是否开启构建时 TypeScript 类型校验。 ## hash @@ -473,4 +473,3 @@ function App() { - 默认值:`true` 是否在 mode 为 development 时将构建结果写入磁盘。 - diff --git a/packages/bundler-okam/fork-ts-checker/index.js b/packages/bundler-okam/fork-ts-checker/index.js deleted file mode 100644 index 9d0f7354f..000000000 --- a/packages/bundler-okam/fork-ts-checker/index.js +++ /dev/null @@ -1,25 +0,0 @@ -const { fork } = require('child_process'); -const path = require('path'); - -class ForkTsChecker { - constructor(projectRoot) { - this.projectRoot = projectRoot; - } - - runTypeCheckInChildProcess() { - const workerScript = path.join(__dirname, 'child_process_fork.js'); - const child = fork(workerScript, [this.projectRoot], { - stdio: 'inherit', - }); - - child.on('exit', (code) => { - if (code === 1) { - console.log('Type checking completed.'); - } else { - console.error('Type checking failed.'); - } - }); - } -} - -module.exports = { ForkTsChecker }; diff --git a/packages/bundler-okam/index.js b/packages/bundler-okam/index.js index fa5afcfbd..86ddf8a4a 100644 --- a/packages/bundler-okam/index.js +++ b/packages/bundler-okam/index.js @@ -51,12 +51,6 @@ exports.build = async function (opts) { throw err; } - // 后置 ts 校验,不影响打包速度 - if (okamConfig.forkTsChecker) { - const forkTypeChecker = new ForkTsChecker(cwd); - forkTypeChecker.runTypeCheckInChildProcess(); - } - const statsJsonPath = path.join(cwd, 'dist', 'stats.json'); const statsJson = JSON.parse(fs.readFileSync(statsJsonPath, 'utf-8')); diff --git a/packages/bundler-okam/package.json b/packages/bundler-okam/package.json index c50925201..50033fcb2 100644 --- a/packages/bundler-okam/package.json +++ b/packages/bundler-okam/package.json @@ -21,8 +21,5 @@ "publishConfig": { "registry": "https://registry.antgroup-inc.cn" }, - "repository": "git@github.com:umijs/mako.git", - "devDependencies": { - "typescript": "^5.4.3" - } + "repository": "git@github.com:umijs/mako.git" } diff --git a/packages/mako/package.json b/packages/mako/package.json index 8ee3f060b..2fc50b1a6 100644 --- a/packages/mako/package.json +++ b/packages/mako/package.json @@ -26,7 +26,8 @@ "devDependencies": { "@napi-rs/cli": "^2.18.0", "@types/less": "^3.0.6", - "@types/node": "^20.12.5" + "@types/node": "^20.12.5", + "typescript": "^5.4.3" }, "engines": { "node": ">= 16" diff --git a/packages/bundler-okam/fork-ts-checker/child_process_fork.js b/packages/mako/src/forkTSChecker/childProcessFork.ts similarity index 85% rename from packages/bundler-okam/fork-ts-checker/child_process_fork.js rename to packages/mako/src/forkTSChecker/childProcessFork.ts index 83e31a272..344f28bd4 100644 --- a/packages/bundler-okam/fork-ts-checker/child_process_fork.js +++ b/packages/mako/src/forkTSChecker/childProcessFork.ts @@ -1,4 +1,4 @@ -const { TypeChecker } = require('./ts-checker'); +import { TypeChecker } from './tsChecker'; const projectRoot = process.argv[2]; diff --git a/packages/mako/src/forkTSChecker/index.ts b/packages/mako/src/forkTSChecker/index.ts new file mode 100644 index 000000000..be737f8e2 --- /dev/null +++ b/packages/mako/src/forkTSChecker/index.ts @@ -0,0 +1,23 @@ +import { fork } from 'child_process'; +import path from 'path'; + +export class ForkTsChecker { + #projectRoot: string; + constructor(projectRoot: string) { + this.#projectRoot = projectRoot; + } + + runTypeCheckInChildProcess() { + const workerScript = path.join(__dirname, 'childProcessFork.js'); + const child = fork(workerScript, [this.#projectRoot], { + stdio: 'inherit', + }); + child.on('exit', (code) => { + if (code === 1) { + console.log('Type checking completed.'); + } else { + console.error('Type checking failed.'); + } + }); + } +} diff --git a/packages/bundler-okam/fork-ts-checker/ts-checker.js b/packages/mako/src/forkTSChecker/tsChecker.ts similarity index 86% rename from packages/bundler-okam/fork-ts-checker/ts-checker.js rename to packages/mako/src/forkTSChecker/tsChecker.ts index ba1484f03..80eaaad11 100644 --- a/packages/bundler-okam/fork-ts-checker/ts-checker.js +++ b/packages/mako/src/forkTSChecker/tsChecker.ts @@ -1,23 +1,24 @@ -const ts = require('typescript'); -const path = require('path'); -const fs = require('fs').promises; +import ts from 'typescript'; +import path from 'path'; +import { promises as fs } from 'fs'; class TypeChecker { - constructor(projectRoot) { - this.projectRoot = projectRoot; + #projectRoot: string; + constructor(projectRoot: string) { + this.#projectRoot = projectRoot; } async check() { try { const configPath = ts.findConfigFile( - this.projectRoot, + this.#projectRoot, ts.sys.fileExists, 'tsconfig.json', ); if (!configPath) { console.error( 'Could not find a valid "tsconfig.json" file in the project root:', - this.projectRoot, + this.#projectRoot, ); return; } @@ -65,7 +66,7 @@ class TypeChecker { } const diagnostics = ts.getPreEmitDiagnostics(program); if (diagnostics.length > 0) { - diagnostics.forEach((diagnostic) => { + diagnostics.forEach((diagnostic: any) => { const message = ts.flattenDiagnosticMessageText( diagnostic.messageText, '\n', @@ -74,8 +75,7 @@ class TypeChecker { const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.error( - `${diagnostic.file.fileName} (${line + 1}, ${ - character + 1 + `${diagnostic.file.fileName} (${line + 1}, ${character + 1 }): ${message}`, ); } else { diff --git a/packages/mako/src/index.ts b/packages/mako/src/index.ts index 8d03083c7..0dbb36c55 100644 --- a/packages/mako/src/index.ts +++ b/packages/mako/src/index.ts @@ -2,6 +2,7 @@ import fs from 'fs'; import path from 'path'; import * as binding from '../binding'; import { LessLoaderOpts, lessLoader } from './lessLoader'; +import { ForkTsChecker } from './forkTSChecker'; // ref: // https://github.com/vercel/next.js/pull/51883 @@ -21,6 +22,7 @@ function blockStdout() { interface ExtraBuildParams { less?: LessLoaderOpts; + forkTsChecker?: boolean; } export async function build(params: binding.BuildParams & ExtraBuildParams) { @@ -115,4 +117,9 @@ export async function build(params: binding.BuildParams & ExtraBuildParams) { } await binding.build(params); + + if (params.forkTsChecker) { + const forkTypeChecker = new ForkTsChecker(params.root); + forkTypeChecker.runTypeCheckInChildProcess(); + } } From 39db1f6dce55ad4b02e4cde226b531e059300da9 Mon Sep 17 00:00:00 2001 From: sorrycc Date: Tue, 16 Apr 2024 11:38:46 +0800 Subject: [PATCH 07/10] chore: improve --- packages/bundler-okam/index.js | 1 - packages/mako/binding.d.ts | 4 ---- packages/mako/src/forkTSChecker/tsChecker.ts | 11 +++++------ packages/mako/src/index.ts | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/bundler-okam/index.js b/packages/bundler-okam/index.js index 86ddf8a4a..a7017fee9 100644 --- a/packages/bundler-okam/index.js +++ b/packages/bundler-okam/index.js @@ -277,7 +277,6 @@ function checkConfig(opts) { 'config.cssLoaderModules', 'config.classPropertiesLoose', 'config.extraPostCSSPlugins', - 'config.forkTSChecker', 'config.postcssLoader', 'config.sassLoader', 'config.styleLoader', diff --git a/packages/mako/binding.d.ts b/packages/mako/binding.d.ts index 9a5801a23..90bf7b7c6 100644 --- a/packages/mako/binding.d.ts +++ b/packages/mako/binding.d.ts @@ -3,10 +3,6 @@ /* auto-generated by NAPI-RS */ -export interface TransformOutput { - code: string; - map?: string; -} export interface JsHooks { load?: (filePath: string) => Promise<{ content: string; type: 'css' | 'js' }>; generateEnd?: (data: { diff --git a/packages/mako/src/forkTSChecker/tsChecker.ts b/packages/mako/src/forkTSChecker/tsChecker.ts index 80eaaad11..fb6339781 100644 --- a/packages/mako/src/forkTSChecker/tsChecker.ts +++ b/packages/mako/src/forkTSChecker/tsChecker.ts @@ -1,8 +1,8 @@ -import ts from 'typescript'; -import path from 'path'; import { promises as fs } from 'fs'; +import path from 'path'; +import ts from 'typescript'; -class TypeChecker { +export class TypeChecker { #projectRoot: string; constructor(projectRoot: string) { this.#projectRoot = projectRoot; @@ -75,7 +75,8 @@ class TypeChecker { const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.error( - `${diagnostic.file.fileName} (${line + 1}, ${character + 1 + `${diagnostic.file.fileName} (${line + 1}, ${ + character + 1 }): ${message}`, ); } else { @@ -93,5 +94,3 @@ class TypeChecker { } } } - -module.exports = { TypeChecker }; diff --git a/packages/mako/src/index.ts b/packages/mako/src/index.ts index 0dbb36c55..14851d038 100644 --- a/packages/mako/src/index.ts +++ b/packages/mako/src/index.ts @@ -1,8 +1,8 @@ import fs from 'fs'; import path from 'path'; import * as binding from '../binding'; -import { LessLoaderOpts, lessLoader } from './lessLoader'; import { ForkTsChecker } from './forkTSChecker'; +import { LessLoaderOpts, lessLoader } from './lessLoader'; // ref: // https://github.com/vercel/next.js/pull/51883 From c52e0b5a8f50a183c5b9918ae56a975f72b75ad2 Mon Sep 17 00:00:00 2001 From: sorrycc Date: Tue, 16 Apr 2024 14:33:43 +0800 Subject: [PATCH 08/10] chore: improve --- docs/api.md | 8 ++++++++ docs/config.md | 7 ------- packages/bundler-okam/index.js | 15 +++++++-------- packages/mako/src/forkTSChecker/index.ts | 20 +++++++++++++------- packages/mako/src/forkTSChecker/tsChecker.ts | 3 +-- packages/mako/src/index.ts | 13 +++++++------ 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/docs/api.md b/docs/api.md index e8411a0e3..427500db0 100644 --- a/docs/api.md +++ b/docs/api.md @@ -13,6 +13,7 @@ await build({ config: {}, hooks: {}, less: {}, + forkTsChecker: true, watch: false, }: BuildOptions); ``` @@ -83,6 +84,13 @@ hooks 是一些钩子函数,用于扩展 Mako 的编译过程。 - `generateEnd`,在 Generate 完成后会调用,通过 `isFirstCompile` 可以判断是否是第一次编译,`time` 为编译时间,`stats` 为编译统计信息 - `load`,用于加载文件,返回文件内容和类型,类型支持 `css`、`javascript` +### forkTsChecker + +- 类型:`boolean` +- 默认值:`false` + +是否开启构建时 TypeScript 类型校验。 + ### watch - 类型:`Boolean` diff --git a/docs/config.md b/docs/config.md index 9d0c9672c..22834f5f9 100644 --- a/docs/config.md +++ b/docs/config.md @@ -173,13 +173,6 @@ import("./a.js") 是否修复 flexbugs。 -## forkTsChecker - -- 类型:`boolean` -- 默认值:`false` - -是否开启构建时 TypeScript 类型校验。 - ## hash - 类型:`boolean` diff --git a/packages/bundler-okam/index.js b/packages/bundler-okam/index.js index a7017fee9..7504a6ade 100644 --- a/packages/bundler-okam/index.js +++ b/packages/bundler-okam/index.js @@ -1,12 +1,10 @@ const path = require('path'); const fs = require('fs'); -const url = require('url'); const http = require('http'); const assert = require('assert'); const { createProxy, createHttpsServer } = require('@umijs/bundler-utils'); const lodash = require('lodash'); const chalk = require('chalk'); -const { ForkTsChecker } = require('./fork-ts-checker/index'); const { createProxyMiddleware, } = require('@umijs/bundler-utils/compiled/http-proxy-middleware'); @@ -41,6 +39,7 @@ exports.build = async function (opts) { sourceMap: getLessSourceMapConfig(okamConfig.devtool), math: opts.config.lessLoader?.math, }, + forkTSChecker: okamConfig.forkTSChecker, watch: false, }); } catch (e) { @@ -169,6 +168,7 @@ exports.dev = async function (opts) { sourceMap: getLessSourceMapConfig(okamConfig.devtool), math: opts.config.lessLoader?.math, }, + forkTSChecker: okamConfig.forkTSChecker, hooks: { generateEnd: (args) => { opts.onDevCompileDone(args); @@ -261,8 +261,7 @@ function checkConfig(opts) { // throw error for other type prefixes // ex. `commonjs`、`var 1 + 1`、`global` throw new Error( - `externals string value prefix \`${ - v.split(' ')[0] + `externals string value prefix \`${v.split(' ')[0] } \` is not supported in Mako bundler`, ); } @@ -363,8 +362,8 @@ function checkConfig(opts) { - ${warningKeys.join('\n - ')} So this project may fail in compile-time or error in runtime, ${chalk.bold( - 'please test and release carefully', - )}. + 'please test and release carefully', + )}. ===================================================================================================== `, ), @@ -405,7 +404,7 @@ async function getOkamConfig(opts) { externals, copy = [], clean, - forkTsChecker, + forkTSChecker, } = opts.config; const outputPath = path.join(opts.cwd, 'dist'); // TODO: @@ -514,7 +513,7 @@ async function getOkamConfig(opts) { flexBugs: true, react: opts.react || {}, emotion, - forkTsChecker, + forkTSChecker: !!forkTSChecker, ...(opts.disableCopy ? { copy: [] } : { copy: ['public'].concat(copy) }), }; diff --git a/packages/mako/src/forkTSChecker/index.ts b/packages/mako/src/forkTSChecker/index.ts index be737f8e2..ec2706441 100644 --- a/packages/mako/src/forkTSChecker/index.ts +++ b/packages/mako/src/forkTSChecker/index.ts @@ -1,22 +1,28 @@ import { fork } from 'child_process'; import path from 'path'; -export class ForkTsChecker { - #projectRoot: string; - constructor(projectRoot: string) { - this.#projectRoot = projectRoot; +interface ForkTSCheckerOpts { + root: string; + watch: boolean; +} + +export class ForkTSChecker { + #opts: ForkTSCheckerOpts; + constructor(opts: ForkTSCheckerOpts) { + this.#opts = opts; } runTypeCheckInChildProcess() { const workerScript = path.join(__dirname, 'childProcessFork.js'); - const child = fork(workerScript, [this.#projectRoot], { + const child = fork(workerScript, [this.#opts.root], { stdio: 'inherit', }); child.on('exit', (code) => { if (code === 1) { - console.log('Type checking completed.'); - } else { console.error('Type checking failed.'); + if (!this.#opts.watch) { + process.exit(1); + } } }); } diff --git a/packages/mako/src/forkTSChecker/tsChecker.ts b/packages/mako/src/forkTSChecker/tsChecker.ts index fb6339781..ba30586f8 100644 --- a/packages/mako/src/forkTSChecker/tsChecker.ts +++ b/packages/mako/src/forkTSChecker/tsChecker.ts @@ -75,8 +75,7 @@ export class TypeChecker { const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.error( - `${diagnostic.file.fileName} (${line + 1}, ${ - character + 1 + `${diagnostic.file.fileName} (${line + 1}, ${character + 1 }): ${message}`, ); } else { diff --git a/packages/mako/src/index.ts b/packages/mako/src/index.ts index 14851d038..bfdd8c566 100644 --- a/packages/mako/src/index.ts +++ b/packages/mako/src/index.ts @@ -1,7 +1,7 @@ import fs from 'fs'; import path from 'path'; import * as binding from '../binding'; -import { ForkTsChecker } from './forkTSChecker'; +import { ForkTSChecker as ForkTSChecker } from './forkTSChecker'; import { LessLoaderOpts, lessLoader } from './lessLoader'; // ref: @@ -22,7 +22,7 @@ function blockStdout() { interface ExtraBuildParams { less?: LessLoaderOpts; - forkTsChecker?: boolean; + forkTSChecker?: boolean; } export async function build(params: binding.BuildParams & ExtraBuildParams) { @@ -100,12 +100,10 @@ export async function build(params: binding.BuildParams & ExtraBuildParams) { if (process.env.XCODE_PROFILE) { await new Promise((resolve) => { const readline = require('readline'); - const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); - rl.question( `Xcode profile enabled. Current process ${process.title} (${process.pid}) . Press Enter to continue...\n`, () => { @@ -118,8 +116,11 @@ export async function build(params: binding.BuildParams & ExtraBuildParams) { await binding.build(params); - if (params.forkTsChecker) { - const forkTypeChecker = new ForkTsChecker(params.root); + if (params.forkTSChecker) { + const forkTypeChecker = new ForkTSChecker({ + root: params.root, + watch: params.watch, + }); forkTypeChecker.runTypeCheckInChildProcess(); } } From 9d94ff1eefaf1286773b4d4298217cd24ef04082 Mon Sep 17 00:00:00 2001 From: sorrycc Date: Tue, 16 Apr 2024 14:38:24 +0800 Subject: [PATCH 09/10] chore: update --- packages/bundler-okam/index.js | 7 ++++--- packages/mako/src/forkTSChecker/tsChecker.ts | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/bundler-okam/index.js b/packages/bundler-okam/index.js index 7504a6ade..20a173edb 100644 --- a/packages/bundler-okam/index.js +++ b/packages/bundler-okam/index.js @@ -261,7 +261,8 @@ function checkConfig(opts) { // throw error for other type prefixes // ex. `commonjs`、`var 1 + 1`、`global` throw new Error( - `externals string value prefix \`${v.split(' ')[0] + `externals string value prefix \`${ + v.split(' ')[0] } \` is not supported in Mako bundler`, ); } @@ -362,8 +363,8 @@ function checkConfig(opts) { - ${warningKeys.join('\n - ')} So this project may fail in compile-time or error in runtime, ${chalk.bold( - 'please test and release carefully', - )}. + 'please test and release carefully', + )}. ===================================================================================================== `, ), diff --git a/packages/mako/src/forkTSChecker/tsChecker.ts b/packages/mako/src/forkTSChecker/tsChecker.ts index ba30586f8..fb6339781 100644 --- a/packages/mako/src/forkTSChecker/tsChecker.ts +++ b/packages/mako/src/forkTSChecker/tsChecker.ts @@ -75,7 +75,8 @@ export class TypeChecker { const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.error( - `${diagnostic.file.fileName} (${line + 1}, ${character + 1 + `${diagnostic.file.fileName} (${line + 1}, ${ + character + 1 }): ${message}`, ); } else { From 7955788acd459500ec07c0dfa1b1971a3832511a Mon Sep 17 00:00:00 2001 From: sorrycc Date: Tue, 16 Apr 2024 14:39:58 +0800 Subject: [PATCH 10/10] chore: update --- packages/mako/src/forkTSChecker/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mako/src/forkTSChecker/index.ts b/packages/mako/src/forkTSChecker/index.ts index ec2706441..735327197 100644 --- a/packages/mako/src/forkTSChecker/index.ts +++ b/packages/mako/src/forkTSChecker/index.ts @@ -14,6 +14,7 @@ export class ForkTSChecker { runTypeCheckInChildProcess() { const workerScript = path.join(__dirname, 'childProcessFork.js'); + // TODO: support watch mode const child = fork(workerScript, [this.#opts.root], { stdio: 'inherit', });