Skip to content

Commit

Permalink
chore!: minimum supported Node.js version is 18.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Jan 15, 2024
1 parent 810e96b commit 2ef7b37
Show file tree
Hide file tree
Showing 29 changed files with 8,798 additions and 17,888 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 21.x]
webpack-version: [latest]

runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ type algorithm =
}
| {
[Symbol.toPrimitive](hint: "string"): string;
}
) => void
},
) => void,
) => any);
```

Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = (api) => {
"@babel/preset-env",
{
targets: {
node: "14.15.0",
node: "18.12.0",
},
},
],
Expand Down
25,916 changes: 8,413 additions & 17,503 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"main": "dist/index.js",
"types": "types/index.d.ts",
"engines": {
"node": ">= 14.15.0"
"node": ">= 18.12.0"
},
"scripts": {
"start": "npm run build -- -w",
Expand Down Expand Up @@ -50,38 +50,38 @@
},
"dependencies": {
"schema-utils": "^4.2.0",
"serialize-javascript": "^6.0.1"
"serialize-javascript": "^6.0.2"
},
"devDependencies": {
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@babel/core": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@gfx/zopfli": "^1.0.15",
"@types/node": "^18.15.11",
"@types/serialize-javascript": "^5.0.2",
"@types/node": "^20.11.2",
"@types/serialize-javascript": "^5.0.4",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"cspell": "^6.31.2",
"del": "^6.1.1",
"del-cli": "^4.0.0",
"eslint": "^8.54.0",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-import": "^2.29.0",
"cspell": "^8.3.2",
"del": "^7.1.0",
"del-cli": "^5.1.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"file-loader": "^6.2.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"lint-staged": "^13.2.3",
"memfs": "^3.5.3",
"lint-staged": "^15.2.0",
"memfs": "^4.6.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"standard-version": "^9.3.0",
"typescript": "^4.9.5",
"prettier": "^3.2.2",
"standard-version": "^9.5.0",
"typescript": "^5.3.3",
"webpack": "^5.89.0",
"webpack-stats-plugin": "^1.1.3",
"workbox-webpack-plugin": "^6.5.4"
"workbox-webpack-plugin": "^7.0.0"
},
"keywords": [
"webpack"
Expand Down
18 changes: 9 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class CompressionPlugin {

if (!this.algorithm) {
throw new Error(
`Algorithm "${this.options.algorithm}" is not found in "zlib"`
`Algorithm "${this.options.algorithm}" is not found in "zlib"`,
);
}

Expand Down Expand Up @@ -211,7 +211,7 @@ class CompressionPlugin {
} else {
resolve(result);
}
}
},
);
});
}
Expand Down Expand Up @@ -240,7 +240,7 @@ class CompressionPlugin {
!compiler.webpack.ModuleFilenameHelpers.matchObject.bind(
// eslint-disable-next-line no-undefined
undefined,
this.options
this.options,
)(name)
) {
return false;
Expand Down Expand Up @@ -289,7 +289,7 @@ class CompressionPlugin {
algorithm: this.options.algorithm,
compressionOptions: this.options.compressionOptions,
}),
cache.getLazyHashedEtag(source)
cache.getLazyHashedEtag(source),
);
const output = (await cacheItem.getPromise()) || {};

Expand Down Expand Up @@ -317,7 +317,7 @@ class CompressionPlugin {
}

return { name, source, info, buffer, output, cacheItem, relatedName };
})
}),
)
).filter((assetForMinify) => Boolean(assetForMinify));

Expand Down Expand Up @@ -388,7 +388,7 @@ class CompressionPlugin {
}

compilation.emitAsset(newFilename, output.source, newInfo);
})()
})(),
);
}

Expand All @@ -410,7 +410,7 @@ class CompressionPlugin {
compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,
additionalAssets: true,
},
(assets) => this.compress(compiler, compilation, assets)
(assets) => this.compress(compiler, compilation, assets),
);

compilation.hooks.statsPrinter.tap(pluginName, (stats) => {
Expand All @@ -421,9 +421,9 @@ class CompressionPlugin {
(compressed, { green, formatFlag }) =>
compressed
? /** @type {Function} */ (green)(
/** @type {Function} */ (formatFlag)("compressed")
/** @type {Function} */ (formatFlag)("compressed"),
)
: ""
: "",
);
});
});
Expand Down
42 changes: 21 additions & 21 deletions test/CompressionPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js?var=[hash]",
chunkFilename: "[id].[name].js?ver=[hash]",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand All @@ -51,7 +51,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js?var=[hash]",
chunkFilename: "[id].[name].js?ver=[hash]",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand Down Expand Up @@ -82,7 +82,7 @@ describe("CompressionPlugin", () => {
rules: [
{
loader: require.resolve(
"./helpers/loader-with-child-compilation.js"
"./helpers/loader-with-child-compilation.js",
),
},
],
Expand All @@ -97,7 +97,7 @@ describe("CompressionPlugin", () => {
},
],
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand All @@ -122,7 +122,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js?var=[hash]",
chunkFilename: "[id].[name].js?ver=[hash]",
},
}
},
);

new CompressionPlugin({
Expand Down Expand Up @@ -162,7 +162,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js",
chunkFilename: "[id].[name].js",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand All @@ -188,7 +188,7 @@ describe("CompressionPlugin", () => {
filename: "[name].[contenthash].js",
chunkFilename: "[id].[name].[contenthash].js",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand Down Expand Up @@ -223,7 +223,7 @@ describe("CompressionPlugin", () => {
expect(newStats.compilation.emittedAssets.size).toBe(0);

expect(getAssetsNameAndSize(newStats, compiler)).toMatchSnapshot(
"assets"
"assets",
);
expect(getWarnings(newStats)).toMatchSnapshot("errors");
expect(getErrors(newStats)).toMatchSnapshot("warnings");
Expand All @@ -243,7 +243,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js",
chunkFilename: "[id].js",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand All @@ -262,7 +262,7 @@ describe("CompressionPlugin", () => {
expect(newStats.compilation.emittedAssets.size).toBe(0);

expect(getAssetsNameAndSize(newStats, compiler)).toMatchSnapshot(
"assets"
"assets",
);
expect(getWarnings(newStats)).toMatchSnapshot("errors");
expect(getErrors(newStats)).toMatchSnapshot("warnings");
Expand All @@ -282,7 +282,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js",
chunkFilename: "[id].js",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand All @@ -306,7 +306,7 @@ describe("CompressionPlugin", () => {
expect(newStats.compilation.emittedAssets.size).toBe(2);

expect(getAssetsNameAndSize(newStats, compiler)).toMatchSnapshot(
"assets"
"assets",
);
expect(getWarnings(newStats)).toMatchSnapshot("errors");
expect(getErrors(newStats)).toMatchSnapshot("warnings");
Expand All @@ -328,7 +328,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js",
chunkFilename: "[id].js",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand All @@ -352,7 +352,7 @@ describe("CompressionPlugin", () => {
expect(newStats.compilation.emittedAssets.size).toBe(2);

expect(getAssetsNameAndSize(newStats, compiler)).toMatchSnapshot(
"assets"
"assets",
);
expect(getWarnings(newStats)).toMatchSnapshot("errors");
expect(getErrors(newStats)).toMatchSnapshot("warnings");
Expand All @@ -372,7 +372,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js",
chunkFilename: "[id].js",
},
}
},
);

new CompressionPlugin({
Expand Down Expand Up @@ -403,7 +403,7 @@ describe("CompressionPlugin", () => {
expect(newStats.compilation.emittedAssets.size).toBe(0);

expect(getAssetsNameAndSize(newStats, compiler)).toMatchSnapshot(
"assets"
"assets",
);
expect(getWarnings(newStats)).toMatchSnapshot("errors");
expect(getErrors(newStats)).toMatchSnapshot("warnings");
Expand All @@ -425,7 +425,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js",
chunkFilename: "[id].[name].js",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand All @@ -444,7 +444,7 @@ describe("CompressionPlugin", () => {
expect(newStats.compilation.emittedAssets.size).toBe(7);

expect(getAssetsNameAndSize(newStats, compiler)).toMatchSnapshot(
"assets"
"assets",
);
expect(getWarnings(newStats)).toMatchSnapshot("errors");
expect(getErrors(newStats)).toMatchSnapshot("warnings");
Expand All @@ -463,7 +463,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js",
chunkFilename: "[id].js",
},
}
},
);

new CompressionPlugin({ minRatio: 10 }).apply(compiler);
Expand All @@ -487,7 +487,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js?var=[hash]",
chunkFilename: "[id].[name].js?ver=[hash]",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand All @@ -511,7 +511,7 @@ describe("CompressionPlugin", () => {
filename: "[name].js?var=[hash]",
chunkFilename: "[id].[name].js?ver=[hash]",
},
}
},
);

new CompressionPlugin().apply(compiler);
Expand Down
Loading

0 comments on commit 2ef7b37

Please sign in to comment.