Skip to content

build: build and test with Vite - #1356

Merged
dangreen merged 5 commits into
masterfrom
build/vite
Nov 30, 2026
Merged

dangreen merged 5 commits into
masterfrom
build/vite

Conversation

@dangreen

@dangreen dangreen commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Part 3 of the tooling stack. Based on #1355.

What

  • Build with Vite instead of rollup + swc. The published entries stay the same: dist/index.js (ESM), dist/index.cjs (CommonJS) and dist/index.d.ts. The output is unminified and built for esnext, so the /* @__PURE__ */ annotations reach the bundlers of consumers. React and Chart.js stay external.
  • Pure annotations in the sources. swc added /* @__PURE__ */ to the forwardRef calls in the build; Vite does not, and without them a bundler kept Chart and the Chart.js core even for an import of a single event helper (149 B grew to ~122 kB in a consumer bundle). The annotations are written in src now, and size-limit has an entry for { getElementAtEvent } (57 B) to keep it that way.
  • TypeScript config is split as in Argue: tsconfig.build.json emits declarations from src, tsconfig.json type-checks everything including specs and config files. verbatimModuleSyntax is on.
  • Tests live next to the code as src/*.spec.tsx (the unit-tests skill). tsd is gone: its cases are @ts-expect-error checks and positive cases inside the specs, verified by tsc --noEmit (test:types) and Vitest typecheck. New runtime tests render <Scatter> and <Doughnut> and check the registered controller, the ref and the options, so the render function of the typed components is covered too.
  • Scripts follow the baseline: build, lint, test:unit, test:types, test:size, test (run -p lint test:unit test:types from @trigen/scripts), clear. prepublishOnly runs tests and the build before clean-publish.
  • .clean-publish drops scripts and publishConfig from the published package.json (clean-publish applies publishConfig fields first, so main, module and exports are as before). linkDirectory: false keeps local consumers of the package on the sources.

ESLint still runs in this PR; the next one replaces it with oxlint.

Checked locally

  • pnpm test, pnpm build, pnpm test:size (sizes unchanged: 857 B for everything, 538 B for Chart, 590 B for Line; 57 B for an event helper).
  • pnpm prepublishOnly produces a package/package.json with the same main, module, exports and types as the current release.

Stack

  1. chore: agent skills and notes (chore: add agent skills lock and agent notes #1354)
  2. ci: Node.js 26, pnpm 12 and workflows (ci: update Node.js, pnpm and workflows #1355)
  3. build: Vite and Vitest ← this PR
  4. chore: Storybook 10 (chore: update Storybook to 10 #1357)
  5. chore: sandboxes in the root workspace (chore: install the sandboxes from the root workspace #1358)
  6. chore: lint with oxlint (chore: lint with oxlint #1359)
  7. chore(deps): update dependencies (chore(deps): update dependencies #1360)
  8. docs: move the website to Starlight (docs: move the website to Starlight #1361)
  9. build!: drop the CommonJS build (build!: drop the CommonJS build #1362)

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.75%. Comparing base (c1249b8) to head (eb39ad8).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1356      +/-   ##
==========================================
+ Coverage   90.00%   93.75%   +3.75%     
==========================================
  Files           3        3              
  Lines          80       80              
  Branches       20       20              
==========================================
+ Hits           72       75       +3     
+ Misses          6        3       -3     
  Partials        2        2              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Vite builds the same ESM and CommonJS entries that rollup with swc did, unminified and for modern targets, so the pure annotations reach the bundlers of consumers. Declarations are emitted from tsconfig.build.json, and the scripts follow the Trigen baseline.
Specs live beside the code they test, and tsd type tests become @ts-expect-error cases in them, checked by tsc and by Vitest typecheck.
swc added them to the build, Vite does not: without them a bundler keeps Chart and its Chart.js core even when only an event helper is imported. The annotations are in the sources now, and size-limit measures a helper-only import. The type test of plugins on the generic Chart, lost in the move from tsd, is back.
The specs checked only the props types, so the render function of the typed components was never run.
With empty datasets Chart.js never looks up the controller, so the tests passed even without the controller registration. Each test now checks one behavior.
@dangreen
dangreen marked this pull request as ready for review November 30, 2026 15:35
@dangreen
dangreen merged commit e74b0d8 into master Nov 30, 2026
11 checks passed
@dangreen
dangreen deleted the build/vite branch November 30, 2026 15:35
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.

1 participant