We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch ts-loader@9.2.6 for the project I'm working on.
ts-loader@9.2.6
Error when running ts-loader with webpack 5 : "times is not iterable" Previous work was done here by @elf-mouse #1290 but was not accepted.
In my solution I used the new webpack 5 API inside the compilation object, that exposes the _fileTimestamps through fileSystemInfo
Here is the diff that solved my problem:
diff --git a/node_modules/ts-loader/dist/watch-run.js b/node_modules/ts-loader/dist/watch-run.js index a2f65a7..5e91edc 100644 --- a/node_modules/ts-loader/dist/watch-run.js +++ b/node_modules/ts-loader/dist/watch-run.js @@ -25,26 +25,30 @@ function makeWatchRun(instance, loader) { instance.reportTranspileErrors = true; } else { - const times = compiler.fileTimestamps; - 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; - } - 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)); - } - } + 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; + 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)); + } + + // 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 if (instance.solutionBuilderHost) {
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered:
If you'd like to submit a PR I'd happily take a look
Sorry, something went wrong.
@johnnyreilly I opened a PR: #1439
Successfully merging a pull request may close this issue.
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
ts-loader@9.2.6
for the project I'm working on.Error when running ts-loader with webpack 5 : "times is not iterable"
Previous work was done here by @elf-mouse #1290 but was not accepted.
In my solution I used the new webpack 5 API inside the compilation object, that exposes the _fileTimestamps through fileSystemInfo
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: