@node-minify/html-minifier 7.1.0 → 8.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ import { MinifierOptions } from '@node-minify/types';
2
+
3
+ /*!
4
+ * node-minify
5
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
6
+ * MIT Licensed
7
+ */
8
+
9
+ /**
10
+ * Run html-minifier.
11
+ *
12
+ * @param {Object} settings
13
+ * @param {String} content
14
+ * @param {Function} callback
15
+ */
16
+ declare const minifyHTMLMinifier: ({ settings, content, callback, index }: MinifierOptions) => any;
17
+
18
+ export { minifyHTMLMinifier as default };
package/dist/index.js ADDED
@@ -0,0 +1,70 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/index.ts
26
+ var src_exports = {};
27
+ __export(src_exports, {
28
+ default: () => src_default
29
+ });
30
+ module.exports = __toCommonJS(src_exports);
31
+ var import_html_minifier = __toESM(require("html-minifier"));
32
+ var import_utils = require("@node-minify/utils");
33
+ var HTMLMinifier = import_html_minifier.default.minify;
34
+ var defaultOptions = {
35
+ collapseBooleanAttributes: true,
36
+ collapseInlineTagWhitespace: true,
37
+ collapseWhitespace: true,
38
+ minifyCSS: true,
39
+ minifyJS: true,
40
+ removeAttributeQuotes: true,
41
+ removeCDATASectionsFromCDATA: true,
42
+ removeComments: true,
43
+ removeCommentsFromCDATA: true,
44
+ removeEmptyAttributes: true,
45
+ removeOptionalTags: true,
46
+ removeRedundantAttributes: true,
47
+ removeScriptTypeAttributes: true,
48
+ removeStyleLinkTypeAttributes: true,
49
+ useShortDoctype: true
50
+ };
51
+ var minifyHTMLMinifier = ({ settings, content, callback, index }) => {
52
+ const options = Object.assign({}, defaultOptions, settings && settings.options);
53
+ const contentMinified = HTMLMinifier(content || "", options);
54
+ if (settings && !settings.content) {
55
+ import_utils.utils.writeFile({ file: settings.output, content: contentMinified, index });
56
+ }
57
+ if (callback) {
58
+ return callback(null, contentMinified);
59
+ }
60
+ return contentMinified;
61
+ };
62
+ var src_default = minifyHTMLMinifier;
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {});
65
+ /*!
66
+ * node-minify
67
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
68
+ * MIT Licensed
69
+ */
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minifier from 'html-minifier';\nimport { utils } from '@node-minify/utils';\nimport { MinifierOptions } from '@node-minify/types';\n\n// interface Options {\n// sourceMap?: boolean;\n// _sourceMap?: { url: string } | boolean;\n// }\n\n// interface Settings {\n// options: Options;\n// content: string;\n// output: string;\n// }\n\n// interface MinifierOptions {\n// settings: Settings;\n// content: string;\n// callback: Function;\n// index: number;\n// }\n\n/**\n * Module variables.\n */\nconst HTMLMinifier = minifier.minify;\nconst defaultOptions = {\n collapseBooleanAttributes: true,\n collapseInlineTagWhitespace: true,\n collapseWhitespace: true,\n minifyCSS: true,\n minifyJS: true,\n removeAttributeQuotes: true,\n removeCDATASectionsFromCDATA: true,\n removeComments: true,\n removeCommentsFromCDATA: true,\n removeEmptyAttributes: true,\n removeOptionalTags: true,\n removeRedundantAttributes: true,\n removeScriptTypeAttributes: true,\n removeStyleLinkTypeAttributes: true,\n useShortDoctype: true\n};\n\n/**\n * Run html-minifier.\n *\n * @param {Object} settings\n * @param {String} content\n * @param {Function} callback\n */\nconst minifyHTMLMinifier = ({ settings, content, callback, index }: MinifierOptions) => {\n const options = Object.assign({}, defaultOptions, settings && settings.options);\n const contentMinified = HTMLMinifier(content || '', options);\n if (settings && !settings.content) {\n utils.writeFile({ file: settings.output, content: contentMinified, index });\n }\n if (callback) {\n return callback(null, contentMinified);\n }\n return contentMinified;\n};\n\n/**\n * Expose `minifyHTMLMinifier()`.\n */\nexport default minifyHTMLMinifier;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,2BAAqB;AACrB,mBAAsB;AAwBtB,IAAM,eAAe,qBAAAA,QAAS;AAC9B,IAAM,iBAAiB;AAAA,EACrB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,uBAAuB;AAAA,EACvB,8BAA8B;AAAA,EAC9B,gBAAgB;AAAA,EAChB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAC3B,4BAA4B;AAAA,EAC5B,+BAA+B;AAAA,EAC/B,iBAAiB;AACnB;AASA,IAAM,qBAAqB,CAAC,EAAE,UAAU,SAAS,UAAU,MAAM,MAAuB;AACtF,QAAM,UAAU,OAAO,OAAO,CAAC,GAAG,gBAAgB,YAAY,SAAS,OAAO;AAC9E,QAAM,kBAAkB,aAAa,WAAW,IAAI,OAAO;AAC3D,MAAI,YAAY,CAAC,SAAS,SAAS;AACjC,uBAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,SAAS,iBAAiB,MAAM,CAAC;AAAA,EAC5E;AACA,MAAI,UAAU;AACZ,WAAO,SAAS,MAAM,eAAe;AAAA,EACvC;AACA,SAAO;AACT;AAKA,IAAO,cAAQ;","names":["minifier"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,42 @@
1
+ // src/index.ts
2
+ import minifier from "html-minifier";
3
+ import { utils } from "@node-minify/utils";
4
+ var HTMLMinifier = minifier.minify;
5
+ var defaultOptions = {
6
+ collapseBooleanAttributes: true,
7
+ collapseInlineTagWhitespace: true,
8
+ collapseWhitespace: true,
9
+ minifyCSS: true,
10
+ minifyJS: true,
11
+ removeAttributeQuotes: true,
12
+ removeCDATASectionsFromCDATA: true,
13
+ removeComments: true,
14
+ removeCommentsFromCDATA: true,
15
+ removeEmptyAttributes: true,
16
+ removeOptionalTags: true,
17
+ removeRedundantAttributes: true,
18
+ removeScriptTypeAttributes: true,
19
+ removeStyleLinkTypeAttributes: true,
20
+ useShortDoctype: true
21
+ };
22
+ var minifyHTMLMinifier = ({ settings, content, callback, index }) => {
23
+ const options = Object.assign({}, defaultOptions, settings && settings.options);
24
+ const contentMinified = HTMLMinifier(content || "", options);
25
+ if (settings && !settings.content) {
26
+ utils.writeFile({ file: settings.output, content: contentMinified, index });
27
+ }
28
+ if (callback) {
29
+ return callback(null, contentMinified);
30
+ }
31
+ return contentMinified;
32
+ };
33
+ var src_default = minifyHTMLMinifier;
34
+ export {
35
+ src_default as default
36
+ };
37
+ /*!
38
+ * node-minify
39
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
40
+ * MIT Licensed
41
+ */
42
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minifier from 'html-minifier';\nimport { utils } from '@node-minify/utils';\nimport { MinifierOptions } from '@node-minify/types';\n\n// interface Options {\n// sourceMap?: boolean;\n// _sourceMap?: { url: string } | boolean;\n// }\n\n// interface Settings {\n// options: Options;\n// content: string;\n// output: string;\n// }\n\n// interface MinifierOptions {\n// settings: Settings;\n// content: string;\n// callback: Function;\n// index: number;\n// }\n\n/**\n * Module variables.\n */\nconst HTMLMinifier = minifier.minify;\nconst defaultOptions = {\n collapseBooleanAttributes: true,\n collapseInlineTagWhitespace: true,\n collapseWhitespace: true,\n minifyCSS: true,\n minifyJS: true,\n removeAttributeQuotes: true,\n removeCDATASectionsFromCDATA: true,\n removeComments: true,\n removeCommentsFromCDATA: true,\n removeEmptyAttributes: true,\n removeOptionalTags: true,\n removeRedundantAttributes: true,\n removeScriptTypeAttributes: true,\n removeStyleLinkTypeAttributes: true,\n useShortDoctype: true\n};\n\n/**\n * Run html-minifier.\n *\n * @param {Object} settings\n * @param {String} content\n * @param {Function} callback\n */\nconst minifyHTMLMinifier = ({ settings, content, callback, index }: MinifierOptions) => {\n const options = Object.assign({}, defaultOptions, settings && settings.options);\n const contentMinified = HTMLMinifier(content || '', options);\n if (settings && !settings.content) {\n utils.writeFile({ file: settings.output, content: contentMinified, index });\n }\n if (callback) {\n return callback(null, contentMinified);\n }\n return contentMinified;\n};\n\n/**\n * Expose `minifyHTMLMinifier()`.\n */\nexport default minifyHTMLMinifier;\n"],"mappings":";AASA,OAAO,cAAc;AACrB,SAAS,aAAa;AAwBtB,IAAM,eAAe,SAAS;AAC9B,IAAM,iBAAiB;AAAA,EACrB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,uBAAuB;AAAA,EACvB,8BAA8B;AAAA,EAC9B,gBAAgB;AAAA,EAChB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAC3B,4BAA4B;AAAA,EAC5B,+BAA+B;AAAA,EAC/B,iBAAiB;AACnB;AASA,IAAM,qBAAqB,CAAC,EAAE,UAAU,SAAS,UAAU,MAAM,MAAuB;AACtF,QAAM,UAAU,OAAO,OAAO,CAAC,GAAG,gBAAgB,YAAY,SAAS,OAAO;AAC9E,QAAM,kBAAkB,aAAa,WAAW,IAAI,OAAO;AAC3D,MAAI,YAAY,CAAC,SAAS,SAAS;AACjC,UAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,SAAS,iBAAiB,MAAM,CAAC;AAAA,EAC5E;AACA,MAAI,UAAU;AACZ,WAAO,SAAS,MAAM,eAAe;AAAA,EACvC;AACA,SAAO;AACT;AAKA,IAAO,cAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/html-minifier",
3
- "version": "7.1.0",
3
+ "version": "8.0.1-beta.0",
4
4
  "description": "html-minifier plugin for @node-minify",
