@node-minify/google-closure-compiler 6.4.0 → 7.1.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/lib/google-closure-compiler.js +36 -51
- package/package.json +6 -5
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
3
|
+
var _googleClosureCompilerJava = _interopRequireDefault(require("google-closure-compiler-java"));
|
|
5
4
|
var _utils = require("@node-minify/utils");
|
|
6
|
-
|
|
5
|
+
var _run = require("@node-minify/run");
|
|
7
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
7
|
/*!
|
|
10
8
|
* node-minify
|
|
11
9
|
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
@@ -16,12 +14,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
14
|
* Module dependencies.
|
|
17
15
|
*/
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
const ClosureCompiler = _googleClosureCompiler.default.jsCompiler; // the allowed flags, taken from https://github.com/google/closure-compiler
|
|
17
|
+
// the allowed flags, taken from https://github.com/google/closure-compiler/wiki/Flags-and-Options
|
|
18
|
+
const allowedFlags = ['angular_pass', 'assume_function_wrapper', 'checks_only', 'compilation_level', 'create_source_map', 'define', 'env', 'externs', 'export_local_property_definitions', 'generate_exports', 'language_in', 'language_out', 'output_wrapper', 'polymer_version', 'process_common_js_modules', 'rename_prefix_namespace', 'rewrite_polyfills', 'use_types_for_optimization', 'warning_level'];
|
|
23
19
|
|
|
24
|
-
const allowedFlags = ['angularPass', 'applyInputSourceMaps', 'assumeFunctionWrapper', 'checksOnly', 'compilationLevel', 'createSourceMap', 'dartPass', 'defines', 'env', 'externs', 'exportLocalPropertyDefinitions', 'generateExports', 'languageIn', 'languageOut', 'newTypeInf', 'outputWrapper', 'polymerVersion', 'preserveTypeAnnotations', 'processCommonJsModules', 'renamePrefixNamespace', 'rewritePolyfills', 'useTypesForOptimization', 'warningLevel'];
|
|
25
20
|
/**
|
|
26
21
|
* Run Google Closure Compiler.
|
|
27
22
|
*
|
|
@@ -29,7 +24,6 @@ const allowedFlags = ['angularPass', 'applyInputSourceMaps', 'assumeFunctionWrap
|
|
|
29
24
|
* @param {String} content
|
|
30
25
|
* @param {Function} callback
|
|
31
26
|
*/
|
|
32
|
-
|
|
33
27
|
const minifyGCC = ({
|
|
34
28
|
settings,
|
|
35
29
|
content,
|
|
@@ -37,65 +31,56 @@ const minifyGCC = ({
|
|
|
37
31
|
index
|
|
38
32
|
}) => {
|
|
39
33
|
const options = applyOptions({}, settings.options);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
return (0, _run.runCommandLine)({
|
|
35
|
+
args: gccCommand(options),
|
|
36
|
+
data: content,
|
|
37
|
+
settings,
|
|
38
|
+
callback: (err, content) => {
|
|
39
|
+
if (err) {
|
|
40
|
+
if (callback) {
|
|
41
|
+
return callback(err);
|
|
42
|
+
} else {
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!settings.content) {
|
|
47
|
+
_utils.utils.writeFile({
|
|
48
|
+
file: settings.output,
|
|
49
|
+
content,
|
|
50
|
+
index
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (callback) {
|
|
54
|
+
return callback(null, content);
|
|
55
|
+
}
|
|
56
|
+
return content;
|
|
46
57
|
}
|
|
47
58
|
});
|
|
48
|
-
|
|
49
|
-
if (!settings.content) {
|
|
50
|
-
_utils.utils.writeFile({
|
|
51
|
-
file: settings.output,
|
|
52
|
-
content: contentMinified.compiledCode,
|
|
53
|
-
index
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Write GCC sourceMap
|
|
58
|
-
* If the createSourceMap option is passed we'll write the sourceMap file
|
|
59
|
-
* If createSourceMap is a boolean we'll append .map to the settings.output file path
|
|
60
|
-
* otherwise use createSourceMap as the file path.
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (settings.options.createSourceMap) {
|
|
65
|
-
const sourceMapOutput = typeof settings.options.createSourceMap === 'boolean' ? settings.output + '.map' : settings.options.createSourceMap;
|
|
66
|
-
|
|
67
|
-
_utils.utils.writeFile({
|
|
68
|
-
file: sourceMapOutput,
|
|
69
|
-
content: contentMinified.sourceMap,
|
|
70
|
-
index
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (callback) {
|
|
75
|
-
return callback(null, contentMinified.compiledCode);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return contentMinified.compiledCode;
|
|
79
59
|
};
|
|
60
|
+
|
|
80
61
|
/**
|
|
81
62
|
* Adds any valid options passed in the options parameters to the flags parameter and returns the flags object.
|
|
82
63
|
* @param {Object} flags
|
|
83
64
|
* @param {Object} options
|
|
84
65
|
* @returns {Object} flags
|
|
85
66
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
67
|
const applyOptions = (flags, options) => {
|
|
89
68
|
if (!options || Object.keys(options).length === 0) {
|
|
90
69
|
return flags;
|
|
91
70
|
}
|
|
92
|
-
|
|
93
71
|
Object.keys(options).filter(option => allowedFlags.indexOf(option) > -1).forEach(option => flags[option] = options[option]);
|
|
94
72
|
return flags;
|
|
95
73
|
};
|
|
74
|
+
|
|
96
75
|
/**
|
|
97
|
-
*
|
|
76
|
+
* GCC command line.
|
|
98
77
|
*/
|
|
99
78
|
|
|
79
|
+
const gccCommand = options => {
|
|
80
|
+
return ['-jar', _googleClosureCompilerJava.default].concat(_utils.utils.buildArgs(options || {}));
|
|
81
|
+
};
|
|
100
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Expose `minifyGCC()`.
|
|
85
|
+
*/
|
|
101
86
|
module.exports = minifyGCC;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/google-closure-compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "google closure compiler plugin for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"main": "lib/google-closure-compiler.js",
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=14.0.0"
|
|
18
18
|
},
|
|
19
19
|
"directories": {
|
|
20
20
|
"lib": "lib",
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"url": "https://github.com/srod/node-minify/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@node-minify/
|
|
38
|
-
"
|
|
37
|
+
"@node-minify/run": "^7.1.0",
|
|
38
|
+
"@node-minify/utils": "^7.1.0",
|
|
39
|
+
"google-closure-compiler-java": "20221102.0.1"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "94cef2d5d653c3bddc3e603b4e25c135b0b6f4b3"
|
|
41
42
|
}
|