@node-minify/google-closure-compiler 9.0.0 → 10.0.0-next.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.
- package/dist/index.cjs +111 -0
- package/dist/{index.d.mts → index.d.cts} +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -32
- package/package.json +21 -20
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -81
- package/dist/index.mjs.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
default: () => src_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
var import_run = require("@node-minify/run");
|
|
37
|
+
var import_utils = require("@node-minify/utils");
|
|
38
|
+
var import_google_closure_compiler_java = __toESM(require("google-closure-compiler-java"), 1);
|
|
39
|
+
var allowedFlags = [
|
|
40
|
+
"angular_pass",
|
|
41
|
+
"assume_function_wrapper",
|
|
42
|
+
"checks_only",
|
|
43
|
+
"compilation_level",
|
|
44
|
+
"create_source_map",
|
|
45
|
+
"define",
|
|
46
|
+
"env",
|
|
47
|
+
"externs",
|
|
48
|
+
"export_local_property_definitions",
|
|
49
|
+
"generate_exports",
|
|
50
|
+
"language_in",
|
|
51
|
+
"language_out",
|
|
52
|
+
"output_wrapper",
|
|
53
|
+
"polymer_version",
|
|
54
|
+
"process_common_js_modules",
|
|
55
|
+
"rename_prefix_namespace",
|
|
56
|
+
"rewrite_polyfills",
|
|
57
|
+
"use_types_for_optimization",
|
|
58
|
+
"warning_level"
|
|
59
|
+
];
|
|
60
|
+
var minifyGCC = ({ settings, content, callback, index }) => {
|
|
61
|
+
const options = applyOptions({}, settings?.options ?? {});
|
|
62
|
+
return (0, import_run.runCommandLine)({
|
|
63
|
+
args: gccCommand(options),
|
|
64
|
+
data: content,
|
|
65
|
+
settings,
|
|
66
|
+
callback: (err, content2) => {
|
|
67
|
+
if (err) {
|
|
68
|
+
if (callback) {
|
|
69
|
+
return callback(err);
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
if (settings && !settings.content && settings.output) {
|
|
74
|
+
import_utils.utils.writeFile({ file: settings.output, content: content2, index });
|
|
75
|
+
}
|
|
76
|
+
if (callback) {
|
|
77
|
+
return callback(null, content2);
|
|
78
|
+
}
|
|
79
|
+
return content2;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
var applyOptions = (flags, options) => {
|
|
84
|
+
if (!options || Object.keys(options).length === 0) {
|
|
85
|
+
return flags;
|
|
86
|
+
}
|
|
87
|
+
Object.keys(options).filter((option) => allowedFlags.indexOf(option) > -1).forEach((option) => {
|
|
88
|
+
const value = options[option];
|
|
89
|
+
if (typeof value === "boolean" || typeof value === "object" && !Array.isArray(value)) {
|
|
90
|
+
flags[option] = value;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return flags;
|
|
94
|
+
};
|
|
95
|
+
var gccCommand = (options) => {
|
|
96
|
+
return ["-jar", import_google_closure_compiler_java.default].concat(import_utils.utils.buildArgs(options ?? {}));
|
|
97
|
+
};
|
|
98
|
+
minifyGCC.default = minifyGCC;
|
|
99
|
+
var src_default = minifyGCC;
|
|
100
|
+
/*!
|
|
101
|
+
* node-minify
|
|
102
|
+
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
103
|
+
* MIT Licensed
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
// fix-cjs-exports
|
|
107
|
+
if (module.exports.default) {
|
|
108
|
+
Object.assign(module.exports.default, module.exports);
|
|
109
|
+
module.exports = module.exports.default;
|
|
110
|
+
delete module.exports.default;
|
|
111
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
|
|
25
1
|
// src/index.ts
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
import { runCommandLine } from "@node-minify/run";
|
|
3
|
+
import { utils } from "@node-minify/utils";
|
|
4
|
+
import compilerPath from "google-closure-compiler-java";
|
|
29
5
|
var allowedFlags = [
|
|
30
6
|
"angular_pass",
|
|
31
7
|
"assume_function_wrapper",
|
|
@@ -49,7 +25,7 @@ var allowedFlags = [
|
|
|
49
25
|
];
|
|
50
26
|
var minifyGCC = ({ settings, content, callback, index }) => {
|
|
51
27
|
const options = applyOptions({}, settings?.options ?? {});
|
|
52
|
-
return
|
|
28
|
+
return runCommandLine({
|
|
53
29
|
args: gccCommand(options),
|
|
54
30
|
data: content,
|
|
55
31
|
settings,
|
|
@@ -61,7 +37,7 @@ var minifyGCC = ({ settings, content, callback, index }) => {
|
|
|
61
37
|
throw err;
|
|
62
38
|
}
|
|
63
39
|
if (settings && !settings.content && settings.output) {
|
|
64
|
-
|
|
40
|
+
utils.writeFile({ file: settings.output, content: content2, index });
|
|
65
41
|
}
|
|
66
42
|
if (callback) {
|
|
67
43
|
return callback(null, content2);
|
|
@@ -83,13 +59,15 @@ var applyOptions = (flags, options) => {
|
|
|
83
59
|
return flags;
|
|
84
60
|
};
|
|
85
61
|
var gccCommand = (options) => {
|
|
86
|
-
return ["-jar",
|
|
62
|
+
return ["-jar", compilerPath].concat(utils.buildArgs(options ?? {}));
|
|
87
63
|
};
|
|
88
64
|
minifyGCC.default = minifyGCC;
|
|
89
|
-
|
|
65
|
+
var src_default = minifyGCC;
|
|
66
|
+
export {
|
|
67
|
+
src_default as default
|
|
68
|
+
};
|
|
90
69
|
/*!
|
|
91
70
|
* node-minify
|
|
92
71
|
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
93
72
|
* MIT Licensed
|
|
94
73
|
*/
|
|
95
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/google-closure-compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-next.0",
|
|
4
4
|
"description": "google closure compiler plugin for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -10,23 +10,22 @@
|
|
|
10
10
|
"google closure compiler"
|
|
11
11
|
],
|
|
12
12
|
"author": "Rodolphe Stoclin <srodolphe@gmail.com>",
|
|
13
|
-
"homepage": "https://github.com/srod/node-minify/tree/
|
|
13
|
+
"homepage": "https://github.com/srod/node-minify/tree/main/packages/google-closure-compiler#readme",
|
|
14
14
|
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
15
16
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
17
|
+
"node": ">=22.0.0"
|
|
17
18
|
},
|
|
18
19
|
"directories": {
|
|
19
20
|
"lib": "dist",
|
|
20
21
|
"test": "__tests__"
|
|
21
22
|
},
|
|
22
|
-
"main": "./dist/index.
|
|
23
|
-
"module": "./dist/index.mjs",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
25
24
|
"exports": {
|
|
25
|
+
"./package.json": "./package.json",
|
|
26
26
|
".": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"require": "./dist/index.cjs"
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"default": "./dist/index.cjs"
|
|
30
29
|
}
|
|
31
30
|
},
|
|
32
31
|
"files": [
|
|
@@ -42,20 +41,22 @@
|
|
|
42
41
|
"bugs": {
|
|
43
42
|
"url": "https://github.com/srod/node-minify/issues"
|
|
44
43
|
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"google-closure-compiler-java": "20231112.0.0",
|
|
47
|
-
"@node-minify/run": "9.0.0",
|
|
48
|
-
"@node-minify/utils": "9.0.0"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@node-minify/types": "9.0.0"
|
|
52
|
-
},
|
|
53
44
|
"scripts": {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
45
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean && bunx fix-tsup-cjs",
|
|
46
|
+
"check-exports": "attw --pack .",
|
|
47
|
+
"format:check": "biome check .",
|
|
56
48
|
"lint": "biome lint .",
|
|
49
|
+
"prepublishOnly": "bun run build",
|
|
57
50
|
"test": "vitest run",
|
|
58
51
|
"test:ci": "vitest run --coverage",
|
|
59
52
|
"test:watch": "vitest"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@node-minify/run": "workspace:*",
|
|
56
|
+
"@node-minify/utils": "workspace:*",
|
|
57
|
+
"google-closure-compiler-java": "20240317.0.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@node-minify/types": "workspace:*"
|
|
60
61
|
}
|
|
61
|
-
}
|
|
62
|
+
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport { runCommandLine } from \"@node-minify/run\";\nimport type {\n MinifierOptions,\n Options,\n OptionsPossible,\n} from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\nimport compilerPath from \"google-closure-compiler-java\";\n\n// the allowed flags, taken from https://github.com/google/closure-compiler/wiki/Flags-and-Options\nconst allowedFlags = [\n \"angular_pass\",\n \"assume_function_wrapper\",\n \"checks_only\",\n \"compilation_level\",\n \"create_source_map\",\n \"define\",\n \"env\",\n \"externs\",\n \"export_local_property_definitions\",\n \"generate_exports\",\n \"language_in\",\n \"language_out\",\n \"output_wrapper\",\n \"polymer_version\",\n \"process_common_js_modules\",\n \"rename_prefix_namespace\",\n \"rewrite_polyfills\",\n \"use_types_for_optimization\",\n \"warning_level\",\n];\n\n/**\n * Run Google Closure Compiler.\n * @param settings GCC options\n * @param content Content to minify\n * @param callback Callback\n * @param index Index of current file in array\n * @returns Minified content\n */\nconst minifyGCC = ({ settings, content, callback, index }: MinifierOptions) => {\n const options = applyOptions({}, settings?.options ?? {});\n return runCommandLine({\n args: gccCommand(options),\n data: content,\n settings,\n callback: (err: unknown, content?: string) => {\n if (err) {\n if (callback) {\n return callback(err);\n }\n throw err;\n }\n if (settings && !settings.content && settings.output) {\n utils.writeFile({ file: settings.output, content, index });\n }\n if (callback) {\n return callback(null, content);\n }\n return content;\n },\n });\n};\n\n/**\n * Adds any valid options passed in the options parameters to the flags parameter and returns the flags object.\n * @param flags the flags object to add options to\n * @param options the options object to add to the flags object\n * @returns the flags object with the options added\n */\ntype Flags = {\n [key: string]: boolean | Record<string, OptionsPossible>;\n};\nconst applyOptions = (flags: Flags, options?: Options): Flags => {\n if (!options || Object.keys(options).length === 0) {\n return flags;\n }\n Object.keys(options)\n .filter((option) => allowedFlags.indexOf(option) > -1)\n .forEach((option) => {\n const value = options[option];\n if (\n typeof value === \"boolean\" ||\n (typeof value === \"object\" && !Array.isArray(value))\n ) {\n flags[option] = value as\n | boolean\n | Record<string, OptionsPossible>;\n }\n });\n return flags;\n};\n\n/**\n * GCC command line.\n * @param options the options to pass to GCC\n * @returns the command line arguments to pass to GCC\n */\n\nconst gccCommand = (options: Record<string, OptionsPossible>) => {\n return [\"-jar\", compilerPath].concat(utils.buildArgs(options ?? {}));\n};\n\n/**\n * Expose `minifyGCC()`.\n */\nminifyGCC.default = minifyGCC;\nexport = minifyGCC;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AASA,iBAA+B;AAM/B,mBAAsB;AACtB,0CAAyB;AAGzB,IAAM,eAAe;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAUA,IAAM,YAAY,CAAC,EAAE,UAAU,SAAS,UAAU,MAAM,MAAuB;AAC3E,QAAM,UAAU,aAAa,CAAC,GAAG,UAAU,WAAW,CAAC,CAAC;AACxD,aAAO,2BAAe;AAAA,IAClB,MAAM,WAAW,OAAO;AAAA,IACxB,MAAM;AAAA,IACN;AAAA,IACA,UAAU,CAAC,KAAcA,aAAqB;AAC1C,UAAI,KAAK;AACL,YAAI,UAAU;AACV,iBAAO,SAAS,GAAG;AAAA,QACvB;AACA,cAAM;AAAA,MACV;AACA,UAAI,YAAY,CAAC,SAAS,WAAW,SAAS,QAAQ;AAClD,2BAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,SAAAA,UAAS,MAAM,CAAC;AAAA,MAC7D;AACA,UAAI,UAAU;AACV,eAAO,SAAS,MAAMA,QAAO;AAAA,MACjC;AACA,aAAOA;AAAA,IACX;AAAA,EACJ,CAAC;AACL;AAWA,IAAM,eAAe,CAAC,OAAc,YAA6B;AAC7D,MAAI,CAAC,WAAW,OAAO,KAAK,OAAO,EAAE,WAAW,GAAG;AAC/C,WAAO;AAAA,EACX;AACA,SAAO,KAAK,OAAO,EACd,OAAO,CAAC,WAAW,aAAa,QAAQ,MAAM,IAAI,EAAE,EACpD,QAAQ,CAAC,WAAW;AACjB,UAAM,QAAQ,QAAQ,MAAM;AAC5B,QACI,OAAO,UAAU,aAChB,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,GACpD;AACE,YAAM,MAAM,IAAI;AAAA,IAGpB;AAAA,EACJ,CAAC;AACL,SAAO;AACX;AAQA,IAAM,aAAa,CAAC,YAA6C;AAC7D,SAAO,CAAC,QAAQ,oCAAAC,OAAY,EAAE,OAAO,mBAAM,UAAU,WAAW,CAAC,CAAC,CAAC;AACvE;AAKA,UAAU,UAAU;AACpB,iBAAS;","names":["content","compilerPath"]}
|
package/dist/index.mjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
// src/index.ts
|
|
7
|
-
import { runCommandLine } from "@node-minify/run";
|
|
8
|
-
import { utils } from "@node-minify/utils";
|
|
9
|
-
import compilerPath from "google-closure-compiler-java";
|
|
10
|
-
var require_src = __commonJS({
|
|
11
|
-
"src/index.ts"(exports, module) {
|
|
12
|
-
var allowedFlags = [
|
|
13
|
-
"angular_pass",
|
|
14
|
-
"assume_function_wrapper",
|
|
15
|
-
"checks_only",
|
|
16
|
-
"compilation_level",
|
|
17
|
-
"create_source_map",
|
|
18
|
-
"define",
|
|
19
|
-
"env",
|
|
20
|
-
"externs",
|
|
21
|
-
"export_local_property_definitions",
|
|
22
|
-
"generate_exports",
|
|
23
|
-
"language_in",
|
|
24
|
-
"language_out",
|
|
25
|
-
"output_wrapper",
|
|
26
|
-
"polymer_version",
|
|
27
|
-
"process_common_js_modules",
|
|
28
|
-
"rename_prefix_namespace",
|
|
29
|
-
"rewrite_polyfills",
|
|
30
|
-
"use_types_for_optimization",
|
|
31
|
-
"warning_level"
|
|
32
|
-
];
|
|
33
|
-
var minifyGCC = ({ settings, content, callback, index }) => {
|
|
34
|
-
const options = applyOptions({}, settings?.options ?? {});
|
|
35
|
-
return runCommandLine({
|
|
36
|
-
args: gccCommand(options),
|
|
37
|
-
data: content,
|
|
38
|
-
settings,
|
|
39
|
-
callback: (err, content2) => {
|
|
40
|
-
if (err) {
|
|
41
|
-
if (callback) {
|
|
42
|
-
return callback(err);
|
|
43
|
-
}
|
|
44
|
-
throw err;
|
|
45
|
-
}
|
|
46
|
-
if (settings && !settings.content && settings.output) {
|
|
47
|
-
utils.writeFile({ file: settings.output, content: content2, index });
|
|
48
|
-
}
|
|
49
|
-
if (callback) {
|
|
50
|
-
return callback(null, content2);
|
|
51
|
-
}
|
|
52
|
-
return content2;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
var applyOptions = (flags, options) => {
|
|
57
|
-
if (!options || Object.keys(options).length === 0) {
|
|
58
|
-
return flags;
|
|
59
|
-
}
|
|
60
|
-
Object.keys(options).filter((option) => allowedFlags.indexOf(option) > -1).forEach((option) => {
|
|
61
|
-
const value = options[option];
|
|
62
|
-
if (typeof value === "boolean" || typeof value === "object" && !Array.isArray(value)) {
|
|
63
|
-
flags[option] = value;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return flags;
|
|
67
|
-
};
|
|
68
|
-
var gccCommand = (options) => {
|
|
69
|
-
return ["-jar", compilerPath].concat(utils.buildArgs(options ?? {}));
|
|
70
|
-
};
|
|
71
|
-
minifyGCC.default = minifyGCC;
|
|
72
|
-
module.exports = minifyGCC;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
export default require_src();
|
|
76
|
-
/*!
|
|
77
|
-
* node-minify
|
|
78
|
-
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
79
|
-
* MIT Licensed
|
|
80
|
-
*/
|
|
81
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport { runCommandLine } from \"@node-minify/run\";\nimport type {\n MinifierOptions,\n Options,\n OptionsPossible,\n} from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\nimport compilerPath from \"google-closure-compiler-java\";\n\n// the allowed flags, taken from https://github.com/google/closure-compiler/wiki/Flags-and-Options\nconst allowedFlags = [\n \"angular_pass\",\n \"assume_function_wrapper\",\n \"checks_only\",\n \"compilation_level\",\n \"create_source_map\",\n \"define\",\n \"env\",\n \"externs\",\n \"export_local_property_definitions\",\n \"generate_exports\",\n \"language_in\",\n \"language_out\",\n \"output_wrapper\",\n \"polymer_version\",\n \"process_common_js_modules\",\n \"rename_prefix_namespace\",\n \"rewrite_polyfills\",\n \"use_types_for_optimization\",\n \"warning_level\",\n];\n\n/**\n * Run Google Closure Compiler.\n * @param settings GCC options\n * @param content Content to minify\n * @param callback Callback\n * @param index Index of current file in array\n * @returns Minified content\n */\nconst minifyGCC = ({ settings, content, callback, index }: MinifierOptions) => {\n const options = applyOptions({}, settings?.options ?? {});\n return runCommandLine({\n args: gccCommand(options),\n data: content,\n settings,\n callback: (err: unknown, content?: string) => {\n if (err) {\n if (callback) {\n return callback(err);\n }\n throw err;\n }\n if (settings && !settings.content && settings.output) {\n utils.writeFile({ file: settings.output, content, index });\n }\n if (callback) {\n return callback(null, content);\n }\n return content;\n },\n });\n};\n\n/**\n * Adds any valid options passed in the options parameters to the flags parameter and returns the flags object.\n * @param flags the flags object to add options to\n * @param options the options object to add to the flags object\n * @returns the flags object with the options added\n */\ntype Flags = {\n [key: string]: boolean | Record<string, OptionsPossible>;\n};\nconst applyOptions = (flags: Flags, options?: Options): Flags => {\n if (!options || Object.keys(options).length === 0) {\n return flags;\n }\n Object.keys(options)\n .filter((option) => allowedFlags.indexOf(option) > -1)\n .forEach((option) => {\n const value = options[option];\n if (\n typeof value === \"boolean\" ||\n (typeof value === \"object\" && !Array.isArray(value))\n ) {\n flags[option] = value as\n | boolean\n | Record<string, OptionsPossible>;\n }\n });\n return flags;\n};\n\n/**\n * GCC command line.\n * @param options the options to pass to GCC\n * @returns the command line arguments to pass to GCC\n */\n\nconst gccCommand = (options: Record<string, OptionsPossible>) => {\n return [\"-jar\", compilerPath].concat(utils.buildArgs(options ?? {}));\n};\n\n/**\n * Expose `minifyGCC()`.\n */\nminifyGCC.default = minifyGCC;\nexport = minifyGCC;\n"],"mappings":";;;;;;AASA,SAAS,sBAAsB;AAM/B,SAAS,aAAa;AACtB,OAAO,kBAAkB;AAhBzB;AAAA;AAmBA,QAAM,eAAe;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAUA,QAAM,YAAY,CAAC,EAAE,UAAU,SAAS,UAAU,MAAM,MAAuB;AAC3E,YAAM,UAAU,aAAa,CAAC,GAAG,UAAU,WAAW,CAAC,CAAC;AACxD,aAAO,eAAe;AAAA,QAClB,MAAM,WAAW,OAAO;AAAA,QACxB,MAAM;AAAA,QACN;AAAA,QACA,UAAU,CAAC,KAAcA,aAAqB;AAC1C,cAAI,KAAK;AACL,gBAAI,UAAU;AACV,qBAAO,SAAS,GAAG;AAAA,YACvB;AACA,kBAAM;AAAA,UACV;AACA,cAAI,YAAY,CAAC,SAAS,WAAW,SAAS,QAAQ;AAClD,kBAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,SAAAA,UAAS,MAAM,CAAC;AAAA,UAC7D;AACA,cAAI,UAAU;AACV,mBAAO,SAAS,MAAMA,QAAO;AAAA,UACjC;AACA,iBAAOA;AAAA,QACX;AAAA,MACJ,CAAC;AAAA,IACL;AAWA,QAAM,eAAe,CAAC,OAAc,YAA6B;AAC7D,UAAI,CAAC,WAAW,OAAO,KAAK,OAAO,EAAE,WAAW,GAAG;AAC/C,eAAO;AAAA,MACX;AACA,aAAO,KAAK,OAAO,EACd,OAAO,CAAC,WAAW,aAAa,QAAQ,MAAM,IAAI,EAAE,EACpD,QAAQ,CAAC,WAAW;AACjB,cAAM,QAAQ,QAAQ,MAAM;AAC5B,YACI,OAAO,UAAU,aAChB,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,GACpD;AACE,gBAAM,MAAM,IAAI;AAAA,QAGpB;AAAA,MACJ,CAAC;AACL,aAAO;AAAA,IACX;AAQA,QAAM,aAAa,CAAC,YAA6C;AAC7D,aAAO,CAAC,QAAQ,YAAY,EAAE,OAAO,MAAM,UAAU,WAAW,CAAC,CAAC,CAAC;AAAA,IACvE;AAKA,cAAU,UAAU;AACpB,qBAAS;AAAA;AAAA;","names":["content"]}
|