-
-
Notifications
You must be signed in to change notification settings - Fork 220
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
TypeScript files are seen as JavaScript when tsup resolves types of an external package in certain conditions #1023
Comments
Well, I found the problem. It is my fault. I should set: "module": "NodeNext",
"moduleResolution": "NodeNext", in tsconfig.json. |
I just noticed that when I set "module": "NodeNext",
"moduleResolution": "NodeNext", in tsconfig.json, it just make the command not complain, but the generated
generated definition file: import { Foo } from './foo.js'; // Cannot find module './foo.js' or its corresponding type declarations.ts(2307)
declare const baz: Foo;
export { baz }; |
I face the same problem, need somebody to help |
I'm also running into this - were you able to find a solution? |
Also hitting this issue within a monorepo where I am trying to bundle an unpublished internal library package into a published one. This internal library is listed under |
I am currently working on resolving this issue in #1225. |
If a package points a subpath export (
exports: { "./a": "./a.ts" }
in package.json) to a TypeScript file (“a.ts”:import {…} from "./b.ts"
), and you use that package as a dependency, when you run tsup withdts: { resolve: true }
:the file (“a.ts”) itself is treated as TypeScript code, but TypeScript files (like “b.ts”) imported by the former file are treated as plain JavaScript codes.
If “a.ts” is set as the main export (
exports: { ".": "./ts" }
), everything works.Reproduction
https://github.com/umajho/tsup-reproduction-dts-resolve-pnpm-workspace
in “packages/support-lib”:
cd packages/lib-to-be-built
pnpm run build-foo-dts-resolve
⭕️Importing from “support-lib” with the subpath “./foo”, and building the library using tsup with
dts: { resolve: true }
:success
pnpm run build-bar-using-main-dts-resolve
⭕️Importing from “support-lib” with the main path, and building the library using tsup with
dts: { resolve: true }
:success
pnpm run build-bar-dts-resolve
❌Importing from “support-lib” with the subpath “./bar-that-imports-foo”, and building the library using tsup with
dts: { resolve: true }
:failed
Upvote & Fund
The text was updated successfully, but these errors were encountered: