feat(lit-virtual): re-export the virtual-core public API - #1264
feat(lit-virtual): re-export the virtual-core public API#1264ousamabenyounes wants to merge 1 commit into
Conversation
lit-virtual was the only framework adapter that did not re-export virtual-core, so consumers had to install virtual-core as a second direct dependency to reach Virtualizer, defaultRangeExtractor, measureElement, the scroll observers and the shared types. react, vue, solid, svelte, angular and marko all re-export it already. virtual-core is already a direct dependency of the package, so this adds nothing to the install graph, and there is no name collision with VirtualizerController or WindowVirtualizerController. Typed as feat/minor rather than fix/patch because it grows the package's public export surface from 2 names to 17. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
ChangesLit virtual core API
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to Lit consumers can import the virtual-core API directly from 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
packages/lit-virtual/tests/re-exports.test.tsParsing error: "parserOptions.project" has been provided for Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎯 Changes
Fixes #839.
Problem
lit-virtualis the only framework adapter that does not re-export the core package. Every other one carries the identicalexport *line:src/index.tsx:14src/index.ts:21src/index.tsx:21src/index.ts:14src/index.ts:27src/index.ts:56So a Lit consumer who needs
defaultRangeExtractor,measureElement,Virtualizeror any of the shared types has to install the core package as a second direct dependency, while the same code in any other adapter needs only the adapter.docs/api/virtualizer.mddocumentsdefaultRangeExtractoras exported without mentioning a second install.This is the same gap that was closed for Vue in #588 (
allow access to virtual-core parts), with the same one-line diff.Fix
One line in
packages/lit-virtual/src/index.ts— the same core re-export the other six adapters carry, placed exactly where react-virtual puts it: after the imports, before the first declaration. The full line is in the diff.The core package is already a direct
dependenciesentry oflit-virtual(workspace:*), so this adds nothing to the install graph.sideEffects: falseis unchanged, so the new names stay tree-shakeable.No name collision: core has 15 runtime exports,
lit-virtualownsVirtualizerControllerandWindowVirtualizerController, and the two sets are disjoint — the built bundle goes from 2 exports to 17, the same 17 react-virtual ships.Release impact
Typed as a minor, not a patch: the change grows the package's public export surface from 2 names to 17. That matches this repo's own pattern — every
minorchangeset here comes from additive API work (react-virtual 3.14.0 shipped### Minor Changesfor three new option names), and everyfixshipspatch. Happy to retitle tofix+patchand treat it purely as an adapter-parity bug instead, if you'd rather — it's a one-word change to the changeset.Test verification (RED → GREEN)
New file
packages/lit-virtual/tests/re-exports.test.ts(4 tests), mirroring thedescribe('re-exports')block marko-virtual already has.RED — unmodified
main(e9874f0). Pristinegit worktree --detachatorigin/mainwith only the new test file copied in, coredist/prebuilt. The production line is absent there (grep -creturns0):The 2 pre-existing Lit tests pass in that same run, so the failure is the missing exports and not a broken environment.
GREEN — this branch:
Built artifact, since the export surface is the thing being changed and source alone would not prove it. After
vite build:dist/esm/index.jsline 2 is the emittedexport *re-export,dist/cjs/index.cjsline 56 re-exports throughObject.keys(virtualCore).forEach(...), anddist/esm/index.d.tsline 3 carries the type re-export.Importing the built package through its own
exportsmap then resolves every core symbol, in ESM and in CJS, with the adapter's own classes intact:Full local suite
nx run-many --skip-nx-cache --targets=test:sherif,test:knip,test:docs,test:eslint,test:lib,test:types,test:build,build, run on the upstream baseline and again on this branch (--skip-nx-cachebecause 118/119 tasks were otherwise served from cache):maine9874f0The only delta is lit-virtual going 1 file / 2 tests → 2 files / 6 tests.
knip,sherif,publint --strict,tscandeslintare all green with the wildcard re-export in place.nx affected --base=origin/main— the literaltest:prjob for this diff — selectsroot(sherif/knip/docs),lit-virtual(eslint/types/lib/build/test:build), the corebuild, and both Lit example builds. All green.Not run locally:
test:e2e(only react-virtual and angular-virtual define that target, and this diff reaches neither), plus theprovenanceandversion-previewjobs, which inspect the registry and the PR rather than the tree.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
Tests