From e160564008ce6cbedf0c974fb166c6c63522aae9 Mon Sep 17 00:00:00 2001 From: Brent Erickson Date: Wed, 30 Dec 2020 22:18:37 -0800 Subject: [PATCH 1/8] Add a cache to file path mapping (#1228) * Add a cache to file path mapping This greatly reduces the time needed to resolve FilePathKey objects on watch builds. * Address PR comments * Bump package.json and CHANGELOG.md Co-authored-by: John Reilly --- CHANGELOG.md | 2 ++ package.json | 2 +- src/instances.ts | 30 +++++++++++++++++++++--------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69a8a2993..092417ab3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # Changelog +## v8.0.13 +* [Speed up builds by adding an in-memory cache to file path lookups](https://github.com/TypeStrong/ts-loader/pull/1228) - thanks @berickson1 ## v8.0.12 * [Instead of checking date, check time thats more accurate to see if something has changed](https://github.com/TypeStrong/ts-loader/pull/1217) - thanks @sheetalkamat diff --git a/package.json b/package.json index 48ff15977..88d44fbd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "8.0.12", + "version": "8.0.13", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", diff --git a/src/instances.ts b/src/instances.ts index d8c29dc60..ce2800382 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -87,23 +87,35 @@ function createFilePathKeyMapper( compiler: typeof typescript, loaderOptions: LoaderOptions ) { + // Cache file path key - a map lookup is much faster than filesystem/regex operations & the result will never change + const filePathMapperCache = new Map(); // FileName lowercasing copied from typescript const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g; return useCaseSensitiveFileNames(compiler, loaderOptions) ? pathResolve : toFileNameLowerCase; - function pathResolve(x: string) { - return path.resolve(x) as FilePathKey; + function pathResolve(filePath: string) { + let cachedPath = filePathMapperCache.get(filePath); + if (!cachedPath) { + cachedPath = path.resolve(filePath) as FilePathKey; + filePathMapperCache.set(filePath, cachedPath); + } + return cachedPath; } - function toFileNameLowerCase(x: string) { - const filePathKey = pathResolve(x); - return fileNameLowerCaseRegExp.test(filePathKey) - ? (filePathKey.replace(fileNameLowerCaseRegExp, ch => - ch.toLowerCase() - ) as FilePathKey) - : filePathKey; + function toFileNameLowerCase(filePath: string) { + let cachedPath = filePathMapperCache.get(filePath); + if (!cachedPath) { + const filePathKey = pathResolve(filePath); + cachedPath = fileNameLowerCaseRegExp.test(filePathKey) + ? (filePathKey.replace(fileNameLowerCaseRegExp, ch => + ch.toLowerCase() + ) as FilePathKey) + : filePathKey; + filePathMapperCache.set(filePath, cachedPath); + } + return cachedPath; } } From 268bc6932cc636df29b5b65c23d9033bea7c83a8 Mon Sep 17 00:00:00 2001 From: Avi Vahl Date: Tue, 5 Jan 2021 19:36:35 +0200 Subject: [PATCH 2/8] chore(deps): upgrade most production deps (#1237) * chore(deps): upgrade most production deps adjusted chalk import/initialization to new major * refactor: use namespace import * chore: bump patch version; update changelog * docs: add contributor name --- CHANGELOG.md | 3 +++ package.json | 10 ++++----- src/instances.ts | 8 ++++--- yarn.lock | 55 +++++++++++++++++++++++++++++++++++------------- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 092417ab3..48adf5178 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## v8.0.14 +* [Upgrade `chalk`, `loader-utils`, and `semver` to latest stable versions](https://github.com/TypeStrong/ts-loader/pull/1237) - thanks Avi Vahl + ## v8.0.13 * [Speed up builds by adding an in-memory cache to file path lookups](https://github.com/TypeStrong/ts-loader/pull/1228) - thanks @berickson1 diff --git a/package.json b/package.json index 88d44fbd5..ad688d5c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "8.0.13", + "version": "8.0.14", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", @@ -54,16 +54,16 @@ }, "homepage": "https://github.com/TypeStrong/ts-loader", "dependencies": { - "chalk": "^2.3.0", + "chalk": "^4.1.0", "enhanced-resolve": "^4.0.0", - "loader-utils": "^1.0.2", + "loader-utils": "^2.0.0", "micromatch": "^4.0.0", - "semver": "^6.0.0" + "semver": "^7.3.4" }, "devDependencies": { "@types/micromatch": "^3.1.0", "@types/node": "*", - "@types/semver": "^6.0.0", + "@types/semver": "^7.3.4", "@types/webpack": "^4.4.30", "@typescript-eslint/eslint-plugin": "^4.0.0", "@typescript-eslint/parser": "^4.0.0", diff --git a/src/instances.ts b/src/instances.ts index ce2800382..a670e4262 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -1,4 +1,4 @@ -import chalk, { Chalk } from 'chalk'; +import * as chalk from 'chalk'; import * as fs from 'fs'; import * as path from 'path'; import * as typescript from 'typescript'; @@ -58,7 +58,9 @@ export function getTypeScriptInstance( return { instance: existing }; } - const colors = new chalk.constructor({ enabled: loaderOptions.colors }); + const level = + loaderOptions.colors && chalk.supportsColor ? chalk.supportsColor.level : 0; + const colors = new chalk.Instance({ level }); const log = logger.makeLogger(loaderOptions, colors); const compiler = getCompiler(loaderOptions, log); @@ -123,7 +125,7 @@ function successfulTypeScriptInstance( loaderOptions: LoaderOptions, loader: webpack.loader.LoaderContext, log: logger.Logger, - colors: Chalk, + colors: chalk.Chalk, compiler: typeof typescript, compilerCompatible: boolean, compilerDetailsLogMessage: string diff --git a/yarn.lock b/yarn.lock index 0edea0a02..ea6e337a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -111,10 +111,10 @@ resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA== -"@types/semver@^6.0.0": - version "6.0.0" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.0.0.tgz#86ba89f02a414e39c68d02b351872e4ed31bd773" - integrity sha512-OO0srjOGH99a4LUN2its3+r6CBYcplhJ466yLqs+zvAWgphCpS8hYZEZ797tRDP/QKcqTdb/YCN6ifASoAWkrQ== +"@types/semver@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.4.tgz#43d7168fec6fa0988bb1a513a697b29296721afb" + integrity sha512-+nVsLKlcUCeMzD2ufHEYuJ9a2ovstb6Dp52A5VsoKxDXgvE051XgHI/33I1EymwkRGQkwnA0LkhnUzituGs4EQ== "@types/source-list-map@*": version "0.1.2" @@ -1616,7 +1616,7 @@ chalk@^1.0.0, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.3.0: +chalk@^2.0.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -1634,7 +1634,7 @@ chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.1, chalk@^2.4.1: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0: +chalk@^4.0.0, chalk@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== @@ -3819,6 +3819,13 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" +json5@^2.1.2: + version "2.1.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43" + integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA== + dependencies: + minimist "^1.2.5" + jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" @@ -4064,6 +4071,15 @@ loader-utils@^1.1.0, loader-utils@^1.2.3: emojis-list "^3.0.0" json5 "^1.0.1" +loader-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" + integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== + dependencies: + big.js "^5.2.2" + emojis-list "^3.0.0" + json5 "^2.1.2" + locate-path@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -4176,6 +4192,13 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -5554,20 +5577,17 @@ semver@^5.7.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b" integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA== -semver@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.0.0.tgz#05e359ee571e5ad7ed641a6eec1e547ba52dea65" - integrity sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ== - semver@^6.1.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.2.1, semver@^7.3.2: - version "7.3.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" - integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== +semver@^7.2.1, semver@^7.3.2, semver@^7.3.4: + version "7.3.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97" + integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw== + dependencies: + lru-cache "^6.0.0" serialize-javascript@^3.1.0: version "3.1.0" @@ -6636,6 +6656,11 @@ yallist@^3.0.2: resolved "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + yargs-parser@13.0.0, yargs-parser@^13.0.0: version "13.0.0" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.0.0.tgz#3fc44f3e76a8bdb1cc3602e860108602e5ccde8b" From 6816735404350ece29b9bce40b2addb396dcba8b Mon Sep 17 00:00:00 2001 From: Nick Excell Date: Wed, 3 Feb 2021 15:12:57 +0000 Subject: [PATCH 3/8] Add afterDeclarations to getCustomTransformers in README.md (#1248) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65d4f2051..7b313efcb 100644 --- a/README.md +++ b/README.md @@ -344,7 +344,7 @@ These options should be functions which will be used to resolve the import state #### getCustomTransformers | Type | |------| -| ` (program: Program) => { before?: TransformerFactory[]; after?: TransformerFactory[]; } ` | +| ` (program: Program) => { before?: TransformerFactory[]; after?: TransformerFactory[]; afterDeclarations?: TransformerFactory[]; } ` | Provide custom transformers - only compatible with TypeScript 2.3+ (and 2.4 if using `transpileOnly` mode). For example usage take a look at [typescript-plugin-styled-components](https://github.com/Igorbek/typescript-plugin-styled-components) or our [test](test/comparison-tests/customTransformer). From b8a70f91aa4a450603342e62b8c03bdd09c7a979 Mon Sep 17 00:00:00 2001 From: Nick Excell Date: Thu, 4 Feb 2021 19:47:54 +0000 Subject: [PATCH 4/8] Update definition files in watch mode in webpack@5 (#1249) * Add afterDeclarations to getCustomTransformers in README.md * Emit d.ts file in subsequent runs in watch mode * Update package.json and changelog.md --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/instances.ts | 38 +++++++++++++++++++++++++------------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48adf5178..af8bb0446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog + +## v8.0.15 +* [Update definition files in watch mode in webpack@5](https://github.com/TypeStrong/ts-loader/pull/1249) - thanks @appzuka,@JonWallsten,@alexander-akait +* [Add afterDeclarations to getCustomTransformers in README.md](https://github.com/TypeStrong/ts-loader/pull/1248) - thanks @appzuka + ## v8.0.14 * [Upgrade `chalk`, `loader-utils`, and `semver` to latest stable versions](https://github.com/TypeStrong/ts-loader/pull/1237) - thanks Avi Vahl diff --git a/package.json b/package.json index ad688d5c6..90b5ff1f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "8.0.14", + "version": "8.0.15", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", diff --git a/src/instances.ts b/src/instances.ts index a670e4262..ad5ddf0a9 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -336,21 +336,33 @@ const addAssetHooks = !!webpack.version!.match(/^4.*/) makeAfterCompile(instance, false, true, instance.configFilePath) ); - // Emit the assets at the afterProcessAssets stage - loader._compilation.hooks.afterProcessAssets.tap( - 'ts-loader', - (_: any) => { - makeAfterCompile( - instance, - true, - false, - instance.configFilePath - )(loader._compilation, () => { - return null; - }); - } + // makeAfterCompile is a closure. It returns a function which closes over the variable checkAllFilesForErrors + // We need to get the function once and then reuse it, otherwise it will be recreated each time + // and all files will always be checked. + const cachedMakeAfterCompile = makeAfterCompile( + instance, + true, + false, + instance.configFilePath ); + // compilation is actually of type webpack.compilation.Compilation, but afterProcessAssets + // only exists in webpack5 and at the time of writing ts-loader is built using webpack4 + const makeAssetsCallback = (compilation: any) => { + compilation.hooks.afterProcessAssets.tap('ts-loader', () => + cachedMakeAfterCompile(compilation, () => { + return null; + }) + ); + }; + + // We need to add the hook above for each run. + // For the first run, we just need to add the hook to loader._compilation + makeAssetsCallback(loader._compilation); + + // For future calls in watch mode we need to watch for a new compilation and add the hook + loader._compiler.hooks.compilation.tap('ts-loader', makeAssetsCallback); + // It may be better to add assets at the processAssets stage (https://webpack.js.org/api/compilation-hooks/#processassets) // This requires Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL, which does not exist in webpack4 // Consider changing this when ts-loader is built using webpack5 From 91206c404b9b365c1b17df6fca094ab9f36a09ac Mon Sep 17 00:00:00 2001 From: Nick Excell Date: Mon, 8 Feb 2021 16:20:06 +0000 Subject: [PATCH 5/8] Re-fix Webpack 5 watch not failing on error (#1254) * Add afterDeclarations to getCustomTransformers in README.md * Emit d.ts file in subsequent runs in watch mode * Update package.json and changelog.md * Re-fixed missing errors in watch mode * Correct merge error --- CHANGELOG.md | 3 +++ package.json | 2 +- src/after-compile.ts | 54 ++++++++++++++++++-------------------------- src/instances.ts | 11 +-------- 4 files changed, 27 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af8bb0446..fe811fa87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v8.0.16 +* [Re-Fixed missing errors in watch mode in webpack5](https://github.com/TypeStrong/ts-loader/issues/1204) - thanks @appzuka + ## v8.0.15 * [Update definition files in watch mode in webpack@5](https://github.com/TypeStrong/ts-loader/pull/1249) - thanks @appzuka,@JonWallsten,@alexander-akait * [Add afterDeclarations to getCustomTransformers in README.md](https://github.com/TypeStrong/ts-loader/pull/1248) - thanks @appzuka diff --git a/package.json b/package.json index 90b5ff1f3..2b31163b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "8.0.15", + "version": "8.0.16", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", diff --git a/src/after-compile.ts b/src/after-compile.ts index 7cc284a08..03fa8543a 100644 --- a/src/after-compile.ts +++ b/src/after-compile.ts @@ -29,8 +29,6 @@ import { */ export function makeAfterCompile( instance: TSInstance, - addAssets: boolean, - provideErrors: boolean, configFilePath: string | undefined ) { let getCompilerOptionDiagnostics = true; @@ -47,22 +45,18 @@ export function makeAfterCompile( } if (instance.loaderOptions.transpileOnly) { - if (addAssets) { - provideAssetsFromSolutionBuilderHost(instance, compilation); - } + provideAssetsFromSolutionBuilderHost(instance, compilation); callback(); return; } removeCompilationTSLoaderErrors(compilation, instance.loaderOptions); - if (provideErrors) { - provideCompilerOptionDiagnosticErrorsToWebpack( - getCompilerOptionDiagnostics, - compilation, - instance, - configFilePath - ); - } + provideCompilerOptionDiagnosticErrorsToWebpack( + getCompilerOptionDiagnostics, + compilation, + instance, + configFilePath + ); getCompilerOptionDiagnostics = false; const modules = determineModules(compilation, instance); @@ -74,25 +68,21 @@ export function makeAfterCompile( checkAllFilesForErrors = false; const filesWithErrors: TSFiles = new Map(); - if (provideErrors) { - provideErrorsToWebpack( - filesToCheckForErrors, - filesWithErrors, - compilation, - modules, - instance - ); - provideSolutionErrorsToWebpack(compilation, modules, instance); - } - if (addAssets) { - provideDeclarationFilesToWebpack( - filesToCheckForErrors, - instance, - compilation - ); - provideTsBuildInfoFilesToWebpack(instance, compilation); - provideAssetsFromSolutionBuilderHost(instance, compilation); - } + provideErrorsToWebpack( + filesToCheckForErrors, + filesWithErrors, + compilation, + modules, + instance + ); + provideSolutionErrorsToWebpack(compilation, modules, instance); + provideDeclarationFilesToWebpack( + filesToCheckForErrors, + instance, + compilation + ); + provideTsBuildInfoFilesToWebpack(instance, compilation); + provideAssetsFromSolutionBuilderHost(instance, compilation); instance.filesWithErrors = filesWithErrors; instance.modifiedFiles = undefined; diff --git a/src/instances.ts b/src/instances.ts index ad5ddf0a9..3d7c299c5 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -323,26 +323,17 @@ const addAssetHooks = !!webpack.version!.match(/^4.*/) // add makeAfterCompile with addAssets = true to emit assets and report errors loader._compiler.hooks.afterCompile.tapAsync( 'ts-loader', - makeAfterCompile(instance, true, true, instance.configFilePath) + makeAfterCompile(instance, instance.configFilePath) ); } : (loader: webpack.loader.LoaderContext, instance: TSInstance) => { // We must be running under webpack 5+ - // Add makeAfterCompile with addAssets = false to suppress emitting assets - // during the afterCompile stage. Errors will be still be reported to webpack - loader._compiler.hooks.afterCompile.tapAsync( - 'ts-loader', - makeAfterCompile(instance, false, true, instance.configFilePath) - ); - // makeAfterCompile is a closure. It returns a function which closes over the variable checkAllFilesForErrors // We need to get the function once and then reuse it, otherwise it will be recreated each time // and all files will always be checked. const cachedMakeAfterCompile = makeAfterCompile( instance, - true, - false, instance.configFilePath ); From e9c2677a07f36a7449ca2e09fa8a684940f46566 Mon Sep 17 00:00:00 2001 From: Lorenzo Dalla Vecchia Date: Wed, 10 Feb 2021 17:34:44 +0100 Subject: [PATCH 6/8] Include standard webpack start/end locations in emitted errors (#1255) --- CHANGELOG.md | 3 + package.json | 2 +- src/interfaces.ts | 15 ++++- src/utils.ts | 64 +++++++++++++++---- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../colors/expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-transpile-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 4 +- .../expectedOutput-4.1/output.txt | 4 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../errors/expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-transpile-4.1/output.txt | 2 +- .../es3/expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/patch1/output.txt | 2 +- .../nolib/expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../production/expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/patch3/output.txt | 2 +- .../expectedOutput-4.1/patch5/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/patch4/output.txt | 2 +- .../expectedOutput-4.1/patch4/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../expectedOutput-4.1/patch2/output.txt | 4 +- .../expectedOutput-4.1/patch4/output.txt | 2 +- .../expectedOutput-4.1/patch2/output.txt | 4 +- .../expectedOutput-4.1/patch4/output.txt | 2 +- .../expectedOutput-4.1/patch2/output.txt | 4 +- .../expectedOutput-4.1/patch4/output.txt | 2 +- .../reportFiles/expectedOutput-4.1/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- .../expectedOutput-4.1/patch0/output.txt | 2 +- 49 files changed, 121 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe811fa87..96b67abfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v8.0.17 +* [Included correct webpack source location in emitted errors](https://github.com/TypeStrong/ts-loader/issues/1199) - thanks @lorenzodallavecchia + ## v8.0.16 * [Re-Fixed missing errors in watch mode in webpack5](https://github.com/TypeStrong/ts-loader/issues/1204) - thanks @appzuka diff --git a/package.json b/package.json index 2b31163b2..c13d40f41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "8.0.16", + "version": "8.0.17", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", diff --git a/src/interfaces.ts b/src/interfaces.ts index 53c48423f..fb7643e44 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -13,12 +13,25 @@ export interface ErrorInfo { context: string; } -export type FileLocation = { line: number; character: number }; +export type FileLocation = { + /** 1-based */ + line: number; + /** 1-based */ + character: number; +}; +export type WebpackSourcePosition = { + /** 1-based */ + line: number; + /** 0-based */ + column?: number; +}; export interface WebpackError { module?: any; file?: string; message: string; + loc?: { start: WebpackSourcePosition; end?: WebpackSourcePosition }; + /* ts-loader extra properties */ location?: FileLocation; loaderSource: string; } diff --git a/src/utils.ts b/src/utils.ts index c1da3e0a2..4974619c0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,6 +7,7 @@ import * as typescript from 'typescript'; import constants = require('./constants'); import { ErrorInfo, + FileLocation, FilePathKey, LoaderOptions, ResolvedModule, @@ -15,6 +16,7 @@ import { TSInstance, WebpackError, WebpackModule, + WebpackSourcePosition, } from './interfaces'; import { getInputFileNameFromOutput } from './instances'; /** @@ -75,10 +77,10 @@ export function formatErrors( }) .map(diagnostic => { const file = diagnostic.file; - const position = - file === undefined - ? undefined - : file.getLineAndCharacterOfPosition(diagnostic.start!); + const { start, end } = + file === undefined || diagnostic.start === undefined + ? { start: undefined, end: undefined } + : getFileLocations(file, diagnostic.start, diagnostic.length); const errorInfo: ErrorInfo = { code: diagnostic.code, severity: compiler.DiagnosticCategory[ @@ -89,8 +91,8 @@ export function formatErrors( constants.EOL ), file: file === undefined ? '' : path.normalize(file.fileName), - line: position === undefined ? 0 : position.line + 1, - character: position === undefined ? 0 : position.character + 1, + line: start === undefined ? 0 : start.line, + character: start === undefined ? 0 : start.character, context, }; @@ -103,15 +105,35 @@ export function formatErrors( loaderOptions, message, merge.file === undefined ? errorInfo.file : merge.file, - position === undefined - ? undefined - : { line: errorInfo.line, character: errorInfo.character } + start, + end ); return Object.assign(error, merge) as WebpackError; }); } +function getFileLocations( + file: typescript.SourceFile, + position: number, + length = 0 +) { + const startLC = file.getLineAndCharacterOfPosition(position); + const start: FileLocation = { + line: startLC.line + 1, + character: startLC.character + 1, + }; + const endLC = + length > 0 + ? file.getLineAndCharacterOfPosition(position + length) + : undefined; + const end: FileLocation | undefined = + endLC === undefined + ? undefined + : { line: endLC.line + 1, character: endLC.character + 1 }; + return { start, end }; +} + export function fsReadFile( fileName: string, encoding: string | undefined = 'utf8' @@ -128,16 +150,36 @@ export function makeError( loaderOptions: LoaderOptions, message: string, file: string | undefined, - location?: { line: number; character: number } + location?: FileLocation, + endLocation?: FileLocation ): WebpackError { return { message, - location, file, + loc: + location === undefined + ? undefined + : makeWebpackLocation(location, endLocation), + location, loaderSource: tsLoaderSource(loaderOptions), }; } +function makeWebpackLocation( + location: FileLocation, + endLocation?: FileLocation +) { + const start: WebpackSourcePosition = { + line: location.line, + column: location.character - 1, + }; + const end: WebpackSourcePosition | undefined = + endLocation === undefined + ? undefined + : { line: endLocation.line, column: endLocation.character - 1 }; + return { start, end }; +} + export function tsLoaderSource(loaderOptions: LoaderOptions) { return `ts-loader-${loaderOptions.instance}`; } diff --git a/test/comparison-tests/aliasResolution/expectedOutput-4.1/output.txt b/test/comparison-tests/aliasResolution/expectedOutput-4.1/output.txt index c0da8c1a3..718fff194 100644 --- a/test/comparison-tests/aliasResolution/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/aliasResolution/expectedOutput-4.1/output.txt @@ -5,6 +5,6 @@ Entrypoint main = bundle.js [./common/components/myComponent.ts] 46 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 2:30-55 [tsl] ERROR in app.ts(2,31)  TS2307: Cannot find module 'components/myComponent2' or its corresponding type declarations. \ No newline at end of file diff --git a/test/comparison-tests/aliasResolution/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/aliasResolution/expectedOutput-4.1/patch0/output.txt index bf0ca3fd3..7c081f883 100644 --- a/test/comparison-tests/aliasResolution/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/aliasResolution/expectedOutput-4.1/patch0/output.txt @@ -5,6 +5,6 @@ Entrypoint main = bundle.js [./common/components/myComponent.ts] 45 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 2:30-55 [tsl] ERROR in app.ts(2,31)  TS2307: Cannot find module 'components/myComponent2' or its corresponding type declarations. \ No newline at end of file diff --git a/test/comparison-tests/allowJs-ts-check/expectedOutput-4.1/output.txt b/test/comparison-tests/allowJs-ts-check/expectedOutput-4.1/output.txt index c978f9feb..c65bff5ac 100644 --- a/test/comparison-tests/allowJs-ts-check/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/allowJs-ts-check/expectedOutput-4.1/output.txt @@ -6,6 +6,6 @@ Entrypoint main = bundle.js [./src/index.js] 207 bytes {main} [built] ERROR in src/error2.js -./src/error2.js +./src/error2.js 4:9-12 [tsl] ERROR in src/error2.js(4,10)  TS2339: Property 'bar' does not exist on type 'Class2'. \ No newline at end of file diff --git a/test/comparison-tests/basic/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/basic/expectedOutput-4.1/patch0/output.txt index 9fac8da0d..a8db6db09 100644 --- a/test/comparison-tests/basic/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/basic/expectedOutput-4.1/patch0/output.txt @@ -6,6 +6,6 @@ Entrypoint main = bundle.js [./submodule/submodule.ts] 149 bytes {main} ERROR in app.ts -./app.ts +./app.ts 3:12-24 [tsl] ERROR in app.ts(3,13)  TS2551: Property 'doSomething2' does not exist on type 'typeof externalLib'. Did you mean 'doSomething'? \ No newline at end of file diff --git a/test/comparison-tests/colors/expectedOutput-4.1/output.txt b/test/comparison-tests/colors/expectedOutput-4.1/output.txt index 117027d85..613a362fe 100644 --- a/test/comparison-tests/colors/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/colors/expectedOutput-4.1/output.txt @@ -13,6 +13,6 @@ You may need an additional loader to handle the result of these loaders. | ERROR in app.ts -./app.ts +./app.ts 1:6-8 [tsl] ERROR in app.ts(1,7) TS1005: ',' expected. \ No newline at end of file diff --git a/test/comparison-tests/colors/expectedOutput-transpile-4.1/output.txt b/test/comparison-tests/colors/expectedOutput-transpile-4.1/output.txt index 117027d85..613a362fe 100644 --- a/test/comparison-tests/colors/expectedOutput-transpile-4.1/output.txt +++ b/test/comparison-tests/colors/expectedOutput-transpile-4.1/output.txt @@ -13,6 +13,6 @@ You may need an additional loader to handle the result of these loaders. | ERROR in app.ts -./app.ts +./app.ts 1:6-8 [tsl] ERROR in app.ts(1,7) TS1005: ',' expected. \ No newline at end of file diff --git a/test/comparison-tests/declarationDeps/expectedOutput-4.1/output.txt b/test/comparison-tests/declarationDeps/expectedOutput-4.1/output.txt index 31af3d0b6..b8e99c377 100644 --- a/test/comparison-tests/declarationDeps/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/declarationDeps/expectedOutput-4.1/output.txt @@ -4,6 +4,6 @@ Entrypoint main = bundle.js [./app.ts] 41 bytes {main} [built] [1 error] ERROR in app.ts -./app.ts +./app.ts 2:6-11 [tsl] ERROR in app.ts(2,7)  TS2339: Property 'sayHi' does not exist on type 'typeof Hello'. \ No newline at end of file diff --git a/test/comparison-tests/declarationWatch/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/declarationWatch/expectedOutput-4.1/patch0/output.txt index f818ddc7c..b6e14df72 100644 --- a/test/comparison-tests/declarationWatch/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/declarationWatch/expectedOutput-4.1/patch0/output.txt @@ -5,11 +5,11 @@ Entrypoint main = bundle.js [./dep.ts] 59 bytes {main} [built] [1 error] ERROR in app.ts -./app.ts +./app.ts 5:6-17 [tsl] ERROR in app.ts(5,7)  TS2339: Property 'doSomething' does not exist on type 'typeof Thing'. ERROR in dep.ts -./dep.ts +./dep.ts 1:6-17 [tsl] ERROR in dep.ts(1,7)  TS2339: Property 'doSomething' does not exist on type 'typeof Thing'. \ No newline at end of file diff --git a/test/comparison-tests/dependencyErrors/expectedOutput-4.1/output.txt b/test/comparison-tests/dependencyErrors/expectedOutput-4.1/output.txt index 9bf366413..ca6be6cde 100644 --- a/test/comparison-tests/dependencyErrors/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/dependencyErrors/expectedOutput-4.1/output.txt @@ -6,11 +6,11 @@ Entrypoint main = bundle.js [./dep2.ts] 76 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 4:5-7 [tsl] ERROR in app.ts(4,6)  TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. ERROR in app.ts -./app.ts +./app.ts 5:5-7 [tsl] ERROR in app.ts(5,6)  TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/test/comparison-tests/dependencyErrors/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/dependencyErrors/expectedOutput-4.1/patch0/output.txt index f4ea07b34..82b969098 100644 --- a/test/comparison-tests/dependencyErrors/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/dependencyErrors/expectedOutput-4.1/patch0/output.txt @@ -6,6 +6,6 @@ Entrypoint main = bundle.js [./dep2.ts] 76 bytes {main} ERROR in app.ts -./app.ts +./app.ts 5:5-7 [tsl] ERROR in app.ts(5,6)  TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/test/comparison-tests/errorFormatter/expectedOutput-4.1/output.txt b/test/comparison-tests/errorFormatter/expectedOutput-4.1/output.txt index ce9b05006..d023ac4c6 100644 --- a/test/comparison-tests/errorFormatter/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/errorFormatter/expectedOutput-4.1/output.txt @@ -5,5 +5,5 @@ Entrypoint main = bundle.js [./common/components/myComponent.ts] 46 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 2:30-55 Does not compute.... code: 2307,severity: error,content: Cannot find module 'components/myComponent2' or its corresponding type declarations.,file: app.ts,line: 2,character: 31,context: .test/errorFormatter \ No newline at end of file diff --git a/test/comparison-tests/errors/expectedOutput-4.1/output.txt b/test/comparison-tests/errors/expectedOutput-4.1/output.txt index c48ec99d2..07aed0162 100644 --- a/test/comparison-tests/errors/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/errors/expectedOutput-4.1/output.txt @@ -13,6 +13,6 @@ You may need an additional loader to handle the result of these loaders. | ERROR in app.ts -./app.ts +./app.ts 1:6-8 [tsl] ERROR in app.ts(1,7)  TS1005: ',' expected. \ No newline at end of file diff --git a/test/comparison-tests/errors/expectedOutput-transpile-4.1/output.txt b/test/comparison-tests/errors/expectedOutput-transpile-4.1/output.txt index ffab7fca9..96bc80dea 100644 --- a/test/comparison-tests/errors/expectedOutput-transpile-4.1/output.txt +++ b/test/comparison-tests/errors/expectedOutput-transpile-4.1/output.txt @@ -4,7 +4,7 @@ Entrypoint main = bundle.js [./app.ts] 220 bytes {main} [built] [failed] [2 errors] ERROR in app.ts -./app.ts +./app.ts 1:6-8 [tsl] ERROR in app.ts(1,7)  TS1005: ',' expected. diff --git a/test/comparison-tests/es3/expectedOutput-4.1/output.txt b/test/comparison-tests/es3/expectedOutput-4.1/output.txt index 12a3418dd..fe96190e5 100644 --- a/test/comparison-tests/es3/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/es3/expectedOutput-4.1/output.txt @@ -4,6 +4,6 @@ Entrypoint main = bundle.js [./app.ts] 29 bytes {main} [built] [1 error] ERROR in app.ts -./app.ts +./app.ts 1:6-7 [tsl] ERROR in app.ts(1,7)  TS1056: Accessors are only available when targeting ECMAScript 5 and higher. \ No newline at end of file diff --git a/test/comparison-tests/ignoreDiagnostics/expectedOutput-4.1/output.txt b/test/comparison-tests/ignoreDiagnostics/expectedOutput-4.1/output.txt index bcc531083..b42812bf2 100644 --- a/test/comparison-tests/ignoreDiagnostics/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/ignoreDiagnostics/expectedOutput-4.1/output.txt @@ -4,6 +4,6 @@ Entrypoint main = bundle.js [./app.ts] 278 bytes {main} [built] [1 error] ERROR in app.ts -./app.ts +./app.ts 9:4-5 [tsl] ERROR in app.ts(9,5)  TS2322: Type 'string' is not assignable to type 'Number'. \ No newline at end of file diff --git a/test/comparison-tests/importsWatch/expectedOutput-4.1/patch1/output.txt b/test/comparison-tests/importsWatch/expectedOutput-4.1/patch1/output.txt index 5773b734b..3e3ae7492 100644 --- a/test/comparison-tests/importsWatch/expectedOutput-4.1/patch1/output.txt +++ b/test/comparison-tests/importsWatch/expectedOutput-4.1/patch1/output.txt @@ -4,6 +4,6 @@ Entrypoint main = bundle.js [./app.ts] 70 bytes {main} [built] [1 error] ERROR in app.ts -./app.ts +./app.ts 4:0-7 [tsl] ERROR in app.ts(4,1)  TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/test/comparison-tests/nolib/expectedOutput-4.1/output.txt b/test/comparison-tests/nolib/expectedOutput-4.1/output.txt index 8c8e530d0..3dd528d24 100644 --- a/test/comparison-tests/nolib/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/nolib/expectedOutput-4.1/output.txt @@ -32,6 +32,6 @@ ERROR in tsconfig.json  TS2318: Cannot find global type 'RegExp'. ERROR in app.ts -./app.ts +./app.ts 1:0-8 [tsl] ERROR in app.ts(1,1)  TS2304: Cannot find name 'parseInt'. \ No newline at end of file diff --git a/test/comparison-tests/onlyCompileBundledFiles/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/onlyCompileBundledFiles/expectedOutput-4.1/patch0/output.txt index 9fac8da0d..a8db6db09 100644 --- a/test/comparison-tests/onlyCompileBundledFiles/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/onlyCompileBundledFiles/expectedOutput-4.1/patch0/output.txt @@ -6,6 +6,6 @@ Entrypoint main = bundle.js [./submodule/submodule.ts] 149 bytes {main} ERROR in app.ts -./app.ts +./app.ts 3:12-24 [tsl] ERROR in app.ts(3,13)  TS2551: Property 'doSomething2' does not exist on type 'typeof externalLib'. Did you mean 'doSomething'? \ No newline at end of file diff --git a/test/comparison-tests/production/expectedOutput-4.1/output.txt b/test/comparison-tests/production/expectedOutput-4.1/output.txt index 63923ad42..22ce36262 100644 --- a/test/comparison-tests/production/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/production/expectedOutput-4.1/output.txt @@ -4,6 +4,6 @@ Entrypoint main = bundle.js [0] ./app.ts 27 bytes {0} [built] [1 error] ERROR in app.ts -./app.ts +./app.ts 4:0-1 [tsl] ERROR in app.ts(4,1)  TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesMultipleDifferentInstance/expectedOutput-4.1/patch3/output.txt b/test/comparison-tests/projectReferencesMultipleDifferentInstance/expectedOutput-4.1/patch3/output.txt index cbffd9cda..476620833 100644 --- a/test/comparison-tests/projectReferencesMultipleDifferentInstance/expectedOutput-4.1/patch3/output.txt +++ b/test/comparison-tests/projectReferencesMultipleDifferentInstance/expectedOutput-4.1/patch3/output.txt @@ -8,6 +8,6 @@ Entrypoint main = bundle.js [./app.ts] 202 bytes {main} [built] ERROR in common/index.ts -../common/index.ts +../common/index.ts 2:2-12 [tsl] ERROR in common/index.ts(2,3)  TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesMultipleDifferentInstance/expectedOutput-4.1/patch5/output.txt b/test/comparison-tests/projectReferencesMultipleDifferentInstance/expectedOutput-4.1/patch5/output.txt index 47669f95b..e43aa5737 100644 --- a/test/comparison-tests/projectReferencesMultipleDifferentInstance/expectedOutput-4.1/patch5/output.txt +++ b/test/comparison-tests/projectReferencesMultipleDifferentInstance/expectedOutput-4.1/patch5/output.txt @@ -8,6 +8,6 @@ Entrypoint main = bundle.js [./app.ts] 202 bytes {main} [built] ERROR in utils/index.ts -../utils/index.ts +../utils/index.ts 5:35-50 [tsl] ERROR in utils/index.ts(5,36)  TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject/expectedOutput-4.1/output.txt index 67bf67e8a..a599e9eaa 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject/expectedOutput-4.1/output.txt @@ -9,6 +9,6 @@ Entrypoint main = bundle.js [./lib/index.ts] 119 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 3:45-49 [tsl] ERROR in app.ts(3,46)  TS2339: Property 'four' does not exist on type '{ one: number; two: number; three: number; }'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject_Composite_WatchApi/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject_Composite_WatchApi/expectedOutput-4.1/output.txt index 7d6aa5942..45a0fb029 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject_Composite_WatchApi/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject_Composite_WatchApi/expectedOutput-4.1/output.txt @@ -11,6 +11,6 @@ Entrypoint main = bundle.js [./lib/index.ts] 119 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 3:45-49 [tsl] ERROR in app.ts(3,46)  TS2339: Property 'four' does not exist on type '{ one: number; two: number; three: number; }'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject_WatchApi/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject_WatchApi/expectedOutput-4.1/output.txt index 67bf67e8a..a599e9eaa 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject_WatchApi/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_ErrorInProject_WatchApi/expectedOutput-4.1/output.txt @@ -9,6 +9,6 @@ Entrypoint main = bundle.js [./lib/index.ts] 119 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 3:45-49 [tsl] ERROR in app.ts(3,46)  TS2339: Property 'four' does not exist on type '{ one: number; two: number; three: number; }'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference/expectedOutput-4.1/output.txt index c74544a53..a3e0228f2 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference/expectedOutput-4.1/output.txt @@ -14,6 +14,6 @@ Error: TypeScript emitted no output for lib/index.ts. The most common cause for @ ./app.ts 3:12-28 ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 6:6-7 [tsl] ERROR in lib/index.ts(6,7)  TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference_Composite_WatchApi/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference_Composite_WatchApi/expectedOutput-4.1/output.txt index 5eb8fe6c7..d38f63610 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference_Composite_WatchApi/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference_Composite_WatchApi/expectedOutput-4.1/output.txt @@ -16,6 +16,6 @@ Error: TypeScript emitted no output for lib/index.ts. The most common cause for @ ./app.ts 3:12-28 ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 6:6-7 [tsl] ERROR in lib/index.ts(6,7)  TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference_WatchApi/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference_WatchApi/expectedOutput-4.1/output.txt index 1d22977b8..3537c6c2d 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference_WatchApi/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_SemanticErrorInReference_WatchApi/expectedOutput-4.1/output.txt @@ -14,6 +14,6 @@ Error: TypeScript emitted no output for lib/index.ts. The most common cause for @ ./app.ts 3:12-28 ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 6:6-7 [tsl] ERROR in lib/index.ts(6,7)  TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference/expectedOutput-4.1/output.txt index f190e2fea..c0a20cfc7 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference/expectedOutput-4.1/output.txt @@ -13,6 +13,6 @@ Error: TypeScript emitted no output for lib/index.ts. The most common cause for @ ./app.ts 3:12-28 ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 4:11-12 [tsl] ERROR in lib/index.ts(4,12)  TS1136: Property assignment expected. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference_Composite_WatchApi/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference_Composite_WatchApi/expectedOutput-4.1/output.txt index 98fa4b8a7..d457d4f0d 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference_Composite_WatchApi/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference_Composite_WatchApi/expectedOutput-4.1/output.txt @@ -15,6 +15,6 @@ Error: TypeScript emitted no output for lib/index.ts. The most common cause for @ ./app.ts 3:12-28 ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 4:11-12 [tsl] ERROR in lib/index.ts(4,12)  TS1136: Property assignment expected. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference_WatchApi/expectedOutput-4.1/output.txt b/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference_WatchApi/expectedOutput-4.1/output.txt index aaf4f848a..56edf71ed 100644 --- a/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference_WatchApi/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/projectReferencesNotBuilt_SyntaxErrorInReference_WatchApi/expectedOutput-4.1/output.txt @@ -13,6 +13,6 @@ Error: TypeScript emitted no output for lib/index.ts. The most common cause for @ ./app.ts 3:12-28 ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 4:11-12 [tsl] ERROR in lib/index.ts(4,12)  TS1136: Property assignment expected. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJson/expectedOutput-4.1/patch4/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJson/expectedOutput-4.1/patch4/output.txt index 2d914655a..6797170be 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJson/expectedOutput-4.1/patch4/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJson/expectedOutput-4.1/patch4/output.txt @@ -5,6 +5,6 @@ Entrypoint main = bundle.js [./lib/out/index.js] 178 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 3:55-60 [tsl] ERROR in app.ts(3,56)  TS2551: Property 'ffive' does not exist on type '{ one: number; two: number; three: number; four: number; five: number; }'. Did you mean 'five'? \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-4.1/patch4/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-4.1/patch4/output.txt index 2d914655a..6797170be 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-4.1/patch4/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-4.1/patch4/output.txt @@ -5,6 +5,6 @@ Entrypoint main = bundle.js [./lib/out/index.js] 178 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 3:55-60 [tsl] ERROR in app.ts(3,56)  TS2551: Property 'ffive' does not exist on type '{ one: number; two: number; three: number; four: number; five: number; }'. Did you mean 'five'? \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesSymLinks/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/projectReferencesSymLinks/expectedOutput-4.1/patch0/output.txt index aa1e397cc..86ba1eac3 100644 --- a/test/comparison-tests/projectReferencesSymLinks/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/projectReferencesSymLinks/expectedOutput-4.1/patch0/output.txt @@ -9,6 +9,6 @@ Entrypoint main = index.js [./src/index.ts] 108 bytes {main} [built] [1 error] ERROR in app/src/index.ts -./src/index.ts +./src/index.ts 1:9-25 [tsl] ERROR in app/src/index.ts(1,10)  TS2724: '"../../lib/dist"' has no exported member named 'getMeaningOfLife'. Did you mean 'getMeaningOfLife3'? \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesSymLinksPreserve/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/projectReferencesSymLinksPreserve/expectedOutput-4.1/patch0/output.txt index ce861ab73..c538b1de1 100644 --- a/test/comparison-tests/projectReferencesSymLinksPreserve/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/projectReferencesSymLinksPreserve/expectedOutput-4.1/patch0/output.txt @@ -9,6 +9,6 @@ Entrypoint main = index.js [./src/index.ts] 108 bytes {main} [built] [1 error] ERROR in app/src/index.ts -./src/index.ts +./src/index.ts 1:9-25 [tsl] ERROR in app/src/index.ts(1,10)  TS2724: '"../../node_modules/lib/dist"' has no exported member named 'getMeaningOfLife'. Did you mean 'getMeaningOfLife3'? \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesSymLinksPreserve_WatchApi/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/projectReferencesSymLinksPreserve_WatchApi/expectedOutput-4.1/patch0/output.txt index ce861ab73..c538b1de1 100644 --- a/test/comparison-tests/projectReferencesSymLinksPreserve_WatchApi/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/projectReferencesSymLinksPreserve_WatchApi/expectedOutput-4.1/patch0/output.txt @@ -9,6 +9,6 @@ Entrypoint main = index.js [./src/index.ts] 108 bytes {main} [built] [1 error] ERROR in app/src/index.ts -./src/index.ts +./src/index.ts 1:9-25 [tsl] ERROR in app/src/index.ts(1,10)  TS2724: '"../../node_modules/lib/dist"' has no exported member named 'getMeaningOfLife'. Did you mean 'getMeaningOfLife3'? \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesSymLinks_WatchApi/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/projectReferencesSymLinks_WatchApi/expectedOutput-4.1/patch0/output.txt index aa1e397cc..86ba1eac3 100644 --- a/test/comparison-tests/projectReferencesSymLinks_WatchApi/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/projectReferencesSymLinks_WatchApi/expectedOutput-4.1/patch0/output.txt @@ -9,6 +9,6 @@ Entrypoint main = index.js [./src/index.ts] 108 bytes {main} [built] [1 error] ERROR in app/src/index.ts -./src/index.ts +./src/index.ts 1:9-25 [tsl] ERROR in app/src/index.ts(1,10)  TS2724: '"../../lib/dist"' has no exported member named 'getMeaningOfLife'. Did you mean 'getMeaningOfLife3'? \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesWatch/expectedOutput-4.1/patch2/output.txt b/test/comparison-tests/projectReferencesWatch/expectedOutput-4.1/patch2/output.txt index cdf7bfbc0..469ab45a1 100644 --- a/test/comparison-tests/projectReferencesWatch/expectedOutput-4.1/patch2/output.txt +++ b/test/comparison-tests/projectReferencesWatch/expectedOutput-4.1/patch2/output.txt @@ -5,11 +5,11 @@ Entrypoint main = bundle.js [./lib/index.ts] 150 bytes {main} [built] [2 errors] ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 6:2-3 [tsl] ERROR in lib/index.ts(6,3)  TS1136: Property assignment expected. ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 7:0-1 [tsl] ERROR in lib/index.ts(7,1)  TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesWatch/expectedOutput-4.1/patch4/output.txt b/test/comparison-tests/projectReferencesWatch/expectedOutput-4.1/patch4/output.txt index e5095f9ca..47da79ac4 100644 --- a/test/comparison-tests/projectReferencesWatch/expectedOutput-4.1/patch4/output.txt +++ b/test/comparison-tests/projectReferencesWatch/expectedOutput-4.1/patch4/output.txt @@ -5,6 +5,6 @@ Entrypoint main = bundle.js [./lib/index.ts] 145 bytes {main} ERROR in app.ts -./app.ts +./app.ts 3:55-60 [tsl] ERROR in app.ts(3,56)  TS2551: Property 'ffive' does not exist on type '{ one: number; two: number; three: number; four: number; five: number; }'. Did you mean 'five'? \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesWatch_Composite_WatchApi/expectedOutput-4.1/patch2/output.txt b/test/comparison-tests/projectReferencesWatch_Composite_WatchApi/expectedOutput-4.1/patch2/output.txt index 6eff0cd61..ba040527a 100644 --- a/test/comparison-tests/projectReferencesWatch_Composite_WatchApi/expectedOutput-4.1/patch2/output.txt +++ b/test/comparison-tests/projectReferencesWatch_Composite_WatchApi/expectedOutput-4.1/patch2/output.txt @@ -6,11 +6,11 @@ Entrypoint main = bundle.js [./lib/index.ts] 150 bytes {main} [built] [2 errors] ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 6:2-3 [tsl] ERROR in lib/index.ts(6,3)  TS1136: Property assignment expected. ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 7:0-1 [tsl] ERROR in lib/index.ts(7,1)  TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesWatch_Composite_WatchApi/expectedOutput-4.1/patch4/output.txt b/test/comparison-tests/projectReferencesWatch_Composite_WatchApi/expectedOutput-4.1/patch4/output.txt index 5367b0c7d..785c12da5 100644 --- a/test/comparison-tests/projectReferencesWatch_Composite_WatchApi/expectedOutput-4.1/patch4/output.txt +++ b/test/comparison-tests/projectReferencesWatch_Composite_WatchApi/expectedOutput-4.1/patch4/output.txt @@ -7,6 +7,6 @@ Entrypoint main = bundle.js [./lib/index.ts] 145 bytes {main} ERROR in app.ts -./app.ts +./app.ts 3:55-60 [tsl] ERROR in app.ts(3,56)  TS2551: Property 'ffive' does not exist on type '{ one: number; two: number; three: number; four: number; five: number; }'. Did you mean 'five'? \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesWatch_WatchApi/expectedOutput-4.1/patch2/output.txt b/test/comparison-tests/projectReferencesWatch_WatchApi/expectedOutput-4.1/patch2/output.txt index cdf7bfbc0..469ab45a1 100644 --- a/test/comparison-tests/projectReferencesWatch_WatchApi/expectedOutput-4.1/patch2/output.txt +++ b/test/comparison-tests/projectReferencesWatch_WatchApi/expectedOutput-4.1/patch2/output.txt @@ -5,11 +5,11 @@ Entrypoint main = bundle.js [./lib/index.ts] 150 bytes {main} [built] [2 errors] ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 6:2-3 [tsl] ERROR in lib/index.ts(6,3)  TS1136: Property assignment expected. ERROR in lib/index.ts -./lib/index.ts +./lib/index.ts 7:0-1 [tsl] ERROR in lib/index.ts(7,1)  TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesWatch_WatchApi/expectedOutput-4.1/patch4/output.txt b/test/comparison-tests/projectReferencesWatch_WatchApi/expectedOutput-4.1/patch4/output.txt index e5095f9ca..47da79ac4 100644 --- a/test/comparison-tests/projectReferencesWatch_WatchApi/expectedOutput-4.1/patch4/output.txt +++ b/test/comparison-tests/projectReferencesWatch_WatchApi/expectedOutput-4.1/patch4/output.txt @@ -5,6 +5,6 @@ Entrypoint main = bundle.js [./lib/index.ts] 145 bytes {main} ERROR in app.ts -./app.ts +./app.ts 3:55-60 [tsl] ERROR in app.ts(3,56)  TS2551: Property 'ffive' does not exist on type '{ one: number; two: number; three: number; four: number; five: number; }'. Did you mean 'five'? \ No newline at end of file diff --git a/test/comparison-tests/reportFiles/expectedOutput-4.1/output.txt b/test/comparison-tests/reportFiles/expectedOutput-4.1/output.txt index 5211bb195..3214b5189 100644 --- a/test/comparison-tests/reportFiles/expectedOutput-4.1/output.txt +++ b/test/comparison-tests/reportFiles/expectedOutput-4.1/output.txt @@ -5,6 +5,6 @@ Entrypoint main = bundle.js [./skip.ts] 79 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 3:0-1 [tsl] ERROR in app.ts(3,1)  TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/test/comparison-tests/simpleDependency/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-4.1/patch0/output.txt index 0f981418b..584de80f1 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-4.1/patch0/output.txt @@ -6,6 +6,6 @@ Entrypoint main = bundle.js [./dep.ts] 70 bytes {main} [built] ERROR in app.ts -./app.ts +./app.ts 3:4-6 [tsl] ERROR in app.ts(3,5)  TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/test/comparison-tests/typeSystemWatch/expectedOutput-4.1/patch0/output.txt b/test/comparison-tests/typeSystemWatch/expectedOutput-4.1/patch0/output.txt index 3de8aa6e6..f2675eeee 100644 --- a/test/comparison-tests/typeSystemWatch/expectedOutput-4.1/patch0/output.txt +++ b/test/comparison-tests/typeSystemWatch/expectedOutput-4.1/patch0/output.txt @@ -4,6 +4,6 @@ Entrypoint main = bundle.js [./app.ts] 212 bytes {main} [built] [1 error] ERROR in app.ts -./app.ts +./app.ts 11:4-5 [tsl] ERROR in app.ts(11,5)  TS2741: Property 'b' is missing in type 'AType' but required in type 'BType'. \ No newline at end of file From 591bd109cd1a7e02cd3bf9e2988edf9a6217deae Mon Sep 17 00:00:00 2001 From: Eric Dai <31838316+e56@users.noreply.github.com> Date: Wed, 10 Feb 2021 13:54:52 -0500 Subject: [PATCH 7/8] update docs for latest webpack 5 syntax (#1244) Co-authored-by: John Reilly --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 7b313efcb..cf83d6caf 100644 --- a/README.md +++ b/README.md @@ -729,12 +729,22 @@ In order to make use of this option your project needs to be correctly configure Because TS will generate .js and .d.ts files, you should ignore these files, otherwise watchers may go into an infinite watch loop. For example, when using webpack, you may wish to add this to your webpack.conf.js file: ```javascript +// for webpack 4 plugins: [ new webpack.WatchIgnorePlugin([ /\.js$/, /\.d\.ts$/ ]) ], + +// for webpack 5 +plugins: [ + new webpack.WatchIgnorePlugin( + paths:{[ + /\.js$/, + /\.d\.ts$/ + ]}) +], ``` It's worth noting that use of the `LoaderOptionsPlugin` is [only supposed to be a stopgap measure](https://webpack.js.org/plugins/loader-options-plugin/). You may want to look at removing it entirely. From 953358eb1b090dd9add0824c4746220b0ebe56c1 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 18 Feb 2021 21:30:09 +0000 Subject: [PATCH 8/8] Stop testing TypeScript 3.6 and 3.7 --- .github/workflows/push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 3dceefbac..519904eb7 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -6,7 +6,7 @@ jobs: comparison_test: name: Ubuntu Comparison Tests runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 25 steps: - uses: actions/checkout@v2 @@ -57,7 +57,7 @@ jobs: matrix: os: [ubuntu, windows] node: [10, 12, 14] - ts: [3.6.5, 3.7.5, 3.8.3, 3.9.3, 4.0.3, 4.1.2, next] + ts: [3.8.3, 3.9.3, 4.0.3, 4.1.2, next] runs-on: ${{ matrix.os }}-latest steps: - uses: actions/checkout@v2