Socket
Socket
Sign inDemoInstall

html-minimizer-webpack-plugin

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-minimizer-webpack-plugin - npm Package Compare versions

Comparing version 4.4.0 to 5.0.0

25

dist/index.js

@@ -9,2 +9,3 @@ "use strict";

throttleAll,
memoize,
htmlMinifierTerser,

@@ -117,24 +118,2 @@ swcMinify,

/**
* @template T
* @param fn {(function(): any) | undefined}
* @returns {function(): T}
*/
const memoize = fn => {
let cache = false;
/** @type {T} */
let result;
return () => {
if (cache) {
return result;
}
result = /** @type {function(): any} */fn();
cache = true;
// Allow to clean up memory for fn
// and all dependent resources
// eslint-disable-next-line no-undefined, no-param-reassign
fn = undefined;
return result;
};
};
const getSerializeJavascript = memoize(() =>

@@ -411,3 +390,3 @@ // eslint-disable-next-line global-require

}
const limit = getWorker && numberOfAssets > 0 ? /** @type {number} */numberOfWorkers : scheduledTasks.length;
const limit = getWorker && numberOfAssets > 0 ? ( /** @type {number} */numberOfWorkers) : scheduledTasks.length;
await throttleAll(limit, scheduledTasks);

@@ -414,0 +393,0 @@ if (initializedWorker) {

25

dist/utils.js

@@ -86,3 +86,2 @@ "use strict";

};
const result = await htmlMinifier.minify(code, {

@@ -175,4 +174,28 @@ ...defaultMinimizerOptions,

}
/**
* @template T
* @param fn {(function(): any) | undefined}
* @returns {function(): T}
*/
function memoize(fn) {
let cache = false;
/** @type {T} */
let result;
return () => {
if (cache) {
return result;
}
result = /** @type {function(): any} */fn();
cache = true;
// Allow to clean up memory for fn
// and all dependent resources
// eslint-disable-next-line no-undefined, no-param-reassign
fn = undefined;
return result;
};
}
module.exports = {
throttleAll,
memoize,
htmlMinifierTerser,

@@ -179,0 +202,0 @@ swcMinify,

{
"name": "html-minimizer-webpack-plugin",
"version": "4.4.0",
"version": "5.0.0",
"description": "html minimizer plugin for Webpack",

@@ -17,3 +17,3 @@ "license": "MIT",

"engines": {
"node": ">= 14.15.0"
"node": ">= 18.12.0"
},

@@ -29,5 +29,5 @@ "scripts": {

"security": "npm audit",
"lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
"lint:prettier": "prettier --cache --list-different .",
"lint:js": "eslint --cache .",
"lint:spelling": "cspell \"**/*.*\"",
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
"lint:types": "tsc --pretty --noEmit",

@@ -59,37 +59,37 @@ "lint": "npm-run-all -l -p \"lint:**\"",

"dependencies": {
"@types/html-minifier-terser": "^7.0.0",
"@types/html-minifier-terser": "^7.0.2",
"html-minifier-terser": "^7.2.0",
"jest-worker": "^29.5.0",
"schema-utils": "^4.0.1",
"serialize-javascript": "^6.0.1"
"jest-worker": "^29.7.0",
"schema-utils": "^4.2.0",
"serialize-javascript": "^6.0.2"
},
"devDependencies": {
"@babel/cli": "^7.21.5",
"@babel/core": "^7.22.1",
"@babel/preset-env": "^7.22.4",
"@commitlint/cli": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5",
"@minify-html/node": "^0.11.1",
"@swc/html": "^0.0.18",
"@types/node": "^18.16.3",
"@types/serialize-javascript": "^5.0.2",
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@minify-html/node": "^0.15.0",
"@swc/html": "^0.0.28",
"@types/node": "^20.11.2",
"@types/serialize-javascript": "^5.0.4",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^29.5.0",
"babel-jest": "^29.7.0",
"copy-webpack-plugin": "^9.0.1",
"cross-env": "^7.0.3",
"cspell": "^6.31.1",
"del": "^6.1.1",
"del-cli": "^5.0.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"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",
"husky": "^8.0.3",
"jest": "^29.5.0",
"lint-staged": "^13.2.2",
"memfs": "^3.5.1",
"jest": "^29.7.0",
"lint-staged": "^15.2.0",
"memfs": "^4.6.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"standard-version": "^9.3.1",
"typescript": "^5.1.3",
"webpack": "^5.85.0"
"prettier": "^3.2.4",
"standard-version": "^9.5.0",
"typescript": "^5.3.3",
"webpack": "^5.89.0"
},

@@ -96,0 +96,0 @@ "keywords": [

@@ -306,3 +306,3 @@ <div align="center">

[key: string]: any;
}
},
) => {

@@ -317,3 +317,3 @@ code: string;

[key: string]: any;
}
},
) => {

@@ -320,0 +320,0 @@ code: string;

@@ -32,3 +32,3 @@ export = HtmlMinimizerPlugin;

| (BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>)
| undefined
| undefined,
);

