Skip to content

Optimize package builds for faster outputs - #1791

Open
mantrakp04 wants to merge 2 commits into
devfrom
codex/optimize-builds-for-speed
Open

mantrakp04 wants to merge 2 commits into
devfrom
codex/optimize-builds-for-speed

Conversation

@mantrakp04

@mantrakp04 mantrakp04 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Exclude test files and duplicate ESM declarations from library builds
  • Refine Turbo build outputs and environment tracking
  • Stop publishing package source files
  • Upgrade Turbo and streamline pnpm setup scripts

Testing

Not run (not requested)


Summary by cubic

Speeds up package builds and trims published artifacts by excluding tests, stopping source publication, and avoiding duplicate ESM type output. Refines turbo outputs and env scoping to improve caching and build times, upgrades turbo, and adds workspace typings for tsdown configs.

  • Refactors

    • Exclude *.test.* and *.spec.* from tsup entries in configs/tsdown/js-library.ts.
    • Set ESM dts: false to emit types once from dist, reducing work and artifacts.
    • Stop publishing src folders by removing them from files in package manifests.
    • Update turbo.json outputs to .next/** (excluding .next/cache/**) and scope envs for @hexclave/* builds (NEXT_PUBLIC_HEXCLAVE_*, VITE_HEXCLAVE_*, etc.) to avoid unnecessary cache busting.
    • Simplify setup scripts to use only-allow pnpm.
    • Add configs/tsdown/tsconfig.json and set VS Code to use workspace TypeScript (js/ts.tsdk.path) for correct IDE typings in build configs.
  • Dependencies

    • Upgrade turbo to ^2.10.5.
    • Refresh pnpm-lock.yaml, bumping @supabase/supabase-js and related packages.

Written for commit 6f508dc. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Build Improvements
    • Library builds now exclude test/spec files from compilation inputs.
    • Declaration generation is disabled for the ESM output to prevent duplicate type artifacts.
    • Build caching now more accurately tracks environment changes for more reliable rebuilds.
  • Package Distribution
    • Published packages no longer include src; only build output plus docs (README/CHANGELOG/LICENSE) are shipped.
  • Maintenance
    • Updated build tooling/versioning and tightened package-manager checks.
    • Added stricter TypeScript settings for tsdown-related code and refreshed a VS Code TypeScript SDK setting.

Copilot AI review requested due to automatic review settings July 22, 2026 01:27
@vercel

vercel Bot commented Jul 22, 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 Jul 24, 2026 5:49pm
stack-auth-internal-tool Error Error Jul 24, 2026 5:49pm
stack-auth-mcp Ready Ready Preview, Comment Jul 24, 2026 5:49pm
stack-auth-skills Ready Ready Preview, Comment Jul 24, 2026 5:49pm
stack-backend Ready Ready Preview, Comment Jul 24, 2026 5:49pm
stack-dashboard Ready Ready Preview, Comment Jul 24, 2026 5:49pm
stack-demo Ready Ready Preview, Comment Jul 24, 2026 5:49pm
stack-docs Error Error Jul 24, 2026 5:49pm
stack-preview-backend Ready Ready Preview, Comment Jul 24, 2026 5:49pm
stack-preview-dashboard Ready Ready Preview, Comment Jul 24, 2026 5:49pm

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The changes exclude test files and duplicate declarations from library builds, remove source directories from published packages, update package-manager scripts and Turbo, add tsdown TypeScript settings, and configure VS Code to use the repository TypeScript SDK.

Changes

Build and package distribution

Layer / File(s) Summary
Library build outputs
configs/tsdown/js-library.ts, configs/tsdown/tsconfig.json
Library entry globs exclude *.test.* and *.spec.* files, the non-watch ESM output disables declaration emission, and tsdown TypeScript files receive a strict no-emit configuration.
Published package contents
packages/*/package.json, packages/template/package-template.json
Package publish allowlists remove src and retain or add README.md, dist, CHANGELOG.md, and LICENSE.
Repository scripts and Turbo tasks
package.json, turbo.json
Lifecycle commands invoke only-allow pnpm directly, Turbo is upgraded, and task environment inputs and .next output globs are refined.
TypeScript editor configuration
.vscode/settings.json
VS Code is configured to use node_modules/typescript/lib as the TypeScript SDK path.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: n2d4

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title is concise and matches the primary change: optimizing package builds.
Description check ✅ Passed The description covers the main changes and testing status, and the template has no additional required sections.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/optimize-builds-for-speed

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.

@vercel vercel 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.

Additional Suggestion:

Removing NEXT_PUBLIC_*/VITE_* from turbo.json globalEnv strips these vars from default build tasks under Turbo 2.x strict env mode, breaking prerender for apps like @hexclave/internal-tool.

Fix on Vercel

@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 15 files

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="turbo.json">

