camel case is weird #1

substack opened this Issue Mar 31, 2013 · 8 comments


None yet
3 participants

I would expect this to define window.ABCDEFG to 555, but instead it defines window.aBCDEFG which is weird and surprising in a bad way.

$ browserify --standalone ABCDEFG <(echo 'module.exports = 555')
(function(e){if("function"==typeof bootstrap)bootstrap("abcdefg",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeABCDEFG=e}else"undefined"!=typeof window?window.aBCDEFG=e():global.aBCDEFG=e()})(function(){var define,ses,bootstrap,module,exports;
return (function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0](function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
module.exports = 555


ForbesLindesay commented Mar 31, 2013

I agree, this should be better. The reasoning was that I wanted people to enter "node" style names, which should all be lower case anyway. I guess the best bet is to respect the initial casing of letters, except immediately after dashes, so:

umd('abcd-efgh') becomes window.abcdEfgh
umd('Abcd-egh') becomes window.AbcdEgh
umd('ABCD-EGH') becomes window.ABCDEGH')

I'll still force all lower-case on Montage Require's bootstrap function, since I think that's node like in nature. And I'll continue to force upper case on first letter for all the Pascal Cased methods.


ForbesLindesay commented Mar 31, 2013

Released as 1.1.0

Looks good.


ForbesLindesay commented Mar 31, 2013


@substack substack referenced this issue in browserify/browserify Apr 1, 2013


-s is giving strange, invalid JS #369

Great, this was throwing me off as well. I need Ctor not ctor. Thanks!


ForbesLindesay commented Apr 2, 2013

Glad this has improved things

@ForbesLindesay right now im .replace()ing it after browserify returns the blob because it wasn't implemented into browserify at the time. I'll check out the latest browserify soon tho :)


ForbesLindesay commented Apr 8, 2013

It should be implemented in the latest browserify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment