Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jQuery shim as part of RFC386 #33

Merged
merged 1 commit into from
Jan 22, 2019
Merged
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
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ module.exports = {
app.import('vendor/jquery/jquery.js', { prepend: true });
}

app.import('vendor/shims/jquery.js');

if (optionalFeatures && !optionalFeatures.isFeatureEnabled('jquery-integration')) {
app.project.ui.writeDeprecateLine('You have disabled the `jquery-integration` optional feature. You now have to delete `@ember/jquery` from your package.json');
}
},

treeForVendor: function() {
treeForVendor: function(tree) {
const BroccoliMergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
const resolve = require('resolve');
const path = require('path');
Expand All @@ -35,6 +38,6 @@ module.exports = {
files: ['jquery.js'],
});

return jquery;
return new BroccoliMergeTrees([jquery, tree]);
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^3.0.2",
"ember-cli-babel": "^7.1.2",
"jquery": "^3.3.1",
"resolve": "^1.9.0"
Expand Down
Empty file removed tests/unit/.gitkeep
Empty file.
9 changes: 9 additions & 0 deletions tests/unit/import-jquery-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import jQuery from 'jquery';
import { module, test } from 'qunit';

module('Unit | import-jquery', function() {

test('it works', function(assert) {
assert.equal(jQuery, window.jQuery, 'jQuery shim return global jQuery');
});
});
12 changes: 12 additions & 0 deletions vendor/shims/jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function() {
function vendorModule() {
'use strict';

return {
'default': self['jquery'],
__esModule: true,
};
}

define('jquery', [], vendorModule);
})();