Repository navigation
fix: forget a block its .vue file no longer has - #1763
Merged
Merged
Conversation
ts-loader kept a compiled file's errors under webpack's name for it and looked for its module under the name the errors are shown by. Where those are not the name TypeScript has, two things went wrong: - A file with no TypeScript extension that appendTsSuffixTo doesn't match was taken by the end-of-build recheck as never checked, so its errors were reported a second time under the made-up name, and that copy stayed after the file was fixed. - The errors of a .vue file's template went on the compilation only, and those of a script matched by appendTsSuffixTo on no module either, so they were lost when the module was restored from webpack's persistent cache. The errors are now kept under TypeScript's name, with the resource of the module that compiled the file, and are reported on that module. Fixes #1745 Fixes #1746 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
…che entry vueBlocksPersistentCache changed other.js in patch0 and expected it to be restored from the cache in patch1. webpack doesn't trust the cache for a file changed that close to the build, so whether it was restored came down to timing. patch1 now changes the file again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
…cript and template alike A block other than the script that a .vue file loses (in practice its compiled template) stayed a file of the TypeScript program for the rest of the watch: nothing compiles it again and nothing says it has gone. It is now forgotten, and hidden from TypeScript, in the build that compiles the file without it: the module of the file itself was built and no module asks for the block. A block whose file is merely out of the build is kept as before. While a .vue file is out of the build, the errors of its template were held back and those of its script were still reported. Neither is reported now: both are text that ts-loader gave TypeScript and that nothing keeps up to date. The same goes for any file compiled under a name ts-loader made up. Fixes #1749 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
…b-7yznjj-1749-vue-block-gone
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
Benchmark (Ubuntu)
PR branch = c438368 merged into next, base branch = next at 4519f74. Each row is the median of up to 60 cold builds, or up to 200 rebuilds, after 2 warmup iterations. Report-only - no threshold fails this check. |
Benchmark (Windows)
PR branch = c438368 merged into next, base branch = next at 4519f74. Each row is the median of up to 60 cold builds, or up to 200 rebuilds, after 2 warmup iterations. Report-only - no threshold fails this check. |
Benchmark (macOS)
PR branch = c438368 merged into next, base branch = next at 4519f74. Each row is the median of up to 60 cold builds, or up to 200 rebuilds, after 2 warmup iterations. Report-only - no threshold fails this check. |
…ropped A file's stored errors are dropped while the file is in neither the build nor the program, and with them went the only record of which module had compiled it. A .vue file's script is in that position when nothing imports the file and the tsconfig doesn't include it (on Windows, also when it does). When the file was imported again, webpack brought the module back from its cache, and the recheck took the script for a file with no module: its error was reported a second time, on the compilation. The layer now records the module the file was compiled as, so the recheck finds it without stored errors. And errors found by a recheck made while the module was out of the build are given the module when it is back. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
…b-7yznjj-1749-vue-block-gone
…ue test Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
Whether a .vue file's script stays in the program while nothing imports it differs between platforms, so its error was reported in patch0 on Linux and not on Windows. Only the template has an error now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
…b-7yznjj-1749-vue-block-gone
… on every platform Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
…745-errors-twice # Conflicts: # CHANGELOG.md # test/comparison-tests/create-and-execute-test.js
…b-7yznjj-1749-vue-block-gone
…745-errors-twice # Conflicts: # CHANGELOG.md
…b-7yznjj-1749-vue-block-gone
…749-vue-block-gone # Conflicts: # CHANGELOG.md # src/diagnostics.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1749.
What changes
1. A block its file no longer has is forgotten. A
.vuefile's block other than the script (in practice the compiled template) has a TypeScript name of its own,component.vue.template.ts. When the file lost the block, it stayed a file of the program for the rest of the watch.forgetRemovedBlocksnow drops the layer and hides the name from TypeScript, using the rule the issue proposes: the module of the file itself (vue-loader's, whose resource has no query) was built in this compilation, and no module asks for the block. "Built" is read from the compilation (builtModules), not fromchangedFilesThisBuild. It runs before the end-of-build recheck, so TypeScript is told in the same build.A block whose file is merely out of the build is kept, as before: webpack can bring its module back from its cache without running the loaders.
2. A file's script and template are treated alike while the file is out of the build. Before, the template's errors were held back and the script's were still reported. Now neither is reported. With #1760 each stored error set knows the module resource it was compiled as, so the rule no longer needs a list of blocks: errors of a file compiled under a name ts-loader made up are held back while no module has that resource. I chose "neither" over "both" because TypeScript only has the text ts-loader last gave it for such a file, and nothing keeps that up to date while the module is out of the build.
This also applies to other made-up names: a
thing.customfile compiled by ts-loader that nothing imports any more stops reporting its errors until it is imported again. A file with a TypeScript extension is not affected: it is a project file that TypeScript reads itself, and its errors are reported as before.getUnrequestedBlocksis replaced byforgetRemovedBlocks; the reporting code no longer takes a list from it.Against the issue's "done when"
vueBlockGoneWatch.other.tsimports a type from./component.vue.template; whencomponent.vueloses its template,other.tsreportsTS2307in that build. Without the change it never does.vueBlockRemovedWatchpasses unchanged.vueFileNotImportedWatch. The script has an error; it is not reported whileapp.tsdoesn't import the file, as a template's isn't (vueBlockRemovedWatch), and comes back when it does. Without the change it is still reported in between, on Linux and macOS. On Windows the script leaves the program when nothing imports it, so the error went there already; that difference is why the test has one error and not two, whose order would differ.Not done: with custom blocks, removing one shifts the indexes of the rest. The last index is then unrequested and is forgotten by the rule above, and the others are compiled again under their new indexes, so I believe this case is covered, but there is no test for it.
Both test packs pass locally.
https://claude.ai/code/session_01Q2Jv7JZWr3VUxCkXiKB5e5
Generated by Claude Code