Closed ato closed 2 months ago
Hi @ato , now that we've worked out the dependency upgrades and related test issues in main, would you mind rebasing this on latest main? Thanks!
Rebased. :-)
Thanks for this @ato (and remembering the history of the adding the semicolon).
In wabac.js, we made this a more involved check to see if it the previous character is actually a newline, and a semicolon only then: https://github.com/webrecorder/wabac.js/blob/main/src/rewrite/jsrewriter.js#L76 from matching: https://github.com/webrecorder/wabac.js/blob/main/src/rewrite/jsrewriter.js#L115 so we don't have that issue there, but maybe even that is unnecessary?
Fixes #850
Description
This changes removes the regex rewrite rule that prepends a semicolon when
this.
special property access occurs immediately after a newline.For example:
will now be rewritten as:
instead of:
Motivation and Context
The prepended semicolon breaks code (such as jQuery in #850) that looks like:
I think the reason we started inserting the semicolon was because in situations like:
we used to rewrite to:
which the browser would interpret as a bogus function call like
2(this && ... )
. But nowadays prepending the semicolon should be unnecessary as we currently rewrite to:which will trigger JavaScript's automatic semicolon insertion rules like the original code does.
Types of changes
Checklist: