Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class UglifyJsPlugin {
exclude,
uglifyOptions: {
output: {
comments: /^\**!|@preserve|@license|@cc_on/,
comments: false,
},
...uglifyOptions,
},
Expand Down
9 changes: 6 additions & 3 deletions src/uglify/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const buildUglifyOptions = ({
mangle: mangle == null ? true : mangle,
output: {
shebang: true,
comments: /^\**!|@preserve|@license|@cc_on/,
comments: false,
beautify: false,
semicolons: true,
...output,
Expand All @@ -37,8 +37,11 @@ const buildComments = (options, uglifyOptions, extractedComments) => {
const condition = {};
const commentsOpts = uglifyOptions.output.comments;

if (
typeof options.extractComments === 'boolean' ||
// /^\**!|@preserve|@license|@cc_on/
if (typeof options.extractComments === 'boolean') {
condition.preserve = commentsOpts;
condition.extract = /^\**!|@preserve|@license|@cc_on/;
} else if (
typeof options.extractComments === 'string' ||
options.extractComments instanceof RegExp
) {
Expand Down
23 changes: 4 additions & 19 deletions test/__snapshots__/extract-comments-options.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ exports[`errors 3`] = `Array []`;

exports[`errors 4`] = `Array []`;

exports[`errors 5`] = `Array []`;

exports[`test.js 1`] = `
"/*! For license information please see test.js.LICENSE */
var foo=1;"
`;
exports[`test.js 1`] = `"var foo=1;"`;

exports[`test.js 2`] = `"var foo=1;"`;

Expand Down Expand Up @@ -52,10 +47,7 @@ exports[`test.license.js 1`] = `
"
`;

exports[`test1.js 1`] = `
"/*! For license information please see test1.js.LICENSE */
var foo=1;"
`;
exports[`test1.js 1`] = `"var foo=1;"`;

exports[`test1.js 2`] = `
"/*! For license information please see test1.js.LICENSE */
Expand All @@ -68,21 +60,16 @@ var foo=1;"
`;

exports[`test1.js.LICENSE 1`] = `
"/* Comment */
"
`;

exports[`test1.js.LICENSE 2`] = `
"// foo
"
`;

exports[`test1.js.LICENSE 3`] = `
exports[`test1.js.LICENSE 2`] = `
"/* Comment */
"
`;

exports[`test1.js.LICENSE 4`] = `
exports[`test1.js.LICENSE 3`] = `
"/* Comment */
"
`;
Expand All @@ -94,5 +81,3 @@ exports[`warnings 2`] = `Array []`;
exports[`warnings 3`] = `Array []`;

exports[`warnings 4`] = `Array []`;

exports[`warnings 5`] = `Array []`;
4 changes: 0 additions & 4 deletions test/all-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('when applied with all options', () => {
mangle: false,
output: {
beautify: true,
comments: false,
},
},
});
Expand All @@ -48,7 +47,6 @@ describe('when applied with all options', () => {
mangle: false,
output: {
beautify: true,
comments: false,
},
warnings: true,
},
Expand Down Expand Up @@ -295,7 +293,6 @@ describe('when applied with all options', () => {
mangle: false,
output: {
beautify: true,
comments: false,
},
},
});
Expand Down Expand Up @@ -349,7 +346,6 @@ describe('when applied with all options', () => {
mangle: false,
output: {
beautify: true,
comments: false,
},
},
});
Expand Down
5 changes: 0 additions & 5 deletions test/ecma.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('when applied with uglifyOptions.ecma', () => {
warnings: true,
output: {
beautify: true,
comments: false,
},
},
}).apply(compiler);
Expand Down Expand Up @@ -60,7 +59,6 @@ describe('when applied with uglifyOptions.ecma', () => {
warnings: true,
output: {
beautify: true,
comments: false,
},
},
}).apply(compiler);
Expand Down Expand Up @@ -97,7 +95,6 @@ describe('when applied with uglifyOptions.ecma', () => {
warnings: true,
output: {
beautify: true,
comments: false,
},
},
}).apply(compiler);
Expand Down Expand Up @@ -133,7 +130,6 @@ describe('when applied with uglifyOptions.ecma', () => {
warnings: true,
output: {
beautify: true,
comments: false,
},
},
}).apply(compiler);
Expand Down Expand Up @@ -170,7 +166,6 @@ describe('when applied with uglifyOptions.ecma', () => {
warnings: true,
output: {
beautify: true,
comments: false,
},
},
}).apply(compiler);
Expand Down
28 changes: 0 additions & 28 deletions test/extract-comments-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ describe('when options.extractComments', () => {
const plugin = new UglifyJsPlugin({
uglifyOptions: {
warnings: true,
output: {
comments: false,
},
mangle: {
properties: {
builtins: true,
Expand Down Expand Up @@ -77,11 +74,6 @@ describe('when options.extractComments', () => {
compilerEnv.context = '';

const plugin = new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false,
},
},
extractComments: true,
});
plugin.apply(compilerEnv);
Expand Down Expand Up @@ -119,11 +111,6 @@ describe('when options.extractComments', () => {
compilerEnv.context = '';

const plugin = new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false,
},
},
extractComments: /foo/,
});
plugin.apply(compilerEnv);
Expand Down Expand Up @@ -161,11 +148,6 @@ describe('when options.extractComments', () => {
compilerEnv.context = '';

const plugin = new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false,
},
},
extractComments: 'all',
});
plugin.apply(compilerEnv);
Expand Down Expand Up @@ -204,11 +186,6 @@ describe('when options.extractComments', () => {
compilerEnv.context = '';

const plugin = new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false,
},
},
extractComments: () => true,
});
plugin.apply(compilerEnv);
Expand Down Expand Up @@ -247,11 +224,6 @@ describe('when options.extractComments', () => {
compilerEnv.context = '';

const plugin = new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false,
},
},
extractComments: {
condition: true,
filename(file) {
Expand Down
5 changes: 0 additions & 5 deletions test/uglify/worker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ describe('matches snapshot', () => {
const options = {
file: 'test1.js',
input: 'var foo = 1;/* hello */',
uglifyOptions: {
output: {
comments: false,
},
},
extractComments: /foo/,
};
worker(JSON.stringify(options, encode), (error, data) => {
Expand Down