@node-minify/google-closure-compiler 8.0.6 → 9.0.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/LICENSE +1 -1
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -16
package/LICENSE
CHANGED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MinifierOptions } from '@node-minify/types';
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* node-minify
|
|
5
|
+
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare const minifyGCC: {
|
|
10
|
+
({ settings, content, callback, index }: MinifierOptions): void;
|
|
11
|
+
default: any;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { minifyGCC as default };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,9 +23,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
|
|
25
25
|
// src/index.ts
|
|
26
|
-
var import_google_closure_compiler_java = __toESM(require("google-closure-compiler-java"));
|
|
27
|
-
var import_utils = require("@node-minify/utils");
|
|
28
26
|
var import_run = require("@node-minify/run");
|
|
27
|
+
var import_utils = require("@node-minify/utils");
|
|
28
|
+
var import_google_closure_compiler_java = __toESM(require("google-closure-compiler-java"));
|
|
29
29
|
var allowedFlags = [
|
|
30
30
|
"angular_pass",
|
|
31
31
|
"assume_function_wrapper",
|
|
@@ -57,9 +57,8 @@ var minifyGCC = ({ settings, content, callback, index }) => {
|
|
|
57
57
|
if (err) {
|
|
58
58
|
if (callback) {
|
|
59
59
|
return callback(err);
|
|
60
|
-
} else {
|
|
61
|
-
throw err;
|
|
62
60
|
}
|
|
61
|
+
throw err;
|
|
63
62
|
}
|
|
64
63
|
if (settings && !settings.content && settings.output) {
|
|
65
64
|
import_utils.utils.writeFile({ file: settings.output, content: content2, index });
|
|
@@ -75,7 +74,12 @@ var applyOptions = (flags, options) => {
|
|
|
75
74
|
if (!options || Object.keys(options).length === 0) {
|
|
76
75
|
return flags;
|
|
77
76
|
}
|
|
78
|
-
Object.keys(options).filter((option) => allowedFlags.indexOf(option) > -1).forEach((option) =>
|
|
77
|
+
Object.keys(options).filter((option) => allowedFlags.indexOf(option) > -1).forEach((option) => {
|
|
78
|
+
const value = options[option];
|
|
79
|
+
if (typeof value === "boolean" || typeof value === "object" && !Array.isArray(value)) {
|
|
80
|
+
flags[option] = value;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
79
83
|
return flags;
|
|
80
84
|
};
|
|
81
85
|
var gccCommand = (options) => {
|
|
@@ -85,7 +89,7 @@ minifyGCC.default = minifyGCC;
|
|
|
85
89
|
module.exports = minifyGCC;
|
|
86
90
|
/*!
|
|
87
91
|
* node-minify
|
|
88
|
-
* Copyright(c) 2011-
|
|
92
|
+
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
89
93
|
* MIT Licensed
|
|
90
94
|
*/
|
|
91
95
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-
|
|
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 * Exp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AAU,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
CHANGED
|
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
// src/index.ts
|
|
7
|
-
import compilerPath from "google-closure-compiler-java";
|
|
8
|
-
import { utils } from "@node-minify/utils";
|
|
9
7
|
import { runCommandLine } from "@node-minify/run";
|
|
8
|
+
import { utils } from "@node-minify/utils";
|
|
9
|
+
import compilerPath from "google-closure-compiler-java";
|
|
10
10
|
var require_src = __commonJS({
|
|
11
11
|
"src/index.ts"(exports, module) {
|
|
12
12
|
var allowedFlags = [
|
|
@@ -40,9 +40,8 @@ var require_src = __commonJS({
|
|
|
40
40
|
if (err) {
|
|
41
41
|
if (callback) {
|
|
42
42
|
return callback(err);
|
|
43
|
-
} else {
|
|
44
|
-
throw err;
|
|
45
43
|
}
|
|
44
|
+
throw err;
|
|
46
45
|
}
|
|
47
46
|
if (settings && !settings.content && settings.output) {
|
|
48
47
|
utils.writeFile({ file: settings.output, content: content2, index });
|
|
@@ -58,7 +57,12 @@ var require_src = __commonJS({
|
|
|
58
57
|
if (!options || Object.keys(options).length === 0) {
|
|
59
58
|
return flags;
|
|
60
59
|
}
|
|
61
|
-
Object.keys(options).filter((option) => allowedFlags.indexOf(option) > -1).forEach((option) =>
|
|
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
|
+
});
|
|
62
66
|
return flags;
|
|
63
67
|
};
|
|
64
68
|
var gccCommand = (options) => {
|
|
@@ -71,7 +75,7 @@ var require_src = __commonJS({
|
|
|
71
75
|
export default require_src();
|
|
72
76
|
/*!
|
|
73
77
|
* node-minify
|
|
74
|
-
* Copyright(c) 2011-
|
|
78
|
+
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
75
79
|
* MIT Licensed
|
|
76
80
|
*/
|
|
77
81
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-
|
|
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,UA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4
4
|
"description": "google closure compiler plugin for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"homepage": "https://github.com/srod/node-minify/tree/master/packages/google-closure-compiler#readme",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
16
|
+
"node": ">=18.0.0"
|
|
17
17
|
},
|
|
18
18
|
"directories": {
|
|
19
19
|
"lib": "dist",
|
|
@@ -23,9 +23,11 @@
|
|
|
23
23
|
"module": "./dist/index.mjs",
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"exports": {
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.mjs",
|
|
29
|
+
"require": "./dist/index.cjs"
|
|
30
|
+
}
|
|
29
31
|
},
|
|
30
32
|
"files": [
|
|
31
33
|
"dist/**/*"
|
|
@@ -40,18 +42,20 @@
|
|
|
40
42
|
"bugs": {
|
|
41
43
|
"url": "https://github.com/srod/node-minify/issues"
|
|
42
44
|
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"clean": "pnpm dlx rimraf dist",
|
|
45
|
-
"build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
|
|
46
|
-
"prepublishOnly": "pnpm build"
|
|
47
|
-
},
|
|
48
45
|
"dependencies": {
|
|
49
|
-
"
|
|
50
|
-
"@node-minify/
|
|
51
|
-
"
|
|
46
|
+
"google-closure-compiler-java": "20231112.0.0",
|
|
47
|
+
"@node-minify/run": "9.0.0",
|
|
48
|
+
"@node-minify/utils": "9.0.0"
|
|
52
49
|
},
|
|
53
50
|
"devDependencies": {
|
|
54
|
-
"@node-minify/types": "
|
|
51
|
+
"@node-minify/types": "9.0.0"
|
|
55
52
|
},
|
|
56
|
-
"
|
|
57
|
-
|
|
53
|
+
"scripts": {
|
|
54
|
+
"clean": "pnpm dlx rimraf dist",
|
|
55
|
+
"build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
|
|
56
|
+
"lint": "biome lint .",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:ci": "vitest run --coverage",
|
|
59
|
+
"test:watch": "vitest"
|
|
60
|
+
}
|
|
61
|
+
}
|