Repository navigation
fix: strip JSDoc import() annotations from dist so bun-based plugin loaders can load it (#1255) - #1258
fix: strip JSDoc import() annotations from dist so bun-based plugin loaders can load it (#1255)#1258ranxianglei wants to merge 1 commit into
Conversation
…oaders can load it (#1255)
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1258Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1258.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Review verdict: direction sound, independently verified — but this PR duplicates #1256. Closing #1258, keeping #1256 (reviewed + hardened).① 原 issue(方向关)Re-verified the root cause on current master ( ② 回归审查(既有行为清点)
③ 代码审查(主关)
④ 测试有效性
⑤ diff 整洁度Single commit, 4 files (#1256) / 3 files (#1258); every line on-purpose. Clean. Independent verification evidence (rebased head on
|
|
Closing as a duplicate of #1256 — same root cause (#1255: undici JSDoc The full independent review — root cause re-verified on current master (770 offending refs across all 11 dist entries in an unflagged build, 0 after the fix), full test suite on the rebased head, dist smoke tests, plus one small gate hardening pushed directly onto the #1256 branch (symlinked invocation used to skip the check silently) — is posted in the tracking issue thread (#1258). Nothing unique is lost by closing this PR. |
Fixes #1255
Root cause (re-verified on master)
The dist bundles contain zero real relative dynamic imports. Every
import('./…')occurrence is a JSDoc type annotation from undici (@param {import('./client.js')} client,{import('./snapshot-utils').HeaderFilters}, …) that survives bundling because esbuild keeps class-body JSDoc in non-minified ESM output. Node's ESM loader ignores comment content, but the bun-based opencode binary resolves those relative specifiers as real files during plugin loading →ENOENT …/dist/agent/client.js→failed to load plugin→ silently dead lane (no compression, no proxy, no updater).Re-verified locally on current master: the gate below counts 770 relative import()/require() text occurrences across all 11 dist entries of an unflagged build — every one inside a JSDoc comment.
Changes
tsup.config.ts:minifyWhitespace: truevia theesbuildOptionshook — drops all non-legal comments (including the JSDoc annotations) while keeping identifiers readable; legal (license) comments are preserved.scripts/check-dist-import-annotations.mjs: new build gate wired intonpm run build(and therefore CI): fails the build if any relativeimport()/require()text ever reappears in dist*.js. The lane cannot silently die again.Pre-flight (this branch)
npm run buildfails withdist-import-annotations: FAIL — 770 relative import()/require() ref(s) in dist; flag on →dist-import-annotations: OK.npm run typecheckclean;npm test: 2351 pass / 0 fail / 2 skipped.node --check; dynamic import ofdist/agent/opencode-native.js(the file that failed under opencode) succeeds with the full export list including thedefaultplugin function.