mirror of
https://github.com/Heretek-AI/opencode.git
synced 2026-11-07 10:56:09 -10:00
fix(core): resolve Node-safe defaults for subpath imports
This commit is contained in:
6 files changed
+31
-11
No files matched your search
@@ -40,31 +40,31 @@
|
||||
"workerd": "./src/pty/pty.workerd.ts",
|
||||
"bun": "./src/pty/pty.bun.ts",
|
||||
"node": "./src/pty/pty.node.ts",
|
||||
"default": "./src/pty/pty.bun.ts"
|
||||
"default": "./src/pty/pty.node.ts"
|
||||
},
|
||||
"#persistent-pty-binary": {
|
||||
"workerd": "./src/persistent-pty/binary.workerd.ts",
|
||||
"bun": "./src/persistent-pty/binary.bun.ts",
|
||||
"node": "./src/persistent-pty/binary.node.ts",
|
||||
"default": "./src/persistent-pty/binary.bun.ts"
|
||||
"default": "./src/persistent-pty/binary.node.ts"
|
||||
},
|
||||
"#fff": {
|
||||
"workerd": "./src/filesystem/fff.workerd.ts",
|
||||
"bun": "./src/filesystem/fff.bun.ts",
|
||||
"node": "./src/filesystem/fff.node.ts",
|
||||
"default": "./src/filesystem/fff.bun.ts"
|
||||
"default": "./src/filesystem/fff.node.ts"
|
||||
},
|
||||
"#photon-wasm": {
|
||||
"workerd": "./src/image/photon-wasm.workerd.ts",
|
||||
"bun": "./src/image/photon-wasm.bun.ts",
|
||||
"node": "./src/image/photon-wasm.node.ts",
|
||||
"default": "./src/image/photon-wasm.bun.ts"
|
||||
"default": "./src/image/photon-wasm.node.ts"
|
||||
},
|
||||
"#shell-parser-wasm": {
|
||||
"workerd": "./src/shell/parser-wasm.workerd.ts",
|
||||
"bun": "./src/shell/parser-wasm.bun.ts",
|
||||
"node": "./src/shell/parser-wasm.node.ts",
|
||||
"default": "./src/shell/parser-wasm.bun.ts"
|
||||
"default": "./src/shell/parser-wasm.node.ts"
|
||||
},
|
||||
"#v1-migration": {
|
||||
"types": "./src/database/v1-migration.bun.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// opencode-pty does not ship Windows binaries.
|
||||
export const available = process.platform !== "win32"
|
||||
|
||||
export async function resolveBinary() {
|
||||
export async function resolveBinary(_bin: string) {
|
||||
return process.env.OPENCODE_PTY_BIN || "opencode-pty"
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
export const available = false
|
||||
|
||||
export async function resolveBinary(): Promise<string> {
|
||||
export async function resolveBinary(_bin: string): Promise<string> {
|
||||
throw new Error("Persistent PTYs are unavailable in this runtime")
|
||||
}
|
||||
@@ -201,6 +201,25 @@ for (const module of modules) {
|
||||
const api = module.OpenCode ?? module.OpenCodeWorkerd
|
||||
if (typeof api?.create !== "function") throw new Error("Packed SDK entrypoint is missing create()")
|
||||
}
|
||||
`,
|
||||
),
|
||||
Bun.write(
|
||||
join(consumer, "imports-default.mjs"),
|
||||
`import { registerHooks } from "node:module"
|
||||
|
||||
// Hide the "node" condition from package subpath imports so Node resolves their
|
||||
// "default" targets, as condition-less loaders and bundlers do.
|
||||
registerHooks({
|
||||
resolve(specifier, context, nextResolve) {
|
||||
if (!specifier.startsWith("#")) return nextResolve(specifier, context)
|
||||
return nextResolve(specifier, {
|
||||
...context,
|
||||
conditions: context.conditions.filter((condition) => condition !== "node"),
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
await import("./imports.mjs")
|
||||
`,
|
||||
),
|
||||
])
|
||||
@@ -214,6 +233,7 @@ for (const module of modules) {
|
||||
}
|
||||
await $`bun imports.mjs`.cwd(consumer)
|
||||
await $`node imports.mjs`.cwd(consumer)
|
||||
await $`node imports-default.mjs`.cwd(consumer)
|
||||
await $`bun --conditions=workerd imports.mjs`.cwd(consumer)
|
||||
await $`node_modules/.bin/wrangler deploy --dry-run --config wrangler.jsonc --outdir dist`.cwd(consumer)
|
||||
|
||||
|
||||
@@ -29,17 +29,17 @@
|
||||
"#attention-sounds": {
|
||||
"bun": "./src/attention-sounds.bun.ts",
|
||||
"node": "./src/attention-sounds.node.ts",
|
||||
"default": "./src/attention-sounds.bun.ts"
|
||||
"default": "./src/attention-sounds.node.ts"
|
||||
},
|
||||
"#string-width": {
|
||||
"bun": "./src/util/string-width.bun.ts",
|
||||
"node": "./src/util/string-width.node.ts",
|
||||
"default": "./src/util/string-width.bun.ts"
|
||||
"default": "./src/util/string-width.node.ts"
|
||||
},
|
||||
"#zed-sqlite": {
|
||||
"bun": "./src/editor-zed-sqlite.bun.ts",
|
||||
"node": "./src/editor-zed-sqlite.node.ts",
|
||||
"default": "./src/editor-zed-sqlite.bun.ts"
|
||||
"default": "./src/editor-zed-sqlite.node.ts"
|
||||
},
|
||||
"#runtime-plugin-support": {
|
||||
"bun": "./src/plugin/runtime-plugin-support.bun.ts",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"workerd": "./src/runtime/import.workerd.ts",
|
||||
"bun": "./src/runtime/import.bun.ts",
|
||||
"node": "./src/runtime/import.node.ts",
|
||||
"default": "./src/runtime/import.bun.ts"
|
||||
"default": "./src/runtime/import.node.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
Reference in new issue
Block a user