Coder Social home page Coder Social logo

closure-compiler-js's Introduction

closure-compiler-js

Note: This package is now deprecated. Distribution of the JavaScript version has been moved to the main npm distribution at https://www.npmjs.com/package/google-closure-compiler. This package will continue to work, but no new versions of the package will be published.


Check, compile, transpile, optimize and compress JavaScript with Closure Compiler in JS.

This repo tracks issues related to the publication to npmjs.org and associated plugins. Any bugs not related to the plugins themselves should be reported to the main repository.

Unlike other packages, this allows Closure Compiler to run entirely in JS. Java is not required.

This is an experimental release - meaning some features are not available and performance may not be on-par with the Java implementation - details here.

Usage

These instructions will continue to work, but the package is deprecated. Development has moved to https://www.npmjs.com/package/google-closure-compiler.

First, install the latest version:

yarn add google-closure-compiler-js --dev  # or
npm install --save-dev google-closure-compiler-js

The module supports modern web browsers as well as Node v4 LTS, and provides compile as a low-level method to compile JavaScript. By default, this compiles ES6 to ES5 and includes the default set of ECMAScript externs files. For example:

const compile = require('google-closure-compiler-js').compile;

const flags = {
  jsCode: [{src: 'const x = 1 + 2;'}],
};
const out = compile(flags);
console.info(out.compiledCode);  // will print 'var x = 3;\n'

Or to install the command-line version, do:

npm install -g google-closure-compiler-js

You should now be able to run google-closure-compiler-js as a command. The google-closure-compiler-js command can read from stdin or from a file. For example:

google-closure-compiler-js code.js > minified.js

Run google-closure-compiler-js --help for full usage information.

Build Systems

Webpack

Your webpack.config.js should look like this:

const ClosureCompiler = require('google-closure-compiler-js').webpack;
const path = require('path');

module.exports = {
  entry: [
    path.join(__dirname, 'app.js')
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'app.min.js'
  },
  plugins: [
    new ClosureCompiler({
      options: {
        languageIn: 'ECMASCRIPT6',
        languageOut: 'ECMASCRIPT5',
        compilationLevel: 'ADVANCED',
        warningLevel: 'VERBOSE',
      },
    })
  ]
};

Gulp

Your gulpfile.js should contain a task like this:

const compiler = require('google-closure-compiler-js').gulp();

gulp.task('script', function() {
  return gulp.src('./path/to/src.js', {base: './'})
      // your other steps here
      .pipe(compiler({
          compilationLevel: 'SIMPLE',
          warningLevel: 'VERBOSE',
          outputWrapper: '(function(){\n%output%\n}).call(this)',
          jsOutputFile: 'output.min.js',  // outputs single file
          createSourceMap: true,
        }))
      .pipe(gulp.dest('./dist'));
});

Flags

Flag Default Usage
angularPass false Generate $inject properties for AngularJS for functions annotated with @ngInject
applyInputSourceMaps true Compose input source maps into output source map
assumeFunctionWrapper false Enable additional optimizations based on the assumption that the output will be wrapped with a function wrapper. This flag is used to indicate that "global" declarations will not actually be global but instead isolated to the compilation unit. This enables additional optimizations.
checksOnly false Don't generate output. Run checks, but no optimization passes.
compilationLevel SIMPLE Specifies the compilation level to use.
Options: WHITESPACE_ONLY, SIMPLE, ADVANCED
dartPass false
defines null Overrides the value of variables annotated with @define, an object mapping names to primitive types
env BROWSER Determines the set of builtin externs to load.
Options: BROWSER, CUSTOM
exportLocalPropertyDefinitions false
generateExports false Generates export code for those marked with @export.
languageIn ES6 Sets what language spec that input sources conform to.
languageOut ES5 Sets what language spec the output should conform to.
newTypeInf false Checks for type errors using the new type inference algorithm.
outputWrapper null Interpolate output into this string, replacing the token %output%
polymerVersion null Specify the Polymer version pass to use.
preserveTypeAnnotations false
processCommonJsModules false Process CommonJS modules to a concatenable form, i.e., support require statements.
renamePrefixNamespace Specifies the name of an object that will be used to store all non-extern globals.
rewritePolyfills true Rewrite ES6 library calls to use polyfills provided by the compiler's runtime.
useTypesForOptimization false Enable or disable the optimizations based on available type information. Inaccurate type annotations may result in incorrect results.
warningLevel DEFAULT Specifies the warning level to use.
Options: QUIET, DEFAULT, VERBOSE
jsCode [] Specifies the source code to compile.
externs [] Additional externs to use for this compile.
createSourceMap false Generates a source map mapping the generated source file back to its original sources.

Languages

The Closure Compiler supports the following languages:

  • ECMASCRIPT3, ECMASCRIPT5 and ECMASCRIPT5_STRICT
  • ECMASCRIPT6 and ECMASCRIPT6_STRICT
  • ECMASCRIPT6_TYPED (experimental)
  • ECMASCRIPT_2017 (experimental)

Source Code

Unless you're using Gulp's or Webpack's plugins, you'll need to specify code via flags:

  • Both jsCode and externs accept an array containing objects in the form {src, path, sourceMap}.
  • Using path you can construct a virtual filesystem for use with ES6 or CommonJS imports — although for CommonJS you'll have to set processCommonJsModules: true.