<violation number="1" location="turbo.json:163">
P2: The build outputs for `@hexclave/hosted-components` and `@hexclave/example-tanstack-start-demo` won't be cached by Turbo. Both use `vite build` (Nitro/TanStack Start) which outputs to `.output/`, but the inherited root `build` outputs only track `.next/**` and `dist/**`. Every invocation will run a full Vite/Nitro build even when nothing changed. Add a package-specific `outputs` entry like `".output/**"` and/or `"!.output/server/**"` to match the actual output and enable caching.</violation>
</file>

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

Re-trigger cubic

Comment thread turbo.json
"VITE_STACK_*"
]
},
"@hexclave/hosted-components#build": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The build outputs for @hexclave/hosted-components and @hexclave/example-tanstack-start-demo won't be cached by Turbo. Both use vite build (Nitro/TanStack Start) which outputs to .output/, but the inherited root build outputs only track .next/** and dist/**. Every invocation will run a full Vite/Nitro build even when nothing changed. Add a package-specific outputs entry like ".output/**" and/or "!.output/server/**" to match the actual output and enable caching.

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

<comment>The build outputs for `@hexclave/hosted-components` and `@hexclave/example-tanstack-start-demo` won't be cached by Turbo. Both use `vite build` (Nitro/TanStack Start) which outputs to `.output/`, but the inherited root `build` outputs only track `.next/**` and `dist/**`. Every invocation will run a full Vite/Nitro build even when nothing changed. Add a package-specific `outputs` entry like `".output/**"` and/or `"!.output/server/**"` to match the actual output and enable caching.</comment>

