On browserify-shim 's page they explicitly try to help with the use case I have:
Modules that just declare a var foo = ... on the script level and assume it gets attached to the window object. Since the only way they will ever be run is in the global context — "ahem, … NO?!"
I have a problem getting this to work. I have a test project with browserify and browserify and I am trying to use the following file as a browserify module:
Note that we use two inter-depending functions and jquery in the ugly.js file!
ugly.js:
var x = function() {
alert("im a global variable using jquery version:" +$.fn.jquery);
};
var y = function() {
x();
};
I want to use it in main.js:
var ugly = require("./ugly.js");
ugly.y();
I tried to add the following in my package.json but to no avail, the "ugly" module is not found....
package.json:
...snip...
"browserify": {
"transform": [
"browserify-shim"
]
},
"browserify-shim": {
"./ugly.js": "ugly"
}