-
-
Notifications
You must be signed in to change notification settings - Fork 233
Open
Description
Hi @tdewolff!
First of all, thanks for this great project!
I recently found an example where the minifier produces JavaScript that throws at runtime, while the original code executes correctly.
Create a file example.js with the following content:
function Rh(){return[0,0,0]}
function ka(){return[function(){return[0,0]},0]}
function sr(){return 0}
function my(){return 0}
var h={useState:()=>[0,()=>{}],useRef:()=>({current:0})}
function Zo(f){return f}
function ku(x){return x}
var Ow = ["E", " "],
uoe = ["AD", "PU", "H"],
SE = ["AU", "PD", "E"],
doe = [...uoe, ...SE],
hoe = { ltr: [...Ow, "AR"], rtl: [...Ow, "AL"] },
goe = { ltr: ["AL"], rtl: ["AR"] },
Jh = "M",
[mh, poe, foe] = Rh(Jh),
[gl, CE] = ka(Jh, [foe, sr, my]),
gy = sr(),
EE = my(),
[boe, pl] = gl(Jh),
[yoe, eg] = gl(Jh),
AE = e => {
const { __scopeMenu: o, open: t = !1, children: a, dir: i, onOpenChange: r, modal: n = !0 } = e,
c = gy(o),
[l, m] = h.useState(null),
u = h.useRef(!1),
d = Zo(r),
g = ku(i);
};
console.log("Everything ok!")
Run it, for instance node example.js.
Output Everything ok!.
Minify it:
./minify --type js < example.js > output.js
Run the minified version, for instance node output.js.
Output:
TypeError: Ow is not iterable
at Object.<anonymous> (.../test-minify-js/output/repro-minify.js:1:347)
at Module._compile (node:internal/modules/cjs/loader:1829:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1969:10)
at Module.load (node:internal/modules/cjs/loader:1552:32)
at Module._load (node:internal/modules/cjs/loader:1354:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
at node:internal/main/run_main_module:33:47
The minifier seems to reorder parts of the chained var declaration without respecting dependencies between initializers.
Thanks,
Marco
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels