Skip to content

Switch to Node 26 and ESM-only - #25

Open
mollpo wants to merge 14 commits into
mainfrom
claude/node26-esm-a41d0e
Open

mollpo wants to merge 14 commits into
mainfrom
claude/node26-esm-a41d0e

Conversation

@mollpo

@mollpo mollpo commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Why

Move the package to the same baseline as the other About Bits libraries: Node 26, ESM-only, React 19 only, TypeScript 6 and the current About Bits ESLint and TypeScript configs.

What changed

The package now ships one ESM bundle with type declarations, built by tsdown, and runs its tests with Vitest.

  • Consumers: ESM-only ("type": "module", an exports map with the root entry only), peer react and react-dom ^19, engines.node >=26. The exported names are unchanged.
  • Tooling: TypeScript ~6.0, @aboutbits/eslint-config 6 with the React rules, @aboutbits/ts-config 1.2, Vitest 5 with jsdom in place of Jest, CI on Node 26 only.
  • Hooks: useMatchMediaQuery and LocationProvider change behaviour, see below.

Review notes

  • useMatchMediaQuery called hooks after an early return; it now uses useSyncExternalStore. During server rendering and hydration it returns undefined, then the real value.
  • LocationProvider now fetches the location again when highAccuracy changes, instead of only on mount. A result that settles after a newer request is dropped.
  • TypeScript stays on 6.0, not 7, because @aboutbits/eslint-config 6.2 allows only typescript <6.1.
  • The ESLint config has no Jest rules anymore: @aboutbits/eslint-config has no Vitest config, and the Jest rules fail without the jest package.
  • TypeScript 6 no longer loads global types by default, so tsconfig.json lists vitest/globals.
  • The tsdown config sets target: 'es2025' explicitly; otherwise tsdown derives a Node target from engines.node.
  • A 2024 commit had added compiled .js copies next to the sources in src/; they are removed.

Where to look

Test scope
  • On Node 26.13: build, lint, typecheck and all 19 tests pass. New tests cover the change listener of useMatchMediaQuery: updates, removal on unmount, and a new query.
  • Importing the built package in Node exposes the same exports as before.
  • Not tried in a consuming app. LocationProvider has no tests. package-lock.json is regenerated and can be skipped.
Risk: needs a human review, assessed at 76dbcb0
  • Two spots to look at, above.
  • No full review by another model family on src/useMatchMediaQuery/__test__/useMatchMediaQuery.test.tsx; only a check of its fix.
  • The package becomes ESM-only and drops React 18 and Node below 26, which breaks consumers on the old setup.

mollpo added 11 commits December 2, 2026 14:12
@aboutbits/eslint-config 5 only supports TypeScript 5, so both are updated
together. The CommonJS build keeps the deprecated node10 resolution until
the package becomes ESM-only.
useMatchMediaQuery now uses useSyncExternalStore instead of calling hooks
conditionally, and LocationProvider fetches the location again when
highAccuracy changes.
The tsc builds for CommonJS and ESM are replaced by a single tsdown build.
The Jest rules need the jest package to detect its version, which is no longer
installed since the tests run on Vitest.
@mollpo mollpo self-assigned this Dec 2, 2026
The lockfile kept @typescript-eslint/parser nested under
@aboutbits/eslint-config, where eslint-plugin-import cannot resolve it.
@github-actions github-actions Bot added the self-review:stale The code changed after the self-review: a new round clears it label Dec 3, 2026
@mollpo
mollpo requested a review from lukasvice December 3, 2026 09:34
Comment thread tsdown.config.ts
// set explicitly, otherwise tsdown derives a Node target from engines.node
target: 'es2025',
dts: true,
exports: true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a single bundle, the createContext(...) call from LocationProvider sits at the top level of dist/index.js, so every import of the package runs it. That breaks AsyncView in a Server Componen-

unbundle: true restores that, as in aboutbits/react-ui#398.

Suggested change
exports: true,
exports: true,
unbundle: true,

Comment thread package.json
"peerDependencies": {
"react": "^18.0.0 || ^19.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react-dom is a new peer dependency, but nothing in src outside the tests imports it, and the build output only imports react and react/jsx-runtime. Can we drop it here? It stays a dev dependency for the tests.

Comment thread package.json
"prepublishOnly": "npm run checks",
"prepare": "npm run build",
"preversion": "npm run checks",
"version": "npm run test && npm run lint && git add -A src",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: preversion already runs npm run checks, so test and lint run twice on a release. react-pagination has just git add -A src here.

Suggested change
"version": "npm run test && npm run lint && git add -A src",
"version": "git add -A src",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

self-review:stale The code changed after the self-review: a new round clears it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants