Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: support webpack 5 in ts-loader #1439

Merged
merged 4 commits into from Mar 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 29 additions & 27 deletions src/watch-run.ts
Expand Up @@ -29,36 +29,38 @@ export function makeWatchRun(
if (instance.loaderOptions.transpileOnly) {
instance.reportTranspileErrors = true;
} else {
const times = compiler.fileTimestamps;
compiler.hooks.compilation.tap('ts-loader', compiliation => {
compiliation.fileSystemInfo._fileTimestamps.stack.forEach(times => {
for (const [filePath, date] of times) {
const key = instance.filePathKeyMapper(filePath);
const lastTime = lastTimes.get(key) || startTime;

for (const [filePath, date] of times) {
const key = instance.filePathKeyMapper(filePath);
const lastTime = lastTimes.get(key) || startTime;
if (
!date ||
date === 'ignore' ||
(date.timestamp || date.safeTime) <= lastTime
) {
continue;
}

if (
!date ||
date === 'ignore' ||
(date.timestamp || date.safeTime) <= lastTime
) {
continue;
}

lastTimes.set(key, date.timestamp || date.safeTime);
promises.push(updateFile(instance, key, filePath, loader, loaderIndex));
}
lastTimes.set(key, date.timestamp || date.safeTime);
promises.push(updateFile(instance, key, filePath, loader, loaderIndex));
}

// On watch update add all known dts files expect the ones in node_modules
// (skip @types/* and modules with typings)
for (const [key, { fileName }] of instance.files.entries()) {
if (
fileName.match(constants.dtsDtsxOrDtsDtsxMapRegex) !== null &&
fileName.match(constants.nodeModules) === null
) {
promises.push(
updateFile(instance, key, fileName, loader, loaderIndex)
);
}
}
// On watch update add all known dts files expect the ones in node_modules
// (skip @types/* and modules with typings)
for (const [key, { fileName }] of instance.files.entries()) {
if (
fileName.match(constants.dtsDtsxOrDtsDtsxMapRegex) !== null &&
fileName.match(constants.nodeModules) === null
) {
promises.push(
updateFile(instance, key, fileName, loader, loaderIndex)
);
}
}
})
})
}

// Update all the watched files from solution builder
Expand Down