From a48903d2c7fc143ff8c88b9e97baffe8c2f65247 Mon Sep 17 00:00:00 2001 From: Kevin Marrec Date: Fri, 19 Jun 2020 10:23:08 +0200 Subject: [PATCH 1/4] feat: upgrade ts-fork-checker to v5 --- packages/typescript-build/package.json | 2 +- packages/typescript-build/src/index.ts | 17 ++++--- .../test/fixture/@types/vue.d.ts | 4 ++ .../test/fixture/pages/index.vue | 2 +- .../test/fixture/tsconfig.json | 12 ++--- yarn.lock | 45 ++++++++++--------- 6 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 packages/typescript-build/test/fixture/@types/vue.d.ts diff --git a/packages/typescript-build/package.json b/packages/typescript-build/package.json index 3e24fd12..6fb9621a 100644 --- a/packages/typescript-build/package.json +++ b/packages/typescript-build/package.json @@ -17,7 +17,7 @@ "dependencies": { "@nuxt/types": "0.7.9", "consola": "^2.13.0", - "fork-ts-checker-webpack-plugin": "^4.1.6", + "fork-ts-checker-webpack-plugin": "^5.0.1", "ts-loader": "^7.0.5", "typescript": "~3.8" }, diff --git a/packages/typescript-build/src/index.ts b/packages/typescript-build/src/index.ts index 9965f9ed..6e73d2fa 100644 --- a/packages/typescript-build/src/index.ts +++ b/packages/typescript-build/src/index.ts @@ -2,7 +2,7 @@ import path from 'path' import consola from 'consola' import { Module } from '@nuxt/types' import { Options as TsLoaderOptions } from 'ts-loader' -import { Options as TsCheckerOptions } from 'fork-ts-checker-webpack-plugin' +import { ForkTsCheckerWebpackPluginOptions as TsCheckerOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions' import { RuleSetUseItem } from 'webpack' declare module '@nuxt/types' { @@ -17,7 +17,7 @@ export interface Options { ts?: Partial tsx?: Partial } - typeCheck?: Partial | boolean + typeCheck?: TsCheckerOptions | boolean } const defaults: Options = { @@ -50,7 +50,7 @@ const tsModule: Module = function (moduleOptions) { } this.extendBuild((config, { isClient, isModern }) => { - config.resolve!.extensions!.push('.ts', '.tsx') + config.resolve!.extensions!.push('.ts', '.tsx', '.vue') const jsxRuleLoaders = config.module!.rules.find(r => (r.test as RegExp).test('.jsx'))!.use as RuleSetUseItem[] const babelLoader = jsxRuleLoaders[jsxRuleLoaders.length - 1] @@ -75,11 +75,14 @@ const tsModule: Module = function (moduleOptions) { if (options.typeCheck && isClient && !isModern) { const ForkTsCheckerWebpackPlugin = require(this.nuxt.resolver.resolveModule('fork-ts-checker-webpack-plugin')) config.plugins!.push(new ForkTsCheckerWebpackPlugin(Object.assign({ - vue: true, - tsconfig: path.resolve(this.options.rootDir!, 'tsconfig.json'), - formatter: 'codeframe', + typescript: { + configFile: path.resolve(this.options.rootDir!, 'tsconfig.json'), + extensions: { + vue: true + } + }, logger: consola.withScope('nuxt:typescript') - }, options.typeCheck))) + } as TsCheckerOptions, options.typeCheck))) } }) } diff --git a/packages/typescript-build/test/fixture/@types/vue.d.ts b/packages/typescript-build/test/fixture/@types/vue.d.ts new file mode 100644 index 00000000..d9f24faa --- /dev/null +++ b/packages/typescript-build/test/fixture/@types/vue.d.ts @@ -0,0 +1,4 @@ +declare module '*.vue' { + import Vue from 'vue' + export default Vue +} diff --git a/packages/typescript-build/test/fixture/pages/index.vue b/packages/typescript-build/test/fixture/pages/index.vue index c13764e9..254c1f81 100644 --- a/packages/typescript-build/test/fixture/pages/index.vue +++ b/packages/typescript-build/test/fixture/pages/index.vue @@ -7,7 +7,7 @@ import Vue from 'vue' export default Vue.extend({ data () { - const text: string = 'Index Page' + const text: string = 2 return { text } } }) diff --git a/packages/typescript-build/test/fixture/tsconfig.json b/packages/typescript-build/test/fixture/tsconfig.json index caa0cba5..d6c7723d 100644 --- a/packages/typescript-build/test/fixture/tsconfig.json +++ b/packages/typescript-build/test/fixture/tsconfig.json @@ -1,12 +1,12 @@ { "compilerOptions": { - "target": "es2018", - "module": "esnext", - "moduleResolution": "node", + "target": "ES2018", + "module": "ESNext", + "moduleResolution": "Node", "lib": [ - "esnext", - "esnext.asynciterable", - "dom" + "ESNext", + "ESNext.AsyncIterable", + "DOM" ], "esModuleInterop": true, "allowJs": true, diff --git a/yarn.lock b/yarn.lock index b4ebe95e..f063102b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5", "@babel/code-frame@^7.8.3": +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e" integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g== @@ -6241,18 +6241,21 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= -fork-ts-checker-webpack-plugin@^4.1.6: - version "4.1.6" - resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-4.1.6.tgz#5055c703febcf37fa06405d400c122b905167fc5" - integrity sha512-DUxuQaKoqfNne8iikd14SAkh5uw4+8vNifp6gmA73yYNS6ywLIWSLD/n/mBzHQRpW3J7rbATEakmiA8JvkTyZw== +fork-ts-checker-webpack-plugin@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-5.0.1.tgz#21adab94c30340c50dc5a3d36c25d180a8bb29e5" + integrity sha512-bys+hPwlPckrSCzNkg0BSUTsCRZWS6qIRiwk+8AjKitLWTqokda0QVImCx/Vm9cL/OGZZUnrFXazsVc99nijKQ== dependencies: - "@babel/code-frame" "^7.5.5" + "@babel/code-frame" "^7.8.3" chalk "^2.4.1" - micromatch "^3.1.10" + cosmiconfig "^6.0.0" + deepmerge "^4.2.2" + fs-extra "^9.0.0" + memfs "^3.1.2" minimatch "^3.0.4" + schema-utils "1.0.0" semver "^5.6.0" tapable "^1.0.0" - worker-rpc "^0.1.0" form-data@~2.3.2: version "2.3.3" @@ -6321,6 +6324,11 @@ fs-minipass@^2.0.0: dependencies: minipass "^3.0.0" +fs-monkey@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.1.tgz#4a82f36944365e619f4454d9fff106553067b781" + integrity sha512-fcSa+wyTqZa46iWweI7/ZiUfegOZl0SG8+dltIwFXo7+zYU9J9kpS3NB6pZcSlJdhvIwp81Adx2XhZorncxiaA== + fs-write-stream-atomic@^1.0.8: version "1.0.10" resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9" @@ -8563,6 +8571,13 @@ mem@^6.0.1: map-age-cleaner "^0.1.3" mimic-fn "^3.0.0" +memfs@^3.1.2: + version "3.2.0" + resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.2.0.tgz#f9438e622b5acd1daa8a4ae160c496fdd1325b26" + integrity sha512-f/xxz2TpdKv6uDn6GtHee8ivFyxwxmPuXatBb1FBwxYNuVpbM3k/Y1Z+vC0mH/dIXXrukYfe3qe5J32Dfjg93A== + dependencies: + fs-monkey "1.0.1" + memory-fs@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" @@ -8671,11 +8686,6 @@ methods@~1.1.2: resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= -microevent.ts@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/microevent.ts/-/microevent.ts-0.1.1.tgz#70b09b83f43df5172d0205a63025bce0f7357fa0" - integrity sha512-jo1OfR4TaEwd5HOrt5+tAZ9mqT4jmpNAusXtyfNzqVm9uiSYFZlKM1wYL4oU7azZW/PxQW53wM0S6OR1JHNa2g== - micromatch@4.x, micromatch@^4.0.0, micromatch@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259" @@ -11385,7 +11395,7 @@ saxes@^5.0.0: dependencies: xmlchars "^2.2.0" -schema-utils@^1.0.0: +schema-utils@1.0.0, schema-utils@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-1.0.0.tgz#0b79a93204d7b600d4b2850d1f66c2a34951c770" integrity sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g== @@ -13287,13 +13297,6 @@ worker-farm@^1.7.0: dependencies: errno "~0.1.7" -worker-rpc@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/worker-rpc/-/worker-rpc-0.1.1.tgz#cb565bd6d7071a8f16660686051e969ad32f54d5" - integrity sha512-P1WjMrUB3qgJNI9jfmpZ/htmBEjFh//6l/5y8SD9hg1Ef5zTTVVoRjTrTEzPrNBQvmhMxkoTsjOXN10GWU7aCg== - dependencies: - microevent.ts "~0.1.1" - wrap-ansi@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" From d2c5e126996d0706ab63d519b44b171e38d52e1c Mon Sep 17 00:00:00 2001 From: Kevin Marrec Date: Fri, 19 Jun 2020 10:29:04 +0200 Subject: [PATCH 2/4] chore: .vue extension already registered by nuxt --- packages/typescript-build/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typescript-build/src/index.ts b/packages/typescript-build/src/index.ts index 6e73d2fa..0c298957 100644 --- a/packages/typescript-build/src/index.ts +++ b/packages/typescript-build/src/index.ts @@ -50,7 +50,7 @@ const tsModule: Module = function (moduleOptions) { } this.extendBuild((config, { isClient, isModern }) => { - config.resolve!.extensions!.push('.ts', '.tsx', '.vue') + config.resolve!.extensions!.push('.ts', '.tsx') const jsxRuleLoaders = config.module!.rules.find(r => (r.test as RegExp).test('.jsx'))!.use as RuleSetUseItem[] const babelLoader = jsxRuleLoaders[jsxRuleLoaders.length - 1] From 9b9ec1434571a8d460b6c0e39b0886c96a06178c Mon Sep 17 00:00:00 2001 From: Kevin Marrec Date: Thu, 2 Jul 2020 10:11:03 +0200 Subject: [PATCH 3/4] chore: upgrade package --- packages/typescript-build/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/typescript-build/package.json b/packages/typescript-build/package.json index a0425eb8..bce5a260 100644 --- a/packages/typescript-build/package.json +++ b/packages/typescript-build/package.json @@ -17,7 +17,7 @@ "dependencies": { "@nuxt/types": "0.7.9", "consola": "^2.13.0", - "fork-ts-checker-webpack-plugin": "^5.0.1", + "fork-ts-checker-webpack-plugin": "^5.0.6", "ts-loader": "^7.0.5", "typescript": "~3.9" }, diff --git a/yarn.lock b/yarn.lock index aaacf1b3..2680ac0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6241,10 +6241,10 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= -fork-ts-checker-webpack-plugin@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-5.0.1.tgz#21adab94c30340c50dc5a3d36c25d180a8bb29e5" - integrity sha512-bys+hPwlPckrSCzNkg0BSUTsCRZWS6qIRiwk+8AjKitLWTqokda0QVImCx/Vm9cL/OGZZUnrFXazsVc99nijKQ== +fork-ts-checker-webpack-plugin@^5.0.6: + version "5.0.6" + resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-5.0.6.tgz#02af713af02e47b338a3992279209bc65d34c773" + integrity sha512-8h4S7WANr69Resw+tMd5U23xdbVPsT+VOeMKQhUaKhkGeMm0fNf7ObJPP81WG+tsmy4LK4ayIf0JXBY+hy6vMw== dependencies: "@babel/code-frame" "^7.8.3" chalk "^2.4.1" From 6e60495e85642ecf3cf64a3608c8d41c8489f4bd Mon Sep 17 00:00:00 2001 From: Kevin Marrec Date: Thu, 2 Jul 2020 10:16:21 +0200 Subject: [PATCH 4/4] chore: fix back fixture --- packages/typescript-build/test/fixture/pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typescript-build/test/fixture/pages/index.vue b/packages/typescript-build/test/fixture/pages/index.vue index 254c1f81..c13764e9 100644 --- a/packages/typescript-build/test/fixture/pages/index.vue +++ b/packages/typescript-build/test/fixture/pages/index.vue @@ -7,7 +7,7 @@ import Vue from 'vue' export default Vue.extend({ data () { - const text: string = 2 + const text: string = 'Index Page' return { text } } })