Skip to content

Commit 0e807d1

Browse files
authored
fix: resolve CJS type declarations via exports require condition (#29)
Split the exports["."] entry into import/require condition blocks so require resolves the CommonJS declarations (./dist/index.d.cts) that tsup already emits, instead of the ESM ./dist/index.d.ts. Fixes the "Masquerading as ESM" (FalseESM) finding from @arethetypeswrong/cli for TypeScript consumers using require() under node16/nodenext module resolution. publint and attw --pack are now clean across all resolution modes.
1 parent a68dcf0 commit 0e807d1

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Fixed
1515

16+
- **CJS type declarations (FalseESM)** - Split the `exports["."]` conditions so `require` resolves the CommonJS declarations (`./dist/index.d.cts`) that the build already emitted, instead of the ESM `./dist/index.d.ts`. Previously, TypeScript consumers using `require()` under `node16`/`nodenext` module resolution got a "Masquerading as ESM" error from `@arethetypeswrong/cli`; both `publint` and `attw --pack` are now clean across all resolution modes.
1617
- **Empty response data errors** - Prompt calls that succeed but return no response data (the behavior of opencode CLI 1.17.x for invalid or unavailable `provider/model` IDs, e.g. the `github-copilot/gpt-5` repro from [#21](https://github.com/ben-vargas/ai-sdk-provider-opencode-sdk/issues/21)) now throw an actionable `APICallError` that names the requested model ID, suggests checking `opencode models`, includes the server error payload when available, and carries `errorType: "EmptyResponseData"` — replacing the generic `No response data from OpenCode`. The streaming path surfaces the same error as an `error` stream part and terminates the stream instead of hanging on the event subscription.
1718
- **`wrapError` double-wrapping** - `wrapError` now returns already-wrapped AI SDK errors (`APICallError`, `LoadAPIKeyError`) unchanged instead of re-wrapping them and losing their metadata.
1819
- **Singleton client manager recovery after dispose** - `OpencodeClientManager.dispose()` now releases the singleton slot when the disposed manager is the singleton, so a later `createOpencode()` builds a fresh client manager. Previously the singleton kept pointing at the disposed instance, and every subsequent provider in the same process failed with `Client manager has been disposed`.

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@
2727
"exports": {
2828
"./package.json": "./package.json",
2929
".": {
30-
"types": "./dist/index.d.ts",
31-
"import": "./dist/index.js",
32-
"require": "./dist/index.cjs"
30+
"import": {
31+
"types": "./dist/index.d.ts",
32+
"default": "./dist/index.js"
33+
},
34+
"require": {
35+
"types": "./dist/index.d.cts",
36+
"default": "./dist/index.cjs"
37+
}
3338
}
3439
},
3540
"files": [

0 commit comments

Comments
 (0)