From 4568156d4cba1b45ad939042242cc6b0c293ff26 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 26 Jun 2024 09:45:18 +0800 Subject: [PATCH] feat: support TypeScript 5 with type checking during build (#587) --- packages/toolpack/package.json | 2 +- .../src/utils/forkTsCheckerWebpackPlugin.ts | 2 +- pnpm-lock.yaml | 220 ++++++++++++------ test/e2e/typescript-5-buildError.test.ts | 40 ++++ .../typescript-type-error-ts5/package.json | 12 + .../typescript-type-error-ts5/shuvi.config.ts | 5 + .../src/routes/page.tsx | 12 + .../typescript-type-error-ts5/tsconfig.json | 39 ++++ 8 files changed, 261 insertions(+), 71 deletions(-) create mode 100644 test/e2e/typescript-5-buildError.test.ts create mode 100644 test/fixtures/typescript-type-error-ts5/package.json create mode 100644 test/fixtures/typescript-type-error-ts5/shuvi.config.ts create mode 100644 test/fixtures/typescript-type-error-ts5/src/routes/page.tsx create mode 100644 test/fixtures/typescript-type-error-ts5/tsconfig.json diff --git a/packages/toolpack/package.json b/packages/toolpack/package.json index aedc49f1c..eeb2af69e 100644 --- a/packages/toolpack/package.json +++ b/packages/toolpack/package.json @@ -50,7 +50,7 @@ "es-module-lexer": "0.10.5", "esbuild": "0.14.38", "esbuild-loader": "2.19.0", - "fork-ts-checker-webpack-plugin": "6.0.8", + "fork-ts-checker-webpack-plugin": "^9.0.2", "fs-extra": "9.0.1", "ignore-loader": "0.1.2", "loader-utils": "3.0.0", diff --git a/packages/toolpack/src/utils/forkTsCheckerWebpackPlugin.ts b/packages/toolpack/src/utils/forkTsCheckerWebpackPlugin.ts index 97b57bf7d..7a855adb6 100644 --- a/packages/toolpack/src/utils/forkTsCheckerWebpackPlugin.ts +++ b/packages/toolpack/src/utils/forkTsCheckerWebpackPlugin.ts @@ -1,5 +1,5 @@ import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; export { Issue } from 'fork-ts-checker-webpack-plugin/lib/issue'; -export { createCodeFrameFormatter } from 'fork-ts-checker-webpack-plugin/lib/formatter/CodeFrameFormatter'; +export { createCodeFrameFormatter } from 'fork-ts-checker-webpack-plugin/lib/formatter'; export default ForkTsCheckerWebpackPlugin; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e6063a0e7..cb745b733 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -877,8 +877,8 @@ importers: specifier: 2.19.0 version: 2.19.0(webpack@5.73.0) fork-ts-checker-webpack-plugin: - specifier: 6.0.8 - version: 6.0.8(typescript@4.8.4)(webpack@5.73.0) + specifier: ^9.0.2 + version: 9.0.2(typescript@4.8.4)(webpack@5.73.0) fs-extra: specifier: 9.0.1 version: 9.0.1 @@ -1257,6 +1257,25 @@ importers: specifier: 18.0.6 version: 18.0.6 + test/fixtures/typescript-type-error-ts5: + dependencies: + shuvi: + specifier: workspace:* + version: link:../../../packages/shuvi + devDependencies: + '@types/node': + specifier: 18.0.6 + version: 18.0.6 + '@types/react': + specifier: 18.0.9 + version: 18.0.9 + '@types/react-dom': + specifier: 18.0.6 + version: 18.0.6 + typescript: + specifier: ^5.0.0 + version: 5.5.2 + test/fixtures/webpack-watch-wait-file-builder: dependencies: shuvi: @@ -4255,7 +4274,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 chalk: 4.1.0 jest-message-util: 28.1.1 jest-util: 28.1.1 @@ -4276,14 +4295,14 @@ packages: '@jest/test-result': 28.1.1 '@jest/transform': 28.1.1 '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 ansi-escapes: 4.3.2 chalk: 4.1.0 ci-info: 3.6.2 exit: 0.1.2 graceful-fs: 4.2.10 jest-changed-files: 28.0.2 - jest-config: 28.1.1(@types/node@12.12.7) + jest-config: 28.1.1(@types/node@18.19.34) jest-haste-map: 28.1.1 jest-message-util: 28.1.1 jest-regex-util: 28.0.2 @@ -4311,7 +4330,7 @@ packages: dependencies: '@jest/fake-timers': 28.1.1 '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 jest-mock: 28.1.1 dev: true @@ -4338,7 +4357,7 @@ packages: dependencies: '@jest/types': 28.1.1 '@sinonjs/fake-timers': 9.1.2 - '@types/node': 12.12.7 + '@types/node': 18.19.34 jest-message-util: 28.1.1 jest-mock: 28.1.1 jest-util: 28.1.1 @@ -4370,7 +4389,7 @@ packages: '@jest/transform': 28.1.1 '@jest/types': 28.1.1 '@jridgewell/trace-mapping': 0.3.13 - '@types/node': 12.12.7 + '@types/node': 18.19.34 chalk: 4.1.0 collect-v8-coverage: 1.0.1 exit: 0.1.2 @@ -4469,7 +4488,7 @@ packages: '@jest/schemas': 28.0.2 '@types/istanbul-lib-coverage': 2.0.3 '@types/istanbul-reports': 3.0.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 '@types/yargs': 17.0.10 chalk: 4.1.0 dev: true @@ -5037,7 +5056,7 @@ packages: dependencies: '@types/http-cache-semantics': 4.0.1 '@types/keyv': 3.1.4 - '@types/node': 12.12.7 + '@types/node': 18.19.34 '@types/responselike': 1.0.0 dev: true @@ -5115,20 +5134,20 @@ packages: /@types/fs-extra@9.0.13: resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/glob@7.2.0: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: '@types/minimatch': 3.0.5 - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/graceful-fs@4.1.5: resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/http-cache-semantics@4.0.1: @@ -5138,7 +5157,7 @@ packages: /@types/http-proxy@1.17.4: resolution: {integrity: sha512-IrSHl2u6AWXduUaDLqYpt45tLVCtYv7o4Z0s1KghBCDgIIS9oW5K1H8mZG/A2CfeLdEa7rTd1ACOiHBc1EMT2Q==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: false /@types/istanbul-lib-coverage@2.0.1: @@ -5184,7 +5203,7 @@ packages: /@types/jsdom@16.2.14: resolution: {integrity: sha512-6BAy1xXEmMuHeAJ4Fv4yXKwBDTGTOseExKE3OaHiNycdHdZw59KfYzrt0DkDluvwmik1HRt6QS7bImxUmpSy+w==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 '@types/parse5': 6.0.3 '@types/tough-cookie': 4.0.2 dev: true @@ -5207,7 +5226,7 @@ packages: /@types/keyv@3.1.4: resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/loader-utils@2.0.1: @@ -5251,6 +5270,7 @@ packages: /@types/node@12.12.7: resolution: {integrity: sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==} + dev: true /@types/node@17.0.23: resolution: {integrity: sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==} @@ -5264,7 +5284,6 @@ packages: resolution: {integrity: sha512-eXF4pfBNV5DAMKGbI02NnDtWrQ40hAN558/2vvS4gMpMIxaf6JmD7YjnZbq0Q9TDSSkKBamime8ewRoomHdt4g==} dependencies: undici-types: 5.26.5 - dev: true /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} @@ -5298,7 +5317,7 @@ packages: /@types/puppeteer@5.4.6: resolution: {integrity: sha512-98Kghehs7+/GD9b56qryhqdqVCXUTbetTv3PlvDnmFRTHQH0j9DIp1f7rkAW3BAj4U3yoeSEQnKgdW8bDq0Y0Q==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/raw-body@2.3.0: @@ -5331,7 +5350,7 @@ packages: /@types/resolve@1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/resolve@1.20.2: @@ -5341,7 +5360,7 @@ packages: /@types/responselike@1.0.0: resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/rimraf@3.0.0: @@ -5355,7 +5374,7 @@ packages: resolution: {integrity: sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ==} dependencies: '@types/glob': 7.2.0 - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/scheduler@0.16.2: @@ -5372,7 +5391,7 @@ packages: resolution: {integrity: sha512-0mwoiK3DXXBu0GIfo+jBv4Wo5s1AcsxdpdwNUtflKm99VEMvmBPJ+/NBNRZy2R5JEYfWL/u4nAHuTUTA3wFecQ==} dependencies: '@types/mime': 2.0.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /@types/source-list-map@0.1.2: @@ -5429,7 +5448,7 @@ packages: /@types/webpack-sources@0.1.5: resolution: {integrity: sha512-zfvjpp7jiafSmrzJ2/i3LqOyTYTuJ7u1KOXlKgDlvsj9Rr0x7ZiYu5lZbXwobL7lmsRNtPXlBfmaUD8eU2Hu8w==} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 '@types/source-list-map': 0.1.2 source-map: 0.6.1 dev: true @@ -5438,7 +5457,7 @@ packages: resolution: {integrity: sha512-tWkdf9nO0zFgAY/EumUKwrDUhraHKDqCPhwfFR/R8l0qnPdgb9le0Gzhvb7uzVpouuDGBgiE//ZdY+5jcZy2TA==} dependencies: '@types/anymatch': 1.3.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 '@types/tapable': 1.0.4 '@types/uglify-js': 3.0.4 '@types/webpack-sources': 0.1.5 @@ -6724,7 +6743,6 @@ packages: dependencies: ansi-styles: 4.3.0 supports-color: 7.2.0 - dev: true /char-regex@1.0.2: resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} @@ -6745,6 +6763,21 @@ packages: optionalDependencies: fsevents: 2.3.2 + /chokidar@3.6.0: + resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} + engines: {node: '>= 8.10.0'} + dependencies: + anymatch: 3.1.2 + braces: 3.0.2 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.2 + dev: false + /chownr@1.1.3: resolution: {integrity: sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==} dev: true @@ -7245,6 +7278,7 @@ packages: parse-json: 5.0.0 path-type: 4.0.0 yaml: 1.10.2 + dev: true /cosmiconfig@7.0.0: resolution: {integrity: sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==} @@ -7256,6 +7290,22 @@ packages: path-type: 4.0.0 yaml: 1.10.2 + /cosmiconfig@8.3.6(typescript@4.8.4): + resolution: {integrity: sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==} + engines: {node: '>=14'} + peerDependencies: + typescript: '>=4.9.5' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + import-fresh: 3.3.0 + js-yaml: 4.1.0 + parse-json: 5.2.0 + path-type: 4.0.0 + typescript: 4.8.4 + dev: false + /cp-file@6.2.0: resolution: {integrity: sha512-fmvV4caBnofhPe8kOcitBwSn2f39QLjnAnGq3gO9dfd75mUytzKNZB1hde6QHunW2Rt+OwuBOMc3i1tNElbszA==} engines: {node: '>=6'} @@ -9474,34 +9524,28 @@ packages: engines: {node: '>=0.10.0'} dev: true - /fork-ts-checker-webpack-plugin@6.0.8(typescript@4.8.4)(webpack@5.73.0): - resolution: {integrity: sha512-2K6Ozamm6TSL5heFIwPhX5+VsOBiiKf9PzaPFS7kwzrILKX+jlN3DBQc5v/6YYZ2oKJyImg3bY0/uZc7cDbDYQ==} - engines: {node: '>=10', yarn: '>=1.0.0'} + /fork-ts-checker-webpack-plugin@9.0.2(typescript@4.8.4)(webpack@5.73.0): + resolution: {integrity: sha512-Uochze2R8peoN1XqlSi/rGUkDQpRogtLFocP9+PGu68zk1BDAKXfdeCdyVZpgTk8V8WFVQXdEz426VKjXLO1Gg==} + engines: {node: '>=12.13.0', yarn: '>=1.0.0'} peerDependencies: - eslint: '>= 6' - typescript: '>= 2.7' - vue-template-compiler: '*' - webpack: '>= 4' + typescript: '>3.6.0' + webpack: ^5.11.0 peerDependenciesMeta: - eslint: - optional: true typescript: optional: true - vue-template-compiler: - optional: true dependencies: - '@babel/code-frame': 7.12.11 - '@types/json-schema': 7.0.6 - chalk: 4.1.0 - chokidar: 3.5.0 - cosmiconfig: 6.0.0 + '@babel/code-frame': 7.16.7 + chalk: 4.1.2 + chokidar: 3.6.0 + cosmiconfig: 8.3.6(typescript@4.8.4) deepmerge: 4.2.2 - fs-extra: 9.0.1 - memfs: 3.2.0 - minimatch: 3.0.4 - schema-utils: 2.7.0 - semver: 7.3.2 - tapable: 1.1.3 + fs-extra: 10.1.0 + memfs: 3.6.0 + minimatch: 3.1.2 + node-abort-controller: 3.1.1 + schema-utils: 3.1.1 + semver: 7.4.0 + tapable: 2.2.1 typescript: 4.8.4 webpack: 5.73.0(esbuild@0.14.38) dev: false @@ -9582,6 +9626,11 @@ packages: /fs-monkey@1.0.1: resolution: {integrity: sha512-fcSa+wyTqZa46iWweI7/ZiUfegOZl0SG8+dltIwFXo7+zYU9J9kpS3NB6pZcSlJdhvIwp81Adx2XhZorncxiaA==} + dev: true + + /fs-monkey@1.0.6: + resolution: {integrity: sha512-b1FMfwetIKymC0eioW7mTywihSQE4oLzQn1dB6rZB5fx/3NpNEdAWeCSMB+60/AeT0TCXsxzAlcYVEFCTAksWg==} + dev: false /fs.realpath@1.0.0: resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=} @@ -10293,6 +10342,14 @@ packages: parent-module: 1.0.1 resolve-from: 4.0.0 + /import-fresh@3.3.0: + resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} + engines: {node: '>=6'} + dependencies: + parent-module: 1.0.1 + resolve-from: 4.0.0 + dev: false + /import-from@3.0.0: resolution: {integrity: sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ==} engines: {node: '>=8'} @@ -10868,7 +10925,7 @@ packages: '@jest/expect': 28.1.1 '@jest/test-result': 28.1.1 '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 chalk: 4.1.0 co: 4.6.0 dedent: 0.7.0 @@ -10915,7 +10972,7 @@ packages: - ts-node dev: true - /jest-config@28.1.1(@types/node@12.12.7): + /jest-config@28.1.1(@types/node@18.0.6): resolution: {integrity: sha512-tASynMhS+jVV85zKvjfbJ8nUyJS/jUSYZ5KQxLUN2ZCvcQc/OmhQl2j6VEL3ezQkNofxn5pQ3SPYWPHb0unTZA==} engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} peerDependencies: @@ -10930,7 +10987,7 @@ packages: '@babel/core': 7.16.0 '@jest/test-sequencer': 28.1.1 '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.0.6 babel-jest: 28.1.1(@babel/core@7.16.0) chalk: 4.1.0 ci-info: 3.6.2 @@ -10954,7 +11011,7 @@ packages: - supports-color dev: true - /jest-config@28.1.1(@types/node@18.0.6): + /jest-config@28.1.1(@types/node@18.19.34): resolution: {integrity: sha512-tASynMhS+jVV85zKvjfbJ8nUyJS/jUSYZ5KQxLUN2ZCvcQc/OmhQl2j6VEL3ezQkNofxn5pQ3SPYWPHb0unTZA==} engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} peerDependencies: @@ -10969,7 +11026,7 @@ packages: '@babel/core': 7.16.0 '@jest/test-sequencer': 28.1.1 '@jest/types': 28.1.1 - '@types/node': 18.0.6 + '@types/node': 18.19.34 babel-jest: 28.1.1(@babel/core@7.16.0) chalk: 4.1.0 ci-info: 3.6.2 @@ -11039,7 +11096,7 @@ packages: '@jest/fake-timers': 28.1.1 '@jest/types': 28.1.1 '@types/jsdom': 16.2.14 - '@types/node': 12.12.7 + '@types/node': 18.19.34 jest-mock: 28.1.1 jest-util: 28.1.1 jsdom: 19.0.0 @@ -11057,7 +11114,7 @@ packages: '@jest/environment': 28.1.1 '@jest/fake-timers': 28.1.1 '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 jest-mock: 28.1.1 jest-util: 28.1.1 dev: true @@ -11078,7 +11135,7 @@ packages: dependencies: '@jest/types': 28.1.1 '@types/graceful-fs': 4.1.5 - '@types/node': 12.12.7 + '@types/node': 18.19.34 anymatch: 3.1.2 fb-watchman: 2.0.1 graceful-fs: 4.2.10 @@ -11129,7 +11186,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 dev: true /jest-pnp-resolver@1.2.2(jest-resolve@28.1.1): @@ -11183,7 +11240,7 @@ packages: '@jest/test-result': 28.1.1 '@jest/transform': 28.1.1 '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 chalk: 4.1.0 emittery: 0.10.2 graceful-fs: 4.2.10 @@ -11269,7 +11326,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 chalk: 4.1.0 ci-info: 3.6.2 graceful-fs: 4.2.10 @@ -11294,7 +11351,7 @@ packages: dependencies: '@jest/test-result': 28.1.1 '@jest/types': 28.1.1 - '@types/node': 12.12.7 + '@types/node': 18.19.34 ansi-escapes: 4.3.2 chalk: 4.1.0 emittery: 0.10.2 @@ -11306,7 +11363,7 @@ packages: resolution: {integrity: sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 merge-stream: 2.0.0 supports-color: 7.2.0 dev: true @@ -11315,7 +11372,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 merge-stream: 2.0.0 supports-color: 8.1.1 dev: false @@ -11324,7 +11381,7 @@ packages: resolution: {integrity: sha512-Au7slXB08C6h+xbJPp7VIb6U0XX5Kc9uel/WFc6/rcTzGiaVCBRngBExSYuXSLFPULPSYU3cJ3ybS988lNFQhQ==} engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: - '@types/node': 12.12.7 + '@types/node': 18.19.34 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -11433,6 +11490,7 @@ packages: /json-parse-better-errors@1.0.2: resolution: {integrity: sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==} + dev: true /json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} @@ -12105,6 +12163,15 @@ packages: engines: {node: '>= 4.0.0'} dependencies: fs-monkey: 1.0.1 + dev: true + + /memfs@3.6.0: + resolution: {integrity: sha512-EGowvkkgbMcIChjMTMkESFDbZeSh8xZ7kNSF0hAiAN4Jh6jgHCRS0Ga/+C8y6Au+oqpezRHCfPsmJ2+DwAgiwQ==} + engines: {node: '>= 4.0.0'} + deprecated: this will be v4 + dependencies: + fs-monkey: 1.0.6 + dev: false /memorystream@0.3.1: resolution: {integrity: sha1-htcJCzDORV1j+64S3aUaR93K+bI=} @@ -12461,6 +12528,10 @@ packages: resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} dev: true + /node-abort-controller@3.1.1: + resolution: {integrity: sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==} + dev: false + /node-fetch@2.6.12: resolution: {integrity: sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==} engines: {node: 4.x || >=6.0.0} @@ -12910,6 +12981,7 @@ packages: error-ex: 1.3.2 json-parse-better-errors: 1.0.2 lines-and-columns: 1.1.6 + dev: true /parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} @@ -13019,7 +13091,6 @@ packages: /picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - dev: true /pidtree@0.3.0: resolution: {integrity: sha512-9CT4NFlDcosssyg8KVFltgokyKZIFjoBxw8CTGy+5F38Y1eQWrt8tRayiUOXE+zVKQnYu5BR8JjCtvK3BcnBhg==} @@ -14472,6 +14543,13 @@ packages: dependencies: picomatch: 2.3.0 + /readdirp@3.6.0: + resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} + engines: {node: '>=8.10.0'} + dependencies: + picomatch: 2.3.1 + dev: false + /redent@3.0.0: resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} engines: {node: '>=8'} @@ -15654,7 +15732,6 @@ packages: engines: {node: '>=8'} dependencies: has-flag: 4.0.0 - dev: true /supports-color@8.1.1: resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} @@ -15715,13 +15792,13 @@ packages: strip-ansi: 6.0.1 dev: true - /tapable@1.1.3: - resolution: {integrity: sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==} + /tapable@2.2.0: + resolution: {integrity: sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw==} engines: {node: '>=6'} dev: false - /tapable@2.2.0: - resolution: {integrity: sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw==} + /tapable@2.2.1: + resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} engines: {node: '>=6'} dev: false @@ -16284,6 +16361,12 @@ packages: engines: {node: '>=4.2.0'} hasBin: true + /typescript@5.5.2: + resolution: {integrity: sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==} + engines: {node: '>=14.17'} + hasBin: true + dev: true + /uglify-js@3.16.3: resolution: {integrity: sha512-uVbFqx9vvLhQg0iBaau9Z75AxWJ8tqM9AV890dIZCLApF4rTcyHwmAvLeEdYRs+BzYWu8Iw81F79ah0EfTXbaw==} engines: {node: '>=0.8.0'} @@ -16309,7 +16392,6 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - dev: true /unicode-canonical-property-names-ecmascript@1.0.4: resolution: {integrity: sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==} diff --git a/test/e2e/typescript-5-buildError.test.ts b/test/e2e/typescript-5-buildError.test.ts new file mode 100644 index 000000000..07c6491ee --- /dev/null +++ b/test/e2e/typescript-5-buildError.test.ts @@ -0,0 +1,40 @@ +import { buildFixture } from '../utils'; +import { SpawnSyncReturns } from 'child_process'; + +jest.setTimeout(5 * 60 * 1000); + +describe('Test build process with ignoreBuildErrors setting', () => { + const fixture = 'typescript-type-error-ts5'; + + test(`build fail without ignoreBuildErrors`, async () => { + let error = false; + let res: SpawnSyncReturns; + try { + res = await buildFixture(fixture, { + typescript: { ignoreBuildErrors: false } + }); + if (res.error || res.status !== 0) { + error = true; + } + } catch (err) { + error = true; + } + expect(error).toBe(true); + }); + + test(`build successful with ignoreBuildErrors`, async () => { + let error = false; + let res: SpawnSyncReturns; + try { + res = await buildFixture(fixture, { + typescript: { ignoreBuildErrors: true } + }); + if (res.error || res.status !== 0) { + error = true; + } + } catch (err) { + error = true; + } + expect(error).toBe(false); + }); +}); diff --git a/test/fixtures/typescript-type-error-ts5/package.json b/test/fixtures/typescript-type-error-ts5/package.json new file mode 100644 index 000000000..ae00dec20 --- /dev/null +++ b/test/fixtures/typescript-type-error-ts5/package.json @@ -0,0 +1,12 @@ +{ + "name": "fixture-typescript-error", + "dependencies": { + "shuvi": "workspace:*" + }, + "devDependencies": { + "@types/node": "18.0.6", + "@types/react": "18.0.9", + "@types/react-dom": "18.0.6", + "typescript": "^5.0.0" + } +} diff --git a/test/fixtures/typescript-type-error-ts5/shuvi.config.ts b/test/fixtures/typescript-type-error-ts5/shuvi.config.ts new file mode 100644 index 000000000..2dd69c07f --- /dev/null +++ b/test/fixtures/typescript-type-error-ts5/shuvi.config.ts @@ -0,0 +1,5 @@ +import { defineConfig } from 'shuvi'; +export default defineConfig({ + ssr: true, + typescript: { ignoreBuildErrors: true } +}); diff --git a/test/fixtures/typescript-type-error-ts5/src/routes/page.tsx b/test/fixtures/typescript-type-error-ts5/src/routes/page.tsx new file mode 100644 index 000000000..63068cd7f --- /dev/null +++ b/test/fixtures/typescript-type-error-ts5/src/routes/page.tsx @@ -0,0 +1,12 @@ +import React from 'react'; + +const Index = () => { + const testString: number = 'hello world!'; + return ( +
+

{testString}

+
+ ); +}; + +export default Index; diff --git a/test/fixtures/typescript-type-error-ts5/tsconfig.json b/test/fixtures/typescript-type-error-ts5/tsconfig.json new file mode 100644 index 000000000..7117de208 --- /dev/null +++ b/test/fixtures/typescript-type-error-ts5/tsconfig.json @@ -0,0 +1,39 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "strict": false, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "strictNullChecks": true, + "esModuleInterop": true, + "noImplicitThis": true, + "module": "esnext", + "moduleResolution": "node16", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "baseUrl": "./", + "paths": { + "@shuvi/runtime": [ + ".shuvi/app/runtime" + ], + "@shuvi/runtime/*": [ + ".shuvi/app/runtime/*" + ] + } + }, + "include": [ + ".shuvi/app/shuvi-app.d.ts", + "src" + ], + "exclude": [ + "node_modules" + ] +}