-
Notifications
You must be signed in to change notification settings - Fork 12.8k
moduleResolution: 'bundler' with subpath import seem to not support directory module and extensionless import #60003
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
Comments
Bundlers are still assumed to follow Node semantics when resolving subpath imports (e.g. file extensions are required).
How are you running/bundling this code such that it works? |
@RyanCavanaugh That being said, are paths with subpath imports treated as absolute paths? According to the documentation, it states that file extensions are not required for relative paths as follows:
|
I can't find where this was discussed before; it may have been a tangent on a related issue. But, this is working as intended, and it's surprising/concerning that Vite's resolver is deviating from the spec like this. Your reading of our docs is correct; module specifiers that start with |
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@RyanCavanaugh @andrewbranch I'm facing a similar issue. I reported a new issue #60139 |
Demo Repo
https://github.com/JunyeongChoi0/typescript-error-reproduce
Which of the following problems are you reporting?
The module specifier resolves at runtime, but not at build time
Demonstrate the defect described above with a code sample.
The TypeScript documentation states that moduleResolution: 'bundler', unlike 'nodenext', supports extensionless imports and directory module imports. This works correctly when importing via relative paths, but when using subpath imports, an error occurs.
package.json
Run
tsc --showConfig
and paste its output here{
"compilerOptions": {
"lib": [
"es2023"
],
"module": "preserve",
"target": "es2022",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "bundler",
"noEmit": true,
"isolatedModules": true,
"allowImportingTsExtensions": true,
"types": [
"node"
],
"allowSyntheticDefaultImports": true,
"resolvePackageJsonExports": true,
"resolvePackageJsonImports": true,
"resolveJsonModule": true,
"preserveConstEnums": true,
"useDefineForClassFields": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"strictBuiltinIteratorReturn": true,
"alwaysStrict": true,
"useUnknownInCatchVariables": true
},
"files": [
"./src/another.ts",
"./src/index.ts",
"./src/libs/bar.ts",
"./src/libs/foo.ts",
"./src/libs/index.ts"
],
"include": [
"src/**/*"
]
}
Run
tsc --traceResolution
and paste its output hereIt is too long - github saids 'There was an error creating your Issue: body is too long, body is too long (maximum is 65536 characters).' So I omit it here
Paste the
package.json
of the importing module, if it existsx
Paste the
package.json
of the target module, if it existsx
Any other comments can go here
x
The text was updated successfully, but these errors were encountered: