Skip to content

Commit 7e8068b

Browse files
committed
failing test: minify, mangle-props, mangle-quoted
1 parent 99744d6 commit 7e8068b

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

internal/bundler/bundler_default_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6239,3 +6239,52 @@ func TestMangleQuotedProps(t *testing.T) {
62396239
},
62406240
})
62416241
}
6242+
6243+
func TestMangleQuotedPropsMinifySyntax(t *testing.T) {
6244+
loader_suite.expectBundled(t, bundled{
6245+
files: map[string]string{
6246+
"/keep.js": `
6247+
foo("_keepThisProperty");
6248+
foo((x, "_keepThisProperty"));
6249+
foo(x ? "_keepThisProperty" : "_keepThisPropertyToo");
6250+
x[foo("_keepThisProperty")];
6251+
x?.[foo("_keepThisProperty")];
6252+
({ [foo("_keepThisProperty")]: x });
6253+
(class { [foo("_keepThisProperty")] = x });
6254+
var { [foo("_keepThisProperty")]: x } = y;
6255+
foo("_keepThisProperty") in x;
6256+
`,
6257+
"/mangle.js": `
6258+
x['_mangleThis'];
6259+
x?.['_mangleThis'];
6260+
x[y ? '_mangleThis' : z];
6261+
x?.[y ? '_mangleThis' : z];
6262+
x[y ? z : '_mangleThis'];
6263+
x?.[y ? z : '_mangleThis'];
6264+
x[y, '_mangleThis'];
6265+
x?.[y, '_mangleThis'];
6266+
({ '_mangleThis': x });
6267+
({ ['_mangleThis']: x });
6268+
({ [(y, '_mangleThis')]: x });
6269+
(class { '_mangleThis' = x });
6270+
(class { ['_mangleThis'] = x });
6271+
(class { [(y, '_mangleThis')] = x });
6272+
var { '_mangleThis': x } = y;
6273+
var { ['_mangleThis']: x } = y;
6274+
var { [(z, '_mangleThis')]: x } = y;
6275+
'_mangleThis' in x;
6276+
(y ? '_mangleThis' : z) in x;
6277+
(y ? z : '_mangleThis') in x;
6278+
(y, '_mangleThis') in x;
6279+
`,
6280+
},
6281+
entryPaths: []string{"/keep.js", "/mangle.js"},
6282+
options: config.Options{
6283+
Mode: config.ModePassThrough,
6284+
AbsOutputDir: "/out",
6285+
MangleProps: regexp.MustCompile("_"),
6286+
MangleQuoted: true,
6287+
MinifySyntax: true,
6288+
},
6289+
})
6290+
}

internal/bundler/snapshots/snapshots_loader.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,26 @@ var { [(z, "a")]: x } = y;
863863
(y ? z : "a") in x;
864864
(y, "a") in x;
865865

866+
================================================================================
867+
TestMangleQuotedPropsMinifySyntax
868+
---------- /out/keep.js ----------
869+
foo("_keepThisProperty"), foo("_keepThisProperty"), foo(x ? "_keepThisProperty" : "_keepThisPropertyToo"), x[foo("_keepThisProperty")], x?.[foo("_keepThisProperty")], foo("_keepThisProperty") + "", class {
870+
[foo("_keepThisProperty")] = x;
871+
};
872+
var { [foo("_keepThisProperty")]: x } = y;
873+
foo("_keepThisProperty") in x;
874+
875+
---------- /out/mangle.js ----------
876+
x._mangleThis, x?._mangleThis, x[y ? "a" : z], x?.[y ? "a" : z], x[y ? z : "a"], x?.[y ? z : "a"], x[y, "a"], x?.[y, "a"], "a" + "", (y, "a") + "", class {
877+
a = x;
878+
}, class {
879+
["a"] = x;
880+
}, class {
881+
[(y, "a")] = x;
882+
};
883+
var { a: x } = y, { ["a"]: x } = y, { [(z, "a")]: x } = y;
884+
"a" in x, (y ? "a" : z) in x, (y ? z : "a") in x, y, "a" in x;
885+
866886
================================================================================
867887
TestMinifyIdentifiersImportPathFrequencyAnalysis
868888
---------- /out/import.js ----------

0 commit comments

Comments
 (0)