6

I'm currently getting to grips with the new (3.1) ArcGIS JavaScript API and how it bundles Dojo and relies on Dojo's Asynchronous Module Definition (AMD) approach.

I'm familiar with AMD and recently completed a project using Require, Backbone, and OpenLayers in combination - overall a very pleasant experience.

However I'm worried by

  • how tightly-coupled Dojo is with the ArcGIS JavaScript API,
  • that trying to use Require instead of Dojo AMD throws an exception, and
  • that Dojo AMD doesn't seem to have the same user-base and momentum as Require, making it difficult to research / resolve problems without hitting the forums

My main concern is that I will write an ArcGIS JavaScript API application and not be able to build / package it into a single / small number of scripts. This will leave me with an application making 100+ HTTP requests at startup for all of the modules it depends on.

I've seen this article covering 3.0 but it doesn't mention the build process and I believe 3.0 is quite different. I've also seen this piece on building / packaging an application that uses the ArcGIS JavaScript API but the comments suggest this is pre-Dojo 1.7 AMD.

Have ESRI really only half implemented the AMD approach, and in a way that will actually make my application slower? Why can I not find ESRI documentation on building / packaging a JavaScript API-based application?

Any thoughts or experience here would be much appreciated.

EDIT Based on the answers so far it seems that no, ESRI hasn't provided any information on building your Dojo application after inflating the number of scripts involved. It seems the only useful information available is from non-official sources and slightly outdated (enough to cause problems). This leads to me wonder why more people aren't vocal about the API's new improvements / deficiencies

  • am I being too critical / demanding in expecting some more information here?
  • is no one using the latest version of the API?
  • should I use an older version of the API that doesn't depend on AMD?
1

2 Answers 2

7

Since esri does not ship source code you cannot build one layer package with all your classes. You will have to push out the esri api locally or using the CDN and then pull down your layer file. So you will have 2 and then the extra's that esri forgot to bundle or chose not to.

We've put together a discard layer so that you don't duplicate packages within your own built layer file and the esri layer file. This is pre AMD but as you've noticed, AMD is only partially implemented in the current version of the API.

This blog post will outline everything you need to know and the concept will apply for newer versions.

the freenode irc chatroom #dojo has great realtime information if you dont' want to wait around for the forum.

2

while ago I was wondering the same question. But on last Esri Developer Summit 2012 I saw a presentation about JS api. Person that was presenting the subject explained how to create basic OO dojo plugin/module. You can watch whole video here: http://proceedings.esri.com/library/userconf/devsummit12/index.html

2
  • Unfortunately this example doesn't seem to use the define([dependencies...], function(callback params) {}) AMD approach and doesn't mention building a production deployable script out of those many classes
    – tomfumb
    Commented Sep 18, 2012 at 1:10
  • above example is based on 2.8 version of ArcGIS JS API which is based on DOJO 1.6.1 so there were no AMD approach. and functions that you mentioned
    – Krystian
    Commented Sep 18, 2012 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.