@node-minify/google-closure-compiler 7.0.0 → 8.0.0-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 Google Closure Compiler.
11
+ *
12
+ * @param {Object} settings
13
+ * @param {String} content
14
+ * @param {Function} callback
15
+ */
16
+ declare const minifyGCC: ({ settings, content, callback, index }: MinifierOptions) => any;
17
+
18
+ export { minifyGCC as default };
package/dist/index.js ADDED
@@ -0,0 +1,96 @@
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_google_closure_compiler_java = __toESM(require("google-closure-compiler-java"));
32
+ var import_utils = require("@node-minify/utils");
33
+ var import_run = require("@node-minify/run");
34
+ var allowedFlags = [
35
+ "angular_pass",
36
+ "assume_function_wrapper",
37
+ "checks_only",
38
+ "compilation_level",
39
+ "create_source_map",
40
+ "define",
41
+ "env",
42
+ "externs",
43
+ "export_local_property_definitions",
44
+ "generate_exports",
45
+ "language_in",
46
+ "language_out",
47
+ "output_wrapper",
48
+ "polymer_version",
49
+ "process_common_js_modules",
50
+ "rename_prefix_namespace",
51
+ "rewrite_polyfills",
52
+ "use_types_for_optimization",
53
+ "warning_level"
54
+ ];
55
+ var minifyGCC = ({ settings, content, callback, index }) => {
56
+ const options = applyOptions({}, settings && settings.options || {});
57
+ return (0, import_run.runCommandLine)({
58
+ args: gccCommand(options),
59
+ data: content,
60
+ settings,
61
+ callback: (err, content2) => {
62
+ if (err) {
63
+ if (callback) {
64
+ return callback(err);
65
+ } else {
66
+ throw err;
67
+ }
68
+ }
69
+ if (settings && !settings.content) {
70
+ import_utils.utils.writeFile({ file: settings.output, content: content2, index });
71
+ }
72
+ if (callback) {
73
+ return callback(null, content2);
74
+ }
75
+ return content2;
76
+ }
77
+ });
78
+ };
79
+ var applyOptions = (flags, options) => {
80
+ if (!options || Object.keys(options).length === 0) {
81
+ return flags;
82
+ }
83
+ Object.keys(options).filter((option) => allowedFlags.indexOf(option) > -1).forEach((option) => flags[option] = options[option]);
84
+ return flags;
85
+ };
86
+ var gccCommand = (options) => {
87
+ return ["-jar", import_google_closure_compiler_java.default].concat(import_utils.utils.buildArgs(options || {}));
88
+ };
89
+ var src_default = minifyGCC;
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {});
92
+ /*!
93
+ * node-minify
94
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
95
+ * MIT Licensed
96
+ */
package/dist/index.mjs ADDED
@@ -0,0 +1,68 @@
1
+ // src/index.ts
2
+ import compilerPath from "google-closure-compiler-java";
3
+ import { utils } from "@node-minify/utils";
4
+ import { runCommandLine } from "@node-minify/run";
5
+ var allowedFlags = [
6
+ "angular_pass",
7
+ "assume_function_wrapper",
8
+ "checks_only",
9
+ "compilation_level",
10
+ "create_source_map",
11
+ "define",
12
+ "env",
13
+ "externs",
14
+ "export_local_property_definitions",
15
+ "generate_exports",
16
+ "language_in",
17
+ "language_out",
18
+ "output_wrapper",
19
+ "polymer_version",
20
+ "process_common_js_modules",
21
+ "rename_prefix_namespace",
22
+ "rewrite_polyfills",
23
+ "use_types_for_optimization",
24
+ "warning_level"
25
+ ];
26
+ var minifyGCC = ({ settings, content, callback, index }) => {
27
+ const options = applyOptions({}, settings && settings.options || {});
28
+ return runCommandLine({
29
+ args: gccCommand(options),
30
+ data: content,
31
+ settings,
32
+ callback: (err, content2) => {
33
+ if (err) {
34
+ if (callback) {
35
+ return callback(err);
36
+ } else {
37
+ throw err;
38
+ }
39
+ }
40
+ if (settings && !settings.content) {
41
+ utils.writeFile({ file: settings.output, content: content2, index });
42
+ }
43
+ if (callback) {
44
+ return callback(null, content2);
45
+ }
46
+ return content2;
47
+ }
48
+ });
49
+ };
50
+ var applyOptions = (flags, options) => {
51
+ if (!options || Object.keys(options).length === 0) {
52
+ return flags;
53
+ }
54
+ Object.keys(options).filter((option) => allowedFlags.indexOf(option) > -1).forEach((option) => flags[option] = options[option]);
55
+ return flags;
56
+ };
57
+ var gccCommand = (options) => {
58
+ return ["-jar", compilerPath].concat(utils.buildArgs(options || {}));
59
+ };
60
+ var src_default = minifyGCC;
61
+ export {
62
+ src_default as default
63
+ };
64
+ /*!
65
+ * node-minify
66
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
67
+ * MIT Licensed
68
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/google-closure-compiler",
3
- "version": "7.0.0",
3
+ "version": "8.0.0-beta.0",
4
4
  "description": "google closure compiler plugin for @node-minify",
5
5
  "keywords": [
6
6
  "compressor",
@@ -12,16 +12,23 @@
12
12
  "author": "Rodolphe Stoclin <srodolphe@gmail.com>",
13
13
  "homepage": "https://github.com/srod/node-minify/tree/master/packages/google-closure-compiler#readme",
14
14
  "license": "MIT",
15
- "main": "lib/google-closure-compiler.js",
16
15
  "engines": {
17
16
  "node": ">=14.0.0"
18
17
  },
19
18
  "directories": {
20
- "lib": "lib",
19
+ "lib": "dist",
21
20
  "test": "__tests__"
22
21
  },
22
+ "main": "./dist/index.js",
23
+ "module": "./dist/index.mjs",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ "require": "./dist/index.js",
27
+ "import": "./dist/index.mjs",
28
+ "types": "./dist/index.d.ts"
29
+ },
23
30
  "files": [
24
- "lib"
31
+ "dist/**/*"
25
32
  ],
