Skip to content

Commit 54858b8

Browse files
committed
fix(plugin): add .js extensions to ESM imports
The @opencode-ai/plugin package fails to load when installed from npm because: 1. package.json exports pointed to ./src/index.ts but only dist/ is published 2. Compiled dist/index.js had 'export * from "./tool"' without .js extension This fix: - Updates package.json exports to point to dist/*.js files - Adds .js extensions to all relative imports in source files Fixes anomalyco#8006
1 parent f1a13f2 commit 54858b8

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎packages/plugin/package.json‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
"build": "tsc"
1010
},
1111
"exports": {
12-
".": "./src/index.ts",
13-
"./tool": "./src/tool.ts"
12+
".": {
13+
"import": "./dist/index.js",
14+
"types": "./dist/index.d.ts"
15+
},
16+
"./tool": {
17+
"import": "./dist/tool.js",
18+
"types": "./dist/tool.d.ts"
19+
}
1420
},
1521
"files": [
1622
"dist"

‎packages/plugin/src/example.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Plugin } from "./index"
2-
import { tool } from "./tool"
1+
import { Plugin } from "./index.js"
2+
import { tool } from "./tool.js"
33

44
export const ExamplePlugin: Plugin = async (ctx) => {
55
return {

‎packages/plugin/src/index.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import type {
1212
Config,
1313
} from "@opencode-ai/sdk"
1414

15-
import type { BunShell } from "./shell"
16-
import { type ToolDefinition } from "./tool"
15+
import type { BunShell } from "./shell.js"
16+
import { type ToolDefinition } from "./tool.js"
1717

18-
export * from "./tool"
18+
export * from "./tool.js"
1919

2020
export type ProviderContext = {
2121
source: "env" | "config" | "custom" | "api"

0 commit comments

Comments
 (0)