Transpilation

The JavaScript version of the Closure-Compiler is transpiled by GWT from the Java source. For more details on the differences in behavior see the super sourced files in the main repository.

Version History

Closure Compiler release notes can be found on the main repository wiki.

License

Copyright © 2017 The Closure Compiler Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

closure-compiler-js's People

Contributors

alexxnica avatar blickly avatar brad4d avatar chadkillingsworth avatar dimvar avatar dmotz avatar graham-h avatar lauraharker avatar maoberlehner avatar matrixfrog avatar nazar-pc avatar reshadi avatar samthor avatar tadeegan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

closure-compiler-js's Issues

node.js + closurecompiler.js

I'm trying to use closurecompiler.js to lint types in node.js application. However, closure fails to resolve global modules – e.g. require("fs") fails.

Is this supported? What's the workaround for this? I would appreciate any guidance and examples.

Here is a demo repository which exhibits the problem: example-node-types

Details for `externs` option flag

What is the format of the externs option flag?

I've tried a couple but nothing worked:

var the_flags = {
  externs: ['cljs.user.foo = function(){};'],
  compilationLevel: "ADVANCED", 
  jsCode: [{src: 'var a = cljs.user.foo();console.log(a);'}]
};
var the_out = compile(the_flags);
console.info(the_out); 
var the_flags = {
  externs: [{src:'cljs.user.foo = function(){};'}],
  compilationLevel: "ADVANCED",
  jsCode: [{src: 'var a = cljs.user.foo();console.log(a);'}]
};
var the_out = compile(the_flags);
console.info(the_out); 

In any case, the compiledCode is:

 "var a=cljs.b.a();console.log(a);"

Error: Process spawn error. Is java in the path?

Node 8.1.3, closure-compiler-js fails with:

events.js:182
      throw er; // Unhandled 'error' event
      ^
Error: Process spawn error. Is java in the path?
spawn java ENOENT

Can be reproduced with:

git clone https://github.com/webcomponents/shadycss.git
npm install
npm run build

And yes, I do not have Java installed and do not plan to install.

INTERNAL COMPILER ERROR. Node(ARRAY_PATTERN)

I’m a contributor to CoffeeScript and we use closure-compiler-js to minify the browser version of the CoffeeScript compiler. Starting with version 2, CoffeeScript’s compiler is output as ES2015 JavaScript (from original CoffeeScript source) which we then pass to closure-compiler-js.

This worked fine for 2.0.0-alpha1, which started outputting things like classes and default parameters using their ES2015 syntax. In 2.0.0-beta1, which I’m preparing now, we output destructuring using ES2015 syntax; and this seems to throw an error in closure-compiler-js:

./coffeescript/node_modules/google-closure-compiler-js/jscomp.js:4453
function iFb(b){var c;try{return b.Vh()}catch(a){a=Ogb(a);if(YK(a,70)){c=a;throw Pgb(new cJ(c))}else throw Pgb(a)}}
                                                                           ^

