Skip to content

Breaking: Node 22+, latest dependencies, tsdown/Biome/TS 7, and bug fixes - #41

Merged
jburnhams merged 5 commits into
mainfrom
claude/project-thread-bgd0e5
Nov 9, 2026
Merged

jburnhams merged 5 commits into
mainfrom
claude/project-thread-bgd0e5

Conversation

@jburnhams

@jburnhams jburnhams commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Requested by Jonathan · project thread

This updates every dependency, moves the toolchain to tsdown, Biome and TypeScript 7, fixes several bugs that affect people using the library in their own apps, and fills in what's missing for a public npm package. The first commit message starts with "Breaking", so the bump workflow should release this as 3.0.0.

Breaking change

  • Requires Node 22.22+, 24.15+ or 26+, the same range as jsdom 31. Node 20 reached end of life in April 2026.

Dependencies and toolchain

  • Runtime: jsdom 27 → 31, undici 6 → 8, @napi-rs/canvas 0.1.84 → 1.1.0, @fontsource/noto-sans 5.3.
  • tsup → tsdown. tsup is no longer maintained. Output file names are unchanged. index and testing now share one chunk instead of each bundling a copy of the library.
  • ESLint + typescript-eslint → Biome for both linting and formatting, and the repo is now formatted with Biome. Biome's noFloatingPromises and noMisusedPromises rules are enabled to cover part of the type-aware checking we lose.
  • TypeScript 7.0. The published .d.ts files are byte-identical to the TS 6 build.
  • vitest 5 and jest 30. Removed chai, ts-jest, @types/jest, eslint, typescript-eslint and globals.
  • npm audit --omit=dev reports 0 vulnerabilities. 19 moderate/low advisories remain, all in dev-only packages inside jest's own dependency tree.

Bug fixes

  • ESM consumers on moduleResolution: nodenext got broken types. L.map didn't type-check because both conditions pointed at the CJS-shaped .d.ts. The exports map now gives import its .d.mts and require its .d.ts. This was broken in 2.x too.
  • Importing the built ESM package under jest-environment-jsdom threw TextDecoder is not defined. The bundler hoisted undici's import above the polyfills, so undici is now loaded lazily. The Jest fixture now tests the built dist/ output, which is how it caught this.
  • Importing leaflet-node broke util.promisify(setTimeout). The polyfill replaced Node's global setTimeout everywhere. It now wraps timers only in jsdom-style environments.
  • Jest/jsdom users crashed on undici 8 with MessagePort is not defined. Added MessagePort/MessageChannel polyfills, and all polyfills now apply only when the global is missing.
  • Proxy handling: HTTPS_PROXY was used for http:// URLs, NO_PROXY was ignored, and the proxy was cached forever. This now uses undici's EnvHttpProxyAgent, re-reads the variables on each request, and shares one agent across concurrent requests.
  • initializeEnvironment(options) was a no-op after the automatic init. It now applies to maps created afterwards.
  • file:// URLs with spaces or Windows drive letters failed to load. They now go through fileURLToPath and pathToFileURL.
  • Tile requests now send an identifying User-Agent, which OSM's tile policy requires, and are aborted after 30 seconds.

Packaging and CI

  • Added the MIT LICENSE file, which package.json listed but didn't exist. Also added homepage, bugs and a git+https repository URL.
  • CI runs on Node 22, 24 and 26 with Biome, typecheck, coverage and the docs test. Coverage runs separately from the docs test, because the docs test rebuilds dist/ and made them flaky when run together.
  • Publish, release and docs workflows now use Node 24, since npm@latest no longer installs on Node 20. The release workflow no longer tries to attach image-stitch's bundle.
  • Removed stray debug scripts and the legacy .eslintrc* files. The old lint glob only matched src/polyfills, so most files were never linted.

Tests and coverage

  • Before: 164 tests, 72.5% lines and 53% branches. After: 195 tests, 81% lines and 65% branches, not counting the docs test.
  • New tests cover image loading through a real local HTTP server and forward proxy (User-Agent, 404, HTTP_PROXY, NO_PROXY, ALL_PROXY, concurrent requests, variable changes), file URLs with spaces, data URIs, initializeEnvironment options, promisify(setTimeout), the marker icon path, and every CSS positioning path in the exporter.
  • Added a coverage floor in vitest.config.mts.
  • Relaxed two pixel tolerances, because canvas 1.x renders text and shadows slightly differently.

