Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils): clone RegExp values with new RegExp instead of structuredClone (fix #19245, fix #18875) #19247

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

askoufis
Copy link

@askoufis askoufis commented Jan 21, 2025

Fixes #19245. Fixes #18875.

Description

Jest appears to provide its own global structuredClone that modifies RegExps in such a way that they fail instanceof RegExp checks, causing an error in a rollup plugin used by vite (and likely other errors elsewhere). As suggested, new RegExp seems to correctly clone RegExps in Jest.

I thought about writing a test that modified the structuredClone global but decided against it as that's more like testing jest implementation detail rather than regexp cloning behaviour (which is already tested).

…turedClone` (fix vitejs#19245, fix vitejs#18875)

- Jest appears to provide its own global `structuredClone` that modifies
  `RegExp`s in such a way that they fail `instanceof RegExp` checks,
  causing an error in a rollup plugin used by `vite` (and likely elsewhere).
  `new RegExp` seems to correctly clone `RegExp`s in Jest.
@askoufis askoufis force-pushed the fix/deep-clone-regexp branch from 313966b to 672e2ea Compare January 21, 2025 02:53
@askoufis askoufis changed the title fix(utils): Clone RegExp values with new RegExp instead of structuredClone (fix #19245, fix #18875) fix(utils): clone RegExp values with new RegExp instead of structuredClone (fix #19245, fix #18875) Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants