Skip to content

fix(check,lsp): support "moduleResolution": "bundler" and "module": "esnext" in tsconfig #30048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nathanwhit
Copy link
Member

@nathanwhit nathanwhit commented Jul 9, 2025

Closes #29673.
Ref #25359.

this adds support initial for "moduleResolution": "bundler".

"bundler" module resolution has two differences compared to "NodeNext":

  • enables support for resolving relative paths without extensions (i.e. sloppy imports)
  • changes the import conditions used. it disables the "node" import condition, and then
    • if "module" === "esnext" , always resolve with the "import" condition (even for require)
    • if "module" === "preserve", resolve with "import" for imports, "require" for requires

this PR implements the sloppy imports part (which is messy because the initialization order isn't quite right), but doesn't do the import conditions part. that shouldn't be too hard either, the main issue is that it would create a cyclic dependency between the node resolver and the tsconfig resolver, which we'd need to break somehow (potentially using arc_swap or something)

@bartlomieju bartlomieju requested review from dsherret and nayeemrmn July 9, 2025 20:33
Comment on lines 1673 to 1675
SloppyImportsOptions::Dynamic(Arc::new(move |referrer| {
if let Some(referrer) = referrer {
let resolver = compiler_options_resolver.load();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

I'll probably have to restructure the subsystem init sequence to clean this up.

Before:

  1. ConfigTree (including WorkspaceResolver)
  2. LspResolver (including NodeResolver and CliResolver)
  3. CompilerOptionsResolver

After:

  1. ConfigTree
  2. NodeResolver
  3. CompilerOptionsResolver
  4. WorkspaceResolver
  5. CliResolver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support "moduleResolution": "bundler" for type checking and bundling
2 participants