Change Rollup config to wrap our dist files with jQuery instead of $

This commit is contained in:
Johann-S 2017-10-24 10:12:45 +02:00
parent ca4ad8bee8
commit 62fbb23ee6
15 changed files with 24 additions and 50 deletions

View File

@ -20,7 +20,7 @@ const plugins = [
})
]
const globals = {
jquery: '$',
jquery: 'jQuery', // ensure we use jQuery which is always available even in noConflict mode
'popper.js': 'Popper'
}

View File

@ -9,7 +9,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Alert = (() => {
const Alert = (($) => {
/**
@ -189,6 +189,6 @@ const Alert = (() => {
return Alert
})(Util.jQuery)
})($)
export default Alert

View File

@ -1,5 +1,4 @@
import $ from 'jquery'
import Util from './util'
/**
* --------------------------------------------------------------------------
@ -8,7 +7,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Button = (() => {
const Button = (($) => {
/**
@ -184,6 +183,6 @@ const Button = (() => {
return Button
})(Util.jQuery)
})($)
export default Button

View File

@ -9,7 +9,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Carousel = (() => {
const Carousel = (($) => {
/**
@ -519,6 +519,6 @@ const Carousel = (() => {
return Carousel
})(Util.jQuery)
})($)
export default Carousel

View File

@ -9,7 +9,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Collapse = (() => {
const Collapse = (($) => {
/**
@ -404,6 +404,6 @@ const Collapse = (() => {
return Collapse
})(Util.jQuery)
})($)
export default Collapse

View File

@ -10,7 +10,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Dropdown = (() => {
const Dropdown = (($) => {
/**
* Check for Popper dependency
@ -445,6 +445,6 @@ const Dropdown = (() => {
return Dropdown
})(Util.jQuery, Popper)
})($, Popper)
export default Dropdown

View File

@ -18,7 +18,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
(() => {
(($) => {
if (typeof $ === 'undefined') {
throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.')
}
@ -33,7 +33,7 @@ import Util from './util'
if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0')
}
})(Util.jQuery)
})($)
export {
Util,

View File

@ -9,7 +9,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Modal = (() => {
const Modal = (($) => {
/**
@ -585,6 +585,6 @@ const Modal = (() => {
return Modal
})(Util.jQuery)
})($)
export default Modal

View File

@ -1,6 +1,5 @@
import $ from 'jquery'
import Tooltip from './tooltip'
import Util from './util'
/**
@ -10,7 +9,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Popover = (() => {
const Popover = (($) => {
/**
@ -190,6 +189,6 @@ const Popover = (() => {
return Popover
})(Util.jQuery)
})($)
export default Popover

View File

@ -9,7 +9,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const ScrollSpy = (() => {
const ScrollSpy = (($) => {
/**
@ -335,6 +335,6 @@ const ScrollSpy = (() => {
return ScrollSpy
})(Util.jQuery)
})($)
export default ScrollSpy

View File

@ -9,7 +9,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Tab = (() => {
const Tab = (($) => {
/**
@ -282,6 +282,6 @@ const Tab = (() => {
return Tab
})(Util.jQuery)
})($)
export default Tab

View File

@ -10,7 +10,7 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Tooltip = (() => {
const Tooltip = (($) => {
/**
* Check for Popper dependency
@ -728,6 +728,6 @@ const Tooltip = (() => {
return Tooltip
})(Util.jQuery, Popper)
})($, Popper)
export default Tooltip

View File

@ -7,7 +7,7 @@ import $ from 'jquery'
* --------------------------------------------------------------------------
*/
const Util = (() => {
const Util = (($) => {
/**
@ -152,10 +152,6 @@ const Util = (() => {
}
}
}
},
get jQuery() {
return window.jQuery || window.$
}
}

View File

@ -119,7 +119,6 @@
<script src="unit/tab.js"></script>
<script src="unit/tooltip.js"></script>
<script src="unit/popover.js"></script>
<script src="unit/util.js"></script>
</head>
<body>
<div id="qunit-container">

View File

@ -1,19 +0,0 @@
$(function () {
'use strict'
QUnit.module('Util')
QUnit.test('Util.jQuery should find window.jQuery if window.$ is not available', function (assert) {
assert.expect(1)
delete window.$
assert.strictEqual(Util.jQuery, window.jQuery)
window.$ = Util.jQuery
})
QUnit.test('Util.jQuery should find window.$ if window.jQuery is not available', function (assert) {
assert.expect(1)
delete window.jQuery
assert.strictEqual(Util.jQuery, window.$)
window.jQuery = Util.jQuery
})
})