Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bonzo produces duplicate named modules when compiled with r.js #98

Closed
commuterjoy opened this issue Sep 25, 2012 · 5 comments
Closed

Bonzo produces duplicate named modules when compiled with r.js #98

commuterjoy opened this issue Sep 25, 2012 · 5 comments

Comments

@commuterjoy
Copy link

Hi,

Bonzo (and Reqwest + Qwery) all produce an empty named AMD module when used with r.js

They all produces this after compilation, alongside the original module :-

define("bonzo",[], function(){}); 

Test case, https://github.com/guardian/requirejs-optimiser-bug

requirejs (client-side) conveniently ignores this, but curl and almond throw exceptions due to duplicate module names.

So, I think r.js is misinterpreting this line for some reason,

else if (typeof context['define'] == 'function' && context['define']['amd']) define(name, definition)

Various other modules (Eg, bean etc.) don't have this problem.

I'm using the latest r.js package,

r.js -v
r.js: 2.0.6, RequireJS: 2.0.6

Thanks,
M

@rvagg
Copy link
Collaborator

rvagg commented Sep 27, 2012

I'd be happy to remove the name from the define in Bonzo but I'll have to bug @ded to get it sorted out in Reqwest and Qwery. Thanks for raising this issue.

@commuterjoy
Copy link
Author

@rvagg great, that would be very helpful.

@ded
Copy link
Owner

ded commented Nov 26, 2012

hey @commuterjoy (and @rvagg )

according to amd's define method, it looks like this:

define(['someModule'] , function (myMod) {
    return function () {};
});

it even says so on the RequireJS website on why amd

so what i don't get is, how this works with bean (which is doing it wrong), and not bonzo, qwery, and reqwest.

@ded
Copy link
Owner

ded commented Nov 26, 2012

ok, really trying to get this right.

have a look at this too: http://requirejs.org/docs/api.html#defdep

from what it looks like, the define method can have a first arg which is an array of dependencies. and in that case, bonzo has no dependencies...... which means we can switch it out to look like bean.

@ded
Copy link
Owner

ded commented Nov 26, 2012

alright folks. this has been fixed and i verified it to be working
d757fe6#L0R8

i added require.js in the integration folder to verify that it does in fact work 👍

cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants