Skip to content

Enable subpath exports and per-component tree-shaking - #91

Merged
cmil merged 4 commits into
mainfrom
subpath-exports
Oct 2, 2026
Merged

cmil merged 4 commits into
mainfrom
subpath-exports

Conversation

@cmil

@cmil cmil commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Build every source module as its own ESM file via Vite's preserveModules, add a "sideEffects": ["**/*.css"] field, and expose each component through an exports subpath (e.g. @dracor/react/NavBar). Modern bundlers can now drop unused components from the barrel import, and bundler-less consumers can import components directly.
  • Mark every non-React peer as optional in peerDependenciesMeta so consumers only need to install the packages used by the components they actually import. react-markdown stays a runtime dependency for now — demoting it would be a breaking change for consumers of DocPage/AuthorInfo, so it's queued for the next major (noted in CLAUDE.md).
  • Tighten the vite-plugin-dts exclude list to drop .d.ts leakage for Storybook-only source files, and refresh README.md and CLAUDE.md to document the new import styles and optional-peer matrix.

This is a non-breaking change — SemVer-safe for a 1.9.0 minor. Needs a version bump in package.json before release.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.62%. Comparing base (5ed550e) to head (3f70725).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #91   +/-   ##
=======================================
  Coverage   95.62%   95.62%           
=======================================
  Files          34       34           
  Lines         320      320           
  Branches      109      109           
=======================================
  Hits          306      306           
  Misses          3        3           
  Partials       11       11           

☔ 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.

cmil and others added 4 commits October 2, 2026 19:37
Build every component as its own ESM file via `preserveModules` and add
an `exports` entry for each so consumers can either rely on tree-shaking
of the barrel import or import components directly (e.g.
`@dracor/react/NavBar`). Mark all non-React peers as optional so users
only install the packages needed by the components they import; move
`react-markdown` out of `dependencies` accordingly. Document both import
styles and the optional-peer matrix in the README.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Moving react-markdown from `dependencies` to an optional peer would
force consumers of `DocPage`/`AuthorInfo` to install it explicitly —
a breaking change requiring a major bump. Since per-component tree
shaking already ensures unused consumers pay zero bundle-size cost,
keep react-markdown auto-installed and drop it from
`peerDependenciesMeta` so the branch can ship as a minor release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Refresh the Architecture section: React is now the only required peer,
the build emits one file per module via `preserveModules`, every
component is reachable through a subpath export, and `tei.css` joins
`dracor.css` as a shipped stylesheet. Record the intent to demote
`react-markdown` from `dependencies` to an optional peer with the
next major release under a new "Deferred for next major" section.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`src/einakter-gh.tsx` and `src/Theme.tsx` are Storybook demo sources
that aren't part of the public API, but vite-plugin-dts was still
emitting `dist/einakter-gh.d.ts` and `dist/Theme.d.ts` for them.
Exclude both so the published tarball only contains declaration
files that correspond to real exports.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cmil
cmil force-pushed the subpath-exports branch from 6bdf516 to 3f70725 Compare October 2, 2026 17:37
@cmil
cmil merged commit 9b0bf0c into main Oct 2, 2026
5 checks passed
@cmil
cmil deleted the subpath-exports branch October 2, 2026 17:44
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