File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,12 @@ describe('terser', () => {
27
27
} ,
28
28
load ( id ) {
29
29
if ( id === '\0entry.js' ) {
30
- return `const foo = 1;console.log(foo)`
30
+ return `
31
+ const foo = 1;
32
+ console.log(foo);
33
+ const bar = { hello: 1, ["world"]: 2 };
34
+ console.log(bar.hello + bar["world"]);
35
+ `
31
36
}
32
37
} ,
33
38
} ,
@@ -52,4 +57,21 @@ describe('terser', () => {
52
57
} )
53
58
expect ( resultCode ) . toContain ( 'prefix_' )
54
59
} )
60
+
61
+ test ( 'nameCache' , async ( ) => {
62
+ const nameCache = { }
63
+
64
+ await run ( {
65
+ compress : false ,
66
+ mangle : {
67
+ properties : {
68
+ keep_quoted : true ,
69
+ } ,
70
+ } ,
71
+ nameCache,
72
+ } )
73
+
74
+ expect ( nameCache ) . toHaveProperty ( 'props.props.$hello' )
75
+ expect ( nameCache ) . not . toHaveProperty ( 'props.props.$world' )
76
+ } )
55
77
} )
Original file line number Diff line number Diff line change @@ -66,7 +66,8 @@ export function terserPlugin(config: ResolvedConfig): Plugin {
66
66
( typeof options . mangle . properties === 'object' &&
67
67
options . mangle . properties . nth_identifier ?. get ) ) ) ||
68
68
typeof options . format ?. comments === 'function' ||
69
- typeof options . output ?. comments === 'function'
69
+ typeof options . output ?. comments === 'function' ||
70
+ options . nameCache
70
71
)
71
72
} ,
72
73
max : maxWorkers ,
You can’t perform that action at this time.
0 commit comments