Esri / jsapi-resources

A collection of resources for developers using the ArcGIS Maps SDK for JavaScript.
https://developers.arcgis.com/javascript/latest/
Apache License 2.0
712 stars 564 forks source link

Bower install: Dojo build hangs with uglify compiler option #14

Closed tomwayson closed 8 years ago

tomwayson commented 8 years ago

The closure compiler is less desirable b/c it is slower, requires Java, defaults to ES3 mode (and I've not found any examples that successfully demonstrate how to pass an option to tell it to use ES5 from the dojo build). For those reasons, I'd rather use uglify to compile my JS files, but it seems to hang forever w/ any build that includes the ArcGIS JS API files from bower.

Steps to reproduce:

  1. cd into bower/dojo folder and follow all install/build instructions to verify that it works
  2. npm install --save-dev uglify-js@1
  3. Modify optimize and layerOptimize options in build.profile.js to use 'uglify' instead of 'closure'
  4. Run npm run clean and npm run build the script will hang during the optimization step.

I've seen this before w/ the slurp files. However I can run the dojo-boilerplate (with no esri modules) w/ those both set to 'uglify' and it works. Furthermore, it also works to just set layerOptimize to 'uglify' and leave optmize set to 'closure'. To me, that means that there's something that is incompatible w/ the uglify compiler in (at least one of) the minified files that is not part of any build layer.

dasa commented 8 years ago

You can set the build profile's optimizeOptions property to set closure to use ES5 like this:

    optimizeOptions: {
      // http://mail.dojotoolkit.org/pipermail/dojo-interest/2014-October/082561.html
      languageIn: Packages.com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT5
    }
tomwayson commented 8 years ago

Thanks @dasa! I'll give that a try.

Just realizing that my uglify build of the dojo-boilerplate may have also hanged (I've got too many console windows open and may have been confused about which builds worked/failed). I'm re-trying now. If that's the case, it means the issue is w/ Dojo, and not the JSAPI files on bower.

tomwayson commented 8 years ago

@dasa

FYI - the above optimizeOptions does not work for me (at least not from grunt dojo on Windows). Following the link to the mailing list, I realized that this was one of the things I hard already tried. I get this error:

error(347) Failed to evaluate profile file. profile: c:/code/git/BayerCropScience/profiles/app.profile.js; error: ReferenceError: Packages is not defined
error(347) Failed to evaluate profile file. profile: c:/code/git/BayerCropScience/profiles/app.profile.js; error: ReferenceError: Packages is not defined
errors on command line; terminating application.

Changing that to a string like:

  optimizeOptions: {
    // http://mail.dojotoolkit.org/pipermail/dojo-interest/2014-October/082561.html
    languageIn:  'Packages.com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT5'
  },

Also fails w/ repeated entries in the output of following error:

 OPTIMIZER FAILED: InternalError: Cannot convert Packages.com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT5 to com.google.javascript.jscomp.CompilerOptions$LanguageMode
dasa commented 8 years ago

Yes, I think this option is only available when running the build from build.bat or build.sh and not when launched from Node.js.

tomwayson commented 8 years ago

Thanks @dasa - I'll try running the build from a terminal instead of grunt.

I'm closing this issue as I've confirmed that setting optimize to 'uglify' in the dojo-boilerplate repo causes the build to hang as well. I've opened a (duplicate) issue there:

https://github.com/csnover/dojo-boilerplate/issues/66