From a75dc8bed97daecc509387a23a72699620695ab2 Mon Sep 17 00:00:00 2001 From: Alexander Krasnoyarov Date: Sat, 19 Sep 2020 19:40:11 +0300 Subject: [PATCH] fix: related asset info --- src/index.js | 3 ++- test/TerserPlugin.test.js | 40 +++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/index.js b/src/index.js index 29fb0636..7b144397 100644 --- a/src/index.js +++ b/src/index.js @@ -457,7 +457,8 @@ class TerserPlugin { if (extractedCommentsSource) { const { commentsFilename } = output; - newInfo.related = { license: commentsFilename }; + // TODO `...` required only for webpack@4 + newInfo.related = { license: commentsFilename, ...info.related }; allExtractedComments.set(name, { extractedCommentsSource, diff --git a/test/TerserPlugin.test.js b/test/TerserPlugin.test.js index 28fc37f0..652fd5e5 100644 --- a/test/TerserPlugin.test.js +++ b/test/TerserPlugin.test.js @@ -946,8 +946,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler); @@ -1007,8 +1007,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler); @@ -1068,8 +1068,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); new ModifyExistingAsset({ name: 'js.js' }).apply(compiler); @@ -1132,8 +1132,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler); @@ -1194,8 +1194,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); new ModifyExistingAsset({ name: 'js.js' }).apply(compiler); @@ -1251,8 +1251,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler); @@ -1306,8 +1306,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); new ModifyExistingAsset({ name: 'two.js', comment: true }).apply(compiler); @@ -1367,8 +1367,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler); @@ -1426,8 +1426,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); new ModifyExistingAsset({ name: 'two.js', comment: true }).apply(compiler); @@ -1489,8 +1489,8 @@ describe('TerserPlugin', () => { } expect(readsAssets(compiler, stats)).toMatchSnapshot('assets'); - expect(getWarnings(stats)).toMatchSnapshot('errors'); - expect(getErrors(stats)).toMatchSnapshot('warnings'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); await new Promise(async (resolve) => { const newStats = await compile(compiler);