Skip to content

Commit

Permalink
Automated g4 rollback of changelist 97892108.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

We don't really support --langauge_out=ES6 in any meaningful way

(and when we do, probably it will be from skipping transpilation rather than doing it twice).

*** Original change description ***

Allow --language_out=ES6

For now, what that means is that we transpile to ES5,
then do checks/optimizations, and then convert to ES6, where possible.

***
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=103891298
  • Loading branch information
blickly committed Sep 24, 2015
1 parent 073e137 commit 60ab7d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -42,6 +42,13 @@ static void preprocess(CompilerOptions options) {
+ "remove_unused_prototype_properties to be turned on.");
}

if (options.getLanguageOut().isEs6OrHigher()
&& !options.skipNonTranspilationPasses && !options.skipTranspilationAndCrash) {
throw new InvalidOptionsException(
"ES6 is only supported for transpilation to a lower ECMAScript"
+ " version. Set --language_out to ES3, ES5, or ES5_STRICT.");
}

if (!options.inlineFunctions
&& options.maxFunctionSizeAfterInlining
!= CompilerOptions.UNLIMITED_FUN_SIZE_AFTER_INLINING) {
Expand Down
2 changes: 2 additions & 0 deletions test/com/google/javascript/jscomp/IntegrationTest.java
Expand Up @@ -2945,6 +2945,7 @@ public void testES5toES6() throws Exception {
CompilerOptions options = createCompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT5_STRICT);
options.setLanguageOut(LanguageMode.ECMASCRIPT6_STRICT);
options.setSkipTranspilationAndCrash(true);
CompilationLevel.SIMPLE_OPTIMIZATIONS
.setOptionsForCompilationLevel(options);
String code = "f = function(c) { for (var i = 0; i < c.length; i++) {} };";
Expand Down Expand Up @@ -3219,6 +3220,7 @@ public void testIsEquivalentTo() {
public void testEs6OutDoesntCrash() {
CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT6);
options.setSkipTranspilationAndCrash(true);
test(options, "function f(x) { if (x) var x=5; }", "function f(x) { if (x) x=5; }");
}

Expand Down

1 comment on commit 60ab7d6

@MatrixFrog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this breaks the webservice. We need to make sure that when @language is set in the webservice we automatically set the output language to ES5.

Please sign in to comment.