Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


-s is giving strange, invalid JS #369

OscarGodson opened this Issue · 3 comments

2 participants


So, I very well could be misunderstanding how to use this but I'm doing:

$ browserify -s index.js > browser.js


This results in:

(function(e){if("function"==typeof bootstrap)bootstrap("index.js",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.makeIndexjs=e}else"undefined"!=typeof window?window.indexjs=e():global.indexjs=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})({},{},[])(undefined)

There's quite a few things wrong here:

  1. two semicolons back to back?
  2. I get Error: Cannot find module 'undefined' when trying to use this code
  3. Ctor is never exported to window
  4. It's missing all the required modules

This seems super wrong and I must be blind. So, how would I:

Create a minified, concatenated, browser.js file? How do I create an unminified version of this file too?


-s takes the argument, which is the name you want to export as. You've set the export name to index.js and aren't loading any files. Do:

$ browserify -s NAME index.js > browser.js
@substack substack closed this

Awesome! A lot closer. This takes care of 2 and 4. 1, not sure, but not a huge deal. But for 3, it's exporting ctor when module.exports is exporting Ctor. I'm expecting it to be capitalized since that's what I put. Why is it lowercasing it?


This functionality is handled by the umd module.

You might be running into an issue that was very recently fixed ForbesLindesay/umd#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.