#'bundler' mode doesn't support directory or extensionless imports with subpath imports.

6 messages · Page 1 of 1 (latest)

spring cargo
#

When using subpath imports with moduleResolution: 'bundler', type errors occur when attempting to use extensionless imports or directory module imports, which seems different from what’s stated in the TypeScript documentation. Am I misunderstanding something?

Here is a reproduction: https://github.com/JunyeongChoi0/typescript-error-reproduce

GitHub

Contribute to JunyeongChoi0/typescript-error-reproduce development by creating an account on GitHub.

waxen hound
#

This is a direct static matching and replacement without any special handling for file extensions. Including the "*.js" on both sides of the mapping restricts the exposed package exports to only JS files.

#

You need to exact when you use import maps

#

You can use

  "imports": {
    "#*": "./src/*.js"
  }

but this will only work for extensionless files OR directory imports depending on how you set it up

#

However, I will note that the JavaScript standard requires exact imports with extensions specified, so configuring your project to work without extensions is going off standard, and could bite you in the butt later