Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/claude-tsgo-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tailor-platform/sdk": patch
---

Build the SDK with tsgo (file-by-file ESM emit) plus a postbuild script instead of the tsdown bundler. The published package is no longer a single bundle: modules are emitted per file and third-party dependencies resolve from the consumer's `node_modules` at runtime. The private `@tailor-platform/tailor-proto` workspace package is vendored into `dist/_proto` so the unbundled output stays self-contained. No public API changes.
35 changes: 1 addition & 34 deletions .github/workflows/sdk-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,6 @@ jobs:
RUN_ID: ${{ github.run_id }}
run: pnpm --filter @tailor-platform/sdk exec tsx scripts/cleanup-e2e-workspaces.ts --run-id="$RUN_ID"

bundle-size:
if: github.event.action != 'synchronize' || github.event.sender.login != 'tailor-pr-trigger[bot]'
name: Bundle Size
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- name: Install deps
uses: ./.github/actions/install-deps

- name: Measure bundle size
run: pnpm --filter @tailor-platform/sdk measure:bundle

- name: Upload results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: bundle-size-results
path: packages/sdk/bundle-size.json

type-performance:
if: github.event.action != 'synchronize' || github.event.sender.login != 'tailor-pr-trigger[bot]'
name: Type Performance
Expand Down Expand Up @@ -174,7 +149,7 @@ jobs:

report-metrics:
name: Report Metrics
needs: [coverage-shard, bundle-size, type-performance, runtime-performance]
needs: [coverage-shard, type-performance, runtime-performance]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
Expand Down Expand Up @@ -211,13 +186,6 @@ jobs:
echo "See octocov report below for coverage details."
echo ""

echo "## Bundle Size"
echo ""
echo "| Metric | Value |"
echo "|--------|------:|"
jq -r '.metrics[] | "| \(.name) | \(.value) \(.unit) |"' artifacts/bundle-size-results/bundle-size.json
echo ""

echo "## Type Check Performance"
echo ""
echo "| Feature | Instantiations | Types |"
Expand All @@ -240,5 +208,4 @@ jobs:
config: packages/sdk/.octocov.yml
env:
OCTOCOV_CUSTOM_METRICS_TYPE_PERFORMANCE: artifacts/type-perf-results/diagnostics.json
OCTOCOV_CUSTOM_METRICS_BUNDLE_SIZE: artifacts/bundle-size-results/bundle-size.json
OCTOCOV_CUSTOM_METRICS_RUNTIME_PERFORMANCE: artifacts/runtime-perf-results/runtime-perf.json
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ lerna-debug.log*
# Eslint cache
.eslintcache

# Bundle analysis
.sonda/
bundle-size.json

# Coverage directory used by tools like istanbul
coverage/
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ diagnostics.json
diagnostics-summary.json
runtime-perf.json
runtime-perf-summary.json
bundle-size.json
scripts/perf/tsconfig.temp.json

