dynamodb-onetable
dynamodb-onetable copied to clipboard
Cannot resolve type when ESM
Describe the bug
When using Native ESM following TypeScript Official Blog, Onetable cannot resolve type(e.g. Table
, OneSchema
and Entity
).
When cjs:
When esm:
To Reproduce
https://github.com/yamatatsu/reproduction-onetable-unresolve-type
Steps to reproduce the behavior:
- Clone this repository.
-
npm i
. - Open
./debug.ts
and you can see no error onschema.foo.bar
. - And it will be error when remove
"type": "module",
frompackage.json
.
Environment (please complete the following information):
- OS: macOS 14.0
- Node Version: v18.18.0
- OneTable Version: 2.7.1
- TypeScript Version: 5.2.2
- Any other relevant environment information: nothing
Additional context
I found some solutions:
- Add
.js
to all imports in*.d.ts
following Official Documentation. - I don't know why but it resolve this issue to replace
dist/mjs/index.d.ts
todist/cjs/index.d.ts
atpackage.json#L7
and removeexports:
frompackage.json
.
It probably also resolve to separate directories tomjs
andtypes
same as any other libraries such as@aws-sdk/client-dynamodb
.
Thank you for the reproduction repo.
Any updates on this?
I like your solution (1). Seems to work.
Sorry for the delay.
Committed now.