<file context>
@@ -101,28 +101,81 @@
+        "VITE_STACK_*"
+      ]
+    },
+    "@hexclave/hosted-components#build": {
+      "dependsOn": [
+        "^build"
</file context>

@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

🤖 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 @.vscode/settings.json:
- Line 188: Update the VS Code TypeScript settings alongside js/ts.tsdk.path to
enable prompting for the workspace TypeScript version, ensuring fresh clones can
use the repository version for IntelliSense without requiring manual selection.
🪄 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 Plus

Run ID: e73f3f73-42d3-4a70-914c-accfc42ed389

📥 Commits

Reviewing files that changed from the base of the PR and between 7e33457 and 6f508dc.

📒 Files selected for processing (2)
  • .vscode/settings.json
  • configs/tsdown/tsconfig.json

Comment thread .vscode/settings.json
"git.ignoreLimitWarning": true,
"chatgpt.commentCodeLensEnabled": false
"chatgpt.commentCodeLensEnabled": false,
"js/ts.tsdk.path": "node_modules/typescript/lib"

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== .vscode/settings.json tsdk settings =="
if [ -f .vscode/settings.json ]; then
  nl -ba .vscode/settings.json | sed -n '170,195p'
else
  echo ".vscode/settings.json not found"
fi

echo "== TypeScript declarations =="
if [ -f package.json ]; then
  node -e 'const p=require("./package.json"); console.log(JSON.stringify({dependencies:p.dependencies,devDependencies:p.devDependencies},null,2))' | sed -n '/"typescript"/,+4p'
fi

echo "== VS Code config references to tsdk/packageInfo/enforce =="
rg -n --hidden --glob '.vscode/settings.json' --glob 'README.md' --glob '*.md' --glob '*.yml' --glob '*.yaml' --glob 'package.json' \
  'tsdk|TypeScript: Select TypeScript Version|packageInfo|workspace trust|typescript' .vscode README.md package.json 2>/dev/null || true

Repository: hexclave/hexclave

Length of output: 237


🌐 Web query:

VS Code TypeScript workspace setting js/ts.tsdk.path select TypeScript Version documentation

💡 Result:

To configure Visual Studio Code to use a specific version of TypeScript for your workspace, you should use the js/ts.tsdk.path setting [1][2]. This setting replaced the deprecated typescript.tsdk ID as part of a unification of JavaScript and TypeScript settings [3][4]. Steps to use a workspace TypeScript version: 1. Installation: Ensure you have installed the desired version of TypeScript locally in your project, typically in your node_modules directory [1][2]. 2. Configure Path: Add the js/ts.tsdk.path setting to your.vscode/settings.json file, pointing to the directory containing the tsserver.js file (usually the lib folder) [1][2][5]. { "js/ts.tsdk.path": "./node_modules/typescript/lib" } 3. Select Version: Simply defining this path in your workspace settings makes the TypeScript version available to VS Code [1][5]. To begin using this version for IntelliSense, you must manually run the TypeScript: Select TypeScript Version command from the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and choose the workspace version [1][6][2]. Note that when the setting is defined in your workspace, VS Code does not automatically switch to it; you must perform the manual selection step mentioned above [1][2][7]. If you want VS Code to prompt you to use the workspace version when opening the project, you can add the following to your settings [8][7]: { "js/ts.tsdk.promptToUseWorkspaceVersion": true } The js/ts.tsdk.path setting must point to a valid full TypeScript installation that includes the package.json file [5]. For further details on managing TypeScript versions, you can refer to the official Visual Studio Code documentation on TypeScript transpiling [2][5].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== .vscode/settings.json tsdk settings =="
if [ -f .vscode/settings.json ]; then
  awk '{printf "%6d\t%s\n", NR, $0}' .vscode/settings.json | sed -n '170,195p'
else
  echo ".vscode/settings.json not found"
fi

echo "== TypeScript declarations in package.json =="
if [ -f package.json ]; then
  awk '
    /"typescript"/ {
      print
      # print next two lines if they are part of same dependency block
      for (i=1;i<=2;i++) { getline; print }
    }
  ' package.json
fi

echo "== Related VS Code/TypeScript references =="
rg -n --hidden --glob '.vscode/settings.json' --glob 'README.md' --glob '*.md' --glob '*.yml' --glob '*.yaml' --glob 'package.json' \
  'js/ts\.tsdk\.path|typescript\.tsdk|Select TypeScript Version|promptToUseWorkspaceVersion|workspace trust|typescript' .vscode README.md package.json 2>/dev/null || true

Repository: hexclave/hexclave

Length of output: 2416


Prompt to use the workspace TypeScript version

js/ts.tsdk.path only exposes node_modules/typescript/lib to VS Code; users still need to run TypeScript: Select TypeScript Version and choose the workspace version. Add js/ts.tsdk.promptToUseWorkspaceVersion: true or another mechanism if fresh clones are expected to use the repository TypeScript version for IntelliSense.

🤖 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 @.vscode/settings.json at line 188, Update the VS Code TypeScript settings
alongside js/ts.tsdk.path to enable prompting for the workspace TypeScript
version, ensuring fresh clones can use the repository version for IntelliSense
without requiring manual selection.

@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 2 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=".vscode/settings.json">

<violation number="1" location=".vscode/settings.json:188">
P3: The `js/ts.tsdk.path` setting tells VS Code where to find the workspace TypeScript, but without the companion `js/ts.tsdk.promptToUseWorkspaceVersion: true` setting, users on fresh clones won't be prompted to actually use it — they'll silently get VS Code's built-in TypeScript for IntelliSense instead.

Consider adding:
```json
"js/ts.tsdk.promptToUseWorkspaceVersion": true
```</violation>
</file>

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

Re-trigger cubic

Comment thread .vscode/settings.json
"git.ignoreLimitWarning": true,
"chatgpt.commentCodeLensEnabled": false
"chatgpt.commentCodeLensEnabled": false,
"js/ts.tsdk.path": "node_modules/typescript/lib"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The js/ts.tsdk.path setting tells VS Code where to find the workspace TypeScript, but without the companion js/ts.tsdk.promptToUseWorkspaceVersion: true setting, users on fresh clones won't be prompted to actually use it — they'll silently get VS Code's built-in TypeScript for IntelliSense instead.

Consider adding:

"js/ts.tsdk.promptToUseWorkspaceVersion": true
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .vscode/settings.json, line 188:

<comment>The `js/ts.tsdk.path` setting tells VS Code where to find the workspace TypeScript, but without the companion `js/ts.tsdk.promptToUseWorkspaceVersion: true` setting, users on fresh clones won't be prompted to actually use it — they'll silently get VS Code's built-in TypeScript for IntelliSense instead.

Consider adding:
```json
"js/ts.tsdk.promptToUseWorkspaceVersion": true
```</comment>

<file context>
@@ -184,5 +184,6 @@
   "git.ignoreLimitWarning": true,
-  "chatgpt.commentCodeLensEnabled": false
+  "chatgpt.commentCodeLensEnabled": false,
+  "js/ts.tsdk.path": "node_modules/typescript/lib"
 }
</file context>
Suggested change
"js/ts.tsdk.path": "node_modules/typescript/lib"
"js/ts.tsdk.path": "node_modules/typescript/lib",
"js/ts.tsdk.promptToUseWorkspaceVersion": true

@mantrakp04
mantrakp04 requested a review from N2D4 August 4, 2026 22:01
Comment thread package.json
"pre-no-codegen": "pnpm exec only-allow pnpm",
"pre-preinstall": "pnpx only-allow@1.2.2 pnpm && node -e \"if(process.env.HEXCLAVE_SKIP_TEMPLATE_GENERATION !== 'true') require('child_process').execSync('pnpm exec tsx ./scripts/generate-sdks.ts', {stdio: 'inherit'})\"",
"pre-no-codegen": "only-allow pnpm",
"pre-preinstall": "only-allow pnpm && node -e \"if(process.env.HEXCLAVE_SKIP_TEMPLATE_GENERATION !== 'true') require('child_process').execSync('pnpm exec tsx ./scripts/generate-sdks.ts', {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.

i don't think this will work because it needs to run pre install — we don't have only-allow installed yet at that point

"files": [
"README.md",
"dist",
"src",

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.

the reason we had this is because ai agents use it to infer things about the source code

Comment thread turbo.json
Comment on lines -9 to -10
"NEXT_PUBLIC_*",
"VITE_*",

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.

why do we make this change?

This branch had an error being deployed

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

3 participants