fix(build): the document field templates stop breaking the package build - #588
hyanmandian wants to merge 2 commits into
Conversation
The declaration build runs the type-checker over every file of the repository that the tsconfig takes in, and the templates the document field examples are generated from carry `@@Placeholder@@` markers, so a file named `schema/zod.ts` does not parse as TypeScript. `docs` is excluded, which covers the templates where they sit, but the Tree-shaking job checks the base revision of a pull request out into `base/`, a second copy of the whole repository that the exclusion does not reach: since the templates landed on `main`, the "Build head" step fails on any pull request rebased onto it, with a TS1003 for every marker. A template is now named for what it is, `schema/zod.ts.tmpl`, keeping the extension of the file it fills in ahead of the suffix. Nothing that walks the repository for `.ts`/`.tsx` files sees a template any more, wherever the folder is checked out and whichever tool does the walking, and an editor stops reporting errors in one that is open. The second checkout is excluded as well, so the build here keeps compiling the head alone whatever the base revision holds.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (21)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe example script now loads ChangesTemplate and generated-file handling
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change redirects example generation to the renamed .tmpl templates and excludes template-related paths from source discovery. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
commit: |
Tree-shaking report✅ No bundle size impact. All 156 exports are the same size as on the base branch (full import 649.3 KB, gzip 166.4 KB). All exports (156)
How this is measuredEvery export is imported alone into an esbuild consumer bundle (minified, tree-shaken) built from the head and from the base of this pull request; the sizes are the resulting bundles, gzip is their gzipped size. 🔴 marks a regression: a pre-existing export that grew more than 20% and more than 256 B, or the bundle importing every pre-existing export growing more than 5%. 🟡 is growth under the threshold, 🟢 a decrease, ⚪ no change, 🆕 an export that does not exist on the base (never a regression), 🗑️ an export that was removed. An intentional increase is accepted with the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #588 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 186 186
Lines 2069 2069
Branches 613 613
=========================================
Hits 2069 2069
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…r them The leading underscore of `_templates` said "not a page" next to the `_sidebar.md` and `_coverpage.md` docsify looks for, which the folder never was: nothing routes to it, the sitemap is built from the links of each `_sidebar.md` and `robots.txt` keeps crawlers out of `/snippets/` whatever sits under it. Now that a template is named `.tmpl`, the extension says what the file is and the folder can say where it belongs. The one walk over `docs/` that the folder name did reach is the Context7 index, which reads the folder list of `context7.json` rather than the site, so the templates are excluded there by name: an index of `@@Placeholder@@` markers helps nobody.
|
@coderabbitai review |
✅ Action performedReview finished.
|
What
The
Tree-shaking reportjob fails on every pull request rebased onto the currentmain(red on #558; the branches that are still green have simply not rebased yet). This renames the document field templates so they are no longer.ts/.tsxfiles, and keeps the second checkout the job makes out of the type-check.The cause
npm run build(vp pack) generates the declarations with tsdown's dts plugin, which spawnstsgo:-p tsconfig.jsonwith noincludemeans "every.ts/.tsxfile under the repository root, minusexclude".--noCheckturns off semantic checking, so only parse errors survive: exactly the TS1xxx errors reported.The templates under
docs/snippets/document-field/templatescarry@@placeholder@@markers (import { @@validatorFn@@ } from "@brazilian-utils/brazilian-utils";), so a file namedschema/zod.tsdoes not parse as TypeScript.exclude: ["docs", ...]is a path relative to the tsconfig, so it covers./docsand the templates are fine where they sit. The Tree-shaking job, though, checks the base revision of the pull request out intobase/, a whole second copy of the repository inside the head checkout, and./base/docsis not whatdocsexcludes. Since the templates landed onmain(#556), the "Build head" step of that job (npm ci && npm run build) parsesbase/docs/snippets/document-field/_templates/**and dies with one TS1003/TS1128/… per marker.Nothing else looks at them today:
npm run check(vp check) ignoresdocsin both the formatter and the linter,kniponly walkssrc/scripts(knip.json), andjscpdthe same (.jscpd.json). The build was the only tool reaching them, and only through the second checkout.Why this fix
Two ways were on the table.
tsconfig.json("**/_templates/**"). One line, but it patches a single tool: the file keeps claiming to be TypeScript, so the next thing that walks the tree for.tsfiles (an editor's language server, a future check,tscrun by hand) hits the same wall, and every one of them needs its own exclusion.schema/zod.ts.tmpl,react/field.tsx.tmpl,vue/form.vue.tmpl,vanilla/field.html.tmpl. A template is no longer a source file for anybody, wherever the folder is checked out and whatever does the walking, and the extension it keeps in front of the suffix still says what the filled in file will be.scripts/examples.tsreads every template through one function, so the whole change on the generator side is appending.tmplthere.baseis excluded intsconfig.jsonas well. That is the other half of the cause: the head build has no business compiling a second copy of the repository at another revision. With it, the job stays green whatever that revision holds, including today'smain, instead of only for branches rebased past this commit.No source, no public API and no generated output changes:
npm run build:exampleswrites byte-identical files (git statusclean after running it).The folder name
A second commit drops the leading underscore:
docs/snippets/document-field/_templatesis nowdocs/snippets/document-field/templates. The underscore said "not a page", the way_sidebar.mdand_coverpage.mddo, which this folder never was; with the.tmplsuffix carrying that job the folder can say where the files belong instead.Nothing relied on the underscore to skip it:
_sidebar.md(scripts/site.ts), never from a walk ofdocs/, and lists no/snippets/page under either name;docs/robots.txtalready answersDisallow: /snippets/, which covers everything under it;docs/whatever it is called (/_sidebar.mdis served today), so serving is unchanged;scripts/llms.tsreadsgetting-started.mdandutilities.mdby name, sollms.txtandllms-full.txtare untouched;.gitignorenamesdocs/snippets/document-field/generated/explicitly,knip.jsonand.jscpd.jsononly walksrc/scripts, andvite.config.tsignoresdocswholesale.The one walk over
docs/that the name did reach is the Context7 index, which takes its folders fromcontext7.jsonrather than from the site. The templates are now excluded there by name, next todocs/pt-br: an index full of@@placeholder@@markers helps nobody.npm run build:examplesoutput is byte-identical to whatmainwrites (diff -roverdocs/snippets/document-field/generatedanddocs/snippets/address-formagainst an unmodifiedmaincheckout: no differences), and the base-checkout reproduction was re-run on the final tree (npm ci && npm run buildwithbase/atmain: exit 0, zeroerror TSlines).Verification
Reproduced the CI failure first, in a scratch clone laid out the way the job lays it out (head checkout at the root, base revision of
mainbdd4e26bcloned intobase/), running exactly what "Build head" runs:base/npm ci && npm run buildmain(bdd4e26b)main(bdd4e26b)error TS…lines,[plugin rolldown-plugin-dts:generate] Error: tsgo process exited with code 2main(bdd4e26b), templates still.tsbaseexclusionmainwith the templates renamed (whatmainlooks like once this merges)The third row is there to show the rename alone fixes the steady state, and the second that the exclusion covers the bases that predate it.
The rest of the job, on this branch against
mainas the base:node scripts/tree-shaking.ts --json head.json, thencd base && npm ci && npm run build && node scripts/tree-shaking.ts --json ../base.json --surviving ../head.json, thennode scripts/tree-shaking.ts --compare base.json --markdown tree-shaking.md— exit 0, "✅ No bundle size impact. All 156 exports are the same size as on the base branch".Gates, all from a clean
npm ci:npm run check— pass (520 files formatted, no lint or type errors in 480 files)npm run test -- --run— pass (187 files, 6131 tests)npm run build— pass (attw and publint clean)npm run build:docs— pass, andnpm run build:examplesleaves the working tree cleannpm run check:tree-shaking— pass, 156 exports, full import 664897 Bnpm run check:unused(knip) — passnpm run check:duplication(jscpd) — pass, 0 clonesnpm run check:commits— passOpen points
base/folder thatvp checkstill walks (itsignorePatternsare the linter's own, not the tsconfig's): on the pre-fix tree that reports 165 errors, every one of them insidebase/src, none in the templates. Nothing in CI does this — only the Tree-shaking job createsbase/, and it never runsvp check— sovite.config.tsis left alone here.docs/snippets/document-field/generated/stays the way to check it, as before.Summary by CodeRabbit
Documentation
.tmplsuffix for templates containing placeholder markers.Chores