1

I am developing a set of modules for others to use using dojo 1.7. All modules are AMD modules and using relative paths within the package. My modules will need to be loaded cross domain, and not interfere with or care about the version of dojo running on the page consuming the modules (Let's assume someone is using. If I understand the documentation correctly, I can specify a packing remapping by doing something like this:

var dojoConfig = {
    packages: [
        {
            name: "myDojo",
            location: "path/to/my/dojo",
            packageMap: {
                dojo: "myDojo",
                dijit: "myDijit",
                dojox: "myDojox"
            }
        },
        {
            name: "myDijit",
            location: "path/to/my/dijit",
            packageMap: {
                dojo: "myDojo"
            }
        },
        {
            name: "myDojox",
            location: "path/to/my/dojox",
            packageMap: {
                dojo: "myDojo",
                dijit: "myDijit",
                dojox: "myDojox"
            }
        },
        {
            name: "myPackage",
            location: "path/to/my/package",
            packageMap: {
                dojo: "myDojo",
                dijit: "myDijit",
                dojox: "myDojox"
            }
        }
    ]
}

Is there a way to burn the remapping into a dojo build so that using any module in my package will automatically use my dojo/dijit/dojox modules instead of the ones loaded in the local version of dojo? If so, what would the profile look like? If possible, I would like consumers to be able to do something like this:

<html>
<head>
    <script src="some/differnt/version/of/dojo.js" type="text/javascript" data-dojo-config="config settings"></script>
    <script type="text/javascript">
        // For legacy syntax users:
        dojo.registerModulePath("hisPackage", "http://somedomain.com/scripts/myPackage");
        dojo.require("hisPackage.HisModule");

        dojo.ready(function() {
            // do stuff
        });

        // Or for AMD users:
        require(["http://somedomain.com/scripts/myPackage/MyModule"], function(HisModule) {
            // do stuff
        }
    </script>
</head>
<body></body>
</html>

Thanks in advance for any help.

4

1 回答 1

0

你有没有在你的 dojoConfig 中尝试过这个

var dojoConfig = { ...
    packages: [
        {name:'dojo',location:'//ajax.googleapis.com/ajax/libs/dojo/1.9.2/dojo/'},
        {name:'dijit',location:'//ajax.googleapis.com/ajax/libs/dojo/1.9.2/dijit/'},
        'dojotut'
    ]
...
}
于 2014-01-14T16:42:21.580 回答