Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

Commit b31b574

Browse files
evilebottnawimichael-ciniawsky
authored andcommitted
fix(index): don't remove legal comments by default (options.extractComments) (#250)
1 parent f9e55fe commit b31b574

File tree

3 files changed

+235
-127
lines changed

3 files changed

+235
-127
lines changed

Diff for: src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class UglifyJsPlugin {
4242
exclude,
4343
uglifyOptions: {
4444
output: {
45-
comments: false,
45+
comments: extractComments ? false : /^\**!|@preserve|@license|@cc_on/,
4646
},
4747
...uglifyOptions,
4848
},
+70-47
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,130 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`errors 1`] = `Array []`;
3+
exports[`"options.extractComments" is "boolean" - "true": errors 1`] = `Array []`;
44

5-
exports[`errors 2`] = `Array []`;
5+
exports[`"options.extractComments" is "boolean" - "true": test.js 1`] = `"var foo=1;"`;
66

7-
exports[`errors 3`] = `Array []`;
8-
9-
exports[`errors 4`] = `Array []`;
10-
11-
exports[`errors 5`] = `Array []`;
12-
13-
exports[`nested/nested/test1.js 1`] = `
7+
exports[`"options.extractComments" is "boolean" - "true": test1.js 1`] = `
148
"/*! For license information please see test1.js.LICENSE */
159
var foo=1;"
1610
`;
1711

18-
exports[`nested/nested/test1.js.LICENSE 1`] = `
19-
"/* Comment */
12+
exports[`"options.extractComments" is "boolean" - "true": test1.js.LICENSE 1`] = `
13+
"/*! Legal Comment */
2014
"
2115
`;
2216

23-
exports[`nested/test.js 1`] = `
17+
exports[`"options.extractComments" is "boolean" - "true": warnings 1`] = `Array []`;
18+
19+
exports[`"options.extractComments" is "function": errors 1`] = `Array []`;
20+
21+
exports[`"options.extractComments" is "function": test.js 1`] = `
2422
"/*! For license information please see test.js.LICENSE */
2523
var foo=1;"
2624
`;
2725

28-
exports[`nested/test1.js.LICENSE 1`] = `
26+
exports[`"options.extractComments" is "function": test.js.LICENSE 1`] = `
2927
"// Comment
3028
"
3129
`;
3230

33-
exports[`test.js 1`] = `"var foo=1;"`;
34-
35-
exports[`test.js 2`] = `"var foo=1;"`;
36-
37-
exports[`test.js 3`] = `
38-
"/*! For license information please see test.js.LICENSE */
31+
exports[`"options.extractComments" is "function": test1.js 1`] = `
32+
"/*! For license information please see test1.js.LICENSE */
3933
var foo=1;"
4034
`;
4135

42-
exports[`test.js 4`] = `
43-
"/*! For license information please see test.js.LICENSE */
44-
var foo=1;"
36+
exports[`"options.extractComments" is "function": test1.js.LICENSE 1`] = `
37+
"/* Comment */
38+
"
4539
`;
4640

47-
exports[`test.js 5`] = `
48-
"/*! For license information please see test1.js.LICENSE */
49-
var foo=1;"
50-
`;
41+
exports[`"options.extractComments" is "function": warnings 1`] = `Array []`;
42+
43+
exports[`"options.extractComments" is "object": errors 1`] = `Array []`;
5144

52-
exports[`test.js 6`] = `
45+
exports[`"options.extractComments" is "object": test.js 1`] = `
5346
"/*! License information can be found in test.license.js */
5447
var foo=1;"
5548
`;
5649

57-
exports[`test.js.LICENSE 1`] = `
50+
exports[`"options.extractComments" is "object": test.license.js 1`] = `
5851
"// Comment
5952
"
6053
`;
6154

62-
exports[`test.js.LICENSE 2`] = `
63-
"// Comment
64-
"
55+
exports[`"options.extractComments" is "object": warnings 1`] = `Array []`;
56+
57+
exports[`"options.extractComments" is "regex": errors 1`] = `Array []`;
58+
59+
exports[`"options.extractComments" is "regex": test.js 1`] = `"var foo=1;"`;
60+
61+
exports[`"options.extractComments" is "regex": test1.js 1`] = `
62+
"/*! For license information please see test1.js.LICENSE */
63+
var foo=1;"
6564
`;
6665

67-
exports[`test.license.js 1`] = `
68-
"// Comment
66+
exports[`"options.extractComments" is "regex": test1.js.LICENSE 1`] = `
67+
"// foo
6968
"
7069
`;
7170

72-
exports[`test1.js 1`] = `"var foo=1;"`;
71+
exports[`"options.extractComments" is "regex": warnings 1`] = `Array []`;
7372

74-
exports[`test1.js 2`] = `
73+
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: errors 1`] = `Array []`;
74+
75+
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: nested/nested/test1.js 1`] = `
7576
"/*! For license information please see test1.js.LICENSE */
7677
var foo=1;"
7778
`;
7879

79-
exports[`test1.js 3`] = `
80-
"/*! For license information please see test1.js.LICENSE */
80+
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: nested/nested/test1.js.LICENSE 1`] = `
81+
"/* Comment */
82+
"
83+
`;
84+
85+
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: nested/test.js 1`] = `
86+
"/*! For license information please see test.js.LICENSE */
8187
var foo=1;"
8288
`;
8389

84-
exports[`test1.js.LICENSE 1`] = `
85-
"// foo
90+
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: nested/test.js.LICENSE 1`] = `
91+
"// Comment
8692
"
8793
`;
8894

89-
exports[`test1.js.LICENSE 2`] = `
90-
"/* Comment */
95+
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: warnings 1`] = `Array []`;
96+
97+
exports[`"options.extractComments" is "string": errors 1`] = `Array []`;
98+
99+
exports[`"options.extractComments" is "string": test.js 1`] = `
100+
"/*! For license information please see test.js.LICENSE */
101+
var foo=1;"
102+
`;
103+
104+
exports[`"options.extractComments" is "string": test.js.LICENSE 1`] = `
105+
"// Comment
91106
"
92107
`;
93108

94-
exports[`test1.js.LICENSE 3`] = `
109+
exports[`"options.extractComments" is "string": test1.js 1`] = `
110+
"/*! For license information please see test1.js.LICENSE */
111+
var foo=1;"
112+
`;
113+
114+
exports[`"options.extractComments" is "string": test1.js.LICENSE 1`] = `
95115
"/* Comment */
96116
"
97117
`;
98118

99-
exports[`warnings 1`] = `Array []`;
119+
exports[`"options.extractComments" is "string": warnings 1`] = `Array []`;
100120

101-
exports[`warnings 2`] = `Array []`;
121+
exports[`"options.extractComments" is not specify: errors 1`] = `Array []`;
102122

103-
exports[`warnings 3`] = `Array []`;
123+
exports[`"options.extractComments" is not specify: test.js 1`] = `"var foo=1;"`;
104124

105-
exports[`warnings 4`] = `Array []`;
125+
exports[`"options.extractComments" is not specify: test1.js 1`] = `
126+
"/*! Legal Comment */
127+
var foo=1;"
128+
`;
106129

107-
exports[`warnings 5`] = `Array []`;
130+
exports[`"options.extractComments" is not specify: warnings 1`] = `Array []`;

0 commit comments

Comments
 (0)