jrburke/requirejs — Issue #196: Module gets loaded twice, where it should load only once...
Author: guidocalvano
Created: 2012-02-27 22:11:32+00:00
State: open

A module gets reloaded where it should not.

The situation:

I have several files all in the same folder, three are relevant:

./main.js
./NodeView.js
./Camera.js

in main the following lines are relevant:

require( './Camera.js' ) ;
require( './NodeView.js' ) ;

in NodeView:

define( [ './Camera.js' ], NodeViewFactory ) ;

in Camera:

a console.log statement to see when it loads

I start the code as follows

../OgreJS/build/ogrenode r.js main.js

ogrenode is a version of node that is only slightly adapted, I didn't change the way it loads modules or anything.

it is based on node version 0.4.8.

after requiring the modules in main I ask:

console.log( requirejs.s.contexts ) ;

console states that both Camera.js and ./Camera.js are loaded, i.e. the same file is loaded twice, as you can see under
requirejs.s.contexts._.loaded

the raw information printed by console.log( requirejs.s.contexts ) :

```
{ _:
{ contextName: '_',
config:
{ waitSeconds: 7,
baseUrl: './',
paths: {},
pkgs: {},
catchError: {} },
defQueue: [],
waiting: {},
waitCount: 0,
specified:
{ require: true,
exports: true,
module: true,
sys: true,
'../OgreJS/src/js/ogre.js': true,
'../OgreJS/src/js/mygui.js': true,
'./Camera.js': true,
'./NodeView.js': true,
'Camera.js': true },
loaded:
{ sys: true,
'../OgreJS/src/js/ogre.js': true,
'../OgreJS/src/js/mygui.js': true,
'./Camera.js': true,
'./NodeView.js': true,
'Camera.js': true },
urlMap:
{ '../OgreJS/src/js/ogre.js': '../OgreJS/src/js/ogre.js',
sys: './sys.js',
'../OgreJS/src/js/mygui.js': '../OgreJS/src/js/mygui.js',
'./Camera.js': './Camera.js',
'./NodeView.js': './NodeView.js',
'Camera.js': 'Camera.js' },
urlFetched: { 'Camera.js': true },
scriptCount: 0,
defined:
{ sys: -1,
'../OgreJS/src/js/ogre.js': null,
'../OgreJS/src/js/mygui.js': null,
'./Camera.js': [Function: Camera],
'Camera.js': [Function: Camera],
'./NodeView.js': [Function: NodeView] },
paused: [],
pausedCount: 0,
plugins: {},
needFullExec: {},
fake: {},
fullExec: {},
managerCallbacks: {},
makeModuleMap: [Function: makeModuleMap],
normalize: [Function: normalize],
configure: [Function],
requireDefined: [Function],
requireSpecified: [Function],
require: [Function],
takeGlobalQueue: [Function],
completeLoad: [Function],
toUrl: [Function],
nameToUrl: [Function],
jQueryCheck: [Function],
resume: [Function],
startTime: 1330378640072 } }

```