Move away from Classic module resolution as default for all module kinds
See original GitHub issueTypeScript’s original module resolution strategy (the Classic resolution strategy) has some strange behavior that apparently doesn’t actually reflect any other resolution strategy. It seems strange that those using non-CommonJS emit targets get this behavior by default.
Classic resolution also causes many disk probes during the walk up the project root - assuming that this strategy does eventually succeed in most cases, it seems like most uses could be subsumed by:
- Using relative paths.
- Modifying the
baseUrl
andpaths
properties intsconfig.json
.
After discussing with @vladima, we think it is worth considering switching the default resolution strategy for all module targets to Node.
Here’s what needs to be done:
- Investigate existing
tsconfig.json
s that target esXXXX` and have no explicit/implied resolution strategy. - Determine the downstream effects to a change to defaults
- Determine if this change outweighs the potential breakage
- Implement if appropriate
Issue Analytics
- State:
- Created 7 years ago
- Reactions:10
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >Module Resolution Strategy | TypeScript Tutorial - YouTube
NODE moduleResolution option 03:23 Classic Relative Import ... Check out my website: - https://bit.ly/smartherd Let's get in touch!
Read more >A comprehensive guide to “Module System” in TypeScript ...
In this lesson, we are going to take a look at how the ECMAScript module system works and how TypeScript implements module resolution...
Read more >Compiler Options - TypeScript - JavaScript that scales.
Option Type Default
‑‑allowJs boolean false
‑‑allowSyntheticDefaultImports boolean module === "system" or ‑‑esModuleInterop
‑‑allowUmdGlobalAccess boolean false
Read more >ts-node - npm
Override the module type of certain files, ignoring the package.json "type" field. See Module type overrides for details. Default: obeys package ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m pretty new to typescript, and this unexpected behavior really tripped me up (see #11712 ). The vast majority of tutorials assume the user is developing with
npm
, including those on the official website, so the defaults should (from my noob-ish perspective) reflect that most common use case.There are more than enough unexpected pitfalls in web development. Eliminating this one would be awesome.
Thanks for weighing in @kitsonk. We knew that Dojo was using
classic
in some capacity, but we figured that there shouldn’t be any major changes, and for new projects people shouldn’t be caught off guard by this behavior.Additionally, we wouldn’t remove
classic
, we’d only switch the defaults for non-CommonJS resolutions, so users could still opt back in toclassic
.@aluanhaddad, it’d also be good to get your thoughts here too.