Skip to main content

Bug Tracker

Side navigation

#14561 closed bug (notabug)

Opened November 20, 2013 01:12PM UTC

Closed November 20, 2013 06:32PM UTC

Last modified November 20, 2013 06:33PM UTC

Don't set window.jQuery and window.$ when inside a commonjs environment

Reported by: niklas@narhinen.net Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.1.0-beta2
Keywords: Cc:
Blocked by: Blocking:
Description

If I try to bundle jquery as a dependency inside a redistributable standalone library with browserify I can't have my library polluting the global window namespace with my version of jQuery.

Please (re-)introduce behavior where window.jQuery and window.$ are only set if _not_ in a commonjs environment. This was the case at least for 1.10.2 but not anymore in 2.x.

Attachments (0)
Change History (3)

Changed November 20, 2013 01:42PM UTC by niklas@narhinen.net comment:1

If someone needs these globals for some plugin or such, they can trivially do var jquery = window.jQuery = window.$ = require('jquery');

Changed November 20, 2013 06:32PM UTC by timmywil comment:2

resolution: → notabug
status: newclosed

The variables are exposed in CommonJS for the sake of browser emulators, as is the case when jQuery is included with Node. However, we have been planning to add a build option to remove this exposure from jQuery (whether for the sake of CommonJS or AMD inclusion). Follow up in this ticket: #13566

Changed November 20, 2013 06:33PM UTC by timmywil comment:3

Sorry, I linked the same ticket twice. Follow up in this ticket: http://bugs.jquery.com/ticket/14016