You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit: The issue had to do with John Resig's Class module, not RequireJS. That's what I was hoping for anyway.
I'm not sure whether or not this is user error, or an error with RequireJS, but it sure is confusing. I'm not sure how the bug could be recreated, but I can give you the source if necessary. If it's not a bug and is user error, it would be nice to have an answer.
All of these files are in the same directory. I define a base class in one, some derivatives in two others, and then an Angular JS module which packages them together in an Angular factory for use in controllers. This file containing the bug, or revealing a bug in RequireJS, is design-tools.js.
Somehow, design-tools is overwriting the derivative classes (tool-selection and tool-creation). When I define the dependencies in the order
['dep1'... 'depN', 'tool-selection', 'tool-creation']
tool-creation gets loaded twice (in the factory function, arguments[5] is tool-selection, and arguments[6] is also tool-selection)
If I change the order to
['dep1'... 'depN', 'tool-creation', 'tool-selection']
tool-selection gets loaded twice (both arguments[5] and arguments[6] are tool-selection).
I don't want to assume there are bugs with RequireJS, but if this is user error on my part, I must have done a really good job at breaking things :)
Can anyone help determine the cause of this error? I'm just going to list the define() calls here from the different files in the same folder, and hopefully someone can resolve this. I'm resorting to moving tool-creation and tool-selection into different sub-directories in an attempt to resolve the issue.
index.js (loaded first)
define([
'./design-tools'
], function () {});
design-tools.js
var needs = ['angular', './module', 'lodash', 'jrClass', './tool'];
needs = needs.concat([
'./tool-creation',
'./tool-selection'
]);
define(needs, function(ng, module, _, Class, Tool){
// Do stuff...
// Slice tool-creation and tool-selection off the end of arguments[] and configure them
}
define(['jrClass', 'lodash'], function (Class, _) {
var Tool;
Tool = Class.extend({ /* Some things */});
return Tool;
});
tool-creation.js
define(['angular', 'lodash', './tool', '../../services/classes/EventMap'], function (ng, _, Tool, EventMap) {
// Define the CreationTool class, return it
var CreationTool;
CreationTool = Tool.extend({
//Stuff
});
return CreationTool;
});
tool-selection.js
define(['angular', 'lodash', './tool', '../../services/classes/EventMap'], function (ng, _, Tool, EventMap) {
// Define the SelectionTool class, return it
var SelectionTool;
SelectionTool = Tool.extend({
//Stuff
});
return SelectionTool;
});
Hopefully this can get resolved.
The text was updated successfully, but these errors were encountered:
bryanerayner
changed the title
define() overwriting differently named modules - Error
define() overwriting differently named modules - User Error
Apr 21, 2014
Solved
Edit: The issue had to do with John Resig's Class module, not RequireJS. That's what I was hoping for anyway.
I'm not sure whether or not this is user error, or an error with RequireJS, but it sure is confusing. I'm not sure how the bug could be recreated, but I can give you the source if necessary. If it's not a bug and is user error, it would be nice to have an answer.
All of these files are in the same directory. I define a base class in one, some derivatives in two others, and then an Angular JS module which packages them together in an Angular factory for use in controllers. This file containing the bug, or revealing a bug in RequireJS, is design-tools.js.
Somehow, design-tools is overwriting the derivative classes (tool-selection and tool-creation). When I define the dependencies in the order
['dep1'... 'depN', 'tool-selection', 'tool-creation']
tool-creation gets loaded twice (in the factory function, arguments[5] is tool-selection, and arguments[6] is also tool-selection)
If I change the order to
['dep1'... 'depN', 'tool-creation', 'tool-selection']
tool-selection gets loaded twice (both arguments[5] and arguments[6] are tool-selection).
I don't want to assume there are bugs with RequireJS, but if this is user error on my part, I must have done a really good job at breaking things :)
Can anyone help determine the cause of this error? I'm just going to list the define() calls here from the different files in the same folder, and hopefully someone can resolve this. I'm resorting to moving tool-creation and tool-selection into different sub-directories in an attempt to resolve the issue.
index.js (loaded first)
design-tools.js
module.js
tool.js
tool-creation.js
tool-selection.js
Hopefully this can get resolved.
The text was updated successfully, but these errors were encountered: