-
Notifications
You must be signed in to change notification settings - Fork 115
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
Cannot split a chunk that has already been edited #208
Comments
Here's an reproduction: import MagicString from 'magic-string'
const s = new MagicString('from foo')
s.replace(/from foo/g, 'bar')
s.replace(/foo/g, 'baz')
// Cannot split a chunk that has already been edited (0:5 – "from foo") I wouldn't expect the second |
https://github.com/Rich-Harris/magic-string#sreplace-regexp-substitution-
This is by design (or limitation), since you can't calculate the offset of the replaced string. The solution I can think about is to avoid cascading replace on MagicString but inside the replacer function. |
calling
s.replace()
after previously replacing a section in a magic string throws the following error:cc: @antfu
related: nuxt/nuxt#13439
The text was updated successfully, but these errors were encountered: