Skip to content

fix(cli): drop the never-produced dist/index.cjs requirement from prepublish's opencode-plugin skip check (#11787) - #11990

Merged
diegosouzapw merged 2 commits into
release/v3.8.51from
fix/11787-prepublish-opencode-plugin-cjs-check
Aug 29, 2026
Merged

diegosouzapw merged 2 commits into
release/v3.8.51from
fix/11787-prepublish-opencode-plugin-cjs-check

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

Closes #11787

Root cause

scripts/build/prepublish.ts (Step 8.8) gated the "@omniroute/opencode-plugin already built → skip rebuild" fast path on both dist/index.js and dist/index.cjs existing. @omniroute/opencode-plugin/tsup.config.ts uses format: ["esm"] only (and package.json is "type": "module" with an exports map exposing only "import", no "require"), so a successful tsup run in that package can never produce dist/index.cjs. The pluginAlreadyBuilt check was therefore permanently false, and every npm run build:cli / prepublish run re-installed and rebuilt the plugin even when its ESM-only dist/ was already correctly built.

Fix

Drop the dist/index.cjs requirement — pluginAlreadyBuilt is now existsSync(opencodePluginDist) (index.js) alone, matching what the ESM-only tsup config actually emits. Removed the now-unused opencodePluginCjs binding.

Regression test

tests/unit/prepublish-opencode-plugin-build-skip.test.ts — builds the real plugin package with the real tsup config (no mocks), confirms dist/index.cjs is never produced, and asserts the fixed predicate correctly reports "already built" when dist/index.js is present and "needs rebuild" when dist/ is absent.

Fail → pass: before the fix, the equivalent predicate (existsSync(index.js) && existsSync(index.cjs)) asserted false !== true against a real ESM-only tsup build output; after the fix, both test cases pass.

Gates run (all green)

  • node --import tsx/esm --test tests/unit/prepublish-opencode-plugin-build-skip.test.ts — 2/2 pass
  • node --import tsx/esm --test tests/unit/opencode-plugin-parses.test.ts — pass (sibling plugin test)
  • node scripts/check/check-file-size.mjs — OK
  • node scripts/check/check-complexity.mjs — OK (2672 violations, baseline 2774)
  • node scripts/check/check-cognitive-complexity.mjs — OK (1192 violations, baseline 1223)
  • node scripts/check/check-changelog-integrity.mjs — OK
  • npm run typecheck:core — exit 0
  • npx eslint --suppressions-location config/quality/eslint-suppressions.json scripts/build/prepublish.ts tests/unit/prepublish-opencode-plugin-build-skip.test.ts — exit 0 (0 errors)

Diff is scoped to scripts/build/prepublish.ts (one predicate + comment), the new test, and the changelog fragment — no drive-by changes.

…instead of a hardcoded .bin path

The old test assumed @omniroute/opencode-plugin/node_modules/.bin/tsup
already existed. A fresh checkout (CI's npm ci never installs this
standalone package's own deps) has no such node_modules at all, so the
test failed with MODULE_NOT_FOUND in CI while passing locally on a devbox
that had installed it before. Mirror scripts/build/prepublish.ts's own
install-then-resolveLocalBinEntry approach.
@diegosouzapw
diegosouzapw merged commit 322b218 into release/v3.8.51 Aug 29, 2026
20 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…publish's opencode-plugin skip check (diegosouzapw#11787) (diegosouzapw#11990)

* fix(cli): drop the never-produced dist/index.cjs requirement from prepublish's opencode-plugin skip check (diegosouzapw#11787)

* test(build): resolve tsup/npm portably in the diegosouzapw#11787 regression test instead of a hardcoded .bin path

The old test assumed @omniroute/opencode-plugin/node_modules/.bin/tsup
already existed. A fresh checkout (CI's npm ci never installs this
standalone package's own deps) has no such node_modules at all, so the
test failed with MODULE_NOT_FOUND in CI while passing locally on a devbox
that had installed it before. Mirror scripts/build/prepublish.ts's own
install-then-resolveLocalBinEntry approach.

---------

Co-authored-by: Markus Hartung <mail@hartmark.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: prepublish still requires opencode-plugin dist/index.cjs after ESM-only tsup

2 participants