html-minimizer-webpack-plugin
Advanced tools
Comparing version 3.4.0 to 3.5.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
const os = require("os"); | ||
var _os = _interopRequireDefault(require("os")); | ||
const { | ||
validate | ||
} = require("schema-utils"); | ||
var _schemaUtils = require("schema-utils"); | ||
const serialize = require("serialize-javascript"); | ||
var _serializeJavascript = _interopRequireDefault(require("serialize-javascript")); | ||
const { | ||
Worker | ||
} = require("jest-worker"); | ||
var _jestWorker = require("jest-worker"); | ||
const schema = require("./options.json"); | ||
var _options = _interopRequireDefault(require("./options.json")); | ||
const { | ||
htmlMinifierTerser, | ||
throttleAll | ||
} = require("./utils"); | ||
var _utils = require("./utils"); | ||
var _minify = require("./minify"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const { | ||
minify | ||
} = require("./minify"); | ||
/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */ | ||
@@ -131,2 +132,4 @@ | ||
*/ | ||
class HtmlMinimizerPlugin { | ||
@@ -137,5 +140,5 @@ /** | ||
constructor(options) { | ||
(0, _schemaUtils.validate)( | ||
validate( | ||
/** @type {Schema} */ | ||
_options.default, options || {}, { | ||
schema, options || {}, { | ||
name: "Html Minimizer Plugin", | ||
@@ -145,3 +148,3 @@ baseDataPath: "options" | ||
const { | ||
minify = _utils.htmlMinifierTerser, | ||
minify = htmlMinifierTerser, | ||
minimizerOptions, | ||
@@ -254,3 +257,3 @@ parallel = true, | ||
// https://github.com/nodejs/node/issues/19022 | ||
const cpus = _os.default.cpus() || { | ||
const cpus = os.cpus() || { | ||
length: 1 | ||
@@ -339,3 +342,3 @@ }; | ||
/** @type {MinimizerWorker<T>} */ | ||
new _jestWorker.Worker(require.resolve("./minify"), { | ||
new Worker(require.resolve("./minify"), { | ||
numWorkers: numberOfWorkers, | ||
@@ -397,3 +400,3 @@ enableWorkerThreads: true | ||
try { | ||
output = await (getWorker ? getWorker().transform((0, _serializeJavascript.default)(options)) : (0, _minify.minify)(options)); | ||
output = await (getWorker ? getWorker().transform(serialize(options)) : minify(options)); | ||
} catch (error) { | ||
@@ -441,3 +444,3 @@ compilation.errors.push( | ||
numberOfWorkers : scheduledTasks.length; | ||
await (0, _utils.throttleAll)(limit, scheduledTasks); | ||
await throttleAll(limit, scheduledTasks); | ||
@@ -480,4 +483,3 @@ if (initializedWorker) { | ||
HtmlMinimizerPlugin.htmlMinifierTerser = _utils.htmlMinifierTerser; | ||
var _default = HtmlMinimizerPlugin; | ||
exports.default = _default; | ||
HtmlMinimizerPlugin.htmlMinifierTerser = htmlMinifierTerser; | ||
module.exports = HtmlMinimizerPlugin; |
@@ -56,3 +56,5 @@ "use strict"; | ||
module.exports.minify = minify; | ||
module.exports.transform = transform; | ||
module.exports = { | ||
minify, | ||
transform | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.htmlMinifierTerser = htmlMinifierTerser; | ||
exports.throttleAll = throttleAll; | ||
/** @typedef {import("./index.js").MinimizedResult} MinimizedResult */ | ||
@@ -111,2 +105,7 @@ | ||
}; | ||
} | ||
} | ||
module.exports = { | ||
throttleAll, | ||
htmlMinifierTerser | ||
}; |
{ | ||
"name": "html-minimizer-webpack-plugin", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "html minimizer plugin for Webpack", | ||
@@ -14,4 +14,4 @@ "license": "MIT", | ||
}, | ||
"main": "dist/cjs.js", | ||
"types": "types/cjs.d.ts", | ||
"main": "dist/index.js", | ||
"types": "types/index.d.ts", | ||
"engines": { | ||
@@ -22,3 +22,3 @@ "node": ">= 12.13.0" | ||
"start": "npm run build -- -w", | ||
"clean": "del-cli dist", | ||
"clean": "del-cli dist types", | ||
"prebuild": "npm run clean", | ||
@@ -25,0 +25,0 @@ "build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write", |
@@ -1,78 +0,2 @@ | ||
export default HtmlMinimizerPlugin; | ||
export type Schema = import("schema-utils/declarations/validate").Schema; | ||
export type Compiler = import("webpack").Compiler; | ||
export type Compilation = import("webpack").Compilation; | ||
export type WebpackError = import("webpack").WebpackError; | ||
export type Asset = import("webpack").Asset; | ||
export type JestWorker = import("jest-worker").Worker; | ||
export type HtmlMinifierTerserOptions = | ||
import("./utils.js").HtmlMinifierTerserOptions; | ||
export type Rule = RegExp | string; | ||
export type Rules = Rule[] | Rule; | ||
export type MinimizedResult = { | ||
code: string; | ||
errors?: unknown[] | undefined; | ||
warnings?: unknown[] | undefined; | ||
}; | ||
export type Input = { | ||
[file: string]: string; | ||
}; | ||
export type CustomOptions = { | ||
[key: string]: any; | ||
}; | ||
export type InferDefaultType<T> = T extends infer U ? U : CustomOptions; | ||
export type MinimizerOptions<T> = InferDefaultType<T> | undefined; | ||
export type MinimizerImplementation<T> = ( | ||
input: Input, | ||
minimizerOptions?: MinimizerOptions<T> | ||
) => Promise<MinimizedResult>; | ||
export type Minimizer<T> = { | ||
implementation: MinimizerImplementation<T>; | ||
options?: MinimizerOptions<T> | undefined; | ||
}; | ||
export type InternalOptions<T> = { | ||
name: string; | ||
input: string; | ||
minimizer: T extends any[] | ||
? { [P in keyof T]: Minimizer<T[P]> } | ||
: Minimizer<T>; | ||
}; | ||
export type InternalResult = { | ||
code: string; | ||
warnings: Array<any>; | ||
errors: Array<any>; | ||
}; | ||
export type MinimizerWorker<T> = Worker & { | ||
transform: (options: string) => InternalResult; | ||
minify: (options: InternalOptions<T>) => InternalResult; | ||
}; | ||
export type Parallel = undefined | boolean | number; | ||
export type BasePluginOptions = { | ||
test?: Rules | undefined; | ||
include?: Rules | undefined; | ||
exclude?: Rules | undefined; | ||
parallel?: Parallel; | ||
}; | ||
export type InternalPluginOptions<T> = BasePluginOptions & { | ||
minimizer: T extends any[] | ||
? { [P in keyof T]: Minimizer<T[P]> } | ||
: Minimizer<T>; | ||
}; | ||
export 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; | ||
}; | ||
export = HtmlMinimizerPlugin; | ||
/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */ | ||
@@ -212,5 +136,106 @@ /** @typedef {import("webpack").Compiler} Compiler */ | ||
declare namespace HtmlMinimizerPlugin { | ||
export { htmlMinifierTerser }; | ||
export { | ||
htmlMinifierTerser, | ||
Schema, | ||
Compiler, | ||
Compilation, | ||
WebpackError, | ||
Asset, | ||
JestWorker, | ||
HtmlMinifierTerserOptions, | ||
Rule, | ||
Rules, | ||
MinimizedResult, | ||
Input, | ||
CustomOptions, | ||
InferDefaultType, | ||
MinimizerOptions, | ||
MinimizerImplementation, | ||
Minimizer, | ||
InternalOptions, | ||
InternalResult, | ||
MinimizerWorker, | ||
Parallel, | ||
BasePluginOptions, | ||
InternalPluginOptions, | ||
DefinedDefaultMinimizerAndOptions, | ||
}; | ||
} | ||
type Compiler = import("webpack").Compiler; | ||
type BasePluginOptions = { | ||
test?: Rules | undefined; | ||
include?: Rules | undefined; | ||
exclude?: Rules | 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"; | ||
type Schema = import("schema-utils/declarations/validate").Schema; | ||
type Compilation = import("webpack").Compilation; | ||
type WebpackError = import("webpack").WebpackError; | ||
type Asset = import("webpack").Asset; | ||
type JestWorker = import("jest-worker").Worker; | ||
type HtmlMinifierTerserOptions = import("./utils.js").HtmlMinifierTerserOptions; | ||
type Rule = RegExp | string; | ||
type Rules = Rule[] | Rule; | ||
type MinimizedResult = { | ||
code: string; | ||
errors?: unknown[] | undefined; | ||
warnings?: unknown[] | undefined; | ||
}; | ||
type Input = { | ||
[file: string]: string; | ||
}; | ||
type CustomOptions = { | ||
[key: string]: any; | ||
}; | ||
type InferDefaultType<T> = T extends infer U ? U : CustomOptions; | ||
type MinimizerOptions<T> = InferDefaultType<T> | undefined; | ||
type MinimizerImplementation<T> = ( | ||
input: Input, | ||
minimizerOptions?: MinimizerOptions<T> | ||
) => Promise<MinimizedResult>; | ||
type Minimizer<T> = { | ||
implementation: MinimizerImplementation<T>; | ||
options?: MinimizerOptions<T> | undefined; | ||
}; | ||
type InternalOptions<T> = { | ||
name: string; | ||
input: string; | ||
minimizer: T extends any[] | ||
? { [P in keyof T]: Minimizer<T[P]> } | ||
: Minimizer<T>; | ||
}; | ||
type InternalResult = { | ||
code: string; | ||
warnings: Array<any>; | ||
errors: Array<any>; | ||
}; | ||
type MinimizerWorker<T> = Worker & { | ||
transform: (options: string) => InternalResult; | ||
minify: (options: InternalOptions<T>) => InternalResult; | ||
}; | ||
type Parallel = undefined | boolean | number; | ||
type InternalPluginOptions<T> = BasePluginOptions & { | ||
minimizer: T extends any[] | ||
? { [P in keyof T]: Minimizer<T[P]> } | ||
: Minimizer<T>; | ||
}; | ||
import { minify } from "./minify"; | ||
import { Worker } from "jest-worker"; | ||
import { htmlMinifierTerser } from "./utils"; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
928
44600
10