nbubna / Case

String case utitility: convert, identify, flip, extend
http://nbubna.github.io/Case/
MIT License
282 stars 23 forks source link

1.2.0 is a broken release #12

Closed jasonkuhrt closed 9 years ago

jasonkuhrt commented 9 years ago

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:

screen shot 2015-01-27 at 2 44 43 pm

jasonkuhrt commented 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

nbubna commented 9 years ago

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.

jasonkuhrt commented 9 years ago

@nbubna this.module is false where module is true.

nbubna commented 9 years ago

That is so stupid, considering that 'this' is coming from (function() { ... }).call(this);

There's some dark node magic at work here.

jasonkuhrt commented 9 years ago

By false/true I mean _falsey_/_truthy_

nbubna commented 9 years ago

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.

jasonkuhrt commented 9 years ago

@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

nbubna commented 9 years ago

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.

:)

jasonkuhrt commented 9 years ago

@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.

nbubna commented 9 years ago

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. :)

nbubna commented 9 years ago

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);
jasonkuhrt commented 9 years ago

@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.

nbubna commented 9 years ago

Cool, i pushed it to master.

jasonkuhrt commented 9 years ago

@nbubna Seems good!

jasonkuhrt commented 9 years ago

Cut a release : )