Error: java.lang.RuntimeException: java.lang.RuntimeException: INTERNAL COMPILER ERROR. Please report this problem.  undefined   Node(ARRAY_PATTERN): Input_0:3071:54       location = 'first_line' in options ? options : ([first_line, first_column] = this.getLineAndColumnFromChunk((ref = options.offset) != null ? ref : 0), {   Parent(ASSIGN): Input_0:3071:54       location = 'first_line' in options ? options : ([first_line, first_column] = this.getLineAndColumnFromChunk((ref = options.offset) != null ? ref : 0), {
    at cJ.zG (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:7571:21850)
    at cJ.CG (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:7571:22051)
    at cJ (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:3458:76)
    at iFb (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:4453:86)
    at iDb (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:6237:93)
    at r5c (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:7196:350)
    at rJ (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:1737:29)
    at uJ (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:3014:44)
    at /private/tmp/coffeescript/node_modules/google-closure-compiler-js/jscomp.js:3196:46
    at Object.module.exports [as compile] (/private/tmp/coffeescript/node_modules/google-closure-compiler-js/compile.js:31:15)
    at Object.action (/private/tmp/coffeescript/Cakefile:197:52)
    at invoke (/usr/local/lib/node_modules/coffeescript/lib/coffee-script/cake.js:44:26)
    at Object.exports.run (/usr/local/lib/node_modules/coffeescript/lib/coffee-script/cake.js:70:20)
    at Object.<anonymous> (/usr/local/lib/node_modules/coffeescript/bin/cake:7:38)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)
    at startup (bootstrap_node.js:147:9)
    at bootstrap_node.js:538:3

You can reproduce this yourself quite easily:

git clone https://github.com/jashkenas/coffeescript.git
cd coffeescript
git checkout 9b77371ea846d498b06d0a88aeaa06bafed2abd9
npm install
cake build:browser

Not compatible with node.js v4

I am using ubuntu 16.04, and node.js was installed by apt-get. The version of node.js for ubuntu 16.04 is 4.2.6. When installed google-closure-compiler-js with npm, the command is not runing. The error is

root@ubuntu:/home/licode/erizoAPI# google-closure-compiler-js
/usr/local/lib/node_modules/google-closure-compiler-js/cmd.js:58
Promise.all([sources, externs]).then(arr => ready(...arr)).catch(error);
^^^

SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

I think node.js v4 doesn't support some kinds of arrow function

Webpack compilation error when code splitting

When using webpack code splitting the compiler will flag an error for missing webpackJsonp function:

asyncCommons.part.js:2 (JSC_UNDEFINED_VARIABLE)
variable webpackJsonp is undeclared
webpackJsonp([0],{

is there a way to tell the compiler that a global variable/function will be available on runtime?

Thanks

ICE when compiling 'bson' module

One of my apps has the 'bson' npm package installed, and the compiler produces an ICE when processing it:

[09:55:15] Starting 'bug'...
/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:4429
function yEb(b){var c;try{return b.Rh()}catch(a){a=Rgb(a);if(iL(a,71)){c=a;throw Sgb(new oJ(c))}else throw Sgb(a)}}
^

Error: java.lang.RuntimeException: java.lang.RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. (TypeError) : Cannot read property 'b' of null Node(NAME Double): node_modules/bson/alternate_parsers/bson.js:2:4 , Double = require('../lib/bson/double').Double Parent(VAR): node_modules/bson/alternate_parsers/bson.js:1:0 var Long = require('../lib/bson/long').Long
at oJ.MG [as Mf] (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:7504:21518)
at oJ.PG [as Of] (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:7504:21719)
at oJ (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:3438:76)
at yEb (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:4429:86)
at zCb (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:6191:93)
at e4c (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:7131:349)
at DJ (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:1729:29)
at GJ (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:3005:44)
at /usr/lib/node_modules/google-closure-compiler-js/jscomp.js:3179:46
at module.exports (/usr/lib/node_modules/google-closure-compiler-js/compile.js:31:15)
at CompilationStream._flush (/usr/lib/node_modules/google-closure-compiler-js/lib/gulp.js:97:22)
at CompilationStream. (_stream_transform.js:118:12)
at CompilationStream.g (events.js:292:16)
at emitNone (events.js:86:13)
at CompilationStream.emit (events.js:185:7)
at prefinish (_stream_writable.js:505:12)
at finishMaybe (_stream_writable.js:513:7)
at endWritable (_stream_writable.js:525:3)
at CompilationStream.Writable.end (_stream_writable.js:490:5)
at DestroyableTransform.onend (/tmp/ov/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:523:10)
at DestroyableTransform.g (events.js:292:16)
at emitNone (events.js:91:20)
at DestroyableTransform.emit (events.js:185:7)
at /tmp/ov/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:965:16
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

npm list -g | grep goo
├─┬ [email protected]

gulpfile to reproduce:

const gulp = require('gulp');
const compiler = require('google-closure-compiler-js').gulp();

gulp.task('bug', function() {
  return gulp.src( [ "node_modules/bson/**/*.js" ], {base: './'})
      // your other steps here
      .pipe(compiler({
          compilationLevel: 'SIMPLE',
          warningLevel: 'VERBOSE',
          processCommonJsModules: true,
          outputWrapper: '(function(){\n%output%\n}).call(this)',
          jsOutputFile: 'output.min.js',  // outputs single file
          createSourceMap: true,
        }))
      .pipe(gulp.dest('./build'));
});

Different results than Java?

I was just spying on a new minifier called babeli. They have a chart where they compare the performance of the Java and JS versions of closure against themselves:

https://github.com/babel/babili#benchmarks

Closure is the most successful minifier and the JS build of Closure is the least.

Here's the code that generates the benchmarks: https://github.com/babel/babili/blob/e38a050ab396df8f7cbcdb6d2784cc7c6193d803/scripts/benchmark.js#L89-L101

Is it a fair test? Should the Java and JS versions be producing different output?

Semantic versioning

Just installed the compiler, but the version is 20160822.
Is there any plan to use semantic versioning or just start from 1.0 when it becomes stable?

Rollup Compatibility

Would there be anyway you could add compatibility for rollup similarly to what you have for webpack? I use rollup currently to build my library and It would be awesome to use closure compiler to minimize the size of it libs.

Support for extraAnnotationNames

It looks to me like there is not a flag that provides the equivalent of --extra_annotation_name. I see extaAnnotationNames in the jscomp.js build, but get an error when trying to use it.

Would it be possible to suppress warnings about specific unrecognized annotations?

Flags should have a "defines" property

The Java command-line interface supports any number of --define arguments that are useful for overriding @define variable definitions. I haven't seen any way to do the same thing in the JavaScript version of the compiler, so I've had to resort to modifying my source code on the fly. Apologies if I've overlooked something.

URI.resolve not implemented error

Given a somewhat trivial ES6 module

bar.js:

import {foo} from './foo'
export let bar= foo + 1;

foo.js:

export let foo = 1;

I get this exception printed:

function lCb(b){var c;try{return b.Lh()}catch(a){a=ifb(a);if(kK(a,72)){c=a;throw jfb(new hH(c))}else throw jfb(a)}}
                                                                           ^

Error: java.lang.RuntimeException: java.lang.RuntimeException: INTERNAL COMPILER ERROR. Please report this problem.  URI.resolve not implemented   Node(IMPORT): bar.js:1:0 import {foo} from './foo'   Parent(SCRIPT): bar.js:1:0 import {foo} from './foo' 

Spread operator breaking Node LTS

There is an instance of the spread operator (and perhaps more) that causes this to break instantly in Node LTS (4.5.0). I'm sure this works just fine in the current version, but the lack of support for certain ES2015 features in the LTS prevents any use of this package.

Externs for node.js core modules; documentation unclear?

It isn't clear how to reference externs.

For example, having trouble with node core modules. Using the gulp plugin to attempt to compile a Node application which includes the following:

const http = require('http');

I get the following errors:

[00:45:29] source/Stats.js:2 (JSC_COMMONJS_MODULE_LOAD_ERROR)
[00:45:29] Failed to load module "http"
[00:45:29] const http = require('http');

Despite including the following flags:

processCommonJsModules: true,
externs: [{ path: './externs/http.js' }],

Where ./externs/http.js is from https://github.com/dcodeIO/node.js-closure-compiler-externs

Surely compiling a node app with core modules is a common use case. Could we include a brief example, or perhaps just an indicator of how to use common externs?

I would offer to contribute, but I really have no idea how to get this working...

Cheers!

Grunt support

I see Gulp is supported, but I am more familiar with and prefer grunt.

Are there any built in Grunt options?

Create webpack loader

Would be nice with a webpack loader for closure compiler.
See: https://webpack.github.io/docs/loaders.html

Today we use Babel like this below at my workplace;

Webpack conf:

    {
        test: /\.js$/,
        exclude: /(node_modules)|(lib)/,
        loader: 'babel',
        query: {
          presets: ['es2015']
        }
      },

Components

define([
  'components/some-component' // .js file
], (
  someComponent
) => {
  'use strict';

  // Do something with someComponent
});

Externs for angular-1.5.js doesn't work

I'm currently trying to compile an angular project with closure with gulp

.pipe(compiler({
compilationLevel: 'ADVANCED',
externs:[
{ path: './externs/angular-1.5.js' }
],
jsOutputFile: 'app.js'
}))

By it doesn't affect the result. I have still result as angular.b instead of angular.module with no error on compile.
How to load externs ?

No error output when invoked from command line

The Node module doesn't output error messages from the command line. For example, this should result in a parse error, but outputs a blank line nothing and has an error code of 0:

% echo '{()};&$*#_;' > blah.js
% node node_modules/.bin/google-closure-compiler-js blah.js

% echo $?
0
% node node_modules/.bin/google-closure-compiler-js -v
20161201.0.1

But:

require('google-closure-compiler-js').compile(
    {jsCode: [{path: 'blah.js', src: '{()};&$*#_;'}]}
);
{ compiledCode: '',
  errors:
   [ { file: 'blah.js',
       description: 'Parse error. invalid parenthesized expression',
       type: 'JSC_PARSE_ERROR',
       lineNo: 1,
       charNo: 3 } ],
  warnings: [] }

Support formatting flag

Hi,

Is it possible to add support for formatting flag?

Currently it is supported in java version as follows:

--formatting=pretty_print
--formatting=print_input_delimiter

Thanks in advance,
Reuven.

webpack treeshaking/deadcode elimination additional features?

So currently, webpack imperitively builds a dependency graph, and has library specific syntax for code splitting, lazy loading, and optimizing chunks (sub-tree of modules), based on order, occurence, size, etc.

However one feature that is limiting that we believe we would love to leverage (as a library) a better tree shaking story.

Currently webpack only "marks" unused modules and exports, dependencies, etc. Would it be possible to design a future that would allow some more advanced c-c-js features like --module but instead passing the symbol/name references in the ast of the code that is not used?

--unused-symbols="name:file:line:loc" etc.

This is kind of off the top of my head but I wondered if this is something that could be considered or noteworthy. If anything just get the discussion flowing for a more powerful webpack+cc-js story.

Thanks!

Gulp plugin should support multiple files to be compiled separately

const gulp     = require('gulp');
const compiler = require('google-closure-compiler-js').gulp();

gulp.task('dist', function () {
    return gulp.src([
    'js/file1.js',
    'js/file2.js'
    ])
        .pipe(compiler())
        .pipe(gulp.dest('dist')); // I want `file1.min.js` and `file2.min.js` here,
                                  // but getting `compiled.js`
});

no command line tool in 20161201.0.0?

As I installed from npm I see no command line provided, but seeing from code in master branch, it does. And a cmd.js is missing:

=>> l /usr/local/lib/node_modules/google-closure-compiler-js
CONTRIBUTING.md  README.md        compile.js       index.js         lib/             node_modules/
LICENSE          build.js         contrib/         jscomp.js        logger.js        package.json

Error with Webpack 2

I'm using Webpack 2.1.0-beta.21 and with a fresh install i get this error from ClosureCompiler:

Error: Cannot find module 'webpack-core/lib/RawSource'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at new module.exports (/home/blacksonic/workspace/babel-webpack-tree-shaking/node_modules/google-closure-compiler-js/lib/webpack.js:27:21)
    at Object.<anonymous> (/home/blacksonic/workspace/babel-webpack-tree-shaking/webpack.prod.config.js:36:5)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at module.exports (/home/blacksonic/workspace/babel-webpack-tree-shaking/node_modules/webpack/bin/convert-argv.js:93:13)
    at Object.<anonymous> (/home/blacksonic/workspace/babel-webpack-tree-shaking/node_modules/webpack/bin/webpack.js:130:40)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
    at bootstrap_node.js:467:3

syntax error in built json

I've been trying to get the source for this project to compile. After installing the correct version of java and maven I can run ./build.js which finishes successfully, but when I run test/simple.js or try:

> require('./compile.js')({ jsCode: [{src: 'const x = 1 + 2;'}] })

I get this error:

SyntaxError: Unexpected token : in JSON at position 1077462
    at Object.parse (native)
    at JLc (/home/substack/projects/closure-compiler-js/jscomp.js:2086:38)
    at i4c (/home/substack/projects/closure-compiler-js/jscomp.js:5961:36)
    at e4c (/home/substack/projects/closure-compiler-js/jscomp.js:7131:293)
    at DJ (/home/substack/projects/closure-compiler-js/jscomp.js:1729:29)
    at GJ (/home/substack/projects/closure-compiler-js/jscomp.js:3005:44)
    at /home/substack/projects/closure-compiler-js/jscomp.js:3179:46
    at module.exports (/home/substack/projects/closure-compiler-js/compile.js:31:15)
    at repl:1:24
    at sigintHandlersWrap (vm.js:32:31)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInContext (vm.js:31:12)
    at REPLServer.defaultEval (repl.js:308:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:477:10)
    at emitOne (events.js:101:20)
    at REPLServer.emit (events.js:188:7)
    at REPLServer.Interface._onLine (readline.js:232:10)
    at REPLServer.Interface._line (readline.js:574:8)
    at REPLServer.Interface._ttyWrite (readline.js:851:14)
    at ReadStream.onkeypress (readline.js:119:10)
    at emitTwo (events.js:106:13)
    at ReadStream.emit (events.js:191:7)
    at emitKeys (internal/readline.js:385:14)
    at next (native)
    at ReadStream.onData (readline.js:947:36)
    at emitOne (events.js:96:13)
    at ReadStream.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:177:18)
    at ReadStream.Readable.push (_stream_readable.js:135:10)
    at TTY.onread (net.js:542:20)

The file that closure-compiler-js is attempting to parse appears to be: closure-compiler/target/classes/com/google/javascript/jscomp/resources.json:

 node closure-compiler/target/classes/com/google/javascript/jscomp/resources.json
module.js:561
    throw err;
    ^

SyntaxError: /home/substack/projects/closure-compiler-js/closure-compiler/target/classes/com/google/javascript/jscomp/resources.json: Unexpected token : in JSON at position 1077462
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:558:27)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
    at bootstrap_node.js:467:3

The other json file from which this file is derived doesn't appear to have the same issue:

$ node closure-compiler/src/com/google/javascript/jscomp/resources.json && echo $?
0

Error when using --use_strict

When using node --use_strict, it throw an error :

TypeError: Cannot set property '$gwtExport' of undefined
    at /Users/rodolphe/Dropbox/www/github/node-minify/node_modules/google-closure-compiler-js/jscomp.js:7410:491339
    at Object.<anonymous> (/Users/rodolphe/Dropbox/www/github/node-minify/node_modules/google-closure-compiler-js/jscomp.js:7410:491399)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/rodolphe/Dropbox/www/github/node-minify/node_modules/google-closure-compiler-js/compile.js:24:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/rodolphe/Dropbox/www/github/node-minify/node_modules/google-closure-compiler-js/index.js:25:12)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/rodolphe/Dropbox/www/github/node-minify/examples/gcc.js:1:116)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

node -v v6.9.1
npm -v 4.0.2

You can reproduce it with the example code sample and run it with node --use_strict

const compile = require('google-closure-compiler-js').compile;

const flags = {
  jsCode: [{src: 'const x = 1 + 2;'}],
};
const out = compile(flags);
console.info(out.compiledCode);  // will print 'var x = 3;\n'

It seems to fail when require jscomp.js

Related to: srod/node-minify#122

Node process runs out of memory

I have been trying to integrate the JavaScript version of the Closure compiler with my application as a Rollup plugin.
The process works for simple projects, but I have observed that the process runs out of memory in bigger projects:

The process runs for a while, but crashes eventually with the error message:

<--- Last few GCs --->

  245503 ms: Mark-sweep 13967.5 (14023.0) -> 13966.5 (14023.0) MB, 14259.4 / 0 ms [allocation failure] [GC in old space requested].
  262655 ms: Mark-sweep 13966.5 (14023.0) -> 13966.5 (14023.0) MB, 17154.0 / 0 ms [allocation failure] [GC in old space requested].
  280443 ms: Mark-sweep 13966.5 (14023.0) -> 13966.4 (14023.0) MB, 17789.0 / 0 ms [last resort gc].
  298983 ms: Mark-sweep 13966.4 (14023.0) -> 13966.4 (14023.0) MB, 18541.4 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x298b1a5b4629 <JS Object>
    1: qhb(aka qhb) [/Users/helgevot/temp/angular-2-samples/node_modules/google-closure-compiler-js/jscomp.js:~4620] [pc=0x1f9c9b11dbc4] (this=0x298b1a5041b9 <undefined>,a=0x178543a1ed51 <a uhb with map 0x1bcd61950b81>,b=0x71dd11e34f1 <a thb with map 0x1bcd61951209>)
    2: aec [/Users/helgevot/temp/angular-2-samples/node_modules/google-closure-compiler-js/jscomp.js:6280] [pc=0x1f9c9b110535] (t...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
sh: line 1: 19438 Abort trap: 6           npm run rollup


Here is my rollup code that integrates the "google-closure-compiler-js": "^20160828.0.1" package

var closure = require('google-closure-compiler-js');

function closureCompilerPlugin(){
  return {
    transformBundle(bundle){
      var transformed = closure.compile({jsCode: [{src: bundle}]});
      return transformed.compiledCode;
    }
  }
}

export default {
    entry: 'main.js',
    dest: 'dist/bundle.js',
    sourceMap: false,
    format: 'iife',
    plugins: [
        commonjs({
            include: 'node_modules/rxjs/**',
        }),
        nodeResolve({
            jsnext: true, module: true
        }),
        closureCompilerPlugin()
    ]

}

I think the Java version will work, but I would really like to get this working with the JS version since the setup is so much simpler.

compiler.gulp() crashes: Cannot find module vinyl

I've installed with:

npm install --save-dev closure-compiler-js

Installation was successful:

To create a gulp task I try to follow the README:

closureCompiler = require('google-closure-compiler-js').gulp();

But as soon as I add .gulp() to the end of that line, Gulp crashes (I can no longer list or execute tasks) with this error:

module.js:327
throw err;
^

Error: Cannot find module 'vinyl'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.module.exports.Transform as gulp
at Object. (\gulpfile.js:365:63)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Liftoff.handleArguments (\node_modules\gulp\bin\gulp.js:116:3)
at Liftoff. (\node_modules\gulp\node_modules\liftoff\index.js:198:16)
at module.exports (\node_modules\gulp\node_modules\liftoff\node_modules\flagged-respawn\index.js:17:3)
at Liftoff. (\node_modules\gulp\node_modules\liftoff\index.js:190:9)
at \node_modules\gulp\node_modules\liftoff\index.js:164:9
at \node_modules\gulp\node_modules\v8flags\index.js:108:14
at \node_modules\gulp\node_modules\v8flags\index.js:36:12
at \node_modules\gulp\node_modules\v8flags\index.js:47:7
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)
at Function.Module.runMain (module.js:443:11)
at startup (node.js:139:18)
at node.js:974:3

vinyl was installed as you can see in the console excerpt above the error. The folder below has content:

/node_modules/google-closure-compiler-js/node_modules/gulp-util/node_modules/vinyl

I have (package.json):

"google-closure-compiler-js": "^20160916.0.0",
"gulp": "^3.9.1",

Any idea why I'm seeing this error? Should I also install google-closure-compiler?

Can't get compiler to compile in dependencies.

I have source that is using google closure library. I'm using goog.provide and goog.require throughout my code.

I tried the gulp version of this compiler out today and was unsuccessful in getting this to work. It throws errors with the following compiler flags
continueWithWarnings
manageClosureDependencies
closureEntryPoint
onlyClosureDependencies

So I tried to comment them out. But the js it results with doesn't actually work and is incomplete. I could not figure out how to tell the compiler what the list of my dependencies is. In the interface for gulp-closure-compiler, you provide the full list of files when you call gulp.src. The resulting file name is defined in the compiler config object instead.

However with this compiler, i have to define the entry file to gulp.src instead of the full list of sources. If there is a way to define my full list of sources, I couldn't find it explained in the readme.

Also I'm not able to specify the closure entry point. And it doesn't seem to read my goog.require statements to look for the dependencies and compile it together.

Here's the config i tried.

gulp.task('herc-docs:js', function() {
  return gulp.src('./site/docs/skins/hercules/assets/js/app.js', {base: './'})
      .pipe(closureCompiler({
    jsOutputFile: 'hercdocs.min.js',
    //continueWithWarnings: true,
    angularPass: true,
    exportLocalPropertyDefinitions: true,
    //closureEntryPoint: 'hercules.demo.app',
    compilationLevel: 'WHITESPACE_ONLY',
    createSourceMap: path.join('./', '/%outname%.map'),
    generateExports: true,
    outputWrapper: '(function(){%output%}).call(window);' +
        '\n//# sourceMappingURL=/releases/latest/' + fileName + '.map',
    //manageClosureDependencies: true,
    //onlyClosureDependencies: true,
    warningLevel: 'DEFAULT', // VERBOSE, QUIET
    languageIn: 'ECMASCRIPT6_STRICT',
    languageOut: 'ECMASCRIPT5',
    externs: [
      'node_modules/google-closure-compiler/contrib/externs/angular-1.5.js',
      'node_modules/google-closure-compiler/contrib/externs/angular-1.5-q_templated.js',
      'node_modules/google-closure-compiler/contrib/externs/angular-1.5-http-promise_templated.js',
      'node_modules/google-closure-compiler/contrib/externs/angular-1.5-resource.js',
      'site/docs/skins/hercules/assets/js/externs.js'
    ]
  }))
      .pipe(gulp.dest('site/docs/skins/hercules/assets/js'));
});

For reference, here's what it looks like with gulp-closure-compiler

gulp.task('herc-docs:js', function() {
  return gulp.src(['foo.js', 'bar.js', 'bat.js'])
      .pipe(closureCompiler({
        fileName: 'main.min.js',
        compilerFlags: {...}
      }))
      .pipe(gulp.dest('site/docs/skins/hercules/assets/js'));
});

Bad compile time performance

I benchmarked this port against other transpilers using jQuery and found that it takes an extraordinary ~13 seconds to transpile using closure-compiler-js as opposed to a little over ~1 second with uglifyjs or esprima.

I understand that this port was generated using a Java to JS compiler and looking at jscomp.js it is really not a big surprise as to why this takes so long, there is a lot of redundancy behind the scenes.
However, it pretty much renders this port useless when tranpiling large projects or when using this module in the browser.
If it takes less time to spawn a child process and compile with the native Java compiler then what's the point?
It makes more sense to me to write this module properly from a technical spec than to have something generated and under perform.

Traceur to Closure usage

Hi all,
Can someone provide a webpack.config.js sample which uses Traceur and Closure together?
I am trying to bundle an ExpressJS application with webpack and hit issues with "use strict" generated from Traceur.

Error when running gulp command

Hi,
When I try to run the gulp, I'm getting this error. I'm using the same code in sample page

C:\auroraorange\node_modules\google-closure-compiler-js\lib\gulp.js:116
  return function(compilationOptions={}, pluginOptions={}) {
                                    ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\auroraorange\node_modules\google-closure-compiler-js\index.js:25:9)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\auroraorange\gulpfile.js:3:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at execute (C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\lib\versioned\^3.7.0\index.js:24:18)
    at Liftoff.handleArguments (C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\index.js:149:63)
    at Liftoff.<anonymous> (C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\liftoff\index.js:198:16)
    at module.exports (C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\liftoff\node_modules\flagged-respawn\index.js:17:3)
    at Liftoff.<anonymous> (C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\liftoff\index.js:190:9)
    at C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\liftoff\index.js:164:9
    at C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\v8flags\index.js:108:14
    at C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\v8flags\index.js:36:12
    at C:\Users\Calvin\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\v8flags\index.js:47:7
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)
    at Function.Module.runMain (module.js:443:11)
    at startup (node.js:139:18)
    at node.js:968:3

