Open grikomsn opened 1 year ago
Thanks for this solution! I think this is great. I haven't seen this .mjs
before, I'm guessing we just point the module
property in the package.json
to the .mjs
file and all just works?
I'd be down for this. I believe @NoahSaso also reported this to me over discord for another library.
I'm also guessing another solution (although not as ideal) is to copy the declarations from types into the respective folders
I'm also guessing another solution (although not as ideal) is to copy the declarations from types into the respective folders
I do not know how the build process works, but at Strangelove we use egoist/tsup to bundle packages, which does the heavy lifting on type declarations and outputs both CommonJS and ESM packages.
Do take a peek on graz's package output: https://unpkg.com/browse/graz@0.0.30/dist/
Maybe pure tsc or https://ts-morph.com/ . We'll investigate now
Seems that most cosmos-kit published packages is using the convention to split CommonJS and ESM sources to separate directories (https://unpkg.com/browse/@cosmos-kit/react@0.26.0/). This results in poor source typings since the path for those typings are in a different directory.
Example edge case related to #106, while
import { SimpleConnectModal } from "@cosmos-kit/react/main/modal/components"
does exist, TypeScript does not detect types because@cosmos-kit/react/main/modal/components
types are on a different directory at@cosmos-kit/react/types/modal/components
. The hacky solution is to override module declaration like below:Proposed solution for this issue is to use
.mjs
extension for ESM sources and merge into single directory, similar to what graz does: https://unpkg.com/browse/graz@0.0.30/dist/