# Integration test fixtures output
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/.octocov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ summary:
if: true
# Custom metrics are specified via environment variables:
# - OCTOCOV_CUSTOM_METRICS_TYPE_PERFORMANCE: diagnostics.json
# - OCTOCOV_CUSTOM_METRICS_BUNDLE_SIZE: bundle-size.json
# - OCTOCOV_CUSTOM_METRICS_RUNTIME_PERFORMANCE: runtime-perf.json
26 changes: 26 additions & 0 deletions packages/sdk/knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
"$schema": "https://unpkg.com/knip@6/schema.json",
"ignoreExportsUsedInFile": true,
"tags": ["-lintignore"],
"entry": [
"src/configure/index.ts",
"src/cli/index.ts",
"src/cli/lib.ts",
"src/cli/skills.ts",
"src/utils/test/index.ts",
"src/kysely/index.ts",
"src/plugin/index.ts",
"src/plugin/builtin/kysely-type/index.ts",
"src/plugin/builtin/enum-constants/index.ts",
"src/plugin/builtin/file-utils/index.ts",
"src/plugin/builtin/seed/index.ts",
"src/seed/index.ts",
"src/vitest/index.ts",
"src/vitest/environment.ts",
"src/vitest/setup.ts",
"src/runtime/index.ts",
"src/runtime/globals.ts",
"src/runtime/iconv.ts",
"src/runtime/secretmanager.ts",
"src/runtime/authconnection.ts",
"src/runtime/idp.ts",
"src/runtime/workflow.ts",
"src/runtime/context.ts",
"src/runtime/file.ts"
],
"ignore": [
"scripts/**",
"e2e/fixtures/**",
Expand Down
5 changes: 1 addition & 4 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"test:coverage": "vitest --coverage",
"docs:check": "vitest run --project=unit* src/cli/docs.test.ts",
"docs:update": "POLITTY_DOCS_UPDATE=true vitest run --project=unit* src/cli/docs.test.ts",
"build": "tsdown && politty generate-worker --bin dist/cli/index.mjs --program tailor-sdk --shell zsh --verify",
"build": "node scripts/build-tsgo.mjs && politty generate-worker --bin dist/cli/index.mjs --program tailor-sdk --shell zsh --verify",
"lint": "oxlint --type-aware .",
"check:public-api-jsdoc": "tsx scripts/check-public-api-jsdoc.ts",
"check:zod-isolation": "tsx scripts/check-zod-isolation.ts",
Expand All @@ -153,7 +153,6 @@
"perf:runtime": "bash scripts/perf/runtime-perf.sh",
"prepublish": "pnpm run build",
"postinstall": "node postinstall.mjs",
"measure:bundle": "node ../../scripts/measure-bundle-size-sonda.js",
"knip": "knip",
"publint": "publint --strict",
"generate": "zinfer && node -e \"const f=require('fs').readdirSync('src/types').filter(f=>f.endsWith('.generated.ts')).map(f=>'src/types/'+f);if(f.length)require('child_process').execSync('pnpm oxfmt --write '+f.join(' '),{stdio:'inherit'})\""
Expand Down Expand Up @@ -222,8 +221,6 @@
"oxfmt": "0.54.0",
"oxlint": "1.69.0",
"oxlint-tsgolint": "0.23.0",
"sonda": "0.13.0",
"tsdown": "0.22.2",
"typescript": "6.0.3",
"vitest": "4.1.8",
"zinfer": "0.1.8"
Expand Down
35 changes: 35 additions & 0 deletions packages/sdk/scripts/build-tsgo.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Build entrypoint: run tsgo (file-by-file emit) then the postbuild rewrites.
//
// The build tsconfig needs `allowImportingTsExtensions` for the workspace
// `@tailor-proto` package to resolve under bundler module resolution, which in
// turn makes tsgo emit a benign TS5096 config diagnostic (and a couple of
// politty TS4023 "cannot be named" declaration-emit notes) and exit non-zero —
// even though it emits correct JS + declarations. Type correctness is gated by
// `pnpm typecheck` (tsc --noEmit), not by this build. So we run tsgo, ignore
// its exit code, and instead gate on the postbuild successfully finding and
// rewriting the expected output. tsgo is rerun with `clean`-like semantics by
// wiping dist first.
import { execFileSync } from "node:child_process";
import { rmSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const pkgRoot = path.resolve(__dirname, "..");

rmSync(path.join(pkgRoot, "dist"), { recursive: true, force: true });

try {
execFileSync("tsgo", ["-p", "tsconfig.build.json"], {
cwd: pkgRoot,
stdio: "inherit",
});
} catch {
// tsgo exits non-zero on the benign diagnostics described above; emission
// still happens. postbuild validates that the expected files exist.
}

execFileSync("node", ["scripts/postbuild-tsgo.mjs"], {
cwd: pkgRoot,
stdio: "inherit",
});
Loading
Loading