codeRanges() had only comment/string/template states: a `/` in code was
checked for `//` and `/*` and otherwise treated as plain code, so the body
of a regex literal was lexed as code. A backtick inside a pattern (the
entities htmlReplacer character class, or a simple /`/) then pushed
'template' onto the stack and flipped template parity — every import
after it was classified as string text and left un-rewritten, so the
plugin failed with "Failed to resolve module specifier 'react'".
Regression from #117610.
Adopts open PR #120302 (credit: that author): a `/` that cannot follow a
value opens a regex-literal region — isRegexStart() is the standard
division-vs-regex heuristic (keyword/charclass/paren awareness, property
division stays code), regexEnd() honors escapes and [...] classes and
refuses to cross a newline, so a division that never closes on its line
stays plain code and its imports still rewrite. The pattern itself is
excluded from code ranges: import-looking text inside it is neither
matched nor rewritten in place.
Regression coverage: backtick-in-regex + import after it; the entities
htmlReplacer line; divisions stay code (imports after real division
still rewrite); `from 'react'` inside a pattern is never rewritten.