-
-
Notifications
You must be signed in to change notification settings - Fork 3
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 library with "type": "module"
generating cjs
declarations with .d.ts
suffix
#208
Comments
@NexZhu The |
@milesj I understand TS doesn't handle that, but I think this tool can do it by renaming file extensions. Because but hybrid package with both ESM and CommonJS build output won't be useful without "exports": {
"./some-path": {
"import": {
"default": "./dist/esm/some-path/index.js",
"types": "./dist/esm/some-path/index.d.ts"
},
"require": {
"default": "./dist/cjs/some-path/index.cjs", # or .js doesn't matter
"types": "./dist/cjs/some-path/index.d.ts" # This will cause issue if used in CommonJS + TypeScript project
}
}
}, If you try to import this library from a CommonJS + TypeScript project like: import { xxx } from 'library-name/some-path' You will get this error, making it not usable from CommonJS + TypeScript project: The links I posted above explain the issue in detail. So, what I'm thinking is, for this tool to be useful for building hybrid package with both ESM and CommonJS build output, it'd better take care of outputting the |
Some more discussion here FYI |
@NexZhu Not sure I feel about this since it feels like a "hack" but I'll support it anyways through a setting. |
Yes. Thanks! |
I have a TypeScript library with
"type": "module"
, I want to build both ESM and CommonJS output.package.json
:Generated
esm
output looks fine but thecjs
output also has declarations with.d.ts
suffixes instead of.d.cts
.This will cause problems in CommonJS project importing the library.
See:
microsoft/TypeScript#50466 (comment)
microsoft/TypeScript#50466 (comment)
The text was updated successfully, but these errors were encountered: