question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move away from Classic module resolution as default for all module kinds

See original GitHub issue

TypeScript’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 and paths properties in tsconfig.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.jsons 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:open
  • Created 7 years ago
  • Reactions:10
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
brhumphecommented, Oct 19, 2016

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.

2reactions
DanielRosenwassercommented, Oct 9, 2016

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 to classic.

@aluanhaddad, it’d also be good to get your thoughts here too.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found