Skip to content

Commit 895fe61

Browse files
refactor: code (#217)
1 parent bd60650 commit 895fe61

9 files changed

+954
-483
lines changed

package-lock.json

+920-468
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@
5656
"@gfx/zopfli": "^1.0.15",
5757
"@webpack-contrib/defaults": "^6.3.0",
5858
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
59-
"babel-jest": "^26.6.1",
59+
"babel-jest": "^26.6.3",
6060
"cross-env": "^7.0.2",
6161
"del": "^6.0.0",
6262
"del-cli": "^3.0.1",
63-
"eslint": "^7.12.1",
63+
"eslint": "^7.13.0",
6464
"eslint-config-prettier": "^6.15.0",
6565
"eslint-plugin-import": "^2.22.1",
6666
"file-loader": "^6.2.0",
6767
"husky": "^4.3.0",
68-
"jest": "^26.6.1",
68+
"jest": "^26.6.3",
6969
"lint-staged": "^10.5.1",
7070
"memfs": "^3.2.0",
7171
"npm-run-all": "^4.1.5",

src/options.json

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
"type": "boolean"
9191
},
9292
{
93-
"type": "string",
9493
"enum": ["keep-source-map"]
9594
}
9695
]

test/__snapshots__/deleteOriginalAssets.test.js.snap.webpack4

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option 'keep-source-map': assets 1`] = `
3+
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option "keep-source-map": assets 1`] = `
44
Array [
55
Array [
66
"09a1a1112c577c2794359715edfcb5ac.png",
@@ -29,9 +29,9 @@ Array [
2929
]
3030
`;
3131

32-
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option 'keep-source-map': errors 1`] = `Array []`;
32+
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option "keep-source-map": errors 1`] = `Array []`;
3333

34-
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option 'keep-source-map': warnings 1`] = `Array []`;
34+
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option "keep-source-map": warnings 1`] = `Array []`;
3535

3636
exports[`"deleteOriginalAssets" option should work and delete original assets: assets 1`] = `
3737
Array [

test/__snapshots__/deleteOriginalAssets.test.js.snap.webpack5

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option 'keep-source-map': assets 1`] = `
3+
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option "keep-source-map": assets 1`] = `
44
Array [
55
Array [
66
"09a1a1112c577c2794359715edfcb5ac.png",
@@ -25,9 +25,9 @@ Array [
2525
]
2626
`;
2727

28-
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option 'keep-source-map': errors 1`] = `Array []`;
28+
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option "keep-source-map": errors 1`] = `Array []`;
2929

30-
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option 'keep-source-map': warnings 1`] = `Array []`;
30+
exports[`"deleteOriginalAssets" option should delete original assets and keep source maps with option "keep-source-map": warnings 1`] = `Array []`;
3131

3232
exports[`"deleteOriginalAssets" option should work and delete original assets: assets 1`] = `
3333
Array [

test/__snapshots__/validate-options.test.js.snap.webpack4

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ exports[`validate options should throw an error on the "deleteOriginalAssets" op
3737
* options.deleteOriginalAssets should be \\"keep-source-map\\"."
3838
`;
3939

40+
exports[`validate options should throw an error on the "deleteOriginalAssets" option with "unknown" value 1`] = `
41+
"Invalid options object. Compression Plugin has been initialized using an options object that does not match the API schema.
42+
- options.deleteOriginalAssets should be one of these:
43+
boolean | \\"keep-source-map\\"
44+
-> Whether to delete the original assets or not.
45+
Details:
46+
* options.deleteOriginalAssets should be a boolean.
47+
* options.deleteOriginalAssets should be \\"keep-source-map\\"."
48+
`;
49+
4050
exports[`validate options should throw an error on the "exclude" option with "[{},"foo",true]" value 1`] = `
4151
"Invalid options object. Compression Plugin has been initialized using an options object that does not match the API schema.
4252
- options.exclude should be one of these:

test/__snapshots__/validate-options.test.js.snap.webpack5

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ exports[`validate options should throw an error on the "deleteOriginalAssets" op
3737
* options.deleteOriginalAssets should be \\"keep-source-map\\"."
3838
`;
3939

40+
exports[`validate options should throw an error on the "deleteOriginalAssets" option with "unknown" value 1`] = `
41+
"Invalid options object. Compression Plugin has been initialized using an options object that does not match the API schema.
42+
- options.deleteOriginalAssets should be one of these:
43+
boolean | \\"keep-source-map\\"
44+
-> Whether to delete the original assets or not.
45+
Details:
46+
* options.deleteOriginalAssets should be a boolean.
47+
* options.deleteOriginalAssets should be \\"keep-source-map\\"."
48+
`;
49+
4050
exports[`validate options should throw an error on the "exclude" option with "[{},"foo",true]" value 1`] = `
4151
"Invalid options object. Compression Plugin has been initialized using an options object that does not match the API schema.
4252
- options.exclude should be one of these:

test/deleteOriginalAssets.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('"deleteOriginalAssets" option', () => {
8585
expect(getErrors(stats)).toMatchSnapshot('errors');
8686
});
8787

88-
it(`should delete original assets and keep source maps with option 'keep-source-map'`, async () => {
88+
it('should delete original assets and keep source maps with option "keep-source-map"', async () => {
8989
compiler = getCompiler(
9090
'./entry.js',
9191
{},
@@ -95,8 +95,8 @@ describe('"deleteOriginalAssets" option', () => {
9595
);
9696

9797
new CompressionPlugin({
98-
filename: '[file]',
99-
exclude: /.map$/,
98+
filename: '[path][base]',
99+
exclude: /\.map$/,
100100
deleteOriginalAssets: 'keep-source-map',
101101
}).apply(compiler);
102102

test/validate-options.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ describe('validate options', () => {
6666
failure: [() => {}],
6767
},
6868
deleteOriginalAssets: {
69-
success: [true, false],
70-
failure: ['true'],
69+
success: [true, false, 'keep-source-map'],
70+
failure: ['true', 'unknown'],
7171
},
7272
unknown: {
7373
success: [],

0 commit comments

Comments
 (0)