consider removing build system support

By removing support for a few particular build systems, you can save yourself a lot of trouble long-term, because there will be an infinite list of systems that people will lobby to add over time.

Already people are petitioning for:

Worse, I think much of the time will be spent maintaining these build tool integrations over time compared to the core concerns of the library itself. This also will cause less churn in the project itself because you won't need to constantly upgrade for upstream changes in build systems.

Unhandled flags

I just tried to switch from Java-based and hit a brick wall... I assumed that every flag should be provided as camelcase. So I rewrote my closure compiler config object and compiler complains about these flags:

entry_point=> entryPoint(pretty important flag to have)
jscomp_Off=> jscompOff
extra_annotation_name=> extraAnnotationName(very useful)
manage_closure_dependencies=> manageClosureDependencies
debug(very useful)

Could you please provide a way how to supply those flags?

INTERNAL COMPILER ERROR. Please report this problem. undefined Node(ASSIGN)

I'm using the closure compiler with TypeScript output. In one class (class Util) I have:

static 'vfo' = '@vfo'; // version info

Which turns into:

Util['vfo'] = '@vfo'; // version info

Which is pretty close to the JS I use with the Java Closure compiler and it has no problem with it.

Then when I use webpack with my JS (that was output from TS with tsc) and the closure compiler, I get:

