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

Allow addon to provide jQuery to final build, but not include Ember <-> jQuery integration. #148

Merged
merged 1 commit into from Oct 2, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Expand Up @@ -2,8 +2,11 @@ ember-jquery
==============================================================================

Ember has been historically coupled to jQuery. As part of
[RFC294](https://github.com/emberjs/rfcs/blob/master/text/0294-optional-jquery.md#introduce-emberjquery-package)
jQuery has been made optional and this addon will explicitly add the jQuery integration functionality.
[RFC294](https://github.com/emberjs/rfcs/blob/master/text/0294-optional-jquery.md#introduce-emberjquery-package),
jQuery has been made optional.

This addon makes jQuery available in an Ember project. It also provides the mechanism that implements jQuery
integration when that feature is enabled.


Compatibility
Expand All @@ -21,7 +24,7 @@ Installation
ember install @ember/jquery
```

You should also explicitly tell Ember to enable its jQuery integration:
If you also wish to enable Ember's jQuery integration, you must do so explicitly:

```bash
ember install @ember/optional-features
Expand Down
16 changes: 16 additions & 0 deletions config/ember-try.js
Expand Up @@ -41,6 +41,22 @@ module.exports = function() {
}
}
},
{
name: 'ember-lts-3.8',
npm: {
devDependencies: {
'ember-source': '~3.8.0'
}
}
},
{
name: 'ember-lts-3.12',
npm: {
devDependencies: {
'ember-source': '~3.12.0'
}
}
},
{
name: 'ember-release',
npm: {
Expand Down
13 changes: 6 additions & 7 deletions index.js
Expand Up @@ -10,24 +10,23 @@ module.exports = {
const VersionChecker = require('ember-cli-version-checker');

let app = this._findHost();
let optionalFeatures = app.project.findAddonByName("@ember/optional-features");


if (!app.vendorFiles || !app.vendorFiles['jquery.js']) {
app.import('vendor/jquery/jquery.js', { prepend: true });
}

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

let optionalFeatures = app.project.findAddonByName("@ember/optional-features");
let integrationTurnedOff = optionalFeatures && !optionalFeatures.isFeatureEnabled('jquery-integration');

let checker = new VersionChecker(this);
let ember = checker.forEmber();

if (ember.gte(EMBER_VERSION_WITH_JQUERY_DEPRECATION)) {
if (ember.gte(EMBER_VERSION_WITH_JQUERY_DEPRECATION) && !integrationTurnedOff) {
app.import('vendor/jquery/component.dollar.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(tree) {
Expand Down