module_resolution=none or =explicit
See original GitHub issueDiscussed in-person with @DanielRosenwasser
In google we have performance issues with tsc and with editor plugins. We have tracked this down to the node moduleResolutionKind looking in many locations on a network-mounted disk.
We don’t actually want the node moduleResolution, we only want the baseUrl/paths/rootDirs feature known as “path mapping”. Put another way, we explicitly list locations for all inputs, and we never want the compiler to stat a file outside of the explicit input locations.
For tsc, we provide a custom CompilerHost that avoids touching the disk, we implement fileExists and directoryExists purely by consulting our file manifest. However, we can’t do this trick for editors, which are becoming increasingly unusable.
As an example, we provide interop with Closure Compiler code that declares goog.module
, by naming these goog:some.module
. This results in the language services looking for a file like goog:some.module.d.ts
all over the network-mounted filesystem, even though a later sourceFile in the program has declare module 'goog:some.module'
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:9 (7 by maintainers)
Top GitHub Comments
Bump again: @RyanCavanaugh I know the team has said no to getting involved with import resolution (re: #16577) but I just wanted to make sure that this different use-case/ask didn’t get wrapped into that decision incorrectly.
The idea that
import "./App.ts"
is invalid assumes a Node.js or browser environment. But different environments like Snowpack and Deno support importingTS
files. In Snowpack’s case, it’s part of a larger handling of importing source files by source name, so that something likeimport "./App.svelte"
is valid. Because Snowpack handles your build, we are able to resolve the import correctly at build time. But for TS, this behavior is broken.It would be really useful if this warning could suppressed via an opt-in compiler option, for environments like Deno and Snowpack where importing the TS file by path is actually the correct user behavior.
This request is aligned with the decision in #16577 imo, because we are specifically not asking for any sort of resolution/rewriting of imports.
/cc @kitsonk
Wanted to bump this thread since Snowpack TS users are also running into problems with TypeScript’s reliance on Node.js module resolution logic. More info: https://github.com/microsoft/TypeScript/issues/27481