-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(es/minifier): Fix a bug about eval
of name mangler
#7615
Merged
+154
−12
Merged
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
1b18fe7
Add tests
kdy1 2f81c1b
Rename
kdy1 516768f
Rename
kdy1 64dc794
Reduce
kdy1 e6a2415
Reduce
kdy1 6bc8e6e
external helpers
kdy1 5efcb70
Reduce
kdy1 25010b1
Reduce
kdy1 bd91293
beutify
kdy1 cb420b2
Remove
kdy1 f00754b
Reduce
kdy1 30e241a
Reduce
kdy1 f9df427
Reduce
kdy1 d91bd8b
Reduce
kdy1 7a6aa82
Reduce
kdy1 71bce8a
Reduce
kdy1 fd812b1
Reduce
kdy1 c817147
Reduce
kdy1 cd78787
Reduce
kdy1 854e879
Reduce
kdy1 dbe32ae
Reduce
kdy1 5b9c872
Reduce
kdy1 2f980d2
Reduce
kdy1 4d8f220
Reduce
kdy1 995957a
Reduce
kdy1 ad17440
Reduce
kdy1 410c447
Reduce
kdy1 b5e7309
Reduce
kdy1 a021b03
Reduce
kdy1 19f815e
Reduce
kdy1 5e4a0e0
Reduce
kdy1 4b6cc50
Reduce
kdy1 04bebbe
Reduce
kdy1 b44f637
Reduce
kdy1 db21bcf
Reduce
kdy1 d23d1a7
Reduce
kdy1 c78abd8
Reduce
kdy1 1d4ed42
Reduce
kdy1 84a8fd3
Reduce
kdy1 9038cca
Reduce
kdy1 f35d300
Reduce
kdy1 2ae2aa7
Reduce
kdy1 46da779
Reduce
kdy1 2db90d4
Reduce
kdy1 2472fb6
Reduce
kdy1 3e39c3c
Reduce
kdy1 4ff4737
Reduce
kdy1 00c16cb
Reduce
kdy1 2af30e7
Reduce
kdy1 2adc820
Reduce
kdy1 2ee968c
Reduce
kdy1 b9f14da
Reduce
kdy1 b8b5d97
Reduce
kdy1 8968f23
Reduce
kdy1 d0c6542
Reduce
kdy1 6e874f7
Reduce
kdy1 6eefbb2
Reduce
kdy1 5e045f3
Reduce
kdy1 ae743e2
Reduce
kdy1 a349a3e
Reduce
kdy1 93afb39
Reduce
kdy1 70679e1
Reduce
kdy1 b9db788
Reduce
kdy1 c3fea3b
Reduce
kdy1 3a6bcda
Reduce
kdy1 2405813
Reduce
kdy1 57870cc
Reduce
kdy1 3f3f92e
Reduce
kdy1 7fbdc1c
Reduce
kdy1 6f0b083
Reduce
kdy1 134e773
Reduce
kdy1 3901031
Reduce
kdy1 639a583
Reduce
kdy1 758b8fc
Reduce
kdy1 ecd3fe4
Reduce
kdy1 37ddd16
Reduce
kdy1 ad3549e
Reduce
kdy1 3b059de
Reduce
kdy1 f9c56fb
Reduce
kdy1 9e9757b
Reduce with config.json
kdy1 d824927
Disable UPDATE=1
kdy1 9b00764
Reduce with config.json
kdy1 45e1866
Reduce with config.json
kdy1 4d6e6c3
Reduce with config.json
kdy1 52d8626
Reduce with config.json
kdy1 92bc544
fix order
kdy1 d3df78b
Update test refs
kdy1 a18edd8
Real fix
kdy1 a0a11c2
What the hell
kdy1 c481fde
Comment
kdy1 9e7fdf2
Update test refs
kdy1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
|
||
export DIFF=0 | ||
export UPDATE=1 | ||
# export UPDATE=1 | ||
export SWC_CHECK=0 | ||
export SWC_RUN=0 | ||
|
||
|
8 changes: 8 additions & 0 deletions
8
crates/swc_ecma_minifier/tests/fixture/next/outstatic/1/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"defaults": true, | ||
"conditionals": false, | ||
"collapse_vars": false, | ||
"properties": false, | ||
"join_vars": false, | ||
"passes": 1 | ||
} |
73 changes: 73 additions & 0 deletions
73
crates/swc_ecma_minifier/tests/fixture/next/outstatic/1/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ | ||
[285], { | ||
1973: | ||
(function (module) { | ||
eval(module.code) | ||
}), | ||
|
||
1985: | ||
(function (__unused_webpack_module, exports, __webpack_require__) { | ||
"use strict"; | ||
|
||
var t = 0, | ||
r = e => "checkbox" === e.type; | ||
var u = (e, t) => e.has((e => e.substring(0, e.search(/\.\d+(\.|$)/)) || e)(t)), | ||
d = () => { | ||
}; | ||
|
||
function H(e, t, r) { | ||
} | ||
var ee = e => "radio" === e.type; | ||
|
||
function Me(e = {}) { | ||
let t, n = { | ||
...e | ||
}, | ||
y = {}, | ||
h = 0, | ||
p = { | ||
}, | ||
_ = { | ||
}; | ||
const E = 0, $ = async e => { | ||
const r = e.target; | ||
let s = r.name; | ||
const a = 0; | ||
if (a) { | ||
let l, c; | ||
const p = 0; | ||
p ? (a._f.onBlur && a._f.onBlur(e), t && t(0)) : a._f.onChange && a._f.onChange(e); | ||
const A = 0; | ||
|
||
a._f.deps && E(s, c, l, A) | ||
} | ||
}, te = (e, t = {}) => { | ||
let s = 0; | ||
const a = 0; | ||
return s ? a && H(h, e, t.disabled ? void 0 : 0) : 0, { | ||
onChange: $, | ||
onBlur: $, | ||
ref: a => { | ||
if (a) { | ||
te(e, t), s = d(y, e); | ||
const n = 0; | ||
(e => ee(e) || r(e))(n), | ||
s._f.refs; | ||
} else s = d(y, e, {}), s._f && (s._f.mount = !1), (n.shouldUnregister || t.shouldUnregister) && (!u(_.array, e) || !p.action) && _.unMount.add(e) | ||
} | ||
} | ||
}; | ||
|
||
} | ||
exports.useForm = function (e = {}) { | ||
const r = t.default.useRef(); | ||
r.current ? r.current.control._options = e : r.current = { | ||
...Me(e), | ||
}; | ||
|
||
}; | ||
}), | ||
|
||
|
||
} | ||
]); |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/fixture/next/outstatic/1/mangle.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
43 changes: 43 additions & 0 deletions
43
crates/swc_ecma_minifier/tests/fixture/next/outstatic/1/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ | ||
[ | ||
285 | ||
], | ||
{ | ||
1973: function(module) { | ||
eval(module.code); | ||
}, | ||
1985: function(o, f, i) { | ||
"use strict"; | ||
var k = 0, v = (o)=>"checkbox" === o.type; | ||
var b = (o, f)=>{ | ||
var i; | ||
return o.has((i = f, i.substring(0, i.search(/\.\d+(\.|$)/)) || i)); | ||
}, g = ()=>{}; | ||
function C(o, f, i) {} | ||
var m = (o)=>"radio" === o.type; | ||
function w(o = {}) { | ||
let f, i = { | ||
...o | ||
}, k = {}, v = 0, b = {}, g = {}; | ||
const C = 0, m = async (o)=>{ | ||
const i = o.target; | ||
let k = i.name; | ||
const v = 0; | ||
if (v) { | ||
let i, b; | ||
const g = 0; | ||
g ? (v._f.onBlur && v._f.onBlur(o), f && f(0)) : v._f.onChange && v._f.onChange(o); | ||
const m = 0; | ||
v._f.deps && C(k, b, i, m); | ||
} | ||
}; | ||
} | ||
f.useForm = function(o = {}) { | ||
const f = k.default.useRef(); | ||
f.current ? f.current.control._options = o : f.current = { | ||
...w(o) | ||
}; | ||
}; | ||
} | ||
} | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case is too large for me to really understand what's changed, and the diff between this and playground doesn't really help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comments for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't know the exact cause of the problem.