Reputation: 679
I've a project in which front-end is developed using dojo 1.3.1 and there are around 100+ custom widgets and dojo files.
My task is to migrate all the code from Dojo 1.3.1 to Dojo 1.9.3(latest till date).
I've tried to replace the Dojo 1.3.1 source with 1.9.3 but everything breaks and I cannot see anything on UI. Obviously this is because of the major syntax differences between the two versions, specifically the changes in syntax of defining modules and including modules.
Is this the only way that I've to change the syntax in all the 100+ files and check if the functionality + UI works or there could be another better workaround for this?
EDIT:
I've used dojo-amd-converter to convert custom modules from pre-AMD to AMD. There is one file which is converted as follows:
Old Code:
dojo.provide("myModule.objects");
dojo.require("dojo._base");
myModule.objects.psCookie = (
function () {
// Default Values
var defaultArgs = {
ident: "",
email: ""
}
return function(args) {
return myModule.objects.cleanArgs(args, defaultArgs);
}
}
)();
Converted Code:
define([
"dojo/_base",
"dojo/_base/lang"
], function (_base, lang) {
myModule.objects.psCookie = (
function () {
// Default Values
var defaultArgs = {
ident: "",
email: ""
}
return function(args) {
return myModule.objects.cleanArgs(args, defaultArgs);
}
}
)();
Now, I'm facing couple of issues after conversion:
GET http://localhost:8080/td/js/dojo-release-1.9.3/dojo/_base.js 404 (Not Found)
Uncaught TypeError: Cannot set property 'psCookie' of undefined /td/js/myModule/objects.js:6
Any idea how I can resolve these issues?
Upvotes: 0
Views: 508
Reputation: 44685
There are two things here, to resolve the following error:
GET http://localhost:8080/td/js/dojo-release-1.9.3/dojo/_base.js 404 (Not Found)
You just have to remove dojo/_base
from your module list, for example:
define([
"dojo/_base/lang"
], function (lang) {
// Rest of your code
});
Then, the whole dojo.provide()
system is gone, so that means there is no object provided for you as a module anymore (so you get an error that that object is undefined
). In stead of that, you just return an object by yourself, for example:
define([
"dojo/_base/lang"
], function(lang) {
return {
psCookie: /** Your code */
};
});
However, I'm not really familiar about what the psCookie
does in your example, so you might have to explain that a bit further.
Upvotes: 1