C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:4529
function FFb(b){var c;try{return b.Xh()}catch(a){a=Xgb(a);if($K(a,70)){c=a;throw Ygb(new eJ(c))}else throw Ygb(a)}}
                                                                           ^

Error: java.lang.RuntimeException: java.lang.RuntimeException: INTERNAL COMPILER ERROR. Please report this problem.  undefined   Node(ASSIGN): go.js:15477:0 Ut
   Parent(EXPR_RESULT): go.js:15477:0 Util['vfo'] = '@vfo'; // version info
    at AG (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:7628:22102)
    at DG (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:7628:22303)
    at eJ (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:3482:76)
    at FFb (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:4529:86)
    at FDb (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:6320:95)
    at J6c (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:7255:359)
    at tJ (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:1746:29)
    at wJ (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:3043:44)
    at C:\SomePath\buildTS\node_modules\google-closure-compiler-js\jscomp.js:3215:46
    at module.exports (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\compile.js:31:15)
    at C:\SomePath\buildTS\node_modules\google-closure-compiler-js\lib\webpack.js:52:28
    at Array.forEach (native)
    at C:\SomePath\buildTS\node_modules\google-closure-compiler-js\lib\webpack.js:40:17
    at Array.forEach (native)
    at Compilation.<anonymous> (C:\SomePath\buildTS\node_modules\google-closure-compiler-js\lib\webpack.js:38:16)
    at Compilation.applyPluginsAsyncSeries (C:\SomePath\buildTS\node_modules\tapable\lib\Tapable.js:142:13)
    at C:\SomePath\buildTS\node_modules\webpack\lib\Compilation.js:631:10
    at Compilation.applyPluginsAsyncSeries (C:\SomePath\buildTS\node_modules\tapable\lib\Tapable.js:131:46)
    at sealPart2 (C:\SomePath\buildTS\node_modules\webpack\lib\Compilation.js:627:9)
    at Compilation.applyPluginsAsyncSeries (C:\SomePath\buildTS\node_modules\tapable\lib\Tapable.js:131:46)
    at Compilation.seal (C:\SomePath\buildTS\node_modules\webpack\lib\Compilation.js:575:8)
    at C:\SomePath\buildTS\node_modules\webpack\lib\Compiler.js:488:16
    at C:\SomePath\buildTS\node_modules\tapable\lib\Tapable.js:225:11
    at C:\SomePath\buildTS\node_modules\webpack\lib\Compilation.js:477:11
    at C:\SomePath\buildTS\node_modules\webpack\lib\Compilation.js:448:13
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Eyeballing it, I'm really not sure why this line would be a problem. If I comment it out, a similar static line is problematic.

