Dojo build fails on ES6 spread operator

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Dojo build fails on ES6 spread operator

sindilevich
Hello,

Dojo build fails when processing files that contain the ES6 spread operator.

The error is: error(356) The optimizer threw an exception; the module probably contains syntax errors. module identifier: app/arrayHelper; exception: JavaException: java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

Unexpected variable Object
  Node(NAME Object):  [synthetic:util/defineproperty] :38:11
    typeof Object.defineProperties == 'function' ?
  Parent(GETPROP):  [synthetic:util/defineproperty] :38:11
    typeof Object.defineProperties == 'function' ?


The POC project consists of a single file, src/app/arrayHelper.js, with the contents as follows:

define(["dojo/_base/declare"], (declare) => {
        "use strict";

        return declare("array.helper", [], {
                getDivs () {
                        return [...document.querySelectorAll("div")];
                }
        });
});


The build profile is:

var profile = (function () {
        return {
                basePath: "./src",
                releaseDir: "../../app",
                releaseName: "lib",
                action: "release",
                optimize: "closure.keepLines",
                mini: true,
                stripConsole: "warn",
                optimizeOptions: {
                        languageIn: "ECMASCRIPT6",
                        languageOut: "ECMASCRIPT5"
                },
                defaultConfig: {
                        hasCache: {
                                "dojo-bidi": true,
                                "dojo-undef-api": true,
                                "dojo-built": 1,
                                "dojo-loader": 1,
                                "dom": 1,
                                "host-browser": 1
                        },
                        async: 1
                },
                packages: [{
                        name: "dojo",
                        location: "dojo"
                }, {
                        name: "app",
                        location: "app"
                }]
        };
})();


Any help is much appreciated!

Thank you.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dojo build fails on ES6 spread operator

dylanks
Are you using Dojo 1.12, or an older version? I believe only 1.12 and
newer use a version of Closure Compiler that can handle the spread operator.

on 2/7/17, 09:37 (GMT-07:00) sindilevich said the following:

> Hello,
>
> Dojo build fails when processing files that contain the ES6 *spread
> operator*.
>
> The error is: /error(356) The optimizer threw an exception; the module
> probably contains syntax errors. module identifier: app/arrayHelper;
> exception: JavaException: java.lang.RuntimeException: INTERNAL COMPILER
> ERROR.
> Please report this problem.
>
> Unexpected variable Object
>   Node(NAME Object):  [synthetic:util/defineproperty] :38:11
>     typeof Object.defineProperties == 'function' ?
>   Parent(GETPROP):  [synthetic:util/defineproperty] :38:11
>     typeof Object.defineProperties == 'function' ?
> /
>
> The POC project consists of a single file, *src/app/arrayHelper.js*, with
> the contents as follows:
>
> /define(["dojo/_base/declare"], (declare) => {
> "use strict";
>
> return declare("array.helper", [], {
> getDivs () {
> return [...document.querySelectorAll("div")];
> }
> });
> });/
>
> The build profile is:
>
> /var profile = (function () {
> return {
> basePath: "./src",
> releaseDir: "../../app",
> releaseName: "lib",
> action: "release",
> optimize: "closure.keepLines",
> mini: true,
> stripConsole: "warn",
> optimizeOptions: {
> languageIn: "ECMASCRIPT6",
> languageOut: "ECMASCRIPT5"
> },
> defaultConfig: {
> hasCache: {
> "dojo-bidi": true,
> "dojo-undef-api": true,
> "dojo-built": 1,
> "dojo-loader": 1,
> "dom": 1,
> "host-browser": 1
> },
> async: 1
> },
> packages: [{
> name: "dojo",
> location: "dojo"
> }, {
> name: "app",
> location: "app"
> }]
> };
> })();/
>
> Any help is much appreciated!
>
> Thank you.
>
>
>
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Dojo-build-fails-on-ES6-spread-operator-tp4007121.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dojo build fails on ES6 spread operator

