From d9fcbfd577486f4c6ce6b44c3f5870ef7058a569 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 20 Sep 2022 20:05:50 +0200 Subject: [PATCH] Hotfix: Disable `enhanced-resolve` (#1506) * Disable `enhanced-resolve` * Regenerate tests * Add changelog entries * Bump the version number --- CHANGELOG.md | 3 +++ package.json | 2 +- src/resolver.ts | 10 +++++++--- .../aliasResolution/expectedOutput-4.8/output.txt | 10 ++++++++-- .../expectedOutput-4.8/patch0/output.txt | 10 ++++++++-- .../errorFormatter/expectedOutput-4.8/output.txt | 9 +++++++-- .../expectedOutput-4.8/output.txt | 11 +++++++++-- 7 files changed, 43 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dd777cf4..91d42fcb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 9.4.1 +* [Hotfix: Disable `enhanced-resolve`](https://github.com/TypeStrong/ts-loader/pull/1505) - thanks @manuth + ## v9.4.0 * [Add Support for Resolving `.cjs`, `.mjs`, `.cts` and `.mts` Files](https://github.com/TypeStrong/ts-loader/pull/1503) [#1503] - thanks @manuth diff --git a/package.json b/package.json index 60b942f5f..40487d987 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "9.4.0", + "version": "9.4.1", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", diff --git a/src/resolver.ts b/src/resolver.ts index 9509f00f6..3f3df630d 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -1,11 +1,15 @@ import type * as webpack from 'webpack'; -import { create } from 'enhanced-resolve'; +import { create as _create } from 'enhanced-resolve'; export function makeResolver( - options: webpack.WebpackOptionsNormalized + _options: webpack.WebpackOptionsNormalized ): ResolveSync { - return create.sync(options.resolve); + /* Currently, `enhanced-resolve` does not work properly alongside `ts-loader`. + * This feature is disabled until a proper worflow has been worked out. */ + return (_context, _path, _moduleName?): string | false => { + throw new Error(); + }; } export type ResolveSync = { diff --git a/test/comparison-tests/aliasResolution/expectedOutput-4.8/output.txt b/test/comparison-tests/aliasResolution/expectedOutput-4.8/output.txt index 61d336885..1258b61ed 100644 --- a/test/comparison-tests/aliasResolution/expectedOutput-4.8/output.txt +++ b/test/comparison-tests/aliasResolution/expectedOutput-4.8/output.txt @@ -1,11 +1,17 @@ asset bundle.js 2.6 KiB [emitted] (name: main) -./app.ts 120 bytes [built] [code generated] [1 error] +./app.ts 120 bytes [built] [code generated] [2 errors] ./common/components/myComponent.ts 46 bytes [built] [code generated] +ERROR in app.ts +./app.ts 1:29-53 +[tsl] ERROR in app.ts(1,30) + TS2307: Cannot find module 'components/myComponent' or its corresponding type declarations. +ts-loader-default_609318b4f68865d3 + ERROR in 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. ts-loader-default_609318b4f68865d3 -webpack compiled with 1 error \ No newline at end of file +webpack compiled with 2 errors \ No newline at end of file diff --git a/test/comparison-tests/aliasResolution/expectedOutput-4.8/patch0/output.txt b/test/comparison-tests/aliasResolution/expectedOutput-4.8/patch0/output.txt index 9ce404768..b9e20a7e7 100644 --- a/test/comparison-tests/aliasResolution/expectedOutput-4.8/patch0/output.txt +++ b/test/comparison-tests/aliasResolution/expectedOutput-4.8/patch0/output.txt @@ -1,11 +1,17 @@ asset bundle.js 2.6 KiB [emitted] (name: main) -./app.ts 120 bytes [built] [code generated] [1 error] +cached modules 120 bytes [cached] 1 module ./common/components/myComponent.ts 45 bytes [built] [code generated] +ERROR in app.ts +./app.ts 1:29-53 +[tsl] ERROR in app.ts(1,30) + TS2307: Cannot find module 'components/myComponent' or its corresponding type declarations. +ts-loader-default_609318b4f68865d3 + ERROR in 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. ts-loader-default_609318b4f68865d3 -webpack compiled with 1 error \ No newline at end of file +webpack compiled with 2 errors \ No newline at end of file diff --git a/test/comparison-tests/errorFormatter/expectedOutput-4.8/output.txt b/test/comparison-tests/errorFormatter/expectedOutput-4.8/output.txt index 28ee4f9d5..57bf27ad4 100644 --- a/test/comparison-tests/errorFormatter/expectedOutput-4.8/output.txt +++ b/test/comparison-tests/errorFormatter/expectedOutput-4.8/output.txt @@ -1,10 +1,15 @@ asset bundle.js 2.6 KiB [emitted] (name: main) -./app.ts 120 bytes [built] [code generated] [1 error] +./app.ts 120 bytes [built] [code generated] [2 errors] ./common/components/myComponent.ts 46 bytes [built] [code generated] +ERROR in app.ts +./app.ts 1:29-53 +Does not compute.... code: 2307,severity: error,content: Cannot find module 'components/myComponent' or its corresponding type declarations.,file: app.ts,line: 1,character: 30,context: .test/errorFormatter +ts-loader-default_85b0565984bbe8dd + ERROR in 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 ts-loader-default_85b0565984bbe8dd -webpack compiled with 1 error \ No newline at end of file +webpack compiled with 2 errors \ No newline at end of file diff --git a/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-4.8/output.txt b/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-4.8/output.txt index 99c0b622c..547ef058e 100644 --- a/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-4.8/output.txt +++ b/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-4.8/output.txt @@ -1,4 +1,11 @@ asset bundle.js 2.59 KiB [emitted] (name: main) -./app.ts 101 bytes [built] [code generated] +./app.ts 101 bytes [built] [code generated] [1 error] ./fake.ts 165 bytes [built] [code generated] -webpack compiled successfully \ No newline at end of file + +ERROR in app.ts +./app.ts 1:29-34 +[tsl] ERROR in app.ts(1,30) + TS2307: Cannot find module 'api' or its corresponding type declarations. +ts-loader-default_609318b4f68865d3 + +webpack compiled with 1 error \ No newline at end of file