Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#14581 closed bug (notabug)

global jquery available when using the npm module

Reported by: [email protected] 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 [email protected]
var $ = require('jquery/dist/jquery')(window);
    console.log(!!window.jQuery); // logs true

browserify the above and check the console.

Change History (4)

comment:1 Changed 9 years ago by m_gol

Cc: timmywil added
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

comment:2 Changed 9 years ago by timmywil

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.

comment:3 Changed 9 years ago by [email protected]

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

comment:4 Changed 9 years ago by timmywil

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.

Note: See TracTickets for help on using tickets.