npm ts-loader 10.0.0-beta.2
v10.0.0-beta.2

38 minutes ago
  • Keep type errors when webpack's persistent cache is used, and say which TypeScript version is needed - thanks @johnnyreilly

  • With cache: { type: 'filesystem' }, a build that compiled some files and took the rest from the cache dropped the type errors of the files it took from the cache. The build could pass with type errors in it. Files taken from the cache are now type checked again in such a build, so their errors are reported, including ones that have appeared or gone since they were cached. A build that takes every file from the cache doesn't run ts-loader, and still reports the errors the cache holds.

  • When the installed TypeScript is older than 7.1, the error now says so, names the version found, and points to ts-loader 9. Before, it only said that typescript/sync could not be found.

  • Stop per-file work growing with the project; fix reportFiles on Windows and the minimum Node.js version - thanks @johnnyreilly

  • Type-checked builds of large projects are much faster. For every file it compiled, ts-loader fetched the project's whole file list twice and created a new TypeScript snapshot, so build time grew with the square of the project's size. The list is now kept while it can't have changed, and a file only gets a snapshot update when its contents are new to TypeScript. A 4,800-file cold build went from 67s to 11s; a 300-file one from 1.6s to 1.2s. This applies to files that reach ts-loader as they are on disk. Where another loader changes a file first (Babel, Vue, a preprocessor), that file is handled as before, so such projects gain little.

  • On Windows, reportFiles patterns with a folder in them, such as src/**/*.ts or !src/skip.ts, now match. Before, only patterns without a / did. Patterns now work as they do on other platforms, so one without a folder, such as *.ts or !skip.ts, no longer matches files in sub-folders on Windows; use **/*.ts for that. Patterns must be written with /; one written with \ still matches nothing.

  • When the TypeScript compiler process is restarted after dying, it is told again the contents of files that another loader changed before ts-loader, or that aren't on disk (such as a Vue file's script). Before, it read them from disk, so files that used them could get the wrong type errors.

  • With webpack 4 in watch mode, deleting a file is now noticed when type checking. webpack 4 doesn't report removed files, so TypeScript went on seeing a deleted file that ts-loader had compiled, and imports of it raised no error. ts-loader now checks for itself, and starts a fresh TypeScript process when such a file has gone.

  • A package named by the compiler option must now provide <compiler>/fs as well as <compiler>/sync. Before, typescript/fs was always taken from the package installed as typescript.

  • The minimum Node.js version is 22.12, not 22.0: earlier versions can't load TypeScript's API, and now get an error that says so.

  • Fix type checking of virtual modules, and of builds after the TypeScript process is replaced - thanks @johnnyreilly

  • A module that only exists in webpack's input file system, such as one from a virtual-modules plugin, can be imported without a false TS2307: Cannot find module error. Before, a file compiled ahead of the virtual module it imports kept that error. In watch mode such a module is also no longer dropped when webpack's watcher, which looks at the disk, reports it as removed, and its contents are given again to a TypeScript process that is restarted.

  • When the TypeScript compiler process is replaced, files that webpack compiles but the tsconfig doesn't include are still checked again when something they depend on changes. Before, their type errors could go stale until they were next compiled.

  • When the TypeScript compiler process dies during type checking, the errors that build missed are reported by the next build even if it compiles no TypeScript file. Before, they waited for a build that did.

  • In watch mode, a file that TypeScript knows under a name ts-loader made up (a .vue file with appendTsSuffixTo, or any file without a TypeScript extension) is no longer watched under that name. webpack reported the name as removed after the first build, which started a rebuild of its own and could make imports of the file fail with TS2307 or lose their types until it was next compiled. With appendTsSuffixTo and vue-loader, a change to a .vue file's script is also compiled again: its module depended on the suffixed name, not on the file, and was left out of the rebuild.

  • With webpack 4 in watch mode, a deleted file is now noticed in two more cases: when a file of the same name without .ts or .tsx exists beside it (schema.graphql.ts beside schema.graphql), and when the rebuild that follows compiles nothing through ts-loader.

  • Keep a Vue file's script and template apart - thanks @johnnyreilly

  • With vue-loader, a .vue file with <script lang="ts">, whose template is then compiled to TypeScript as well, no longer gives files that import it a false TS1192: Module has no default export. The script and the compiled template both reach ts-loader as the same file, and whichever was compiled last was what TypeScript saw for it. The script now keeps the file's name and the template gets its own.

  • Make fewer requests to the TypeScript process when type checking - thanks @johnnyreilly

  • Type-checked builds are faster. A compiled file's errors and output are now fetched from the TypeScript process in one request, not three, and the check at the end of each build fetches its files' errors in batches. With 300 files, a cold build took about 10% less time and a rebuild after changing a widely imported file about 25% less.

  • With the compilerOptions or context loader option, a compiled file no longer sorts and compares the project's whole list of root files. That work grew with the square of the project's size.

  • No change in behaviour is intended. src/ was reorganised to remove duplicated code.

  • Ask the TypeScript process for less on each build - thanks @johnnyreilly

  • Type-checked builds are faster. To tell a project's own files from library files, ts-loader asked the TypeScript process for every file in the program and was sent each one's syntax tree, libraries included; it now asks only for what it needs to know, in one request. What a compiled file imports is now resolved in the request that compiles it, not in one more. With 300 files, a cold build took up to about 20% less time and a rebuild after changing a widely imported file about 5% less.

  • Type checking a project with more than about 120,000 imports no longer fails with Maximum call stack size exceeded. It did whenever all of those imports were resolved at once, which a build did for the files webpack doesn't bundle, and for every other file after one was created in watch mode.

  • A package named by the compiler option must now export all from <compiler>/sync, as TypeScript 7.1 does.

  • Stop reading every recompiled file from disk on a rebuild - thanks @johnnyreilly

  • In watch mode, a type-checked rebuild no longer reads from disk every file it compiles. When a widely imported file changes, each file that imports it is compiled again with the text it had before, and since the virtual modules fix above ts-loader read every one of them from disk, to see whether what it had been handed was what the disk holds. It now looks at a file on disk when it first compiles it, when the text it is handed has changed, or when webpack's watcher has reported the file, and otherwise keeps what it found the last time. With 300 files, 157 of which import the changed one, a rebuild made 158 such reads and now makes 1, and took roughly 5% to 18% less time on macOS and Windows and 1% to 3% less on Linux.

  • Report a file's errors once, on the module that compiled it - thanks @johnnyreilly

  • A file without a TypeScript extension that appendTsSuffixTo doesn't match (a .custom or .graphql file sent through ts-loader, say) has its type errors reported once. Before, each was reported twice, the second time under the file's name with .ts added, and that copy stayed after the file was fixed.

  • With vue-loader and webpack's persistent cache (cache: { type: 'filesystem' }), the type errors of a .vue file's template, and of its script when appendTsSuffixTo matches the file, are still reported when the file is taken from the cache. Before, they were lost, so such a build could pass with type errors in it. A template's errors are now shown with the module they are in (./component.vue?vue&type=template&ts=true) and what imports it.

  • Keep TypeScript in step with files that webpack no longer compiles - thanks @johnnyreilly

  • With webpack 5 in watch mode, a file that ts-loader compiled and that is then deleted stays deleted for type checking. Before, files that import it reported TS2307: Cannot find module at first, and lost the error the next time they were checked, although the file was still gone. When the file is put back, that is noticed even if no module imports it.

  • With webpack 5 in watch mode, a change to a file that ts-loader compiled earlier and webpack no longer bundles (nothing imports it now except for its types, or only the tsconfig includes it) is seen by type checking. Before, files that import it went on being checked against the text it had when it was last compiled.

  • Check the whole project again after the TypeScript process dies - thanks @johnnyreilly

  • When the TypeScript compiler process dies and is replaced, the next type check covers every file of the project. Before, it only covered the files that import one compiled since, found from what the new process knows. A file whose import had been deleted in the build the process died in kept its clean result, with no TS2307: Cannot find module, until it was next edited.

  • A build no longer fails with no project found for opened file when a file that was compiled in a build the process died in has been deleted before the next build.

  • Forget a block its .vue file no longer has - thanks @johnnyreilly

  • With vue-loader in watch mode, a template that is removed from its .vue file is no longer type checked, or seen by other files, for the rest of the watch.

  • While nothing imports a .vue file, neither its script's type errors nor its template's are reported; they are reported again when it is imported. Before, the template's were held back and the script's were not. The same now holds for any file ts-loader compiles that has no TypeScript extension.

  • Keep a real file apart from a file whose made-up name it has - thanks @johnnyreilly

  • In watch mode, changing or deleting a file with no TypeScript extension, such as schema.graphql, no longer tells TypeScript that the file of that name with .ts added (schema.graphql.ts) has changed or gone. After a deletion the build could fail with no project found for opened file. This applied whichever loader handled the first file.

  • When ts-loader compiles a file with no TypeScript extension and a real file has that name with .ts added, files that import the real file are type checked against it. Before, they were checked against what ts-loader had compiled for the other file.

Don't miss a new ts-loader release

NewReleases is sending notifications on new releases.