Skip to content

Commit d5ff05c

Browse files
authored
Merge pull request #33 from simonihmig/jquery-shim
Add jQuery shim as part of RFC386
2 parents c2b439e + fa88a3a commit d5ff05c

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ module.exports = {
1111
app.import('vendor/jquery/jquery.js', { prepend: true });
1212
}
1313

14+
app.import('vendor/shims/jquery.js');
15+
1416
if (optionalFeatures && !optionalFeatures.isFeatureEnabled('jquery-integration')) {
1517
app.project.ui.writeDeprecateLine('You have disabled the `jquery-integration` optional feature. You now have to delete `@ember/jquery` from your package.json');
1618
}
1719
},
1820

19-
treeForVendor: function() {
21+
treeForVendor: function(tree) {
22+
const BroccoliMergeTrees = require('broccoli-merge-trees');
2023
const Funnel = require('broccoli-funnel');
2124
const resolve = require('resolve');
2225
const path = require('path');
@@ -35,6 +38,6 @@ module.exports = {
3538
files: ['jquery.js'],
3639
});
3740

38-
return jquery;
41+
return new BroccoliMergeTrees([jquery, tree]);
3942
},
4043
};

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
},
2222
"dependencies": {
2323
"broccoli-funnel": "^2.0.1",
24+
"broccoli-merge-trees": "^3.0.2",
2425
"ember-cli-babel": "^7.1.2",
2526
"jquery": "^3.3.1",
2627
"resolve": "^1.10.0"

tests/unit/.gitkeep

Whitespace-only changes.

tests/unit/import-jquery-test.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import jQuery from 'jquery';
2+
import { module, test } from 'qunit';
3+
4+
module('Unit | import-jquery', function() {
5+
6+
test('it works', function(assert) {
7+
assert.equal(jQuery, window.jQuery, 'jQuery shim return global jQuery');
8+
});
9+
});

vendor/shims/jquery.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(function() {
2+
function vendorModule() {
3+
'use strict';
4+
5+
return {
6+
'default': self['jquery'],
7+
__esModule: true,
8+
};
9+
}
10+
11+
define('jquery', [], vendorModule);
12+
})();

0 commit comments

Comments
 (0)