Problem with custom build of v3.16 app

2411
4
Jump to solution
03-16-2016 08:50 AM
BillDaigle
Occasional Contributor III

Has anyone out there done a successful build an app using the version 3.16?

For some reason, dojo's build system doesn't seem to like moment.js​, which appears to be a dependency of 3.16.

The first error that I get in my build report is:

moment.js.uncompressed.js:9: ERROR - Parse error. '}' expected
import { hooks as moment, setHookCallback } from './lib/utils/hooks';
^

1 error(s), 0 warning(s)
Done (compile time:0.114s)

There are many other errors as well, all associated with the moment library. I took a cursory look at the library.   It appears as thought it was written using ES6 syntax.  Not sure if this a problem for the build system.

Anyone else having luck with 3.16 builds?

Rene Rubalcava

Lloyd Heberlie

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

The inclusion of the moment lib requires a little extra steps in the Dojo build profile.

See this sample here.

jsapi-resources/build.profile.js at master · Esri/jsapi-resources · GitHub

  packages: [
    // 'app' is a sample path for your application
    // set this accordingly
    'app',
    '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)/]
      ]
    }
  ],

When you bower install moment, it will build fine, but you have to tell Dojo where to find it and also what files to ignore, which is what that trees property does for the package.

Hope that helps.

View solution in original post

4 Replies
LloydHeberlie
Occasional Contributor

Hi Bill,

Are you using bower to generate a custom build or the Web Optimizer?


Thanks,

Lloyd

0 Kudos
BillDaigle
Occasional Contributor III

Bower and grunt.

0 Kudos
ReneRubalcava
Frequent Contributor

The inclusion of the moment lib requires a little extra steps in the Dojo build profile.

See this sample here.

jsapi-resources/build.profile.js at master · Esri/jsapi-resources · GitHub

  packages: [
    // 'app' is a sample path for your application
    // set this accordingly
    'app',
    '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)/]
      ]
    }
  ],

When you bower install moment, it will build fine, but you have to tell Dojo where to find it and also what files to ignore, which is what that trees property does for the package.

Hope that helps.

BillDaigle
Occasional Contributor III

Bingo!  Error free now.  Thanks Rene!

0 Kudos