Skip to content

feat(lit-virtual): re-export the virtual-core public API - #1264

Open
ousamabenyounes wants to merge 1 commit into
TanStack:mainfrom
ousamabenyounes:fix/issue-839
Open

feat(lit-virtual): re-export the virtual-core public API#1264
ousamabenyounes wants to merge 1 commit into
TanStack:mainfrom
ousamabenyounes:fix/issue-839

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Sep 5, 2026

Copy link
Copy Markdown

🎯 Changes

Fixes #839.

Problem

lit-virtual is the only framework adapter that does not re-export the core package. Every other one carries the identical export * line:

adapter line
react-virtual src/index.tsx:14
vue-virtual src/index.ts:21
solid-virtual src/index.tsx:21
svelte-virtual src/index.ts:14
angular-virtual src/index.ts:27
marko-virtual src/index.ts:56
lit-virtual absent

So a Lit consumer who needs defaultRangeExtractor, measureElement, Virtualizer or 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.md documents defaultRangeExtractor as 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 dependencies entry of lit-virtual (workspace:*), so this adds nothing to the install graph. sideEffects: false is unchanged, so the new names stay tree-shakeable.

No name collision: core has 15 runtime exports, lit-virtual owns VirtualizerController and WindowVirtualizerController, 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 minor changeset here comes from additive API work (react-virtual 3.14.0 shipped ### Minor Changes for three new option names), and every fix ships patch. Happy to retitle to fix + patch and 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 the describe('re-exports') block marko-virtual already has.

RED — unmodified main (e9874f0). Pristine git worktree --detach at origin/main with only the new test file copied in, core dist/ prebuilt. The production line is absent there (grep -c returns 0):

 ❯ tests/re-exports.test.ts (4 tests | 4 failed)
   × re-exports the Virtualizer class from virtual-core
   × re-exports the element observers and scroller from virtual-core
   × re-exports the window observers and scroller from virtual-core
   × re-exports the default extractors and measureElement from virtual-core

AssertionError: expected 'undefined' to be 'function' // Object.is equality
Expected: "function"
Received: "undefined"
 ❯ tests/re-exports.test.ts:20:30

 Test Files  1 failed | 1 passed (2)
      Tests  4 failed | 2 passed (6)

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:

 Test Files  2 passed (2)
      Tests  6 passed (6)

Built artifact, since the export surface is the thing being changed and source alone would not prove it. After vite build: dist/esm/index.js line 2 is the emitted export * re-export, dist/cjs/index.cjs line 56 re-exports through Object.keys(virtualCore).forEach(...), and dist/esm/index.d.ts line 3 carries the type re-export.

Importing the built package through its own exports map then resolves every core symbol, in ESM and in CJS, with the adapter's own classes intact:

core   Virtualizer              function      core   observeElementRect       function
core   defaultRangeExtractor    function      core   observeElementOffset     function
core   defaultKeyExtractor      function      core   observeWindowRect        function
core   measureElement           function      core   observeWindowOffset      function
core   elementScroll            function      lit    VirtualizerController    function
core   windowScroll             function      lit    WindowVirtualizerController function

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-cache because 118/119 tasks were otherwise served from cache):

main e9874f0 this branch
test files 9 10
tests 209 passed 213 passed
failures 0 0
targets all green, 69 projects all green, 69 projects

The only delta is lit-virtual going 1 file / 2 tests → 2 files / 6 tests. knip, sherif, publint --strict, tsc and eslint are all green with the wildcard re-export in place.

nx affected --base=origin/main — the literal test:pr job for this diff — selects root (sherif/knip/docs), lit-virtual (eslint/types/lib/build/test:build), the core build, 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 the provenance and version-preview jobs, which inspect the registry and the PR rather than the tree.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features

    • The Lit virtualizer package now exposes the core virtualizer API, including virtualizer utilities, observers, scrollers, range extraction, measurement, and shared types.
    • Consumers can access these capabilities directly through the Lit package.
  • Tests

    • Added coverage verifying availability of the re-exported core API.

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>
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 86979039-40b1-4e74-a798-992c377e971d

📥 Commits

Reviewing files that changed from the base of the PR and between e9874f0 and 55bcfe4.

📒 Files selected for processing (3)
  • .changeset/rich-poems-tickle.md
  • packages/lit-virtual/src/index.ts
  • packages/lit-virtual/tests/re-exports.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

@tanstack/lit-virtual now re-exports all public exports from @tanstack/virtual-core. Tests verify representative classes, observers, scrollers, extractors, and measurement utilities. A minor changeset documents the release.

Changes

Lit virtual core API

Layer / File(s) Summary
Core API re-export and validation
packages/lit-virtual/src/index.ts, packages/lit-virtual/tests/re-exports.test.ts, .changeset/rich-poems-tickle.md
The package entry point re-exports @tanstack/virtual-core. Tests verify representative virtualizer APIs. The changeset records a minor release.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 55bcf

Lit consumers can import the virtual-core API directly from @tanstack/lit-virtual. The re-export is covered by tests and presents no remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: re-exporting the virtual-core public API from lit-virtual.
Description check ✅ Passed The description is complete. It explains the problem, implementation, release impact, testing results, and includes the required checklist and changeset information.
Linked Issues check ✅ Passed The PR satisfies issue #839 by adding the virtual-core wildcard re-export and tests for the expected core APIs. It enables Lit consumers to import the core API directly from lit-virtual.
Out of Scope Changes check ✅ Passed All changes are directly related to issue #839: the public re-export, focused re-export tests, and the release changeset. No unrelated code changes are identified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/lit-virtual/tests/re-exports.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/lit-virtual/tests/re-exports.test.ts


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

@tanstack/lit-virtual does not re-export @tanstack/virtual-core

1 participant