Repository: webpack-contrib/compression-webpack-plugin
Pull request #179 (2020-08-14 16:13:23)

fix: default value of the `filename` option is `'[path].gz'`
BREAKING CHANGE: default value of the `filename` option is `'[path].gz'`

<!--
  HOLY CRAP a Pull Request. We ❤️ those!

  If you remove or skip this template, you'll make the 🐼 sad and the mighty god
  of Github will appear and pile-drive the close button from a great height
  while making animal noises.

  Please place an x (no spaces!) in all [ ] that apply
-->

This PR contains a:

- [ ] **bugfix**
- [ ] new **feature**
- [x] **code refactor**
- [x] **test update** <!-- if bug or feature is checked, this should be too -->
- [ ] **typo fix**
- [x] **metadata update**

### Motivation / Use-Case

no need `query` in `filename` by default

### Breaking Changes

Yes

### Additional Info

No

codecov[bot]: # [Codecov](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179?src=pr&el=h1) Report
> Merging [#179](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179?src=pr&el=desc) into [master](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/commit/1f9674e7573a2b30822c08d4c719fc4849cce793&el=desc) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179/graphs/tree.svg?width=650&height=150&src=pr&token=wLGv0aBxEE)](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #179   +/-   ##
=======================================
  Coverage   96.47%   96.47%           
=======================================
  Files           4        4           
  Lines         170      170           
  Branches       44       44           
=======================================
  Hits          164      164           
  Misses          4        4           
  Partials        2        2           
```


| [Impacted Files](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/index.js](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179/diff?src=pr&el=tree#diff-c3JjL2luZGV4Lmpz) | `95.83% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179?src=pr&el=footer). Last update [1f9674e...3b03343](https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/pull/179?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/README.md b/README.md
index f88b303..f158294 100644
--- a/README.md
+++ b/README.md
@@ -40,17 +40,17 @@ And run `webpack` via your preferred method.
 
 ## Options
 
-|                      Name                       |                   Type                    |      Default       | Description                                                                                                   |
-| :---------------------------------------------: | :---------------------------------------: | :----------------: | :------------------------------------------------------------------------------------------------------------ |
-|               **[`test`](#test)**               | `{String\|RegExp\|Array<String\|RegExp>}` |    `undefined`     | Include all assets that pass test assertion                                                                   |
-|            **[`include`](#include)**            | `{String\|RegExp\|Array<String\|RegExp>}` |    `undefined`     | Include all assets matching any of these conditions                                                           |
-|            **[`exclude`](#exclude)**            | `{String\|RegExp\|Array<String\|RegExp>}` |    `undefined`     | Exclude all assets matching any of these conditions                                                           |
-|          **[`algorithm`](#algorithm)**          |           `{String\|Function}`            |       `gzip`       | The compression algorithm/function                                                                            |
-| **[`compressionOptions`](#compressionoptions)** |                `{Object}`                 |   `{ level: 9 }`   | Compression options for `algorithm`                                                                           |
-|          **[`threshold`](#threshold)**          |                `{Number}`                 |        `0`         | Only assets bigger than this size are processed (in bytes)                                                    |
-|           **[`minRatio`](#minratio)**           |                `{Number}`                 |       `0.8`        | Only assets that compress better than this ratio are processed (`minRatio = Compressed Size / Original Size`) |
-|           **[`filename`](#filename)**           |           `{String\|Function}`            | `[path].gz[query]` | The target asset filename.                                                                                    |
-|              **[`cache`](#cache)**              |                `{Boolean}`                |       `true`       | Enable file caching                                                                                           |
+|                      Name                       |                   Type                    |    Default     | Description                                                                                                   |
+| :---------------------------------------------: | :---------------------------------------: | :------------: | :------------------------------------------------------------------------------------------------------------ |
+|               **[`test`](#test)**               | `{String\|RegExp\|Array<String\|RegExp>}` |  `undefined`   | Include all assets that pass test assertion                                                                   |
+|            **[`include`](#include)**            | `{String\|RegExp\|Array<String\|RegExp>}` |  `undefined`   | Include all assets matching any of these conditions                                                           |
+|            **[`exclude`](#exclude)**            | `{String\|RegExp\|Array<String\|RegExp>}` |  `undefined`   | Exclude all assets matching any of these conditions                                                           |
+|          **[`algorithm`](#algorithm)**          |           `{String\|Function}`            |     `gzip`     | The compression algorithm/function                                                                            |
+| **[`compressionOptions`](#compressionoptions)** |                `{Object}`                 | `{ level: 9 }` | Compression options for `algorithm`                                                                           |
+|          **[`threshold`](#threshold)**          |                `{Number}`                 |      `0`       | Only assets bigger than this size are processed (in bytes)                                                    |
+|           **[`minRatio`](#minratio)**           |                `{Number}`                 |     `0.8`      | Only assets that compress better than this ratio are processed (`minRatio = Compressed Size / Original Size`) |
+|           **[`filename`](#filename)**           |           `{String\|Function}`            |  `[path].gz`   | The target asset filename.                                                                                    |
+|              **[`cache`](#cache)**              |                `{Boolean}`                |     `true`     | Enable file caching                                                                                           |
 
 ### `test`
 
@@ -236,7 +236,7 @@ The target asset filename.
 module.exports = {
   plugins: [
     new CompressionPlugin({
-      filename: '[path].gz[query]',
+      filename: '[path].gz',
     }),
   ],
 };
@@ -371,7 +371,7 @@ const zlib = require('zlib');
 module.exports = {
   plugins: [
     new CompressionPlugin({
-      filename: '[path].br[query]',
+      filename: '[path].br',
       algorithm: 'brotliCompress',
       test: /\.(js|css|html|svg)$/,
       compressionOptions: {
@@ -398,14 +398,14 @@ const zlib = require('zlib');
 module.exports = {
   plugins: [
     new CompressionPlugin({
-      filename: '[path].gz[query]',
+      filename: '[path].gz',
       algorithm: 'gzip',
       test: /\.js$|\.css$|\.html$/,
       threshold: 10240,
       minRatio: 0.8,
     }),
     new CompressionPlugin({
-      filename: '[path].br[query]',
+      filename: '[path].br',
       algorithm: 'brotliCompress',
       test: /\.(js|css|html|svg)$/,
       compressionOptions: {
diff --git a/src/index.js b/src/index.js
index dbb6fdc..68f11f0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -27,7 +27,7 @@ class CompressionPlugin {
       cache = true,
       algorithm = 'gzip',
       compressionOptions = {},
-      filename = '[path].gz[query]',
+      filename = '[path].gz',
       threshold = 0,
       minRatio = 0.8,
       deleteOriginalAssets = false,


Test patch:
diff --git a/test/CompressionPlugin.test.js b/test/CompressionPlugin.test.js
index 3deaeba..6a50be8 100644
--- a/test/CompressionPlugin.test.js
+++ b/test/CompressionPlugin.test.js
@@ -14,8 +14,6 @@ import {
   removeCache,
 } from './helpers/index';
 
-jest.setTimeout(30000);
-
 describe('CompressionPlugin', () => {
   beforeEach(() => {
     return removeCache();
diff --git a/test/__snapshots__/CompressionPlugin.test.js.snap.webpack4 b/test/__snapshots__/CompressionPlugin.test.js.snap.webpack4
index 367ef83..dd586a7 100644
--- a/test/__snapshots__/CompressionPlugin.test.js.snap.webpack4
+++ b/test/__snapshots__/CompressionPlugin.test.js.snap.webpack4
@@ -24,7 +24,7 @@ Array [
     },
   ],
   Array [
-    "async.async.js.gz?ver=810493800e70254b803c",
+    "async.async.js.gz",
     171,
     Object {
       "compressed": true,
@@ -36,7 +36,7 @@ Array [
     Object {
       "immutable": true,
       "related": Object {
-        "gziped": "async.async.js.gz?ver=810493800e70254b803c",
+        "gziped": "async.async.js.gz",
       },
     },
   ],
@@ -58,7 +58,7 @@ Array [
     },
   ],
   Array [
-    "main.js.gz?var=810493800e70254b803c",
+    "main.js.gz",
     3001,
     Object {
       "compressed": true,
@@ -70,7 +70,7 @@ Array [
     Object {
       "immutable": true,
       "related": Object {
-        "gziped": "main.js.gz?var=810493800e70254b803c",
+        "gziped": "main.js.gz",
       },
     },
   ],
@@ -179,7 +179,7 @@ Array [
     },
   ],
   Array [
-    "async.async.js.gz?ver=dc74724f7b13a2de5a20",
+    "async.async.js.gz",
     220,
     Object {
       "compressed": true,
@@ -198,7 +198,7 @@ Array [
     Object {
       "immutable": true,
       "related": Object {
-        "gziped": "async.async.js.gz?ver=dc74724f7b13a2de5a20",
+        "gziped": "async.async.js.gz",
       },
     },
   ],
@@ -220,14 +220,14 @@ Array [
     },
   ],
   Array [
-    "main.js.gz?var=dc74724f7b13a2de5a20",
+    "main.js.gz",
     3035,
     Object {
       "compressed": true,
     },
   ],
   Array [
-    "main.js.map.gz?var=dc74724f7b13a2de5a20",
+    "main.js.map.gz",
     3134,
     Object {
       "compressed": true,
@@ -239,7 +239,7 @@ Array [
     Object {
       "development": true,
       "related": Object {
-        "gziped": "main.js.map.gz?var=dc74724f7b13a2de5a20",
+        "gziped": "main.js.map.gz",
       },
     },
   ],
@@ -249,7 +249,7 @@ Array [
     Object {
       "immutable": true,
       "related": Object {
-        "gziped": "main.js.gz?var=dc74724f7b13a2de5a20",
+        "gziped": "main.js.gz",
       },
     },
   ],
@@ -377,7 +377,7 @@ Array [
     393,
   ],
   Array [
-    "async.async.js.gz?ver=dc74724f7b13a2de5a20",
+    "async.async.js.gz",
     171,
   ],
   Array [
@@ -385,7 +385,7 @@ Array [
     249,
   ],
   Array [
-    "main.js.gz?var=dc74724f7b13a2de5a20",
+    "main.js.gz",
     3002,
   ],
   Array [
diff --git a/test/__snapshots__/CompressionPlugin.test.js.snap.webpack5 b/test/__snapshots__/CompressionPlugin.test.js.snap.webpack5
index 1c94059..f048bec 100644
--- a/test/__snapshots__/CompressionPlugin.test.js.snap.webpack5
+++ b/test/__snapshots__/CompressionPlugin.test.js.snap.webpack5
@@ -28,7 +28,7 @@ Array [
     },
   ],
   Array [
-    "async.async.js.gz?ver=eaac5896fb97f0569c16",
+    "async.async.js.gz",
     181,
     Object {
       "compressed": true,
@@ -41,7 +41,7 @@ Array [
     Object {
       "immutable": true,
       "related": Object {
-        "gziped": "async.async.js.gz?ver=eaac5896fb97f0569c16",
+        "gziped": "async.async.js.gz",
       },
       "size": 269,
     },
@@ -66,7 +66,7 @@ Array [
     },
   ],
   Array [
-    "main.js.gz?var=eaac5896fb97f0569c16",
+    "main.js.gz",
     3583,
     Object {
       "compressed": true,
@@ -79,7 +79,7 @@ Array [
     Object {
       "immutable": true,
       "related": Object {
-        "gziped": "main.js.gz?var=eaac5896fb97f0569c16",
+        "gziped": "main.js.gz",
       },
       "size": 15312,
     },
@@ -193,7 +193,7 @@ Array [
     },
   ],
   Array [
-    "async.async.js.gz?ver=2aedac1e87f8e43534a8",
+    "async.async.js.gz",
     233,
     Object {
       "compressed": true,
@@ -214,7 +214,7 @@ Array [
     Object {
       "immutable": true,
       "related": Object {
-        "gziped": "async.async.js.gz?ver=2aedac1e87f8e43534a8",
+        "gziped": "async.async.js.gz",
         "sourceMap": "async.async.js.map?ver=2aedac1e87f8e43534a8",
       },
       "size": 334,
@@ -240,7 +240,7 @@ Array [
     },
   ],
   Array [
-    "main.js.gz?var=2aedac1e87f8e43534a8",
+    "main.js.gz",
     3617,
     Object {
       "compressed": true,
@@ -248,7 +248,7 @@ Array [
     },
   ],
   Array [
-    "main.js.map.gz?var=2aedac1e87f8e43534a8",
+    "main.js.map.gz",
     3585,
     Object {
       "compressed": true,
@@ -261,7 +261,7 @@ Array [
     Object {
       "development": true,
       "related": Object {
-        "gziped": "main.js.map.gz?var=2aedac1e87f8e43534a8",
+        "gziped": "main.js.map.gz",
       },
       "size": 11216,
     },
@@ -272,7 +272,7 @@ Array [
     Object {
       "immutable": true,
       "related": Object {
-        "gziped": "main.js.gz?var=2aedac1e87f8e43534a8",
+        "gziped": "main.js.gz",
         "sourceMap": "main.js.map?var=2aedac1e87f8e43534a8",
       },
       "size": 15373,
@@ -453,7 +453,7 @@ Array [
     393,
   ],
   Array [
-    "async.async.js.gz?ver=2aedac1e87f8e43534a8",
+    "async.async.js.gz",
     181,
   ],
   Array [
@@ -461,7 +461,7 @@ Array [
     269,
   ],
   Array [
-    "main.js.gz?var=2aedac1e87f8e43534a8",
+    "main.js.gz",
     3586,
   ],
   Array [
diff --git a/test/__snapshots__/exclude-option.test.js.snap.webpack4 b/test/__snapshots__/exclude-option.test.js.snap.webpack4
index 2ffdfb8..1804e45 100644
--- a/test/__snapshots__/exclude-option.test.js.snap.webpack4
+++ b/test/__snapshots__/exclude-option.test.js.snap.webpack4
@@ -15,7 +15,7 @@ Array [
     672,
   ],
   Array [
-    "async.async.js.gz?ver=dc74724f7b13a2de5a20",
+    "async.async.js.gz",
     171,
   ],
   Array [
@@ -23,7 +23,7 @@ Array [
     249,
   ],
   Array [
-    "main.js.gz?var=dc74724f7b13a2de5a20",
+    "main.js.gz",
     3002,
   ],
   Array [
@@ -48,7 +48,7 @@ Array [
     672,
   ],
   Array [
-    "async.async.js.gz?ver=dc74724f7b13a2de5a20",
+    "async.async.js.gz",
     171,
   ],
   Array [
@@ -56,7 +56,7 @@ Array [
     249,
   ],
   Array [
-    "main.js.gz?var=dc74724f7b13a2de5a20",
+    "main.js.gz",
     3002,
   ],
   Array [
diff --git a/test/__snapshots__/exclude-option.test.js.snap.webpack5 b/test/__snapshots__/exclude-option.test.js.snap.webpack5
index df75ca0..4c27f0f 100644
--- a/test/__snapshots__/exclude-option.test.js.snap.webpack5
+++ b/test/__snapshots__/exclude-option.test.js.snap.webpack5
@@ -15,7 +15,7 @@ Array [
     672,
   ],
   Array [
-    "async.async.js.gz?ver=2aedac1e87f8e43534a8",
+    "async.async.js.gz",
     181,
   ],
   Array [
@@ -23,7 +23,7 @@ Array [
     269,
   ],
   Array [
-    "main.js.gz?var=2aedac1e87f8e43534a8",
+    "main.js.gz",
     3586,
   ],
   Array [
@@ -48,7 +48,7 @@ Array [
     672,
   ],
   Array [
-    "async.async.js.gz?ver=2aedac1e87f8e43534a8",
+    "async.async.js.gz",
     181,
   ],
   Array [
@@ -56,7 +56,7 @@ Array [
     269,
   ],
   Array [
-    "main.js.gz?var=2aedac1e87f8e43534a8",
+    "main.js.gz",
     3586,
   ],
   Array [
diff --git a/test/__snapshots__/include-option.test.js.snap.webpack4 b/test/__snapshots__/include-option.test.js.snap.webpack4
index b1bba2f..089bcc9 100644
--- a/test/__snapshots__/include-option.test.js.snap.webpack4
+++ b/test/__snapshots__/include-option.test.js.snap.webpack4
@@ -11,7 +11,7 @@ Array [
     672,
   ],
   Array [
-    "async.async.js.gz?ver=dc74724f7b13a2de5a20",
+    "async.async.js.gz",
     171,
   ],
   Array [
@@ -19,7 +19,7 @@ Array [
     249,
   ],
   Array [
-    "main.js.gz?var=dc74724f7b13a2de5a20",
+    "main.js.gz",
     3002,
   ],
   Array [
@@ -48,7 +48,7 @@ Array [
     393,
   ],
   Array [
-    "async.async.js.gz?ver=dc74724f7b13a2de5a20",
+    "async.async.js.gz",
     171,
   ],
   Array [
@@ -56,7 +56,7 @@ Array [
     249,
   ],
   Array [
-    "main.js.gz?var=dc74724f7b13a2de5a20",
+    "main.js.gz",
     3002,
   ],
   Array [
diff --git a/test/__snapshots__/include-option.test.js.snap.webpack5 b/test/__snapshots__/include-option.test.js.snap.webpack5
index f233f6b..b979d0b 100644
--- a/test/__snapshots__/include-option.test.js.snap.webpack5
+++ b/test/__snapshots__/include-option.test.js.snap.webpack5
@@ -11,7 +11,7 @@ Array [
     672,
   ],
   Array [
-    "async.async.js.gz?ver=2aedac1e87f8e43534a8",
+    "async.async.js.gz",
     181,
   ],
   Array [
@@ -19,7 +19,7 @@ Array [
     269,
   ],
   Array [
-    "main.js.gz?var=2aedac1e87f8e43534a8",
+    "main.js.gz",
     3586,
   ],
   Array [
@@ -48,7 +48,7 @@ Array [
     393,
   ],
   Array [
-    "async.async.js.gz?ver=2aedac1e87f8e43534a8",
+    "async.async.js.gz",
     181,
   ],
   Array [
@@ -56,7 +56,7 @@ Array [
     269,
   ],
   Array [
-    "main.js.gz?var=2aedac1e87f8e43534a8",
+    "main.js.gz",
     3586,
   ],
   Array [
diff --git a/test/__snapshots__/test-option.test.js.snap.webpack4 b/test/__snapshots__/test-option.test.js.snap.webpack4
index 82c8e9f..550f693 100644
--- a/test/__snapshots__/test-option.test.js.snap.webpack4
+++ b/test/__snapshots__/test-option.test.js.snap.webpack4
@@ -81,7 +81,7 @@ Array [
     393,
   ],
   Array [
-    "async.async.js.gz?ver=dc74724f7b13a2de5a20",
+    "async.async.js.gz",
     171,
   ],
   Array [
@@ -89,7 +89,7 @@ Array [
     249,
   ],
   Array [
-    "main.js.gz?var=dc74724f7b13a2de5a20",
+    "main.js.gz",
     3002,
   ],
   Array [
diff --git a/test/__snapshots__/test-option.test.js.snap.webpack5 b/test/__snapshots__/test-option.test.js.snap.webpack5
index 783ddd5..3d277ff 100644
--- a/test/__snapshots__/test-option.test.js.snap.webpack5
+++ b/test/__snapshots__/test-option.test.js.snap.webpack5
@@ -81,7 +81,7 @@ Array [
     393,
   ],
   Array [
-    "async.async.js.gz?ver=2aedac1e87f8e43534a8",
+    "async.async.js.gz",
     181,
   ],
   Array [
@@ -89,7 +89,7 @@ Array [
     269,
   ],
   Array [
-    "main.js.gz?var=2aedac1e87f8e43534a8",
+    "main.js.gz",
     3586,
   ],
   Array [