Skip to content

Don't search the file system for node: modules #48431

@amcasey

Description

@amcasey

Running tsc on this .ts file results in a number of unnecessary file system accesses

import * as fs from "node:fs";

fs.chmod; // Prevent it from being unused

On my box, it searches

/home/amcasey/repos/perf_utils/node_modules/node:fs
/home/amcasey/repos/perf_utils/node_modules/node:fs.ts
/home/amcasey/repos/perf_utils/node_modules/node:fs.tsx
/home/amcasey/repos/perf_utils/node_modules/node:fs.d.ts
/home/amcasey/repos/perf_utils/node_modules/@types/node:fs
/home/amcasey/repos/perf_utils/node_modules/@types/node:fs.d.ts
/home/amcasey/repos/perf_utils/node_modules/node:fs.js
/home/amcasey/repos/perf_utils/node_modules/node:fs.jsx

Since file system access has been a performance bottleneck in the past, it would be nice to avoid these checks.

(Caveat: Linux actually allows colons in file names, so this would technically change the resolution behavior. I can't tell whether it's by-design or not that it might find node:fs.ts on disk.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions