Skip to content

Use tsdown -W --watch (workspace mode) for dev builds - #1689

Merged
N2D4 merged 14 commits into
devfrom
devin/1782779680-tsdown-workspace-mode
Jun 30, 2026
Merged

N2D4 merged 14 commits into
devfrom
devin/1782779680-tsdown-workspace-mode

Conversation

@N2D4

@N2D4 N2D4 commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces 11 separate per-package tsdown --watch processes with a single tsdown -W (workspace mode) invocation, reducing tsdown memory from ~7.6 GB to ~58 MB (chokidar watcher).

tsdown -W --watch hangs with 21 concurrent Rolldown watchers (11 packages × 2 formats), so file watching is handled by chokidar triggering one-shot tsdown -W builds on source changes. The tradeoff is ~24s full rebuild latency vs near-instant per-package rebuilds, but memory drops from 7.6 GB to ~58 MB idle + ~150 MB transient during builds.

Changes:

  • Remove per-package dev scripts that ran tsdown --watch individually
  • Add build-packages:watch script using chokidar --initial -c 'tsdown -W' to watch packages/*/src/**
  • Move dashboard-ui-components IIFE build into its tsdown.config.ts onSuccess hook so it runs automatically after workspace builds
  • Update dev, dev:full, dev:tui, dev:basic to use build-packages:watch

Link to Devin session: https://app.devin.ai/sessions/685e85e744d442efaab0d365de4cc61d
Requested by: @N2D4

Summary by CodeRabbit

  • New Features
    • Added an optional post-build success callback to the shared JavaScript library build configuration.
  • Refactor
    • Updated the dashboard UI build flow to automatically run its build/copy steps after successful library builds.
    • Streamlined development scripts across multiple packages to focus on code generation watchers instead of TypeScript-down watch.
  • Chores
    • Added a root “packages build” watch script and wired it into main dev commands.
    • Removed unused per-package dev scripts that only started library watch tasks.
    • Adjusted library dependency bundling behavior for the CLI and core packages.

…6GB -> 224MB

Replace 11 separate tsdown --watch processes with a single tsdown -W --watch
at the root level. Workspace mode discovers all tsdown.config.ts files and
builds them in a single process, sharing the Rolldown runtime.

- Root dev scripts: add tsdown -W --watch to concurrently blocks
- Packages with dev=tsdown --watch only: remove dev script (shared, shared-backend, ui, sc, cli)
- SDK packages: dev now only runs codegen:watch (tsdown handled by workspace mode)
- dashboard-ui-components: onSuccess moved to tsdown.config.ts with cwd-aware function
- configs/tsdown/js-library.ts: accept onSuccess option

Co-Authored-By: Konstantin Wohlwend <[email protected]>
@N2D4 N2D4 self-assigned this Jun 30, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review June 30, 2026 00:47
@vercel

vercel Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-auth-hosted-components Ready Ready Preview, Comment Jun 30, 2026 7:37pm
stack-auth-internal-tool Error Error Jun 30, 2026 7:37pm
stack-auth-mcp Ready Ready Preview, Comment Jun 30, 2026 7:37pm
stack-auth-skills Ready Ready Preview, Comment Jun 30, 2026 7:37pm
stack-backend Ready Ready Preview, Comment Jun 30, 2026 7:37pm
stack-dashboard Ready Ready Preview, Comment Jun 30, 2026 7:37pm
stack-demo Ready Ready Preview, Comment Jun 30, 2026 7:37pm
stack-docs Error Error Jun 30, 2026 7:37pm
stack-preview-backend Ready Ready Preview, Comment Jun 30, 2026 7:37pm
stack-preview-dashboard Ready Ready Preview, Comment Jun 30, 2026 7:37pm

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Package dev scripts stop running local tsdown --watch. Root dev scripts add a centralized package watch process. The shared tsdown config now accepts onSuccess, and dashboard UI components uses it to run its IIFE build steps after successful builds.

Changes

Centralize tsdown watch in root dev scripts

Layer / File(s) Summary
onSuccess support in shared tsdown config
configs/tsdown/js-library.ts
createJsLibraryTsupConfig accepts optional onSuccess and forwards it into the generated config, while the same config block replaces noExternal/inlineOnly with deps.alwaysBundle and deps.onlyBundle.
dashboard-ui-components onSuccess post-build hook
packages/dashboard-ui-components/tsdown.config.ts, packages/dashboard-ui-components/package.json
tsdown.config.ts computes pkgDir and runs pnpm run build-iife && pnpm run copy-iife in onSuccess; the package dev script is removed.
Root dev scripts add centralized tsdown watch
package.json
dev:full, dev, dev:tui, and dev:basic add build-packages:watch to their concurrent commands, and build-packages:watch runs tsdown -W --watch.
Remove per-package tsdown watch scripts
packages/cli/package.json, packages/js/package.json, packages/next/package.json, packages/react/package.json, packages/sc/package.json, packages/shared-backend/package.json, packages/shared/package.json, packages/tanstack-start/package.json, packages/template/package*.json, packages/ui/package.json
Package dev scripts are removed or reduced to pnpm run codegen:watch, dropping local tsdown --watch usage.
CLI tsdown deps config
packages/cli/tsdown.config.ts
The CLI build config switches from external to deps.neverBundle for @anthropic-ai/claude-agent-sdk.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • hexclave/hexclave#1598: Touches packages/shared-backend/package.json’s dev script boundary and the shared tsdown config shape.
  • hexclave/hexclave#1639: Also adjusts bundling treatment for @anthropic-ai/claude-agent-sdk.

Poem

🐇 One watcher now hops from the root,
While package dev scripts change their route.
onSuccess hums after builds are done,
And IIFE steps follow, one by one.
Hop, build, and whisker-twitch — all set and soot!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and directly describes the shift to workspace-mode tsdown dev builds.
Description check ✅ Passed The description covers the workflow change, rationale, key script updates, and config migration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch devin/1782779680-tsdown-workspace-mode

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces 11 separate per-package tsdown --watch processes with a single root-level tsdown -W --watch (workspace mode), reducing dev-mode RAM from ~7.6 GB to ~224 MB. Packages that only had dev: "tsdown --watch" have that script removed; SDK packages keep dev only for codegen:watch; and dashboard-ui-components migrates its post-build IIFE steps into tsdown's onSuccess hook so they work correctly from both the workspace root and the package directory.

  • Root dev/dev:tui/dev:full/dev:basic scripts now launch tsdown -W --watch alongside turbo and the watch generators.
  • packages/dashboard-ui-components removes build-iife && copy-iife from the build script and moves them into an onSuccess callback in tsdown.config.ts, using import.meta.dirname to compute the correct CWD when invoked from the workspace root.
  • configs/tsdown/js-library.ts gains an optional onSuccess pass-through parameter.

Confidence Score: 4/5

Safe to merge. The change is purely a dev-workflow optimization with no effect on production build output paths.

The core optimization is sound: workspace mode replaces 11 redundant watch processes with one. The only behavioral change worth watching is that dashboard-ui-components's build-iife / copy-iife steps moved from being explicit shell commands in the build script to tsdown's onSuccess hook. tsdown fires onSuccess in non-watch builds today, so CI output is unchanged, but the dependency is now implicit and would be silently broken by a future tsdown release that restricts onSuccess to watch mode only.

packages/dashboard-ui-components/package.json and packages/dashboard-ui-components/tsdown.config.ts — the IIFE post-build steps are now driven by tsdown's onSuccess rather than the explicit build script chain.

Important Files Changed

Filename Overview
package.json Root dev scripts updated to add tsdown -W --watch as a concurrent process, replacing per-package watch invocations.
packages/dashboard-ui-components/tsdown.config.ts Adds an onSuccess hook that runs build-iife && copy-iife from the package directory; CI builds now rely on tsdown firing this hook in non-watch mode.
packages/dashboard-ui-components/package.json Removes dev script and removes explicit build-iife && copy-iife from build; those steps now live in the tsdown onSuccess hook.
configs/tsdown/js-library.ts Adds optional onSuccess parameter to createJsLibraryTsupConfig and threads it into defineConfig.
packages/js/package.json dev reduced to codegen:watch only; tsdown build now handled by workspace mode.
packages/cli/package.json Removes dev script (tsdown --watch); workspace mode handles the watch build. scripts/copy-runtime-assets.mjs was already not run in the old watch mode.
packages/template/package-template.json dev in the template reduced to codegen:watch; matches the same change applied to the concrete SDK packages.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["pnpm run dev / dev:full / dev:basic"] --> B["pnpm pre"]
    B --> C["concurrently -k"]
    C --> D["tsdown -W --watch\n(workspace root)"]
    C --> E["generate-sdks:watch"]
    C --> F["turbo run dev\n(apps + packages)"]

    D -->|"discovers all tsdown.config.ts"| G["packages/shared"]
    D --> H["packages/ui"]
    D --> I["packages/sc"]
    D --> J["packages/shared-backend"]
    D --> K["packages/cli"]
    D --> L["packages/js / next / react / tanstack-start / template"]
    D --> M["packages/dashboard-ui-components"]

    M -->|"onSuccess"| N["build-iife\n(pkgDir cwd)"]
    N --> O["copy-iife\n(pkgDir cwd)"]

    F -->|"SDK packages dev script\n(codegen:watch only)"| P["env:watch / css:watch"]

    style D fill:#22c55e,color:#fff
    style M fill:#f59e0b,color:#fff
    style N fill:#f59e0b,color:#fff
    style O fill:#f59e0b,color:#fff
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["pnpm run dev / dev:full / dev:basic"] --> B["pnpm pre"]
    B --> C["concurrently -k"]
    C --> D["tsdown -W --watch\n(workspace root)"]
    C --> E["generate-sdks:watch"]
    C --> F["turbo run dev\n(apps + packages)"]

    D -->|"discovers all tsdown.config.ts"| G["packages/shared"]
    D --> H["packages/ui"]
    D --> I["packages/sc"]
    D --> J["packages/shared-backend"]
    D --> K["packages/cli"]
    D --> L["packages/js / next / react / tanstack-start / template"]
    D --> M["packages/dashboard-ui-components"]

    M -->|"onSuccess"| N["build-iife\n(pkgDir cwd)"]
    N --> O["copy-iife\n(pkgDir cwd)"]

    F -->|"SDK packages dev script\n(codegen:watch only)"| P["env:watch / css:watch"]

    style D fill:#22c55e,color:#fff
    style M fill:#f59e0b,color:#fff
    style N fill:#f59e0b,color:#fff
    style O fill:#f59e0b,color:#fff
Loading
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
packages/dashboard-ui-components/tsdown.config.ts:9-11
The `onSuccess` callback is declared `async` but only calls `execSync` (which is entirely synchronous). The `async` wrapper is harmless — tsdown awaits the returned `Promise<void>` and `execSync` completes before the promise resolves — but it's misleading. Either drop `async` or replace `execSync` with the async `exec` from `node:child_process/promises` to make the intent clear.

```suggestion
  onSuccess: () => {
    execSync('pnpm run build-iife && pnpm run copy-iife', { cwd: pkgDir, stdio: 'inherit' });
  },
```

### Issue 2 of 3
packages/dashboard-ui-components/package.json:7
**CI build now silently depends on tsdown `onSuccess` for IIFE artifacts**

The old `build` script explicitly chained `pnpm run build-iife && pnpm run copy-iife` after `tsdown`, so the steps were guaranteed to run regardless of tsdown internals. The new script is just `rimraf dist && tsdown`, and the IIFE steps only execute if tsdown fires its `onSuccess` callback — which it does for both watch and non-watch builds today, but this is an implicit contract. If a future tsdown upgrade changes that behavior (e.g. `onSuccess` becomes watch-only), CI builds will silently produce an incomplete `dist` without any script-level error.

### Issue 3 of 3
package.json:60
**`dev:basic` now builds every package in the monorepo via workspace mode**

`dev:basic` is described as a lightweight setup (backend + mcp + dashboard + mock-oauth-server only), but `tsdown -W --watch` at the workspace root will discover and watch all `tsdown.config.ts` files across the repo, including packages not relevant to that setup. Each source-file change in any package will also trigger `dashboard-ui-components`'s `onSuccess` (running `build-iife && copy-iife`). This isn't a correctness issue, but it may surprise developers who reach for `dev:basic` specifically to reduce build overhead.

Reviews (1): Last reviewed commit: "Use tsdown workspace mode (-W) for dev: ..." | Re-trigger Greptile

Comment on lines +9 to +11
onSuccess: async () => {
execSync('pnpm run build-iife && pnpm run copy-iife', { cwd: pkgDir, stdio: 'inherit' });
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The onSuccess callback is declared async but only calls execSync (which is entirely synchronous). The async wrapper is harmless — tsdown awaits the returned Promise<void> and execSync completes before the promise resolves — but it's misleading. Either drop async or replace execSync with the async exec from node:child_process/promises to make the intent clear.

Suggested change
onSuccess: async () => {
execSync('pnpm run build-iife && pnpm run copy-iife', { cwd: pkgDir, stdio: 'inherit' });
},
onSuccess: () => {
execSync('pnpm run build-iife && pnpm run copy-iife', { cwd: pkgDir, stdio: 'inherit' });
},
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/dashboard-ui-components/tsdown.config.ts
Line: 9-11

Comment:
The `onSuccess` callback is declared `async` but only calls `execSync` (which is entirely synchronous). The `async` wrapper is harmless — tsdown awaits the returned `Promise<void>` and `execSync` completes before the promise resolves — but it's misleading. Either drop `async` or replace `execSync` with the async `exec` from `node:child_process/promises` to make the intent clear.

```suggestion
  onSuccess: () => {
    execSync('pnpm run build-iife && pnpm run copy-iife', { cwd: pkgDir, stdio: 'inherit' });
  },
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in 2ce9308 — dropped async.

"repository": "https://github.com/hexclave/hexclave",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 CI build now silently depends on tsdown onSuccess for IIFE artifacts

The old build script explicitly chained pnpm run build-iife && pnpm run copy-iife after tsdown, so the steps were guaranteed to run regardless of tsdown internals. The new script is just rimraf dist && tsdown, and the IIFE steps only execute if tsdown fires its onSuccess callback — which it does for both watch and non-watch builds today, but this is an implicit contract. If a future tsdown upgrade changes that behavior (e.g. onSuccess becomes watch-only), CI builds will silently produce an incomplete dist without any script-level error.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/dashboard-ui-components/package.json
Line: 7

Comment:
**CI build now silently depends on tsdown `onSuccess` for IIFE artifacts**

The old `build` script explicitly chained `pnpm run build-iife && pnpm run copy-iife` after `tsdown`, so the steps were guaranteed to run regardless of tsdown internals. The new script is just `rimraf dist && tsdown`, and the IIFE steps only execute if tsdown fires its `onSuccess` callback — which it does for both watch and non-watch builds today, but this is an implicit contract. If a future tsdown upgrade changes that behavior (e.g. `onSuccess` becomes watch-only), CI builds will silently produce an incomplete `dist` without any script-level error.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in 2ce9308 — restored the explicit && pnpm run build-iife && pnpm run copy-iife chain in the build script. The onSuccess in tsdown.config.ts now only matters for workspace watch mode; CI builds use the explicit script chain.

Comment thread package.json Outdated
"dev:inspect": "pnpm pre && STACK_BACKEND_DEV_EXTRA_ARGS=\"--inspect\" pnpm run dev",
"dev:profile": "pnpm pre && STACK_BACKEND_DEV_EXTRA_ARGS=\"--experimental-cpu-prof\" pnpm run dev",
"dev:basic": "pnpm pre && concurrently -k \"pnpm run generate-sdks:watch\" \"turbo run dev --concurrency 99999 --filter=@hexclave/backend --filter=@hexclave/mcp --filter=@hexclave/dashboard --filter=@hexclave/mock-oauth-server\"",
"dev:basic": "pnpm pre && concurrently -k \"tsdown -W --watch\" \"pnpm run generate-sdks:watch\" \"turbo run dev --concurrency 99999 --filter=@hexclave/backend --filter=@hexclave/mcp --filter=@hexclave/dashboard --filter=@hexclave/mock-oauth-server\"",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 dev:basic now builds every package in the monorepo via workspace mode

dev:basic is described as a lightweight setup (backend + mcp + dashboard + mock-oauth-server only), but tsdown -W --watch at the workspace root will discover and watch all tsdown.config.ts files across the repo, including packages not relevant to that setup. Each source-file change in any package will also trigger dashboard-ui-components's onSuccess (running build-iife && copy-iife). This isn't a correctness issue, but it may surprise developers who reach for dev:basic specifically to reduce build overhead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: package.json
Line: 60

Comment:
**`dev:basic` now builds every package in the monorepo via workspace mode**

`dev:basic` is described as a lightweight setup (backend + mcp + dashboard + mock-oauth-server only), but `tsdown -W --watch` at the workspace root will discover and watch all `tsdown.config.ts` files across the repo, including packages not relevant to that setup. Each source-file change in any package will also trigger `dashboard-ui-components`'s `onSuccess` (running `build-iife && copy-iife`). This isn't a correctness issue, but it may surprise developers who reach for `dev:basic` specifically to reduce build overhead.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Intentional tradeoff. Workspace mode uses ~224 MB total for all 11 packages (vs 7.6 GB separate), so building "extra" packages costs almost nothing in memory. The alternative would require listing 10 package filters explicitly which is fragile and hard to maintain. The whole point of workspace mode is that one process handles everything cheaply.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a fair point — the memory savings are so dramatic that the "extra" packages in dev:basic are essentially free, and explicit per-package filters would be a maintenance burden. Makes sense.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
configs/tsdown/js-library.ts (1)

45-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Derive onSuccess from tsdown’s config type. The wrapper re-declares this as string | ((...args: unknown[]) => void), but tsdown’s hook is string | ((config, signal) => void | Promise<void>); reusing the upstream type keeps the signature and async support aligned.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@configs/tsdown/js-library.ts` around lines 45 - 53, The
createJsLibraryTsupConfig wrapper is re-declaring the onSuccess hook with an
outdated signature, so update it to derive the type from tsdown’s config type
instead of using a local string | ((...args: unknown[]) => void) union. Keep the
implementation in createJsLibraryTsupConfig aligned with the upstream onSuccess
contract so it accepts the same config and signal parameters and supports async
returns, and use the existing defineConfig entry point to preserve the inferred
hook type.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/js/package.json`:
- Line 55: The change was made directly in packages/js/package.json, but this
package must not be edited in place; move the update to the corresponding source
in packages/template and then regenerate or sync packages/js from there. Locate
the affected script entry in package.json and ensure the template copy is the
only place updated so the generated package stays consistent.

---

Nitpick comments:
In `@configs/tsdown/js-library.ts`:
- Around line 45-53: The createJsLibraryTsupConfig wrapper is re-declaring the
onSuccess hook with an outdated signature, so update it to derive the type from
tsdown’s config type instead of using a local string | ((...args: unknown[]) =>
void) union. Keep the implementation in createJsLibraryTsupConfig aligned with
the upstream onSuccess contract so it accepts the same config and signal
parameters and supports async returns, and use the existing defineConfig entry
point to preserve the inferred hook type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 79e9d85d-7103-4537-b70f-1022f7188036

📥 Commits

Reviewing files that changed from the base of the PR and between 6bbc792 and d62b08e.

📒 Files selected for processing (15)
  • configs/tsdown/js-library.ts
  • package.json
  • packages/cli/package.json
  • packages/dashboard-ui-components/package.json
  • packages/dashboard-ui-components/tsdown.config.ts
  • packages/js/package.json
  • packages/next/package.json
  • packages/react/package.json
  • packages/sc/package.json
  • packages/shared-backend/package.json
  • packages/shared/package.json
  • packages/tanstack-start/package.json
  • packages/template/package-template.json
  • packages/template/package.json
  • packages/ui/package.json
💤 Files with no reviewable changes (5)
  • packages/shared-backend/package.json
  • packages/shared/package.json
  • packages/cli/package.json
  • packages/ui/package.json
  • packages/sc/package.json

Comment thread packages/js/package.json Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/dashboard-ui-components/tsdown.config.ts (1)

9-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document why this hook is cwd-bound.

This works because the workspace watcher now runs from the repo root while the post-build scripts still have to execute from this package. A short comment here would keep someone from “simplifying” away cwd: pkgDir later.

Suggested comment
+  // Workspace watch runs from the repo root; keep these post-build scripts
+  // pinned to this package directory so they work from either entry point.
   onSuccess: () => {
     execSync('pnpm run build-iife && pnpm run copy-iife', { cwd: pkgDir, stdio: 'inherit' });
   },

As per coding guidelines, "When you fix an obscure bug or make a small change from complex thought, add a concise comment explaining the thought in detail to avoid re-learning decisions."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dashboard-ui-components/tsdown.config.ts` around lines 9 - 11, Add a
short inline comment in the onSuccess hook in tsdown.config.ts explaining that
execSync must stay cwd-bound to pkgDir because the workspace watcher runs from
the repo root while the post-build scripts must execute from this package. Keep
the existing cwd: pkgDir behavior in the onSuccess callback and annotate it near
execSync so future refactors do not remove it.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/dashboard-ui-components/package.json`:
- Line 9: The build script in package.json is still invoking build-iife and
copy-iife even though tsdown.config.ts already runs those steps in onSuccess, so
the IIFE work is duplicated. Update the build command to leave IIFE
generation/copying to tsdown.config.ts only, and remove the extra pnpm run
build-iife and pnpm run copy-iife calls from the build script.

---

Nitpick comments:
In `@packages/dashboard-ui-components/tsdown.config.ts`:
- Around line 9-11: Add a short inline comment in the onSuccess hook in
tsdown.config.ts explaining that execSync must stay cwd-bound to pkgDir because
the workspace watcher runs from the repo root while the post-build scripts must
execute from this package. Keep the existing cwd: pkgDir behavior in the
onSuccess callback and annotate it near execSync so future refactors do not
remove it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a7f1c655-7adf-4fd2-9283-8c4fc5230eae

📥 Commits

Reviewing files that changed from the base of the PR and between d62b08e and 2ce9308.

📒 Files selected for processing (2)
  • packages/dashboard-ui-components/package.json
  • packages/dashboard-ui-components/tsdown.config.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/dashboard-ui-components/tsdown.config.ts">

<violation number="1" location="packages/dashboard-ui-components/tsdown.config.ts:10">
P2: Synchronous `execSync` blocks the shared Rolldown process in workspace mode. Consider using `exec` (async) from `node:child_process` wrapped in a promise so tsdown's event loop is not blocked during IIFE build/copy.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread package.json Resolved
tsdown -W --watch hangs with 21 concurrent Rolldown watchers (11 packages × 2
formats). Replace with chokidar watching package source dirs and triggering
one-shot tsdown -W builds on changes. Same memory savings (~58MB chokidar vs
7.6GB for 11 persistent tsdown processes), with working file change detection.

Co-Authored-By: Konstantin Wohlwend <[email protected]>
Copilot AI review requested due to automatic review settings June 30, 2026 02:53
@N2D4
N2D4 removed the request for review from Copilot June 30, 2026 02:53
@devin-ai-integration devin-ai-integration Bot changed the title Use tsdown -W (workspace mode) for dev: 7.6 GB → 224 MB Use tsdown -W (workspace mode) for dev builds Jun 30, 2026
Template, CLI, and generated SDK packages were still on ^0.20.3, which
doesn't support the new deps config format (deps.alwaysBundle, etc.).

Co-Authored-By: Konstantin Wohlwend <[email protected]>
Also regenerated lockfile from scratch to ensure all specifiers match.

Co-Authored-By: Konstantin Wohlwend <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 10 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/cli/package.json">

<violation number="1" location="packages/cli/package.json:42">
P1: CLI workspace builds skip required runtime asset copy</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/cli/package.json
@@ -11,7 +11,6 @@
"scripts": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: CLI workspace builds skip required runtime asset copy

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/cli/package.json, line 42:

<comment>CLI workspace builds skip required runtime asset copy</comment>

<file context>
@@ -39,7 +39,7 @@
     "@types/node": "20.17.6",
     "rimraf": "^6.0.1",
-    "tsdown": "^0.20.3",
+    "tsdown": "^0.22.3",
     "typescript": "6.0.3"
   },
</file context>

devin-ai-integration Bot and others added 2 commits June 30, 2026 17:51
- Add unrun as explicit devDependency (required peer dep of tsdown 0.22.3)
- Remove onSuccess hook from dashboard-ui-components tsdown config (causes
  race condition in workspace mode where build-iife runs before shared/ui
  packages are built)
- Restore chokidar-based watch mode since tsdown -W --watch still hangs
  with 11 packages (rolldown semaphore bug not fixed in 1.1.2)
- build-packages:watch now runs tsdown -W one-shot then build-iife, with
  chokidar watching for changes

Co-Authored-By: Konstantin Wohlwend <[email protected]>
…rolldown watcher deadlock

Root cause: rolldown's native watcher creates one thread pool per build config.
The DTS plugin doubles the watcher count, and dual format (ESM+CJS) doubles it
again. With 11 packages, this exceeds rolldown's concurrency limit and causes
a deadlock (rolldown/tsdown#789, rolldown/rolldown#8643).

Fix: conditionally disable DTS and CJS in watch mode via defineConfig callback.
Production builds (tsdown -W without --watch) retain full DTS + dual format.

Also: pin rolldown to 1.1.2 (1.1.3 fails 7-day minimumReleaseAge until Jul 1),
regenerate lockfile from base branch to pass supply-chain policy.

Co-Authored-By: Konstantin Wohlwend <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="package.json">

<violation number="1" location="package.json:85">
P1: The dashboard-ui-components IIFE build/copy steps were removed from the watch rebuild loop but the replacement `onSuccess` hook was never added to `packages/dashboard-ui-components/tsdown.config.ts`. During `tsdown -W --watch`, the IIFE artifacts will become stale after the first source change because there is no mechanism to re-run `build-iife` and `copy-iife` after subsequent workspace rebuilds.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread package.json
"generate-openapi-docs:watch": "pnpm exec tsx ./scripts/wait-for-dev-package-imports.ts && pnpm run --filter=@hexclave/backend codegen-docs && chokidar --silent -c 'pnpm run --filter=@hexclave/backend codegen-docs' './apps/backend/src/app/api/latest/**/route.{js,jsx,ts,tsx}' './apps/backend/src/lib/openapi.ts' './packages/shared/src/interface/webhooks.ts' --throttle 2000",
"generate-setup-prompt-docs:watch": "pnpm run generate-setup-prompt-docs && chokidar --silent -c 'pnpm run generate-setup-prompt-docs' './docs-mintlify/docs.json' './packages/shared/src/ai/unified-prompts/**/*.ts' './scripts/generate-setup-prompt-docs.ts' --throttle 2000"
"generate-setup-prompt-docs:watch": "pnpm run generate-setup-prompt-docs && chokidar --silent -c 'pnpm run generate-setup-prompt-docs' './docs-mintlify/docs.json' './packages/shared/src/ai/unified-prompts/**/*.ts' './scripts/generate-setup-prompt-docs.ts' --throttle 2000",
"build-packages:watch": "tsdown -W && pnpm -C packages/dashboard-ui-components run build-iife && pnpm -C packages/dashboard-ui-components run copy-iife && tsdown -W --watch"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: The dashboard-ui-components IIFE build/copy steps were removed from the watch rebuild loop but the replacement onSuccess hook was never added to packages/dashboard-ui-components/tsdown.config.ts. During tsdown -W --watch, the IIFE artifacts will become stale after the first source change because there is no mechanism to re-run build-iife and copy-iife after subsequent workspace rebuilds.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At package.json, line 85:

<comment>The dashboard-ui-components IIFE build/copy steps were removed from the watch rebuild loop but the replacement `onSuccess` hook was never added to `packages/dashboard-ui-components/tsdown.config.ts`. During `tsdown -W --watch`, the IIFE artifacts will become stale after the first source change because there is no mechanism to re-run `build-iife` and `copy-iife` after subsequent workspace rebuilds.</comment>

<file context>
@@ -82,7 +82,7 @@
     "generate-openapi-docs:watch": "pnpm exec tsx ./scripts/wait-for-dev-package-imports.ts && pnpm run --filter=@hexclave/backend codegen-docs && chokidar --silent -c 'pnpm run --filter=@hexclave/backend codegen-docs' './apps/backend/src/app/api/latest/**/route.{js,jsx,ts,tsx}' './apps/backend/src/lib/openapi.ts' './packages/shared/src/interface/webhooks.ts' --throttle 2000",
     "generate-setup-prompt-docs:watch": "pnpm run generate-setup-prompt-docs && chokidar --silent -c 'pnpm run generate-setup-prompt-docs' './docs-mintlify/docs.json' './packages/shared/src/ai/unified-prompts/**/*.ts' './scripts/generate-setup-prompt-docs.ts' --throttle 2000",
-    "build-packages:watch": "tsdown -W && pnpm -C packages/dashboard-ui-components run build-iife && pnpm -C packages/dashboard-ui-components run copy-iife && chokidar --silent -c 'tsdown -W && pnpm -C packages/dashboard-ui-components run build-iife && pnpm -C packages/dashboard-ui-components run copy-iife' './packages/*/src/**/*.(ts|tsx)' './configs/tsdown/**/*.(ts|tsx)' './packages/*/tsdown.config.ts' --ignore '**/node_modules/**' --ignore '**/dist/**' --ignore '**/.turbo/**' --throttle 2000"
+    "build-packages:watch": "tsdown -W && pnpm -C packages/dashboard-ui-components run build-iife && pnpm -C packages/dashboard-ui-components run copy-iife && tsdown -W --watch"
   },
   "devDependencies": {
</file context>

This branch had an error being deployed

1 failed and 4 active deployments
Preview – stack-preview-backend — 316ba6bd Deployed Jun 30, 2026 by vercel[bot]
Preview – stack-preview-dashboard — 316ba6bd Deployed Jun 30, 2026 by vercel[bot]
Preview – stack-auth-internal-tool — 316ba6bd Deployed Jun 30, 2026 by vercel[bot]
Preview – stack-auth-skills — 316ba6bd Deployed Jun 30, 2026 by vercel[bot]
Preview – stack-auth-mcp — 316ba6bd Deployed Jun 30, 2026 by vercel[bot]
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.

1 participant