thlorenz / browserify-shim

📩 Makes CommonJS incompatible files browserifyable.
MIT License
933 stars 87 forks source link

All dependencies are global by default #201

Closed RobertSasak closed 8 years ago

RobertSasak commented 8 years ago

I included an old library that depends on jQuery. I am lucky enough that old widget do not touch window, but still it need access to variable jQuery. So I wrote following shim and make everything work.

"browserify-shim": {
        "./libs/widget.js": {
            "exports": "widget",
            "depends": [
                "jQuery:jQuery"
            ]
        }
    },

However now jQuery is attached to global namespace. This happens due following line in https://github.com/thlorenz/browserify-shim/blob/master/index.js#L62

jQuery = global.jQuery = require("jquery");

I do not need jQuery to be global, is there a way to prevent this behaviour? I would need only following line to be prepended.

jQuery = require("jquery");
bendrucker commented 8 years ago

No, there isn't a way to do that. browserify-shim tries to achieve maximum compatibility, even though that might expose some variables that don't need exposing.