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

amdify/npmrel fail on "this" as exports idiom #17

Closed
asutherland opened this issue Apr 5, 2012 · 3 comments
Closed

amdify/npmrel fail on "this" as exports idiom #17

asutherland opened this issue Apr 5, 2012 · 3 comments

Comments

@asutherland
Copy link
Contributor

This file:
https://github.com/andris9/mailparser/blob/master/lib/datetime.js

whose content is basically:

this.strtotime = function(str, now) {
}

Does not amdify properly. When I use npmrel, the wrapper is:

//Wrapped in an outer function to preserve global this
(function (root) { define([undefined], function (undefined) { (function () {
....
}.call(root));

undefined
}); }(this));

When I manually use amdify, it looks similar, but the undefineds aren't there. FWIW, the module does work "properly" in node.

@asutherland
Copy link
Contributor Author

er, and when RequireJS goes and requires the file, it gets undefined out. I double-checked by going to require.s.contexts._.defined["mailparser/datetime"] and its value is undefined there too.

@jrburke jrburke closed this as completed in 3e0a02f Apr 5, 2012
@jrburke
Copy link
Member

jrburke commented Apr 5, 2012

This should be fetched in master:
https://raw.github.com/volojs/volo/master/dist/volo

so the converted file would now look like:

define(function (require, exports, module) {

  this.strtotime = function(str, now) {
  }

});

which should also work in requirejs. The "this" binding should be the exports object for the define factory call with the above conversion syntax.

@asutherland
Copy link
Contributor Author

Woo, thanks! I had a look at the source but the specific problem did not jump out at me. Glad to see it was obvious to you!

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

2 participants