Describe the bug#
The migrate-from-experimental schematic in @tanstack/angular-query@5.0.0-rc.3 aborts before migrating anything when a project source imports a package subpath that names a file, such as import { sha3_256 } from '@noble/hashes/sha3.js':
Path "/node_modules/@noble/hashes/sha3.js" is a file.
The cause is the compiler host built in configuredSources() (packages/angular-query/schematics/migrate-from-experimental/workspace.ts). Its directoryExists calls tree.getDir(path) directly. TypeScript's module resolution probes candidate paths with directoryExists, and some of them are files. The devkit Tree.getDir() then throws PathIsFileException rather than reporting that no directory exists.
Your minimal, reproducible example#
https://github.com/imaksp/tanstack-angular-query-migrate-schematic-repro
Steps to reproduce#
- Clone the repro and run
pnpm install.
- Run
pnpm exec ng generate @tanstack/angular-query:migrate-from-experimental --dry-run.
- See
Path "/node_modules/@noble/hashes/sha3.js" is a file.
It also reproduces with an npm-style flat layout (pnpm install --config.node-linker=hoisted). Removing the @noble/hashes/sha3.js import makes the dry run succeed.
Expected behavior#
The schematic migrates the workspace: the dry run lists UPDATE src/main.ts and UPDATE package.json. Instead it throws, and none of the project's files are migrated. In a real workspace, every file is skipped as soon as one source imports such a subpath.
How often does this bug happen?#
Every time
Platform#
- OS: macOS 26
- Node: 26.8.2
- pnpm: 12.9.1
- Angular CLI: 22.2.1
Tanstack Query adapter#
angular-query
TanStack Query version#
5.0.0-rc.3
TypeScript version#
6.0.3
Additional context#
Making directoryExists return false for a path that is a file fixes it. tree.exists() is true only for files:
host.directoryExists = (path) => {
if (tree.exists(path)) return false
const directory = tree.getDir(path)
return directory.subfiles.length > 0 || directory.subdirs.length > 0
}
With that change the repro's dry run succeeds. I'll open a PR with the fix and a regression test.
Fixed in
@tanstack/angular-query@rc.4