google-closure-compiler
Advanced tools
Comparing version 20180624.0.0-webpack-beta to 20180701.0.0-webpack-beta
@@ -38,2 +38,3 @@ /* | ||
* @template T | ||
* @implements {IThenable<T>} | ||
*/ | ||
@@ -52,2 +53,3 @@ angular.$q.Promise = function() {}; | ||
* @return {RESULT} | ||
* @override | ||
* @template THIS | ||
@@ -54,0 +56,0 @@ * @template VALUE |
@@ -38,2 +38,3 @@ /* | ||
* @template T | ||
* @implements {IThenable<T>} | ||
*/ | ||
@@ -52,2 +53,3 @@ angular.$q.Promise = function() {}; | ||
* @return {RESULT} | ||
* @override | ||
* @template THIS | ||
@@ -54,0 +56,0 @@ * @template VALUE |
@@ -38,2 +38,3 @@ /* | ||
* @template T | ||
* @extends {IThenable<T>} | ||
*/ | ||
@@ -52,2 +53,3 @@ angular.$q.Promise = function() {}; | ||
* @return {RESULT} | ||
* @override | ||
* @template THIS | ||
@@ -54,0 +56,0 @@ * @template VALUE |
@@ -29,3 +29,3 @@ /* | ||
module.exports = (grunt, extraArguments) => { | ||
module.exports = (grunt, pluginOptions) => { | ||
const chalk = require('chalk'); | ||
@@ -36,3 +36,26 @@ const VinylStream = require('./vinyl-stream'); | ||
const gulp = require('gulp'); | ||
const {getFirstSupportedPlatform} = require('../utils'); | ||
let extraArguments; | ||
let platforms; | ||
if (pluginOptions) { | ||
if (Array.isArray(extraArguments)) { | ||
extraArguments = pluginOptions; | ||
} else if (pluginOptions === 'javascript') { | ||
platforms = ['javascript']; | ||
} else { | ||
if (pluginOptions.platform) { | ||
platforms = Array.isArray(pluginOptions.platform) ? pluginOptions.platform : [pluginOptions.platform]; | ||
} | ||
if (pluginOptions.extraArguments) { | ||
extraArguments = pluginOptions.extraArguments; | ||
} | ||
} | ||
} | ||
if (!platforms) { | ||
platforms = ['java', 'javascript']; | ||
} | ||
const platform = getFirstSupportedPlatform(platforms); | ||
/** | ||
@@ -65,7 +88,6 @@ * @param {Array<string>}|null} files | ||
let stream; | ||
const args = Object.assign({}, {jsMode: extraArguments === 'javascript'}); | ||
const args = {}; | ||
let gulpOpts; | ||
if (args.jsMode) { | ||
if (platform === 'javascript') { | ||
gulpOpts = Object.assign({}, gulpCompilerOptions, { | ||
jsMode: true, | ||
logger: grunt.log, | ||
@@ -93,3 +115,3 @@ pluginName: 'grunt-google-closure-compiler' | ||
.pipe(gulpCompiler(options, compilerOpts)); | ||
if (args.jsMode) { | ||
if (platform === 'javascript') { | ||
stream = stream.on('error', err => { | ||
@@ -105,3 +127,3 @@ hadError = true; | ||
stream = gulpCompiler(options, compilerOpts); | ||
if (args.jsMode) { | ||
if (platform === 'javascript') { | ||
stream = stream.on('error', err => { | ||
@@ -141,3 +163,2 @@ hadError = true; | ||
delete opts.args; | ||
delete opts.jsMode; | ||
@@ -171,3 +192,3 @@ return { | ||
compileTasks.push(compilationPromise(src, options.args || options.compilerOpts, {jsMode: options.jsMode}) | ||
compileTasks.push(compilationPromise(src, options.args || options.compilerOpts, {platform}) | ||
.then(function () {}, function(err) { | ||
@@ -182,3 +203,3 @@ throw err; | ||
const options = getCompilerOptions(); | ||
compileTasks.push(compilationPromise(null, options.args || options.compilerOpts, {jsMode: options.jsMode})); | ||
compileTasks.push(compilationPromise(null, options.args || options.compilerOpts, {platform})); | ||
} | ||
@@ -185,0 +206,0 @@ |
@@ -45,7 +45,6 @@ /* | ||
const stream = require('stream'); | ||
const {getNativeImagePath, getFirstSupportedPlatform} = require('../utils'); | ||
/** @const */ | ||
const PLUGIN_NAME = 'gulp-google-closure-compiler'; | ||
const extraCommandArguments = initOptions ? initOptions.extraArguments : undefined; | ||
const jsMode = Boolean(initOptions && initOptions.jsMode); | ||
const applySourceMap = require('vinyl-sourcemaps-apply'); | ||
@@ -55,2 +54,4 @@ const chalk = require('chalk'); | ||
const extraCommandArguments = initOptions ? initOptions.extraArguments : undefined; | ||
let PluginError; | ||
@@ -70,3 +71,5 @@ try { | ||
const Compiler = jsMode ? require('../node/closure-compiler-js') : require('../node/closure-compiler'); | ||
function getCompiler(platform) { | ||
return platform === 'javascript' ? require('../node/closure-compiler-js') : require('../node/closure-compiler'); | ||
} | ||
@@ -85,2 +88,9 @@ class CompilationStream extends stream.Transform { | ||
this._streamInputRequired = pluginOptions.requireStreamInput !== false; | ||
const jsMode = Boolean(initOptions && initOptions.jsMode); | ||
let platforms = (pluginOptions && pluginOptions.platform) || (jsMode ? ['javascript'] : ['java', 'javascript']); | ||
if (!Array.isArray(platforms)) { | ||
platforms = [platforms]; | ||
} | ||
this.platform = getFirstSupportedPlatform(platforms); | ||
} | ||
@@ -113,3 +123,3 @@ | ||
if (file.sourceMap && jsMode) { | ||
if (file.sourceMap && this.platform === 'javascript') { | ||
this.compilationOptions_.createSourceMap = true; | ||
@@ -139,4 +149,9 @@ } | ||
} | ||
const Compiler = getCompiler(this.platform); | ||
const compiler = new Compiler(this.compilationOptions_, extraCommandArguments); | ||
if (jsMode) { | ||
if (this.platform === 'native') { | ||
compiler.JAR_PATH = null; | ||
compiler.javaPath = getNativeImagePath(); | ||
} | ||
if (this.platform === 'javascript') { | ||
let compilerProcess; | ||
@@ -143,0 +158,0 @@ try { |
@@ -37,6 +37,7 @@ /* | ||
constructor(args, extraCommandArgs) { | ||
this.commandArguments = (extraCommandArgs || []).slice(); | ||
this.commandArguments = []; | ||
this.extraCommandArgs = extraCommandArgs; | ||
if (Compiler.JAR_PATH) { | ||
this.commandArguments.push('-jar', Compiler.JAR_PATH); | ||
this.JAR_PATH = Compiler.JAR_PATH; | ||
} | ||
@@ -66,6 +67,12 @@ | ||
run(callback) { | ||
if (this.JAR_PATH) { | ||
this.commandArguments.unshift('-jar', Compiler.JAR_PATH); | ||
if (this.extraCommandArgs) { | ||
this.commandArguments.unshift(...this.extraCommandArgs); | ||
} | ||
} | ||
if (this.logger) { | ||
this.logger(this.getFullCommand() + '\n'); | ||
} | ||
let compileProcess = spawn(this.javaPath, this.commandArguments, this.spawnOptions); | ||
@@ -72,0 +79,0 @@ |
{ | ||
"name": "google-closure-compiler", | ||
"version": "20180624.0.0-webpack-beta", | ||
"version": "20180701.0.0-webpack-beta", | ||
"description": "Check, compile, optimize and compress Javascript with Closure-Compiler", | ||
@@ -51,2 +51,6 @@ "publishConfig": { | ||
}, | ||
"optionalDependencies": { | ||
"google-closure-compiler-linux": "^20180701.0.0-webpack-beta", | ||
"google-closure-compiler-osx": "^20180701.0.0-webpack-beta" | ||
}, | ||
"devDependencies": { | ||
@@ -53,0 +57,0 @@ "gulp": "^3.9.0", |
@@ -25,4 +25,9 @@ # google-closure-compiler | ||
The compiler is distributed as a Java jar or as a JavaScript library. | ||
The compiler is distributed as a Java jar, a JavaScript library. Mac OS and Linux also have native binaries. | ||
### Native Binary Version | ||
On Mac OS or Linux, optional dependencies will install a native binary of the compiler. | ||
Native binaries offer faster compile times without requiring Java to be installed and available. | ||
Compilations with a very large number of source files may be slightly slower than the java version. | ||
### Java Version | ||
@@ -102,2 +107,4 @@ Requires java to be installed and in the path. Using the java version typically results in faster compilation times. | ||
### Running the compiler using nailgun | ||
*Note: nailgun users are encouraged to try the native binary viersions where available.* | ||
This gets around the long startup time of Google Closure Compiler using | ||
@@ -104,0 +111,0 @@ [Nailgun](https://github.com/facebook/nailgun), which runs a single java process in the background |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19054129
164
246235
188
248
5
2