sindilevich
I am using Dojo 1.11.2 with the same Google Closure Compiler and changes to dojo/util needed to support that compiler in 1.12. I handpicked the changes and applied it to 1.11.2. It seems to be the same issue still with 1.12 itself too.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dojo build fails on ES6 spread operator

dylanks
Ok, and are you using the spread operator on function calls, array
literals or for object destructuring? I don't believe the latter is
supported by Closure Compiler yet.

I'm assuming it's one of the former, in which case we'll need to put
together the simplest possible test case for the build system so we can
track it down.

Regards,
-Dylan

on 2/7/17, 09:54 (GMT-07:00) sindilevich said the following:

> I am using Dojo 1.11.2 with the same Google Closure Compiler and changes to
> dojo/util needed to support that compiler in 1.12. I handpicked the changes
> and applied it to 1.11.2. It seems to be the same issue still with 1.12
> itself too.
>
>
>
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Dojo-build-fails-on-ES6-spread-operator-tp4007121p4007123.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dojo build fails on ES6 spread operator

sindilevich
I have already provided the simplest test case I could think of. It is described in the body of my first message to the thread. I use a single file with a single method whose only line is: return [...document.querySelectorAll("div")];.

If I change that line to something like: return document.querySelectorAll("div").map((node) => node); the Dojo build succeeds.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dojo build fails on ES6 spread operator

dylanks
Right, sorry, have the flu and I'm not completely coherent today.

Not sure how soon we can look into this, but we'll look at is as soon as
time permits.

on 2/7/17, 10:12 (GMT-07:00) sindilevich said the following:

> I have already provided the simplest test case I could think of. It is
> described in the body of my first message to the thread. I use a single file
> with a single method whose only line is: /return
> [...document.querySelectorAll("div")];/.
>
> If I change that line to something like: /return
> document.querySelectorAll("div").map((node) => node);/ the Dojo build
> succeeds.
>
>
>
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Dojo-build-fails-on-ES6-spread-operator-tp4007121p4007125.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dojo build fails on ES6 spread operator

sindilevich
I appreciate you're looking into the issue very much! Hope you feel better soon.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dojo build fails on ES6 spread operator

keemor
Hi,

I have similar problem with destructuring during build of Dojo 1.12.1, my code:

http://jsfiddle.net/keemor/us8ub3se/2/

Test.js
require([], function() {
  "use strict";
  const obj = {
    'a': 1,
    'b': 2,
    'c': 3
  };
  const {a, b, c} = obj;
  alert(`a: ${a}`)
});

throws error(307) Failed to evaluate module tagged as pure AMD (fell back to processing with regular expressions). module: app/Test; error: SyntaxError: Unexpected token {

If closure compiler is used manually:
java -jar src/util/closureCompiler/compiler.jar --language_in=ECMASCRIPT6 --js src/app/Test.js --js_output_file src/app/Test_compiled.js --language_out=ES5

The result is OK:
require([],function(){alert("a: 1")});


In profile.js:
..
optimizeOptions: {
    languageIn: 'ECMASCRIPT6',
    languageOut: 'ECMASCRIPT5'
},
layerOptimize: "closure.keeplines",
optimize: "closure.keeplines",
..

So other ES6 features work.

Greetings,
Romek

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dojo build fails on ES6 spread operator

sindilevich
Hello Dylan,

I got to look at the missing full ES6 support after a long break.

I think that running the Google Closure Compiler with Java is failing to transpile some ES6 syntax, because it runs in a ES3-compliant environment, not the ES5-compliant one.

If you look at the build.bat file, you'd see you bootstrap the dojo build system using shrinksafe's Rhino implementation. This implementation is pretty outdated and does not support ES5.

Maybe, if you could upgrade the shrinksafe's Rhino to a more recent version (say 1.7.7.1), you'd be able to run the Google Closure Compile in a ES5-compliant environment, as it expects.

Another option - move to use Java 8+ Nashorn.
Loading...