Webpack 2 processCommonJsModules breaks require

Using webpack 2 with processCommonJsModules: true seems to break require.

"use strict";
const path = require("path");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const ClosureCompiler = require("google-closure-compiler-js").webpack;
const cssLoaders = [
  {
    loader: "css-loader",
    options: {
      modules: true,
      minimize: true
    }
  },
  {
    loader: "sass-loader"
  }
]
module.exports = {
  context: __dirname + "/source",
  entry: {
    site: "./javascripts/all.js",
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /(node_modules)/,
        loader: "babel-loader",
      },
      {
        test: /\.(sass|scss)$/,
        use: [{
          loader: ExtractTextPlugin.extract({
            fallbackLoader: ["style-loader"],
            loader: cssLoaders
          }), //end ExtractTextPlugin loader
        }],
      },
    ],//end rules
  },
  output: {
    path: __dirname + "/build/javascripts",
    filename: "[name].bundle.js",
  },

  plugins: [
    new webpack.LoaderOptionsPlugin({
      minimize: true,
      debug: false
    }),
    new ExtractTextPlugin({
      path: __dirname + "/build/stylesheets",
      filename: "[name].bundle.css",
      disable: false,
      allChunks: true,
    }),
    new ClosureCompiler({
      options: {
        processCommonJsModules: true,
        languageIn: "ECMASCRIPT6",
        languageOut: "ECMASCRIPT5",
        compilationLevel: "SIMPLE",
        warningLevel: "VERBOSE"
      },
    })
  ],
};

