Can I use the esri api with require.js?

1981
17
Jump to solution
09-26-2013 05:56 AM
DonnieHolmes
New Contributor III
I need to use the esri API within a JavaScript app that is built using require.js + backbone + others (all are a part of a standard internal company toolkit). Does anyone have any examples of how this can be done? I have done some searching on this forum and the internet in general and can't seem to find any concrete examples of how to make this happen.

I should clarify that I have tried to make this happen and can't seem to prevent the AMD loaders from stepping on each other.

Thanks.

Donnie Holmes
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Frequent Contributor
The short answer is no, you can't use requirejs next to Dojo. If you're using Dojo, use Dojo's module loader.

View solution in original post

0 Kudos
17 Replies
JonathanUihlein
Esri Regular Contributor
I'm sure you saw: http://requirejs.org/docs/dojo.html
Which leads to: https://bugs.dojotoolkit.org/ticket/15616

Since the ticket discussed there is resolved, it should be possible.

Some great comments further down; they should lead you in the right direction.
0 Kudos
DonnieHolmes
New Contributor III
I'm sure you saw: http://requirejs.org/docs/dojo.html
Which leads to: https://bugs.dojotoolkit.org/ticket/15616

Since the ticket discussed there is resolved, it should be possible.

Some great comments further down; they should lead you in the right direction.


Thanks - I did see that. However, I'm very new to dojo and I'm not sure which comments are relevant. I require a little more hand-holding at this point. 🙂
0 Kudos
JonathanUihlein
Esri Regular Contributor
Spent another few minutes on Google, found this:

http://stackoverflow.com/questions/17475515/using-requirejs-with-dojo-1-9-1


You need to use the source/SDK version of the Dojo Toolkit. Built copies of AMD modules are not compatible between loaders.


Hope this helps.
0 Kudos
derekswingley1
Frequent Contributor
The short answer is no, you can't use requirejs next to Dojo. If you're using Dojo, use Dojo's module loader.
0 Kudos
DonnieHolmes
New Contributor III
Spent another few minutes on Google, found this:

http://stackoverflow.com/questions/17475515/using-requirejs-with-dojo-1-9-1




Hope this helps.


Thanks. So, it sounds like you cannot use another loader with the esri api at the moment because it is a "built" version of dojo. I guess that means I'll need to use the dojo loader or nothing. That's disappointing. Hopefully this changes in a future release.
0 Kudos
derekswingley1
Frequent Contributor
What does requirejs do that you can't do with the Dojo module loader?
0 Kudos
DonnieHolmes
New Contributor III
What does requirejs do that you can't do with the Dojo module loader?

  My problem is that we have a company-internal toolkit that includes a handful of require.js plugins that are to be used as part of our web client "standard". It means that, unless there is some quick and easy way to make these same plugins work with dojo, it's going to be very hard for me to integrate an esri map into apps that are built with our in-house toolkit.. Being new to the game, I don't know if that's even feasible yet.
0 Kudos
derekswingley1
Frequent Contributor
Have you looked at using Dojo's loader to load your require plug-ins? I'm not sure if they're compatible but it's worth trying:  http://livedocs.dojotoolkit.org/loader/amd#plugins

What do your current requirejs plug-ins do?
0 Kudos
DonnieHolmes
New Contributor III
Have you looked at using Dojo's loader to load your require plug-ins? I'm not sure if they're compatible but it's worth trying:  http://livedocs.dojotoolkit.org/loader/amd#plugins

What do your current requirejs plug-ins do?


Thanks, I'll take a look. It looks like the plugins mostly read in external files as text, css, etc.
0 Kudos