build(sdk): replace tsdown bundler with tsgo file-by-file build#1496
Draft
toiroakr wants to merge 2 commits into
Draft
build(sdk): replace tsdown bundler with tsgo file-by-file build#1496toiroakr wants to merge 2 commits into
toiroakr wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: fcc0c6b The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
toiroakr
force-pushed
the
chore/build-with-tsgo
branch
from
June 18, 2026 00:11
be469a0 to
e2a74a3
Compare
Build with tsgo (file-by-file ESM emit) plus a postbuild script instead of the tsdown bundler. The postbuild renames to .mjs/.d.mts, rewrites module specifiers, emits YAML files as runtime modules, adds CLI shebangs (and the exec bit), injects the runtime-globals banner on configure/index.d.mts only, copies ERD viewer assets, and vendors the private @tailor-platform/tailor-proto package into dist/_proto so the unbundled output stays self-contained. Annotate initOperatorClient's return type so the declaration emit keeps OperatorClient instead of collapsing to Client<any> under file-by-file emit. Remove tsdown and sonda, and drop the redundant measure:bundle metric with its sdk-metrics Bundle Size CI job: deployed function-bundle sizes are already guarded by example's bundled_execution size test. Add explicit knip entries that tsdown's plugins previously provided. Clean build ~6s (was ~22s).
toiroakr
force-pushed
the
chore/build-with-tsgo
branch
from
June 18, 2026 01:22
e2a74a3 to
62901f6
Compare
commit: |
The postbuild specifier rewrite matched raw text, so import-like text inside string literals and comments was rewritten too — corrupting the generated migration-script template (`./db` -> `./db.mjs`). Locate specifiers via the oxc AST (static import/export, dynamic import, and type-level `import()`), leaving template/comment text untouched. Also harden the build: - derive the post-emit existence check from every package.json exports/bin entry instead of four hand-listed ones, so a broken emit of any published entry is caught despite the ignored tsgo exit code - align the tsconfig.build.json `@tailor-proto` path alias with the canonical tsconfig.json mapping (was a doubled `tailor/v1` segment) - anchor the sourceMappingURL rewrite per-line so trailing content cannot leave a stale `.js.map` reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the tsdown bundler build of
@tailor-platform/sdkwith a tsgo (file-by-file ESM) build plus a Node postbuild script. Clean build drops from ~22s to ~6s.This is exploratory. It changes how the package is published (no longer bundled), so the trade-offs below need review before merging.
What changed
tsgo -p tsconfig.build.jsonemits per-file ESM;scripts/build-tsgo.mjsorchestrates tsgo + postbuild.scripts/postbuild-tsgo.mjs) replicates what tsdown's config/plugins did: rename.js->.mjs/.d.ts->.d.mts, rewrite all relative module specifiers (incl. bare./..and.yml->.yml.mjs), emit YAML files as runtime.mjsmodules, add CLI shebangs + exec bit, inject the runtime-globals triple-slash banner onconfigure/index.d.mtsonly, copy the ERD viewer assets, and vendor the private tailor-proto package intodist/_proto.initOperatorClient's return type so the per-file.d.mtsemit keepsOperatorClientinstead of collapsing toClient<any>.measure:bundlescript + its sdk-metrics "Bundle Size" CI job. Deployed function-bundle sizes are already guarded by example'sbundled_execution.test.ts("bundled JS files should not be excessively large"), which asserts the real deploy artifacts stay small and free of unwanted deps (e.g. zod).tsdownandsonda. Deletetsdown.config.ts, the old root Sonda measure script, and the stale.sondaignore. Add explicitknipentries (tsdown previously drove entry detection).Verification
pnpm check(build, generate, lint, typecheck:go, knip, jsdoc, zod-isolation, import-cycles) exits 0.pnpm test:unit: 2865 tests pass.publint --strictclean; CLI smoke (node dist/cli/index.mjs --help) works.Trade-offs / review points
node_modulesat runtime. The published package now has a real dependency tree instead of a vendored bundle. This is the core methodology change to evaluate.dist/_protoand its specifiers rewritten, since it can't resolve from npm. Review whether vendoring is the desired distribution strategy.build-tsgo.mjstolerates tsgo's non-zero exit (non-fatal TS4023 on politty re-exports, TS5096 onallowImportingTsExtensions) and gates on emitted-file presence. Type correctness is still enforced bypnpm typecheck/CI; a genuine emit failure that still leaves the entry files could slip past the build gate.Notes
Supersedes the interim "make Sonda opt-in on tsdown" approach by removing tsdown entirely.