When a use the following in my entry point:
const prism = require("./prism")

I get a require not defined error in the browser. Removing ClosureCompiler fixes the error.

Webpack API / compatibility

I was trying to integrate Closure Compiler to my Advanced Boilerplate.

My setup currently looks super simple:

      ifProdClient(new ClosureCompilerPlugin({
        options: {
          compilationLevel: "SIMPLE"
        }
      })),

I have some kind of factory producing the actual webpack config. That's the reason why there is the ifProdClient() call.

Effects I saw:

  • A ton of outputs (=hundreds) regarding some 3rd party dependencies I include about some JSDoc comments (I don't care about) e.g. main-LeExkXKk.js:19675 (JSC_PARSE_ERROR) Parse error. illegal use of unknown JSDoc tag "category"; ignoring it @category Lang without mentioning any source file (wouldn't it be useful to reverse map based on the existing source map?)

  • A lot of messages regarding "JSC_UNREACHABLE_CODE" - I figure these are mostly regarding some conditionals based on process.env in the original code which are evaluated into true/false in the compiled code.

  • No support for my vendor chunk. Maybe this is some kind of parse error as their are other messages e.g. warnings coming from the processing of the vendor package. But the output file is just the Webpack original code. The only error message here looks like: vendor-QRGMGbNu.js:29608 (JSC_INVALID_NO_SIDE_EFFECT_ANNOTATION) @nosideeffects may only appear in externs files. render: 'DEFINE_ONCE',

  • I wonder about unreachable code for catch clauses. How could it actually figure this out?

  • Duplicated polyfills and infrastructure in different places. There should be definitely an option to prevent adding these. I either use Babel polyfill / Babel helper or some remote service like polyfill.io. I definitely don't want to bake all these things into my code. And definitely not into every chunk again.

  • It does not seem to "like" the "default" export handling of Webpack: main-LeExkXKk.js:9704 (JSC_USELESS_CODE) Suspicious code. This code lacks side-effects. Is there a bug? return !(0, _deepEqual2.default)(this.props, nextProps);

I wish, based on what I read, Closure Compiler JS would be in a better state. Right now it seems that there are so many issues, in such a simple boilerplate project, that I could not suggest anyone from the typical Webpack users to care about.

I wonder if there is actually any progress happening on improving the situation.

It does not help to claim that something could be used as some kind of drop-in replacement (presentations/conferences) to Uglify/Babili when even the most basic things are not working. Some good ES6 compatible (input and output) compressor would be really appreciated.

As far as I understand this project it's basically cross-compiled from Java. If these issues are more about the original Java implementation, feel free to forward them.

Webpack and Gulp plugins don't read jsCode/externs file content

There is my configurations and files, the flag externs works in gulp-closure-compiler, but doesn't work in closure-compiler-js.

gulp configuration:

https://github.com/DIYgod/demo/blob/master/bad-closure-compiler-js/gulpfile.js

externs file

https://github.com/DIYgod/demo/blob/master/bad-closure-compiler-js/externs.js

...
var DIYgod;

source file:

var DIYgod = 'cat';
console.log(DIYgod);

gulp-closure-compiler output:

var DIYgod="cat";console.log(DIYgod);

closure-compiler-js output:

console.log("cat");

There is a minimal demo project of this problem, you can also try it yourself, thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.