5
5
  "keywords": [
6
6
  "compressor",
@@ -11,16 +11,23 @@
11
11
  "author": "Rodolphe Stoclin <srodolphe@gmail.com>",
12
12
  "homepage": "https://github.com/srod/node-minify/tree/master/packages/html-minifier#readme",
13
13
  "license": "MIT",
14
- "main": "lib/html-minifier.js",
15
14
  "engines": {
16
15
  "node": ">=14.0.0"
17
16
  },
18
17
  "directories": {
19
- "lib": "lib",
18
+ "lib": "dist",
20
19
  "test": "__tests__"
21
20
  },
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.mjs",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ "require": "./dist/index.js",
26
+ "import": "./dist/index.mjs",
27
+ "types": "./dist/index.d.ts"
28
+ },
22
29
  "files": [
23
- "lib"
30
+ "dist/**/*"
24
31
  ],
25
32
  "publishConfig": {
26
33
  "access": "public"
@@ -32,9 +39,18 @@
32
39
  "bugs": {
33
40
  "url": "https://github.com/srod/node-minify/issues"
34
41
  },
42
+ "scripts": {
43
+ "clean": "pnpm dlx rimraf dist",
44
+ "build": "npm run clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
45
+ "prepublishOnly": "npm run build"
46
+ },
35
47
  "dependencies": {
36
- "@node-minify/utils": "^7.1.0",
48
+ "@node-minify/utils": "8.0.1-beta.0",
37
49
  "html-minifier": "4.0.0"
38
50
  },
39
- "gitHead": "94cef2d5d653c3bddc3e603b4e25c135b0b6f4b3"
51
+ "devDependencies": {
52
+ "@node-minify/types": "8.0.1-beta.0",
53
+ "@types/html-minifier": "^4.0.2"
54
+ },
55
+ "gitHead": "35a8a41ec86a11cbec05d8a7db9113475ece2cef"
40
56
  }
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- var _htmlMinifier = _interopRequireDefault(require("html-minifier"));
4
- var _utils = require("@node-minify/utils");
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
- /*!
7
- * node-minify
8
- * Copyright(c) 2011-2022 Rodolphe Stoclin
9
- * MIT Licensed
10
- */
11
-
12
- /**
13
- * Module dependencies.
14
- */
15
-
16
- /**
17
- * Module variables.
18
- */
19
- const HTMLMinifier = _htmlMinifier.default.minify;
20
- const defaultOptions = {
21
- collapseBooleanAttributes: true,
22
- collapseInlineTagWhitespace: true,
23
- collapseWhitespace: true,
24
- minifyCSS: true,
25
- minifyJS: true,
26
- removeAttributeQuotes: true,
27
- removeCDATASectionsFromCDATA: true,
28
- removeComments: true,
29
- removeCommentsFromCDATA: true,
30
- removeEmptyAttributes: true,
31
- removeOptionalTags: true,
32
- removeRedundantAttributes: true,
33
- removeScriptTypeAttributes: true,
34
- removeStyleLinkTypeAttributes: true,
35
- useShortDoctype: true
36
- };
37
-
38
- /**
39
- * Run html-minifier.
40
- *
41
- * @param {Object} settings
42
- * @param {String} content
43
- * @param {Function} callback
44
- */
45
- const minifyHTMLMinifier = ({
46
- settings,
47
- content,
48
- callback,
49
- index
50
- }) => {
51
- const options = Object.assign({}, defaultOptions, settings.options);
52
- const contentMinified = HTMLMinifier(content, options);
53
- if (!settings.content) {
54
- _utils.utils.writeFile({
55
- file: settings.output,
56
- content: contentMinified,
57
- index
58
- });
59
- }
60
- if (callback) {
61
- return callback(null, contentMinified);
62
- }
63
- return contentMinified;
64
- };
65
-
66
- /**
67
- * Expose `minifyHTMLMinifier()`.
68
- */
69
- module.exports = minifyHTMLMinifier;