How do I use uncompressed files in Dojo 1.7?

可紊 提交于 2019-12-06 01:20:17
Craig Swing

You have two options

1) Create a custom build. The custom build will output a single uncompressed file that you can use for debugging. Think the dojo.js.uncompressed.js but it includes all the extra modules that you use.

OR

2) For a development environment, use the dojo source code. This means downloading the Dojo Toolkit SDK and referencing dojo.js from that in the development environment.

For the projects I work on, I do both. I set up the Dojo configuration so that it can be dynamic and I can change which configuration that I want using a query string parameter.

When I am debugging a problem, I will use the first option just to let me step through code and see what is going on. I use the second option when I am writing some significant js and don't want the overhead of the custom build to see my changes.

I describe this a bit more at

http://swingingcode.blogspot.com/2012/03/dojo-configurations.html

I think the reason for this is due to the fact that the loader declares its class-loads (modules), by the file conventions used. The 1.7 loader is not too robust just yet, ive had similar problems until realizing how to separate the '.' and '/' chars.

Its only a qualified guess; but i believe it has to do with the interpretation of '.' character in the class-name which signifies as a sub-namespace and not module name.

The 'define(/ * BLANK * / [ / * DEPENDENCIES * / ], ...)' - where no first string parameter is given - gets loaded by the filename (basename). The returned declare also has a saying though. So, for your example with jsonrest, its split/parsed as such:

toplevel = dojox
mid = data
modulename = JsonRestStore.js.uncompressed

(Fail.. Module renders as dojox.data.JsonRestStore.js.uncompressed, not dojox.data.JsonRestStore as should).

So, three options;

  1. Load uncomressed classes through <script src="{{dataUrl}}/dojox/data/JsonRestStore.js.uncompressed.js"></script> and work them on dojo.ready
  2. I think modifying the define([], function(){}) in uncompressed.js to define("JsonRestStore", [], function() {}) would do the trick (uncomfirmed)
  3. Use the dojo/text loader, see below

Text filler needed :)

define("my/MyRestStore", 
    ["dojo/_base/declare", "dojo/text!dojox/data/JsonRestStore.js.uncompressed.js"], 
    function(declare, JsonRestStore) {
...
        JsonRestStore = eval(JsonRestStore);
        // not 100% sure 'define' returns reference to actual class, 
        // if above renders invalid, try access through global reference, such as
        // dojox.dat...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!