Closed jasonkuhrt closed 9 years ago
The bug is on this line https://github.com/nbubna/Case/blob/master/dist/Case.js#L129 See initial source and commit here https://github.com/nbubna/Case/commit/919b11058c0bf81226a89ec283428f4bd7b99b1e
Yeah, i figured as much. First, let me reiterate that i hate all module systems in JavaScript.
Second, that was to fix a problem when loading directly in the browser. I don't see how explicitly looking for 'module' in global (to prevent undefined reference warnings) would cause a structural change in the exports.
@nbubna this.module
is false
where module
is true
.
That is so stupid, considering that 'this' is coming from (function() { ... }).call(this);
There's some dark node magic at work here.
By false
/true
I mean _falsey_/_truthy_
Well, i don't have time to go looking up the latest and greatest UMD stuff now. Feel free to take a shot at it and PR this, otherwise, i'll try to make time tonight or tomorrow.
@nbubna In node all modules are wrapped already with a self-invoking function. I think its browsers that are magical and retarded by allowing implicit globals. But the entire JS community is fragmented with mostly lame tools etc. I feel your pain. In this case Node is a lot better than the browser though; you're just being bitten by optimizing for the crappier platform.
I'll see if I have time for a PR. For not I've just hard-pinned to 1.1.x
1) optimizing !== make functional 2) it sure looks like 'module' is functionally an implicit global in node, such that it's not clear how to test for its presence. At least in the browser, i know how to tell if something exists.
:)
@nbubna If I remember module
is implicit per module as it were. If it were truly global you'd have a whole bunch of other unholy problems.
Yep, that's why i said "functionally", not "truly". It's magic. It is always present, like a global, but always a different object. And no way to inquire of any other scope/object whether it is there without breaking it.
It's very clever, of course. Solves a tough problem in a very clever way. But all too often, too clever == stupid. :)
Seriously, don't take offense. The node/io guys have made a very cool and useful thing. But nothing is sacrosanct. :)
Ok, so would this work for you/node?
var define = typeof define === "function" ? define : function(){};
define(typeof module === "object" && module.exports ? module.exports = Case : this.Case = Case);
@nbubna Yes I think so! If you make a commit I can pull from master and try it to verify at least in my use-case.
Cool, i pushed it to master.
@nbubna Seems good!
Cut a release : )
At first I thought it was because of this https://github.com/nbubna/Case/commit/2ee18f3c19e3c4d1b8986b83e6e1c23a08094808#commitcomment-9465980 but I see that its not now. Instead it appears that the export type has changed from being an object of functions to a two-layer nested object structure, see: