rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

fix(postcss-hover-classes): avoid large regex overflow by filtering selectors

Open EricLLLLLL opened this issue 6 months ago • 1 comments

Problem

When using the old postcss-hover-classes plugin, large stylesheets with many :hover selectors caused the following error:

Regular expression too large

This is reported in #1675.


Solution

This PR rewrites the plugin logic with the following improvements:

  • Filters out only :hover selectors before applying replacements
  • Uses a WeakSet to ensure we only process each rule once
  • Avoids unnecessary string operations and large regex inputs

This not only solves the regex overflow issue but also improves memory efficiency and overall performance when processing large stylesheets.


Related Issue

Closes #1675

EricLLLLLL avatar Apr 11 '25 01:04 EricLLLLLL