26
33
  "publishConfig": {
27
34
  "access": "public"
@@ -33,9 +40,18 @@
33
40
  "bugs": {
34
41
  "url": "https://github.com/srod/node-minify/issues"
35
42
  },
43
+ "scripts": {
44
+ "clean": "pnpm dlx rimraf dist",
45
+ "build": "npm run clean && tsup src/index.ts --format cjs,esm --dts --clean",
46
+ "prepublishOnly": "npm run build"
47
+ },
36
48
  "dependencies": {
37
- "@node-minify/utils": "^7.0.0",
38
- "google-closure-compiler-java": "20220719.0.0"
49
+ "@node-minify/run": "8.0.0-beta.0",
50
+ "@node-minify/utils": "8.0.0-beta.0",
51
+ "google-closure-compiler-java": "20221102.0.1"
52
+ },
53
+ "devDependencies": {
54
+ "@node-minify/types": "8.0.0-beta.0"
39
55
  },
40
- "gitHead": "8b5bda6f1ac9fe7180006f2a19ec3253e8fff4ec"
56
+ "gitHead": "0507c6190577e1939997a8231b07952ba167a780"
41
57
  }
@@ -1,95 +0,0 @@
1
- "use strict";
2
-
3
- var _googleClosureCompilerJava = _interopRequireDefault(require("google-closure-compiler-java"));
4
-
5
- var _utils = require("@node-minify/utils");
6
-
7
- var _run = require("@node-minify/run");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- /*!
12
- * node-minify
13
- * Copyright(c) 2011-2022 Rodolphe Stoclin
14
- * MIT Licensed
15
- */
16
-
17
- /**
18
- * Module dependencies.
19
- */
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
28
- */
29
-
30
- const minifyGCC = ({
31
- settings,
32
- content,
33
- callback,
34
- index
35
- }) => {
36
- const options = applyOptions({}, settings.options);
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;
63
- }
64
- });
65
- };
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
71
- */
72
-
73
-
74
- const applyOptions = (flags, options) => {
75
- if (!options || Object.keys(options).length === 0) {
76
- return flags;
77
- }
78
-
79
- Object.keys(options).filter(option => allowedFlags.indexOf(option) > -1).forEach(option => flags[option] = options[option]);
80
- return flags;
81
- };
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()`.
92
- */
93
-
94
-
95
- module.exports = minifyGCC;