thlorenz / browserify-shim

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

module.exports is defined for shimmed modules #198

Closed 88kami88 closed 8 years ago

88kami88 commented 8 years ago

I'm hoping for browserified jQuery to be attached to the window, but I don't believe it is. Per the README:

Makes define and also module be undefined, in order to fix improperly-authored libraries that need shimming but try anyway to use AMD or CommonJS.

If I'm reading this correctly then module should be undefined when the browserify-shim transform is run when jQuery executes this (https://github.com/jquery/jquery/blob/99e8ff1baa7ae341e94bb89c3e84570c7c3ad9ea/src/intro.js#L17):

if ( typeof module === "object" && typeof module.exports === "object" ) {

which should result in window.jQuery and window.$ being defined here https://github.com/jquery/jquery/blob/99e8ff1baa7ae341e94bb89c3e84570c7c3ad9ea/src/exports/global.js#L24-L26:

if ( !noGlobal ) { window.jQuery = window.$ = jQuery; }

However module and module.exports both end up being defined and jQuery is not attached to window.

I would like it attached to window because bootstrap expects it to be on window specifically. I don't want to add a <script> for jQuery. Please let me know what I'm doing wrong. Thanks in advance.

bendrucker commented 8 years ago

Have a feeling I know what's up here but I need your build config to investigate