@@ -86,26 +86,2 @@ /**

}
type Compiler = import("webpack").Compiler;
type BasePluginOptions = {
test?: Rule | undefined;
include?: Rule | undefined;
exclude?: Rule | undefined;
parallel?: Parallel;
};
type DefinedDefaultMinimizerAndOptions<T> =
T extends import("html-minifier-terser").Options
? {
minify?: MinimizerImplementation<T> | undefined;
minimizerOptions?: MinimizerOptions<T> | undefined;
}
: T extends any[]
? {
minify: { [P in keyof T]: MinimizerImplementation<T[P]> };
minimizerOptions?:
| { [P_1 in keyof T]?: MinimizerOptions<T[P_1]> }
| undefined;
}
: {
minify: MinimizerImplementation<T>;
minimizerOptions?: MinimizerOptions<T> | undefined;
};
import { htmlMinifierTerser } from "./utils";

@@ -116,2 +92,3 @@ import { swcMinify } from "./utils";

type Schema = import("schema-utils/declarations/validate").Schema;
type Compiler = import("webpack").Compiler;
type Compilation = import("webpack").Compilation;

@@ -139,3 +116,3 @@ type WebpackError = import("webpack").WebpackError;

input: Input,
minimizerOptions?: MinimizerOptions<T>
minimizerOptions?: MinimizerOptions<T>,
) => Promise<MinimizedResult>;

@@ -163,2 +140,8 @@ type Minimizer<T> = {

type Parallel = undefined | boolean | number;
type BasePluginOptions = {
test?: Rule | undefined;
include?: Rule | undefined;
exclude?: Rule | undefined;
parallel?: Parallel;
};
type InternalPluginOptions<T> = BasePluginOptions & {

@@ -169,1 +152,18 @@ minimizer: T extends any[]

};
type DefinedDefaultMinimizerAndOptions<T> =
T extends import("html-minifier-terser").Options
? {
minify?: MinimizerImplementation<T> | undefined;
minimizerOptions?: MinimizerOptions<T> | undefined;
}
: T extends any[]
? {
minify: { [P in keyof T]: MinimizerImplementation<T[P]> };
minimizerOptions?:
| { [P_1 in keyof T]?: MinimizerOptions<T[P_1]> }
| undefined;
}
: {
minify: MinimizerImplementation<T>;
minimizerOptions?: MinimizerOptions<T> | undefined;
};

@@ -11,3 +11,3 @@ export type MinimizedResult = import("./index.js").MinimizedResult;

export function minify<T>(
options: import("./index.js").InternalOptions<T>
options: import("./index.js").InternalOptions<T>,
): Promise<InternalResult>;

@@ -14,0 +14,0 @@ /**

@@ -19,2 +19,8 @@ export type Task<T> = () => Promise<T>;

/**
* @template T
* @param fn {(function(): any) | undefined}
* @returns {function(): T}
*/
export function memoize<T>(fn: (() => any) | undefined): () => T;
/**
* @param {Input} input

@@ -26,3 +32,3 @@ * @param {CustomOptions | undefined} [minimizerOptions]

input: Input,
minimizerOptions?: CustomOptions | undefined
minimizerOptions?: CustomOptions | undefined,
): Promise<MinimizedResult>;

@@ -36,3 +42,3 @@ /**

input: Input,
minimizerOptions?: CustomOptions | undefined
minimizerOptions?: CustomOptions | undefined,
): Promise<MinimizedResult>;

@@ -46,3 +52,3 @@ /**

input: Input,
minimizerOptions?: CustomOptions | undefined
minimizerOptions?: CustomOptions | undefined,
): Promise<MinimizedResult>;

@@ -56,3 +62,3 @@ /**

input: Input,
minimizerOptions?: CustomOptions | undefined
minimizerOptions?: CustomOptions | undefined,
): Promise<MinimizedResult>;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc