Skip to content

Commit 12f4ffe

Browse files
Bug fix: support webpack 5 in ts-loader (#1439)
* Bug fix: support webpack 5 in ts-loader Error when running ts-loader with webpack 5 : "times is not iterable" * fix: guard compiler.fileTimestamps * Update package.json * Update CHANGELOG.md Co-authored-by: John Reilly <[email protected]>
1 parent 65bb27c commit 12f4ffe

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

3+
## v9.2.8
4+
5+
* [Bug fix: support webpack 5 in ts-loader](https://github.com/TypeStrong/ts-loader/pull/1439) [#1438] - thanks @einatbar
6+
37
## v9.2.7
48

5-
* [cater for change in resolveTypeReferenceDirective API in TypeScript 4.7](https://github.com/TypeStrong/ts-loader/pull/1422) [#1421] - thanks @johnny_reilly and @cspotcode for inspiration in ts-node work here: https://github.com/TypeStrong/ts-node/pull/1648
9+
* [cater for change in resolveTypeReferenceDirective API in TypeScript 4.7](https://github.com/TypeStrong/ts-loader/pull/1422) [#1421] - thanks @johnny_reilly and @cspotcode for inspiration in ts-node work here: https://github.com/TypeStrong/ts-node/pull/1648
610

711
## v9.2.6
812

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-loader",
3-
"version": "9.2.7",
3+
"version": "9.2.8",
44
"description": "TypeScript loader for webpack",
55
"main": "index.js",
66
"types": "dist",

src/watch-run.ts

+26-25
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,35 @@ export function makeWatchRun(
3030
instance.reportTranspileErrors = true;
3131
} else {
3232
const times = compiler.fileTimestamps;
33+
if (times) {
34+
for (const [filePath, date] of times) {
35+
const key = instance.filePathKeyMapper(filePath);
36+
const lastTime = lastTimes.get(key) || startTime;
3337

34-
for (const [filePath, date] of times) {
35-
const key = instance.filePathKeyMapper(filePath);
36-
const lastTime = lastTimes.get(key) || startTime;
38+
if (
39+
!date ||
40+
date === 'ignore' ||
41+
(date.timestamp || date.safeTime) <= lastTime
42+
) {
43+
continue;
44+
}
3745

38-
if (
39-
!date ||
40-
date === 'ignore' ||
41-
(date.timestamp || date.safeTime) <= lastTime
42-
) {
43-
continue;
44-
}
45-
46-
lastTimes.set(key, date.timestamp || date.safeTime);
47-
promises.push(updateFile(instance, key, filePath, loader, loaderIndex));
48-
}
46+
lastTimes.set(key, date.timestamp || date.safeTime);
47+
promises.push(updateFile(instance, key, filePath, loader, loaderIndex));
48+
}
4949

50-
// On watch update add all known dts files expect the ones in node_modules
51-
// (skip @types/* and modules with typings)
52-
for (const [key, { fileName }] of instance.files.entries()) {
53-
if (
54-
fileName.match(constants.dtsDtsxOrDtsDtsxMapRegex) !== null &&
55-
fileName.match(constants.nodeModules) === null
56-
) {
57-
promises.push(
58-
updateFile(instance, key, fileName, loader, loaderIndex)
59-
);
60-
}
50+
// On watch update add all known dts files expect the ones in node_modules
51+
// (skip @types/* and modules with typings)
52+
for (const [key, { fileName }] of instance.files.entries()) {
53+
if (
54+
fileName.match(constants.dtsDtsxOrDtsDtsxMapRegex) !== null &&
55+
fileName.match(constants.nodeModules) === null
56+
) {
57+
promises.push(
58+
updateFile(instance, key, fileName, loader, loaderIndex)
59+
);
60+
}
61+
}
6162
}
6263
}
6364

0 commit comments

Comments
 (0)