Build Conventions (tsdown)
The mechanism — what runs, in what order, and why — is openspec/specs/architecture/build-pipeline/design.md. This skill is the conventions you apply when editing it.
Settled — do not re-propose
Every line here is a direction a reader reaches for on meeting the Rules section on this page. Each was tried or considered; the argument is where the line points.
- Finishing the source split — giving the app's Vite and Nitro builds, or its Vitest project, the
sourcecondition. The package whose stores rely on its own build's auto-import injection breaks outright; reach for a rebuild of the package (references/source-exports.md). devExports: truein place of the condition name. It points every condition at source, and Node's own loader reads no TypeScript (references/source-exports.md).- A repo-namespaced condition (
esposter-source), to stop a stranger's resolver matching the arm. Nothing published carries a source arm at all (references/source-exports.md). - A hand-maintained
onlyBundleallowlist, to answer tsdown's standing hint.inlinedDependenciesalready records every vendored package, and a new package's first build could never pass the check (references/opt-outs.md). - A guard that skips barrel generation on a hash of the file list. Generation costs milliseconds, and CI's traced task cache already gives what a sound key would (
references/barrels.md). - Committing the generated barrels. A tracked barrel is linted like authored code, and every line is an
export *from a relative specifier, whichno-restricted-importsandconsistent-type-exportsreject, so thousands of findings followed. The generator must write the relative, extension-keeping specifier, so the barrel stays gitignored and no lint reads it. The kit map is committed, because its generator emits code that passes every rule (references/barrels.md). - ctix, or any barrel generator that loads a TypeScript program. ctix dropped a name exported twice from the barrel with exit 0 and every check green, and its program was most of a package's build;
export *lines from rolldown's oxc parse make the same collisionTS2308(references/barrels.md). - Per-file
exportsfor the barrel packages, the Nuxt module's shape. Its glob entries exist because Nuxt loads each runtime file by path; everywhere else the flat.export is what every sibling imports, built unbundled so one import loads only the modules it reaches, and tsdown's default single entry is the shape (references/barrels.md). - A subpath, or a list of pure annotations, to keep a bundled client from loading the rest of a package. The build keeps one file per module and every package answers
sideEffects, so the bundler prunes by itself; a subpath stays only for a consumer with no bundler (references/subpaths.md). - An include list, or a hand-written
exportsmap, for a Nuxt module's runtime arms. The third-party Nuxt modules the app registers ship a map of one to four hand-declared entries, except the testing toolkit@nuxt/test-utils, which ships eleven. tsdown'sexportstakesexcludeandcustomExportsand no include list, and it copies acustomExportsarm as written into bothexportsandpublishConfig.exports, so an opt-in map writes every public arm by hand in the shape each map needs (trpc-nuxt-modulehas eleven) to save one exclude line per private file. A new runtime file gaining an arm is caught by the manifest check and the subpath audit, and the answer is the package's ownexclude(references/subpaths.md). - Building the packages more concurrently. The wall time is one topological chain through the siblings' generated barrels (
references/barrels.md). - A
tsconfig.build.jsonin every package. tsdown's transform readscompilerOptions, which the build preset has none of, and a declaration program seeded from the entries never reads an exclude — every other package'sdistis byte-identical againsttsconfig.json. Only the Vue build'seagerprogram is loaded from the file list, so it alone keeps one (references/tsconfig-presets.md). - Vendoring CJS dependencies as a policy. It is a named exception per dependency; generalised it vendors the same library into half the dists here (
references/opt-outs.md). - Bundling a dependency to spare the consumer an install. It saves nothing and splits the dependency's types into two that fail
instanceof(references/dependency-placement.md). vizeandvuelisted in every Vue package instead of the root.tsrsruns from the root's binaries and loadsvizefrom where it is installed, so the root lists the tool and thevueit must share with the project; a library's ownvueis not what the mapper compares (references/dependency-placement.md, "Where a tool lives").- Dropping
compositefrom a preset (tsconfig.library.json,tsconfig.node.json,tsconfig.browser.json,tsconfig.nuxt-module.json), on the reading that nothing consumes it. It is the precondition forisolatedDeclarations; without it every package failsTS5069(references/tsconfig-presets.md). - A
compilerOptionsblock intsconfig.build.base.json, or apathsblock intsconfig.base.json. The first emits declarations against the wrong lib set; the second shadows real package names (references/tsconfig-presets.md). - Hashing
.github/into a package build's task cache input. Every command those workflows run is already hashed through a manifest, so the key would move on every comment edit and rebuild a package for a change no build can observe (openspec/specs/architecture/monorepo-tooling/design.md, "CI job shape"). - Filling a published package's metadata fields —
engines,repository.directory, aLICENSEfile — none of which a gate can hold honest (openspec/rejected/architecture/published-package-metadata/design.md). - A size band, or a ceiling per file, in place of the record — the committed record of exact sizes is the one gate (
openspec/specs/architecture/bundle-sizes/design.md).
Rules
- A package's
tsdown.config.tsis one factory call plus what is genuinely its own, composed withmergeConfig— a spread of agetTsdownConfiguration*()drops every nested option the factory set (no-restricted-syntax); barrels are generated by the build (references/shared-configs.md,references/barrels.md). - The manifest decides what is bundled, not the config:
dependenciesandpeerDependenciesare externalized, thedevDependenciesthe source imports are bundled except a workspace sibling, which a built package keeps external, a peer is listed once and only for a singleton, and a manifest names only what its own code imports (vp run lint:unused) — never bundle to spare a consumer an install (references/dependency-placement.md). - A manifest's
filesis the tarball:distand what a runtime reads beside it for a built package, its directories less!**/*.test.tsand!.claude-plugin/typesfor a plugin shipping its source — only a release reads the list, soscripts/src/workspace/packages/publishedFiles.test.tspacks every published package (openspec/specs/architecture/monorepo-tooling/design.md, "Lerna Lite"). - Every
depsentry goes throughgetPackagePatterns, so a subpath import matches (references/dependency-placement.md). - A tool that checks the whole workspace is listed in the root manifest, and a tool a package's own build names is listed in that package; a tool that loads a plugin by name has the plugin, and what the plugin must share with the project, at the root beside it, with a knip ignore saying why (
references/dependency-placement.md). deps.onlyImportgates every bundle's externals, and the factory gates every published package withpublintandattw, both declared by@esposter/configurationand never by a package — none is ever widened or disabled to get a build through, save the externals a deploy artifact's host provides or its code never reaches, which that package names in its own config (references/gates.md,references/opt-outs.md).- A package reaches its own source through
#src/*subpath imports, never@/, which is what gives every package itssourceexport arm;apps/webtakes the same form (references/self-alias.md). - The bundle-size record is written by the review of
ai/queueafter the change that moves a bundle lands, asreferences/dist-size.mdsets out. - A package that is a Nuxt module builds its runtime unbundled beside a
src/module.tsentry, and the app registers it by the path to that source, never its package name, whichnuxt preparecannot load before the packages build (references/nuxt-module-packages.md). - Presets live in
@esposter/configuration, extended by path, and the base carries no framework assumption (references/tsconfig-presets.md). - A data set a browser reads is published, never imported, so no build bundles it and no declaration program reads it:
genshin-worldimports only its lock and one save bound, and the build tsconfig maps no generated path (.agents/skills/genshin-data/SKILL.md,openspec/specs/architecture/build-pipeline/design.md). - A package is built through its vp task:
vp run build:<directory>, orvp run build:packagesfor every package, and a build's own rewritten files stay out of its cache inputs. The task's order, its replay and where its cache lives areopenspec/specs/architecture/build-pipeline/design.md, "A package builds as a task of the root". - Installs and the workspace graph are
AGENTS.mdandopenspec/specs/architecture/monorepo-tooling/design.md— wherepnpm ineeds the network, ask for plainpnpm irather than changing pnpm store settings.
Reference pages
references/gates.md— whendeps.onlyImport,publintorattwfails a build, or a consumer reports a module the package never referenced.references/source-exports.md— when a specifier has to survive a sibling bundling it, or thesourcecondition's reach is in question.references/tsconfig-presets.md— when editing atsconfig*.jsonpreset, or@esposter/configurationitself.references/barrels.md— when a generatedsrc/index.ts, the answerreadExportsGenerationreads off a package, theentrythe build hook needs, or a module undersrc/internal/is in question, or a build rewrites a barrel with no export moved.references/subpaths.md— when a package gains or loses a subpath export or entry, or a review asks why one exists.references/opt-outs.md— when a package minifies a deploy artifact, vendors what the default externalizes, or declares an entry field a host loads by convention.references/side-effects.md— when settingsideEffects, or a bundle loads and never runs a trigger (scripts/src/workspace/packages/sideEffects.test.tsenforces that every package answers).references/declarations.md— when a package holds an ambient.d.tsno entry imports, or wraps a library a plugin augments.references/dependency-placement.md— when adding, moving or removing a dependency, or deciding whether one is bundled.references/shared-configs.md— when writing a package'stsdown.config.tsor a configuration factory.references/dist-size.md— when the bundle-size test fails after a manifest,deps, factory or export change, or a recorded size is in question.references/nuxt-module-packages.md— when a workspace package is a Nuxt module, or the app registers one.references/self-alias.md— when a package's own#src/*import fails to resolve, or a@/specifier appears in any tree.