Skip to content

replace escape-string-regexp with tiny-escape#5772

Closed
ofershap wants to merge 1 commit intomochajs:mainfrom
ofershap:replace-escape-string-regexp-with-tiny-escape
Closed

replace escape-string-regexp with tiny-escape#5772
ofershap wants to merge 1 commit intomochajs:mainfrom
ofershap:replace-escape-string-regexp-with-tiny-escape

Conversation

@ofershap
Copy link

@ofershap ofershap commented Feb 26, 2026

PR Checklist

Note: #5746 is a Renovate bot PR to bump escape-string-regexp to v5, which can't land because v5 is ESM-only. This PR offers an alternative path that doesn't need the label.

Overview

escape-string-regexp v5 is ESM-only, so the Renovate PR to upgrade from v4 (#5746) can't land while mocha is still CommonJS (#5400).

tiny-escape has the same API and ships both ESM and CJS. 192 bytes gzipped, zero deps, TypeScript types included.

This unblocks the upgrade without waiting for the CJS-to-ESM migration.

All tests pass (lint, test-node, test-browser).

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 26, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: ofershap / name: Ofer Shapira (b880931)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

👋 Hi @ofershap, thanks for the pull request! A scan flagged a concern with it. Could you please take a look?

[pr-task-completion] This PR's body is missing [x] checks on the following tasks from the PR template.

Repositories often provide a set of tasks that pull request authors are expected to complete. Those tasks should be marked as completed with a [x] in the pull request description. Please complete those tasks and mark the checks as [x] completed.

🗺️ This message was posted automatically by OctoGuide: a bot for GitHub repository best practices.

escape-string-regexp v5 is ESM-only, which blocks upgrading from v4
(see mochajs#5746). tiny-escape has the same API and ships both ESM and CJS
with TypeScript types. 192 bytes gzipped, zero deps.

Made-with: Cursor
@ofershap ofershap force-pushed the replace-escape-string-regexp-with-tiny-escape branch from dc5c4c3 to b880931 Compare February 26, 2026 21:25
@mark-wiemer
Copy link
Member

@ofershap ESM-only is not a blocker for us. Mocha's main branch is for v12 and supports Node 20.19.0+, which allows us to require ESM modules. That said, always open to switching to smaller dependencies :) I'll create a backing issue for deeper conversation and link this PR to it :)

@mark-wiemer mark-wiemer marked this pull request as draft February 27, 2026 01:14
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.74%. Comparing base (5905ed9) to head (b880931).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5772   +/-   ##
=======================================
  Coverage   88.74%   88.74%           
=======================================
  Files          66       66           
  Lines        4744     4744           
  Branches      976      976           
=======================================
  Hits         4210     4210           
  Misses        534      534           

☔ View full report in Codecov by Sentry.
📢 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.

@roman-psc
Copy link

roman-psc commented Feb 27, 2026

Once mocha becomes Node >= 24, RegExp.escape can be used

@JoshuaKGoldberg
Copy link
Member

Closing out as #5773 is wontfix. Thanks for thinking of us!

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.

🛠️ Repo: replace escape-string-regexp with tiny-escape

4 participants