jrburke/requirejs — Issue #203: Copies made of module objects that should not be made
Author: guidocalvano
Created: 2012-03-06 17:49:57+00:00
State: open

I needed a circular dependency, so I had to declare a prototype before I defined it.

// declare.js

define( [], function() { function MyProtototypeFunction() {} ; return MyPrototypeFunction ; } ) ;

// define.js

define( ['./declare.js' ],
function ( MyPrototypeFunction )
{
MyPrototypeFunction.prototype.init = function() { console.log( 'bla' ) ; } ;
} ) ;

// test.js

define( [ './declare.js', './define.js' ], function( Declare, Define )
{
if( Declare === Define ) console.log( 'equal' ) ; else console.log( 'unequal' ) ;
} ) ;

// output

unequal

This should not be the case from my point of view...

Do you agree? Do you have a solution?