Skip to main content

Bug Tracker

Side navigation

#14581 closed bug (notabug)

Opened November 27, 2013 09:28PM UTC

Closed December 02, 2013 03:42PM UTC

Last modified December 03, 2013 03:44PM UTC

global jquery available when using the npm module

Reported by: Owned by:
Priority: low Milestone: None
Component: build Version: 2.1.0-beta2
Keywords: Cc: timmywil
Blocked by: Blocking:

I'm still seeing a global jQuery.

npm install jquery@2.1.0-beta2
var $ = require('jquery/dist/jquery')(window);
    console.log(!!window.jQuery); // logs true

browserify the above and check the console.

Attachments (0)
Change History (4)

Changed November 28, 2013 08:33AM UTC by m_gol comment:1

cc: → timmywil
component: unfiledbuild
priority: undecidedlow

I think this was intended. A lot of jQuery plugins intend on the jQuery variable being available in the global scope so there's no safe way to avoid that.

Things in the browser land are different from the node one, even if coding via browserify.

The question is: does using browserify require for all of the dependencies, including jQuery plugins, to be converted to be registering as npm modules? If not, I'm opposed to changing the status quo; removing the global that is required is a much bigger problem than registering a global that is not used.

cc @timmywil on that

Changed December 02, 2013 03:42PM UTC by timmywil comment:2

resolution: → notabug
status: newclosed

This is intended behavior for browser emulators in Node. They will not work correctly without the global. $.noConflict(true) will remove it.

Changed December 02, 2013 04:12PM UTC by comment:3

Can you give an example of a browser emulator where this makes sense? I'd like to understand that use case. Thanks.

Changed December 03, 2013 03:44PM UTC by timmywil comment:4

The ticket for adding the global for CJS is here. We will be adding a build option to remove the global for both AMD and CJS environments.

Is there a use case where the global causes problems in the browser? If so, we can revisit.