How to use the google-closure-compiler.jsCompiler function in google-closure-compiler

To help you get started, we’ve selected a few google-closure-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ct-js / ct-js / src / node_requires / exporter.js View on Github external
if (await fs.exists(path.join(basePath, `./ct.libs/${lib}/includes/`))) {
            await fs.copy(path.join(basePath, `./ct.libs/${lib}/includes/`), writeDir);
        }
    }));

    /* Global injects, provided by modules */
    for (const i in injects) {
        buffer = buffer.replace(`/*%${i}%*/`, injects[i]);
    }

    /* Final touches and script output */
    if (currentProject.settings.minifyjs) {
        const preamble = '/* Made with ct.js http://ctjs.rocks/ */\n';
        const ClosureCompiler = require('google-closure-compiler').jsCompiler;

        const compiler = new ClosureCompiler({
            /* eslint-disable camelcase */
            compilation_level: 'SIMPLE',
            use_types_for_optimization: false,
            jscomp_off: '*', // Disable warnings to not to booo users
            language_out: 'ECMASCRIPT3',
            language_in: 'ECMASCRIPT_NEXT',
            warning_level: 'QUIET'
            /* eslint-enable camelcase */
        });
        const out = await new Promise((resolve, reject) => {
            compiler.run([{
                path: path.join(writeDir, '/ct.js'),
                src: buffer
            }], (exitCode, stdout, stderr) => {
                if (stderr && !stdout) {
                    reject(stderr);
github jquense / react-dom-lite / scripts / rdl-hacky-babel-inliner.js View on Github external
return new Promise((resolve, reject) => {
    const closureCompiler = new ClosureCompiler({
      // debug: true,
      assumeFunctionWrapper: true,
      compilationLevel: 'SIMPLE',
      languageIn: 'ECMASCRIPT5_STRICT',
      languageOut: 'ECMASCRIPT5_STRICT',
      env: 'CUSTOM',
      rewritePolyfills: false,
      applyInputSourceMaps: false,
    });

    const compilerProcess = closureCompiler.run(
      [
        {
          path: fileName,
          src: source,
        },
github srod / node-minify / packages / google-closure-compiler / src / google-closure-compiler.js View on Github external
/*!
 * node-minify
 * Copyright(c) 2011-2019 Rodolphe Stoclin
 * MIT Licensed
 */

/**
 * Module dependencies.
 */
import compiler from 'google-closure-compiler';
import { utils } from '@node-minify/utils';

/**
 * Module variables.
 */
const ClosureCompiler = compiler.jsCompiler;

// the allowed flags, taken from https://github.com/google/closure-compiler
const allowedFlags = [
  'angularPass',
  'applyInputSourceMaps',
  'assumeFunctionWrapper',
  'checksOnly',
  'compilationLevel',
  'createSourceMap',
  'dartPass',
  'defines',
  'env',
  'externs',
  'exportLocalPropertyDefinitions',
  'generateExports',
  'languageIn',
github pinf / pinf-loader-js / workspace / build.js View on Github external
const minResult = await new Promise(function (resolve, reject) {
			const compilerProcess = new CLOSURE_COMPILER({
				compilation_level: 'ADVANCED'
			}).run([{
				src: source
			}], function (exitCode, result, stdErr) {
				if (!result) {
					console.error(COLORS.red(stdErr));
					return reject(new Error(`Closure Compiler failed with exit code: ${exitCode}`));
				}
				return resolve(result[0]);
			});
		});
github bcinarli / uxr / build / index.js View on Github external
const minify = () => {
    //performance('Minification');
    info('Starting to minify...');

    const uxr = getContent('dist/uxr.js');

    const closureCompiler = new ClosureCompiler(flags)

    closureCompiler.run([
        {
            src: uxr,
            path: 'dist/uxr.js'
        }
    ], (exitCode, stdOut, stdErr) => {
        fs.writeFile('dist/uxr.min.js', stdOut[0].src, 'UTF8', error => {
            if (error) {
                throw error;
            }

            info('Minification Complete!');
            //performance('Minification');
        });
    });