Skip to content

Commit

Permalink
Fix for the issue #79: Closure Compiler Error with ES6 code and Dojo …
Browse files Browse the repository at this point in the history
…1.16.0 (#80)

* Upgraded Closure Compiler

Upgraded the Google Closure Compiler to v20200112

* Fixed a typo

* New format of Closure Compiler errors

The format of a Google Closure Compiler error has changed (see https://github.com/google/closure-compiler/blob/35beaa864997442d635875add4d60b7b73be6294/src/com/google/javascript/jscomp/LightweightMessageFormatter.java#L113-L116)

* Fixed shutting Closure Executor Service down

The API accessing the Closure Executor Service has changed in this commit: google/closure-compiler@7bdbe96

* Allow compiling dojo's non-strict-mode code

1. Assume the Google Closure Compiler's input as non-strict-mode JavaScript

2. Do not emit "use strict"; in the transpiled output

3. Force reporting DiagnosticGroups.ES5_STRICT issues as warnings, instead of errors
(cherry picked from commit 86f0042)
  • Loading branch information
sindilevich authored and dylans committed Jun 8, 2020
1 parent 426281d commit a2d5ab8
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 87 deletions.
2 changes: 1 addition & 1 deletion build/buildControlBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define([
], function(messages, defaultCopyright, defaultBuildNotice){
var bc = {
// 0 => no errors
// 1 => messages.getErrorCount()>0 at exist
// 1 => messages.getErrorCount()>0 at exit
exitCode:0,

// use this variable for all newlines inserted by build transforms
Expand Down
4 changes: 3 additions & 1 deletion build/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ define([], function(){
optimizerOutput= "",

logOptimizerOutput = function(text){
if(/\sERROR\s/.test(text)){
if(/\sERROR\s-\s\[[^\]]+]\s/.test(text)){
// the google closure error format
// i.e., " ERROR - [JSC_JSDOC_ON_RETURN] "
// see https://github.com/google/closure-compiler/blob/35beaa864997442d635875add4d60b7b73be6294/src/com/google/javascript/jscomp/LightweightMessageFormatter.java#L113-L116
logOptimizerReportedErrors();
}
optimizerOutput+= text;
Expand Down
13 changes: 8 additions & 5 deletions build/optimizeRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ function ccompile(src, dest, optimizeSwitch, copyright, optimizeOptions, useSour

// force this option to false to prevent overly agressive code elimination (#18919)
options.setDeadAssignmentElimination(false);
options.setEmitUseStrict(false);
options.setStrictModeInput(false);
options.setWarningLevel(jscomp.DiagnosticGroups.ES5_STRICT, jscomp.CheckLevel.WARNING);

for(var k in optimizeOptions){
// Skip compilation level option
Expand Down Expand Up @@ -262,14 +265,14 @@ function ccompile(src, dest, optimizeSwitch, copyright, optimizeOptions, useSour

function shutdownClosureExecutorService(){
try{
var compilerClass = java.lang.Class.forName("com.google.javascript.jscomp.Compiler");
var compilerExecutorField = compilerClass.getDeclaredField("compilerExecutor");
var compilerClass = compiler.getClass();
var compilerExecutorField = compilerClass.getDeclaredMethod("getCompilerExecutor");
compilerExecutorField.setAccessible(true);
var compilerExecutor = compilerExecutorField.get(compiler);
var compilerExecutor = compilerExecutorField.invoke(compiler);
compilerClass = compilerExecutor.getClass();
compilerExecutorField = compilerClass.getDeclaredField("compilerExecutor");
compilerExecutorField = compilerClass.getDeclaredMethod("getExecutorService");
compilerExecutorField.setAccessible(true);
compilerExecutor = compilerExecutorField.get(compilerExecutor);
compilerExecutor = compilerExecutorField.invoke(compilerExecutor);
compilerExecutor.shutdown();
}catch (e){
print(e);
Expand Down
3 changes: 3 additions & 0 deletions build/transforms/optimizer/closure.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ define([

// force this option to false to prevent overly agressive code elimination (#18919)
options.setDeadAssignmentElimination(false);
options.setEmitUseStrict(false);
options.setStrictModeInput(false);
options.setWarningLevel(jscomp.DiagnosticGroups.ES5_STRICT, jscomp.CheckLevel.WARNING);

for(var k in optimizeOptions){
// Skip compilation level option
Expand Down
Loading

0 comments on commit a2d5ab8

Please sign in to comment.