Repository navigation
fix: strip JSDoc import() annotations from dist bundles — dead opencode plugin lane (#1255) - #1256
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1256Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1256.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…de plugin lane (#1255) Non-minified esbuild output keeps class-member JSDoc comments; undici's {import('./client.js')}-style type annotations therefore survive into every dist entry. Node's ESM loader ignores them, but opencode's plugin loader resolves them as real files -> ENOENT -> 'failed to load plugin' -> silent dead lane for all modern versions under opencode 1.x. Set minifyWhitespace via tsup's esbuildOptions hook (drops non-legal comments, keeps structure + license footers) and add a build gate that fails if relative import()/require() text ever reappears in dist.
[bot] 🏷 Reviewed #1256 against current master ( ① Original issue (#1255) — direction holds. I reproduced the root cause independently: building unmodified master leaves exactly 770 relative ② Regression review — existing behaviors of touched paths:
③ Code. Gate regex correctly targets relative specifiers only ( ④ Tests. The 3 gate tests have teeth (specific bad-case forms incl. ⑤ Diff. Single commit, 4 files, +118/−1, every line on-purpose. No contention: no other open PR touches CI: 8/9 green. The one failure — Follow-up candidate you flagged (report the JSDoc-resolves-as-files behavior to anomalyco/opencode): agreed it's their side too — per the source-chain rule I'm leaving it to you to decide whether to file/report upstream. 修复了 opencode 插件通道静默死亡的问题(undici 的 JSDoc |
[bot] 🏷 Follow-up: the failed Windows 重跑已通过,CI 全绿(确认为运行器瞬时故障),无遗留问题,可以合并。 |
… (review of #1256) Node resolves entry-point symlinks, so when the gate script is invoked through a symlink (pnpm-style symlinked trees, /tmp -> /private/tmp), process.argv[1] no longer string-matches import.meta.url and the main-module guard silently skipped the whole check (exit 0, no output) — a silent gate death of exactly the class this gate exists to prevent. Compare realpathSync(fileURLToPath(import.meta.url)) against realpathSync(argv[1]) instead. Verified: direct/symlink/copy invocations all run the check; negative case still fails loudly; unit tests pass.
0efd921 to
af65c57
Compare
Review complete — this PR is the survivor of a duplicate pair: #1258 (same fix for #1255) has been closed as 重复; the full review report is in that thread. What I did to this branch during review:
CI is re-running on new head 中文摘要: 复核完成:#1256 为保留项(#1258 已作为重复关闭);分支已 rebase 到当前 master 并直接补了一个小修——原门禁在符号链接方式调用时会静默跳过检查,现改为 realpath 比较并已验证(直接/符号链接/拷贝三种调用都生效,负例仍响亮失败);等新 CI 全绿即可合并。 |
|
Independent verification (human lane) on
Ready to merge. Note for release notes: dist becomes whitespace-minified (structure readable, sourcemaps ship). |
Fixes #1255
What
Every modern dist entry carries undici's JSDoc type annotations (
@param {import('./client.js')} client, …) as plain text. Node ignores them; opencode's plugin loader resolves them as real files →ENOENT … dist/agent/client.js→failed to load plugin→ the entire opencode lane (compression + proxy + updater) dies silently on every affected version (content scan: back to 0.1.57).Why this shape
esbuild keeps class-member comments in non-minified ESM output (verified empirically against tsup 8.x's bundled esbuild: function-level JSDoc stripped by default, class-body JSDoc kept). Two parts:
tsup.config.ts:minifyWhitespace: truevia tsup'sesbuildOptionshook — drops all non-legal comments, keeps code structure readable and license/legal footers intact.scripts/check-dist-import-annotations.mjs(new) wired intonpm run build: fails the build if any relativeimport()/require()text ever reappears in dist*.js. The gate is what makes this stick — without it the lane can silently die again on any future dependency whose comments contain relative specifiers.Pre-flight
dist-import-annotations: OK.Candidate follow-up (not done here, owner decides): report the loader behavior upstream to anomalyco/opencode — resolving JSDoc type annotations as files is arguably their bug too.