Skip to content

Commit a8597e3

Browse files
authored
Fixed generating cache for loading options to handle objects (#1317)
* fix: Fixed generating cache for loading options to handle objects Fixes #1316 * fix: Updated ts-loader instance hash in tests * Added changelog and changed version in package.json
1 parent 94480fb commit a8597e3

File tree

80 files changed

+398
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+398
-84
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v9.2.0
4+
5+
* [Fixed impossibility to have several instances of ts-loader with different compiler options](https://github.com/TypeStrong/ts-loader/issues/1316) - thanks @timocov
6+
37
## v9.1.2
48

59
* [Fix removed files handling in watch mode](https://github.com/TypeStrong/ts-loader/pull/1293) - thanks @gasnier

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-loader",
3-
"version": "9.1.2",
3+
"version": "9.2.0",
44
"description": "TypeScript loader for webpack",
55
"main": "index.js",
66
"types": "dist",

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ function getOptionsHash(loaderOptions: LoaderOptions) {
161161
const hash = crypto.createHash('sha256');
162162
Object.keys(loaderOptions).forEach(key => {
163163
const value = loaderOptions[key];
164-
if (value) {
165-
hash.update(key + value.toString());
164+
if (value !== undefined) {
165+
const valueString =
166+
typeof value === 'function' ? value.toString() : JSON.stringify(value);
167+
hash.update(key + valueString);
166168
}
167169
});
168170
return hash.digest('hex').substring(0, 16);

test/comparison-tests/aliasResolution/expectedOutput-4.2/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ ERROR in app.ts
66
./app.ts 1:29-53
77
[tsl] ERROR in app.ts(1,30)
88
 TS2307: Cannot find module 'components/myComponent' or its corresponding type declarations.
9-
ts-loader-default_b02295d909a3e7cf
9+
ts-loader-default_609318b4f68865d3
1010

1111
ERROR in app.ts
1212
./app.ts 2:30-55
1313
[tsl] ERROR in app.ts(2,31)
1414
 TS2307: Cannot find module 'components/myComponent2' or its corresponding type declarations.
15-
ts-loader-default_b02295d909a3e7cf
15+
ts-loader-default_609318b4f68865d3
1616

1717
webpack compiled with 2 errors

test/comparison-tests/aliasResolution/expectedOutput-4.2/patch0/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ ERROR in app.ts
66
./app.ts 1:29-53
77
[tsl] ERROR in app.ts(1,30)
88
 TS2307: Cannot find module 'components/myComponent' or its corresponding type declarations.
9-
ts-loader-default_b02295d909a3e7cf
9+
ts-loader-default_609318b4f68865d3
1010

1111
ERROR in app.ts
1212
./app.ts 2:30-55
1313
[tsl] ERROR in app.ts(2,31)
1414
 TS2307: Cannot find module 'components/myComponent2' or its corresponding type declarations.
15-
ts-loader-default_b02295d909a3e7cf
15+
ts-loader-default_609318b4f68865d3
1616

1717
webpack compiled with 2 errors

test/comparison-tests/allowJs-ts-check/expectedOutput-4.2/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ERROR in src/error2.js
77
./src/error2.js 4:9-12
88
[tsl] ERROR in src/error2.js(4,10)
99
 TS2339: Property 'bar' does not exist on type 'Class2'.
10-
ts-loader-default_b02295d909a3e7cf
10+
ts-loader-default_609318b4f68865d3
1111
@ ./src/index.js 4:15-34
1212

1313
webpack compiled with 1 error

test/comparison-tests/basic/expectedOutput-4.2/patch0/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ ERROR in app.ts
66
./app.ts 3:12-24
77
[tsl] ERROR in app.ts(3,13)
88
 TS2551: Property 'doSomething2' does not exist on type 'typeof externalLib'. Did you mean 'doSomething'?
9-
ts-loader-default_b02295d909a3e7cf
9+
ts-loader-default_609318b4f68865d3
1010

1111
webpack compiled with 1 error

test/comparison-tests/colors/expectedOutput-4.2/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ ERROR in app.ts
1414
./app.ts 1:6-8
1515
[tsl] ERROR in app.ts(1,7)
1616
TS1005: ',' expected.
17-
ts-loader-default_b02295d909a3e7cf
17+
ts-loader-default_dda4fd88600de236
1818

1919
webpack compiled with 2 errors

test/comparison-tests/colors/expectedOutput-transpile-4.2/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ERROR in app.ts
55
./app.ts 1:6-8
66
[tsl] ERROR in app.ts(1,7)
77
TS1005: ',' expected.
8-
ts-loader-default_66eeaf8be3a46130
8+
ts-loader-default_94b2ce3d1ca5f363
99

1010
ERROR in ./app.ts 2:1
1111
Module parse failed: Unexpected token (2:1)

test/comparison-tests/declarationDeps/expectedOutput-4.2/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ ERROR in app.ts
55
./app.ts 2:6-11
66
[tsl] ERROR in app.ts(2,7)
77
 TS2339: Property 'sayHi' does not exist on type 'typeof Hello'.
8-
ts-loader-default_b02295d909a3e7cf
8+
ts-loader-default_609318b4f68865d3
99

1010
webpack compiled with 1 error

0 commit comments

Comments
 (0)