UNPKG

@node-minify/google-closure-compiler

Version:
81 lines (80 loc) 2.47 kB
var __getOwnPropNames = Object.getOwnPropertyNames; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; // src/index.ts import { runCommandLine } from "@node-minify/run"; import { utils } from "@node-minify/utils"; import compilerPath from "google-closure-compiler-java"; var require_src = __commonJS({ "src/index.ts"(exports, module) { var 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" ]; var minifyGCC = ({ settings, content, callback, index }) => { const options = applyOptions({}, settings?.options ?? {}); return runCommandLine({ args: gccCommand(options), data: content, settings, callback: (err, content2) => { if (err) { if (callback) { return callback(err); } throw err; } if (settings && !settings.content && settings.output) { utils.writeFile({ file: settings.output, content: content2, index }); } if (callback) { return callback(null, content2); } return content2; } }); }; var applyOptions = (flags, options) => { if (!options || Object.keys(options).length === 0) { return flags; } Object.keys(options).filter((option) => allowedFlags.indexOf(option) > -1).forEach((option) => { const value = options[option]; if (typeof value === "boolean" || typeof value === "object" && !Array.isArray(value)) { flags[option] = value; } }); return flags; }; var gccCommand = (options) => { return ["-jar", compilerPath].concat(utils.buildArgs(options ?? {})); }; minifyGCC.default = minifyGCC; module.exports = minifyGCC; } }); export default require_src(); /*! * node-minify * Copyright(c) 2011-2024 Rodolphe Stoclin * MIT Licensed */ //# sourceMappingURL=index.mjs.map