Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
// Next for Node.js or CommonJS. jQuery may not be needed as a module.
} else if (typeof exports !== 'undefined') {
var _ = require('underscore'), $;
try { $ = require('jquery'); } catch (e) {}
// Indirect the optional jQuery require through a variable so that
// Webpack, Rollup, esbuild, packd and friends do not try to resolve
// it at bundle time. The literal `require('jquery')` form was being
// statically analyzed by bundlers and failing the build for users
// who don't actually want jQuery (#4184).
var nodeRequire = typeof require === 'function' && require;
try { if (nodeRequire) $ = nodeRequire('jquery'); } catch (e) {}
factory(root, exports, _, $);

// Finally, as a browser global.
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
"dependencies": {
"underscore": ">=1.8.3"
},
"peerDependencies": {
"jquery": ">=1.11.0"
},
"peerDependenciesMeta": {
"jquery": {
"optional": true
}
},
"devDependencies": {
"coffeescript": "^2.7.0",
"cpy-cli": "^5.0.0",
Expand Down
Loading