Hello,

The BuildSystem documentation on livedocs
(http://livedocs.dojotoolkit.org/build/buildSystem)
references in the "Extra Features" section the following subsections
that happens not to exist yet:

http://livedocs.dojotoolkit.org/build/relocatingPackages
http://livedocs.dojotoolkit.org/build/htmlToProfile

Do you know if a draft is available somewhere ? I am particularly
interested in "Relocating Packages" as it could be the solution to an
issue I have with a custom dojo build. Meanwhile, if you have any
hints/pointers, do not hesitate ;-)

Thanks !
--
Patrick

Search Discussions

  • Ben hockey at Jan 5, 2012 at 9:54 am
    what do you want to know about relocating packages? i believe that it
    is the packageMap feature and if so i can explain it to you. you can
    see
    http://bdframework.org/bdLoad/docs/bdLoad-tutorial/bdLoad-tutorial.html#nameClashes
    for some info.

    and... here's an example from how i've used it:
    dojoConfig = {
    async: 1,
    packages: [
    {
    name: '__cdojo',
    location: '../dojo',
    packageMap: {
    dojo: '__cdojo',
    dijit: '__cdijit',
    dojox: '__cdojox'
    }
    },
    {
    name: '__cdijit',
    location: '../dijit',
    packageMap: {
    dojo: '__cdojo',
    dijit: '__cdijit'
    }
    },
    {
    name: '__cdojox',
    location: '../dojox',
    packageMap: {
    dojo: '__cdojo',
    dijit: '__cdijit',
    dojox: '__cdojox'
    }
    },
    {
    name: 'app',
    packageMap: {
    dojo: '__cdojo',
    dijit: '__cdijit',
    dojox: '__cdojox'
    },
    location: '../app'
    }
    ]
    };


    this achieves 2 things.
    - the globals dojo, dijit and dojox are remapped to __cdojo,
    __cdijit and __cdojox respectively
    - in my "app" package, any mention of the dojo, dijit and dojox
    packages will resolve to the __cdojo, __cdijit and __cdojox packages
    respectively.

    you'll notice that the __cdojo, __cdijit and __cdojox packages also have
    a packageMap. this is so that they also pick up the right packages when
    they reference dojo, dijit and dojox. you may wonder why __cdojo needs
    a packageMap since it doesn't reference the other packages - the reason
    is that this is how the globals get remapped.

    is that the kind of thing you're trying to achieve?

    ben...

    On 1/5/2012 8:57 AM, Patrick Ruzand wrote:
    Hello,

    The BuildSystem documentation on livedocs
    (http://livedocs.dojotoolkit.org/build/buildSystem)
    references in the "Extra Features" section the following subsections
    that happens not to exist yet:

    http://livedocs.dojotoolkit.org/build/relocatingPackages
    http://livedocs.dojotoolkit.org/build/htmlToProfile

    Do you know if a draft is available somewhere ? I am particularly
    interested in "Relocating Packages" as it could be the solution to an
    issue I have with a custom dojo build. Meanwhile, if you have any
    hints/pointers, do not hesitate ;-)

    Thanks !
    --
    Patrick
    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
  • Patrick Ruzand at Jan 5, 2012 at 10:29 am
    Hi Ben,

    my question is in fact a follow up to :
    http://comments.gmane.org/gmane.comp.web.dojo.devel/16323

    The use case was to be able to use 2 differents dojo 1.7 builds in the
    same app. Thanks to your help, I could make it work, using the
    following profile for my custom build (let's call it cdojo_build):
    dependencies= {
    insertAbsMids: 0,
    optimize: "shrinksafe"
    };

    and the following dojoConfig:

    var dojoConfig = {
    async: true,
    parseOnLoad: true,
    packages: [{
    name: 'myScript',
    location: '../../myScript',
    packageMap:{ dojo: "cdojo17"}
    },{
    name:"cdojo17",
    location:'../../cdojo_build/dojo'
    }]
    };

    That is, myScript should loads dojo from the cdojo_build.


    With that, everything works fine (but maybe I should double check as
    as opposed to your config, I have not specified a package map for
    cdojo17 itself) : the mapping is resolved as expected, except I
    noticed that the loader loads the module files individually (e.g. it
    loads cdojo_build/dojo/ready.js).
    I would like to know if there could be a way to load the big dojo.js
    bundle from my cdojo_build, so that for example ready.js gets loaded
    from the cdojo_build dojo.js "cache" and not as a standalone module.
    Like having a dojo "layer" for my cdojo build.
    I did not find an option that would have allowed me to load the
    cdojo_build/dojo/dojo.js and "wire it" with the package map
    definition.
    So I was trying to find if it cannot be solved at build time, by
    changing the namespace of the dojo modules so that I can explicitly
    load the cdojo_build dojo.js file without any risk of conflict.

    Hope my explanations are clear enough...

    Thx
    Patrick
  • Ben hockey at Jan 5, 2012 at 11:18 am

    On 1/5/2012 10:29 AM, Patrick Ruzand wrote:
    Hi Ben,

    my question is in fact a follow up to :
    http://comments.gmane.org/gmane.comp.web.dojo.devel/16323

    The use case was to be able to use 2 differents dojo 1.7 builds in the
    same app. Thanks to your help, I could make it work, using the
    following profile for my custom build (let's call it cdojo_build):
    dependencies= {
    insertAbsMids: 0,
    optimize: "shrinksafe"
    };

    and the following dojoConfig:

    var dojoConfig = {
    async: true,
    parseOnLoad: true,
    packages: [{
    name: 'myScript',
    location: '../../myScript',
    packageMap:{ dojo: "cdojo17"}
    },{
    name:"cdojo17",
    location:'../../cdojo_build/dojo'
    }]
    };

    That is, myScript should loads dojo from the cdojo_build.


    With that, everything works fine (but maybe I should double check as
    as opposed to your config, I have not specified a package map for
    cdojo17 itself) : the mapping is resolved as expected, except I
    noticed that the loader loads the module files individually (e.g. it
    loads cdojo_build/dojo/ready.js).
    afaik, the packageMap for the cdojo17 package is only for the sake of
    remapping the globals. however, i would try adding a packageMap to see
    if it helps - once everything is working i would remove it to confirm
    whether or not its needed. when everything is configured properly, you
    certainly shouldn't see an extra request for that file.

    if you're able to provide some files for me to work with i can take a
    look for you - getting everything just right can be kind of tricky. for
    example, for the loader to know that cdojo_build/dojo/ready is actually
    in cdojo_build/dojo/dojo.js, something needs to have requested
    cdojo_build/dojo/dojo *before* anything requests
    cdojo_build/dojo/ready. if this doesn't happen then the loader will see
    a request for cdojo_build/dojo/ready and then figure out the url for
    that module and get that file - it doesn't know that its included in
    cdojo_build/dojo/dojo.js if dojo.js isn't already loaded.
    I would like to know if there could be a way to load the big dojo.js
    bundle from my cdojo_build, so that for example ready.js gets loaded
    from the cdojo_build dojo.js "cache" and not as a standalone module.
    Like having a dojo "layer" for my cdojo build.
    for this to work properly, you need this kind of code:

    // load the layer/cache first
    require(['dojo'], function () {
    // now use things from that layer
    require(['dojo/ready'], function (ready) {
    // do your stuff
    });
    });

    if you don't load the layer first and wait for it to resolve before you
    load things included in that layer then you will see extra requests that
    you were hoping to avoid.
    I did not find an option that would have allowed me to load the
    cdojo_build/dojo/dojo.js and "wire it" with the package map
    definition.
    So I was trying to find if it cannot be solved at build time, by
    changing the namespace of the dojo modules so that I can explicitly
    load the cdojo_build dojo.js file without any risk of conflict.
    i got a little lost here at the end.

    at build time, modules can be bundled together in layers. by ensuring
    that insertAbsMids is false during the build then you can use packageMap
    when you load those layers and relocate the namespace however you want.
    i suspect that maybe you're not loading the layer before you try to use
    the modules included in that layer. if you have some files (html page,
    some myScript code and a build profile) that would help me.
    http://bugs.dojotoolkit.org/ticket/13597 contains my example of those
    files except the javascript code is in the html. you'll see that
    http://bugs.dojotoolkit.org/attachment/ticket/13597/packageMap.html#L43
    loads the layer before anything else happens.

    maybe that will at least get you one step closer.

    ben...
  • Patrick Ruzand at Jan 6, 2012 at 10:56 am

    if you're able to provide some files for me to work with i can take a
    look for you - getting everything just right can be kind of tricky. ?for
    example, for the loader to know that cdojo_build/dojo/ready is actually
    in cdojo_build/dojo/dojo.js, something needs to have requested
    cdojo_build/dojo/dojo *before* anything requests
    cdojo_build/dojo/ready. ?if this doesn't happen then the loader will see
    a request for cdojo_build/dojo/ready and then figure out the url for
    that module and get that file - it doesn't know that its included in
    cdojo_build/dojo/dojo.js if dojo.js isn't already loaded.
    This is exactly what blocked me: make the cdojo dojo.js loaded before
    anything else in myScript requires dojo dependencies. More
    specifically, I couldn't see a proper way to load it. I tried to add a
    'main' option, but without success.
    // load the layer/cache first
    require(['dojo'], function () {
    ? ? // now use things from that layer
    ? ? require(['dojo/ready'], function (ready) {
    ? ? ? ? // do your stuff
    ? ? });
    });
    Thanks to your suggestion, I could eventually make it work, with some tweeks:

    1/ I added a myScript/bootstrap.js file that only loads the
    cdojo/dojo/dojo.js. So that the packageMap associated with myScript/
    is taken into account, I had to do a define(["dojo/dojo"]), not a
    require (path to dojo was not the right one with the latter). So
    basically, the myScript/boostrap.js does :
    define(["dojo/dojo"],function(){});


    2/ I had to update my dojoConfig to specifify a packageMap for cdojo17
    too, as you mentioned in your first answer. Without it, dependencies
    of the cdojo build were loaded from the dojo/ one. So, with the
    following dojoConfig:
    var dojoConfig = {
    async: true,
    parseOnLoad: true,
    packages: [{
    name: 'myScript',
    location: '../../myScript',
    packageMap:{ dojo: "cdojo17"}
    },{
    name:"cdojo17",
    location:'../../cdojo_build/dojo',
    packageMap:{ dojo: "cdojo17"}
    }]
    };

    3/ Finally, I modified my "startrup" sequence like that one:

    require(["dojo/ready", "dojo/parser", "myScript/bootstrap"],
    function(ready,parser){
    require(["myScript/inline_dummy"], function(dummy){
    // do something with dummy
    });
    });
    That way, the 'dojo/dojo' dependencies of bootstrap is properly
    redirected to the myScript/ packageMap and loads my custom dojo layer,
    and it ensures it is loaded before myScript/dummy.
    With this config, I can see that the cdojo/dojo/ready is not loaded
    individually but fetched from the cdojo layer. Seems you solved my
    problem one more time :-)

    if you want me to test other ways (or if what I did raises some
    questions) I can do more test if you wish, just let me know.

    Thanks
    Patrick
  • Ben hockey at Jan 6, 2012 at 11:13 am
    it sounds like you've got it working so no need to try anything else.
    my hope is now that its working you can see why you had to do all those
    things and see how they fit together. i realize that at first its not
    exactly obvious why you might need to do certain things but, for me,
    once i got it working and understood how it worked i could see why
    everything was necessary.

    if you have some time maybe you could take a shot at filling in the
    missing documentation.

    thanks,

    ben...
    On 1/6/2012 10:56 AM, Patrick Ruzand wrote:
    if you're able to provide some files for me to work with i can take a
    look for you - getting everything just right can be kind of tricky. for
    example, for the loader to know that cdojo_build/dojo/ready is actually
    in cdojo_build/dojo/dojo.js, something needs to have requested
    cdojo_build/dojo/dojo *before* anything requests
    cdojo_build/dojo/ready. if this doesn't happen then the loader will see
    a request for cdojo_build/dojo/ready and then figure out the url for
    that module and get that file - it doesn't know that its included in
    cdojo_build/dojo/dojo.js if dojo.js isn't already loaded.
    This is exactly what blocked me: make the cdojo dojo.js loaded before
    anything else in myScript requires dojo dependencies. More
    specifically, I couldn't see a proper way to load it. I tried to add a
    'main' option, but without success.
    // load the layer/cache first
    require(['dojo'], function () {
    // now use things from that layer
    require(['dojo/ready'], function (ready) {
    // do your stuff
    });
    });
    Thanks to your suggestion, I could eventually make it work, with some tweeks:

    1/ I added a myScript/bootstrap.js file that only loads the
    cdojo/dojo/dojo.js. So that the packageMap associated with myScript/
    is taken into account, I had to do a define(["dojo/dojo"]), not a
    require (path to dojo was not the right one with the latter). So
    basically, the myScript/boostrap.js does :
    define(["dojo/dojo"],function(){});


    2/ I had to update my dojoConfig to specifify a packageMap for cdojo17
    too, as you mentioned in your first answer. Without it, dependencies
    of the cdojo build were loaded from the dojo/ one. So, with the
    following dojoConfig:
    var dojoConfig = {
    async: true,
    parseOnLoad: true,
    packages: [{
    name: 'myScript',
    location: '../../myScript',
    packageMap:{ dojo: "cdojo17"}
    },{
    name:"cdojo17",
    location:'../../cdojo_build/dojo',
    packageMap:{ dojo: "cdojo17"}
    }]
    };

    3/ Finally, I modified my "startrup" sequence like that one:

    require(["dojo/ready", "dojo/parser", "myScript/bootstrap"],
    function(ready,parser){
    require(["myScript/inline_dummy"], function(dummy){
    // do something with dummy
    });
    });
    That way, the 'dojo/dojo' dependencies of bootstrap is properly
    redirected to the myScript/ packageMap and loads my custom dojo layer,
    and it ensures it is loaded before myScript/dummy.
    With this config, I can see that the cdojo/dojo/ready is not loaded
    individually but fetched from the cdojo layer. Seems you solved my
    problem one more time :-)

    if you want me to test other ways (or if what I did raises some
    questions) I can do more test if you wish, just let me know.

    Thanks
    Patrick
    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
  • Patrick Ruzand at Jan 6, 2012 at 11:17 am

    it sounds like you've got it working so no need to try anything else.
    my hope is now that its working you can see why you had to do all those
    things and see how they fit together. ?i realize that at first its not
    exactly obvious why you might need to do certain things but, for me,
    once i got it working and understood how it worked i could see why
    everything was necessary.
    The only thing that really puzzles me is why define() was working and
    not require() when resolving the path to the cdojo dojo.js (that is,
    in bootstrap.js). I am investigating.

    Patrick
  • Ben hockey at Jan 6, 2012 at 11:40 am
    oh ok... that is interesting. in my application, i'm using define
    everywhere so i hadn't seen that problem. i could believe that define
    might take a different path than require - the reasoning might be that
    packageMap applies to packages and packages should contain modules that
    call define. maybe this is intentional? i'm not sure i would call it a
    bug.

    ben...
    On 1/6/2012 11:17 AM, Patrick Ruzand wrote:
    it sounds like you've got it working so no need to try anything else.
    my hope is now that its working you can see why you had to do all those
    things and see how they fit together. i realize that at first its not
    exactly obvious why you might need to do certain things but, for me,
    once i got it working and understood how it worked i could see why
    everything was necessary.
    The only thing that really puzzles me is why define() was working and
    not require() when resolving the path to the cdojo dojo.js (that is,
    in bootstrap.js). I am investigating.

    Patrick
    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdojo-contributors @
categoriesdojo
postedJan 5, '12 at 8:57a
activeJan 6, '12 at 11:40a
posts8
users2
websitedojotoolkit.org

2 users in discussion

Patrick Ruzand: 4 posts Ben hockey: 4 posts

People

Translate

site design / logo © 2021 Grokbase