Dojo Build System with Custom Widget not Building Compressed js

1676
3
Jump to solution
06-07-2016 02:43 PM
JamesFaron
Occasional Contributor

I’m having an issue with the Dojo build system with my custom widgets. The dojo build creates uncompressed versions of  the custom widgets in the Dist folder, but not compressed. The uncompressed js file has the Template.html  at the top under a ‘require({cache:{‘url: app/widget/templates/%WidgetName%.html’ with a compressed version of the template, and then underneath that, the uncompressed widget. It does create a %widgetname%.js file, but with only "//>>built" in the file at the top.

I don’t think the problem is with my directory structure or with the build.profile, since it is copying the files, just not compressing the js for those widgets. Am I missing something with custom code and how build system works? All works fine in my dev environment.

The build runs in command prompt, and finishes with very generic errors that are not specific to why the build fails to complete. It seems that everything else works as expected with the build, just not my custom widgets.

Thanks,

Jim Faron

Katy ISD

Katy, TX

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

If you search the buildreport.txt for stuff like " error" (the space is important) try and see if that can clarify what the issue might be?

Are you using closure or uglify? If closure, what version of Java?

You can check out the demo build app on github and compare your build profile with ours, and see if that helps.

jsapi-resources/3.x/bower/dojo at master · Esri/jsapi-resources · GitHub

I'm assuming this is 3.x, but 4.x isn't much different.

View solution in original post

0 Kudos
3 Replies
ReneRubalcava
Frequent Contributor

If you search the buildreport.txt for stuff like " error" (the space is important) try and see if that can clarify what the issue might be?

Are you using closure or uglify? If closure, what version of Java?

You can check out the demo build app on github and compare your build profile with ours, and see if that helps.

jsapi-resources/3.x/bower/dojo at master · Esri/jsapi-resources · GitHub

I'm assuming this is 3.x, but 4.x isn't much different.

0 Kudos
JamesFaron
Occasional Contributor

Rene,

I posted my comment before reading your response. The build report did help me as you indicated.

Custom code is bit tricky to make work: perhaps a simple sample in the documentation might help.

What I did specifically was to add a map to my app/widgets directory, and referred to it in the packages array:

packages: [
    // 'app' is a sample path for your application
    // set this accordingly
    'app',
    'widget',
    'dijit',
    'dojo',
    'dojox',
    'dstore',
    'dgrid',
    'xstyle',
    'put-selector',
    'esri', {
      name: 'moment',
      location: 'moment',
      main: 'moment',
      trees: [
          // don't bother with .hidden, tests, min, src, and templates
          [".", ".", /(\/\.)|(~$)|(test|txt|src|min|templates)/]
      ],
      resourceTags: {
        amd: function(filename, mid){
          return /\.js$/.test(filename);
        }
      }
    }
  ],
    
  map: {
      '*': {
        widget: "app/widget"
      }
    },

And in the include:

 include: [
        // include the app, set accordingly for your application
        'app/main',
        'widget/SaraWidget',
        'widget/SchoolsWidget',
        'widget/utils/PopupExtended',
        // dependencies of esri/map that will be requested if not included

There were other syntax and argument errors that I fixed as well. Again, it was confusing in that the errors did not cause problems in dev environment, but all is well, at least for now!

0 Kudos
JamesFaron
Occasional Contributor

On further review, I used the build-report.txt file that dojo outputs to the dist directory to get to the source of the problem. For others who may encounter this, the file is huge, so it worked for me to copy and paste it into Excel, then do a search for "Missing dependencies", as well as a search for "error(" . I had to adjust my build.profile to create a map to my widget directory, include it in packages, and then add it the include array in 'dojo/dojo'.

What is peculiar is that the problems that I had with build did not cause the dev environment to fail to load the project.

0 Kudos