Verification

  • npm run lint, npm run typecheck, npm run test:coverage (178 passed) and npm run test:docs (17 passed) all pass on Node 22.
  • Installed the npm pack tarball in a clean project. ESM rendered a PNG, CJS require works for both entry points, and the types check under both nodenext and bundler resolution.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QhgcNyPGK62bg5XGGZhpkx

Node 20 reached end of life in April 2026. jsdom 31, undici 8, vitest 5 and
tsup 9 all need Node 22, so engines now mirror jsdom's range.

- Runtime: jsdom 31, undici 8, @napi-rs/canvas 1.1, @fontsource/noto-sans 5.3
- Dev: vitest 5, eslint 10, typescript 6.0, tsup 9, jest 30, typescript-eslint 8.72
- Drop unused chai and the redundant @typescript-eslint/* packages
- Remove legacy .eslintrc files ignored by ESLint 9+; lint now covers all of src
- tsconfig: moduleResolution bundler (node10 is deprecated in TS 6)
- tsup: target node22, drop the undeclared glob import
- undici polyfills: add MessagePort/MessageChannel for jest-environment-jsdom
  (undici 8 needs them) and only patch globals that are actually missing
- Recalibrate two pixel tolerances for canvas 1.x text and shadow rendering

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QhgcNyPGK62bg5XGGZhpkx
- Proxy: use EnvHttpProxyAgent so HTTP_PROXY/HTTPS_PROXY apply to the
  right scheme and NO_PROXY is honoured; re-read variables per request
- Send an identifying User-Agent to tile servers and abort fetches after 30s
- Decode file:// URLs with fileURLToPath (spaces, Windows drive letters)
  and build the marker icon path with pathToFileURL
- Stop replacing Node's global setTimeout, which broke
  util.promisify(setTimeout) for any app that imported leaflet-node
- initializeEnvironment() options now apply after the automatic init
  instead of being silently ignored
- Keep error causes and fix the remaining lint errors
- New tests for image loading, proxies, init options and export
  positioning; add a coverage floor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QhgcNyPGK62bg5XGGZhpkx
- Add the MIT LICENSE file that package.json already promised
- CI: test Node 22/24/26, run lint, typecheck and coverage
- Publish/release/docs workflows on Node 24 (npm@latest no longer runs on 20)
- Release workflow no longer tries to attach image-stitch's bundle
- README: API table, Node requirement, network/proxy section, current
  ts-jest config syntax
- Remove stray debugging scripts from the repo root

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QhgcNyPGK62bg5XGGZhpkx
@jburnhams jburnhams self-assigned this Nov 9, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T20:52:09.425507Z 9b6fc1a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

- Build with tsdown instead of tsup, which is no longer maintained. File names
  are unchanged; index and testing now share one chunk instead of each
  bundling a copy of the library.
- exports map: separate types per condition (.d.mts for import, .d.ts for
  require). Before this, ESM consumers on moduleResolution nodenext got the
  CJS-shaped types and `L.map` did not type-check.
- Load undici lazily. In the bundled ESM output its static import ran before
  the polyfills, so importing the package under jest-environment-jsdom threw
  "TextDecoder is not defined". The proxy agent is cached as a promise so
  concurrent first requests share one agent.
- Replace ESLint and typescript-eslint with Biome (lint and format), keeping
  noFloatingPromises and noMisusedPromises. Format the repo with Biome.
- TypeScript 7.0. Type declarations are byte-identical to the TS 6 build.
- Jest fixture is now plain .mjs against dist/, so ts-jest and @types/jest
  are no longer needed. pretest scripts build first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QhgcNyPGK62bg5XGGZhpkx
@jburnhams jburnhams changed the title Breaking: Node 22+, latest dependencies, and bug fixes for public use Breaking: Node 22+, latest dependencies, tsdown/Biome/TS 7, and bug fixes Nov 9, 2026
oxlint --type-aware runs typescript-eslint's type-checked rules through
tsgolint, which is built on typescript-go (TS 7). This restores the checks
dropped with typescript-eslint: no-floating-promises, no-misused-promises,
await-thenable, require-await, unbound-method, prefer-promise-reject-errors,
restrict-template-expressions, no-base-to-string, only-throw-error and others.
Biome still handles formatting and the general lint rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QhgcNyPGK62bg5XGGZhpkx
@jburnhams
jburnhams merged commit 4630d4e into main Nov 9, 2026
3 checks passed
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.

2 participants