Skip to content

chore(cli): bundle with bun target node and publish from staged dir#2637

Open
RomanHotsiy wants to merge 10 commits intomainfrom
codex/bun-node-publish-dir
Open

chore(cli): bundle with bun target node and publish from staged dir#2637
RomanHotsiy wants to merge 10 commits intomainfrom
codex/bun-node-publish-dir

Conversation

@RomanHotsiy
Copy link
Member

What/Why/How?

  • Switch CLI build output to Bun bundling for Node (bun build --target node) instead of the previous TypeScript-only compile flow.
  • Fix bundled-runtime resolution issues by replacing runtime createRequire('../../package.json') patterns with static JSON imports in CLI runtime paths.
  • Add a built-in build-docs template fallback so bundled artifacts do not depend on template.hbs being present as a filesystem asset.
  • Replace publish-time package.json mutation/restore with a staged publish directory (packages/cli/.publish) and publishConfig.directory so changeset publish publishes from the staged manifest/artifacts.
  • Keep the staged directory minimal: bin/cli.js, bundled lib/index.js, README.md, LICENSE, and a stripped package.json (no deps/devDeps/scripts).
  • Update local pack/smoke/perf/release snapshot flows to use the staged directory.
  • Update CI jobs that execute e2e/pack/publish flows to ensure Bun is installed.

Reference

  • N/A

Testing

  • npm --workspace packages/cli run compile
  • node packages/cli/lib/index.js --help
  • npm run typecheck
  • npm run pack:prepare
  • npm run release (no unpublished packages in this run; verified publish-dir prepare/cleanup path)

Screenshots (optional)

  • N/A

Check yourself

  • Code changed? - Tested with Redoc/Realm/Reunite (internal)
  • All new/updated code is covered by tests
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: b902fbf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/cli Patch
@redocly/openapi-core Patch
@redocly/respect-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@RomanHotsiy RomanHotsiy added the snapshot Create experimental release PR label Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.26% (🎯 79%) 6440 / 8125
🔵 Statements 78.72% (🎯 78%) 6659 / 8459
🔵 Functions 82.51% (🎯 82%) 1317 / 1596
🔵 Branches 71.25% (🎯 71%) 4400 / 6175
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/cli/src/commands/build-docs/index.ts 93.75% 50% 100% 93.75% 55
packages/cli/src/commands/build-docs/utils.ts 59.45% 33.33% 85.71% 61.11% 52-73, 128, 135, 150
packages/cli/src/utils/package.ts 100% 100% 100% 100%
Generated in workflow #8952 for commit b902fbf by the Vitest Coverage Report Action

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 3.421s ± 0.030s ▓▓ 1.04x
cli-next 3.277s ± 0.015s ▓ 1.00x (Fastest)

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

📦 A new experimental 🧪 version v0.0.0-snapshot.1772635755 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1772635755
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1772635755
# or
npm install @redocly/respect-core@0.0.0-snapshot.1772635755

⚠️ Note: This is a development build and may contain unstable features.

@RomanHotsiy RomanHotsiy removed the snapshot Create experimental release PR label Mar 4, 2026
@RomanHotsiy RomanHotsiy marked this pull request as ready for review March 12, 2026 03:43
@RomanHotsiy RomanHotsiy requested review from a team as code owners March 12, 2026 03:43
Copy link
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a brief look. Will give it another pass later.

import { performance } from 'node:perf_hooks';
import { default as redoc } from 'redoc';

import packageJson from '../../../package.json' with { type: 'json' };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably makes more sense to import it from utils/package.js.

import { createRequire } from 'node:module';

const packageJson = createRequire(import.meta.url ?? __dirname)('../../package.json');
import packageJson from '../../package.json' with { type: 'json' };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vaguely recall there was an issue with this syntax, probably somewhere in our other products, so we decided to stick with createRequire during migration to ESM. Have you tested your changes with Realm/Reunite?

}

function cleanUpStyledComponentWarnings(str: string): string {
return str.replace(/^styled-components: it looks like an unknown prop .*?(?:\r?\n|$)/gm, '');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the message anywhere. Why do wee need this?

const result = spawnSync(command, args, {
cwd: rootDir,
stdio: 'inherit',
shell: process.platform === 'win32',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to publish from Win?

with:
node-version: 24
cache: npm
- uses: oven-sh/setup-bun@v2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this imply Redocly CLI won't get executed on a system without Bun installed?

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.

3 participants