@node-minify/google-closure-compiler 6.1.0 → 7.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/lib/google-closure-compiler.js +58 -64
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _googleClosureCompilerJava = _interopRequireDefault(require("google-closure-compiler-java"));
|
|
4
4
|
|
|
5
5
|
var _utils = require("@node-minify/utils");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
var _run = require("@node-minify/run");
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* node-minify
|
|
11
|
-
* Copyright(c) 2011-2020 Rodolphe Stoclin
|
|
12
|
-
* MIT Licensed
|
|
13
|
-
*/
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
*
|
|
11
|
+
/*!
|
|
12
|
+
* node-minify
|
|
13
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
14
|
+
* MIT Licensed
|
|
17
15
|
*/
|
|
18
16
|
|
|
19
|
-
/**
|
|
20
|
-
* Module
|
|
17
|
+
/**
|
|
18
|
+
* Module dependencies.
|
|
21
19
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {Function} callback
|
|
20
|
+
// the allowed flags, taken from https://github.com/google/closure-compiler/wiki/Flags-and-Options
|
|
21
|
+
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'];
|
|
22
|
+
/**
|
|
23
|
+
* Run Google Closure Compiler.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} settings
|
|
26
|
+
* @param {String} content
|
|
27
|
+
* @param {Function} callback
|
|
31
28
|
*/
|
|
32
29
|
|
|
33
30
|
const minifyGCC = ({
|
|
@@ -37,51 +34,40 @@ const minifyGCC = ({
|
|
|
37
34
|
index
|
|
38
35
|
}) => {
|
|
39
36
|
const options = applyOptions({}, settings.options);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
return (0, _run.runCommandLine)({
|
|
38
|
+
args: gccCommand(options),
|
|
39
|
+
data: content,
|
|
40
|
+
settings,
|
|
41
|
+
callback: (err, content) => {
|
|
42
|
+
if (err) {
|
|
43
|
+
if (callback) {
|
|
44
|
+
return callback(err);
|
|
45
|
+
} else {
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!settings.content) {
|
|
51
|
+
_utils.utils.writeFile({
|
|
52
|
+
file: settings.output,
|
|
53
|
+
content,
|
|
54
|
+
index
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (callback) {
|
|
59
|
+
return callback(null, content);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return content;
|
|
46
63
|
}
|
|
47
64
|
});
|
|
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
65
|
};
|
|
80
|
-
/**
|
|
81
|
-
* Adds any valid options passed in the options parameters to the flags parameter and returns the flags object.
|
|
82
|
-
* @param {Object} flags
|
|
83
|
-
* @param {Object} options
|
|
84
|
-
* @returns {Object} flags
|
|
66
|
+
/**
|
|
67
|
+
* Adds any valid options passed in the options parameters to the flags parameter and returns the flags object.
|
|
68
|
+
* @param {Object} flags
|
|
69
|
+
* @param {Object} options
|
|
70
|
+
* @returns {Object} flags
|
|
85
71
|
*/
|
|
86
72
|
|
|
87
73
|
|
|
@@ -93,8 +79,16 @@ const applyOptions = (flags, options) => {
|
|
|
93
79
|
Object.keys(options).filter(option => allowedFlags.indexOf(option) > -1).forEach(option => flags[option] = options[option]);
|
|
94
80
|
return flags;
|
|
95
81
|
};
|
|
96
|
-
/**
|
|
97
|
-
*
|
|
82
|
+
/**
|
|
83
|
+
* GCC command line.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const gccCommand = options => {
|
|
88
|
+
return ['-jar', _googleClosureCompilerJava.default].concat(_utils.utils.buildArgs(options || {}));
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Expose `minifyGCC()`.
|
|
98
92
|
*/
|
|
99
93
|
|
|
100
94
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/google-closure-compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.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,8 @@
|
|
|
34
34
|
"url": "https://github.com/srod/node-minify/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@node-minify/utils": "^
|
|
38
|
-
"google-closure-compiler": "
|
|
37
|
+
"@node-minify/utils": "^7.0.0",
|
|
38
|
+
"google-closure-compiler-java": "20220719.0.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8b5bda6f1ac9fe7180006f2a19ec3253e8fff4ec"
|
|
41
41
|
}
|