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

[INTERNAL] Improve jQuery deprecation message #8399

Merged
merged 2 commits into from Feb 3, 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
6 changes: 5 additions & 1 deletion lib/broccoli/ember-app.js
Expand Up @@ -489,7 +489,11 @@ class EmberApp {
if (optionFeatures && !optionFeatures.isFeatureEnabled('jquery-integration')) {
return;
}
this.project.ui.writeDeprecateLine('Ember will stop including jQuery by default in an upcoming version. If you wish keep using jQuery in your application explicitly add `@ember/jquery` to your package.json');
this.project.ui.writeDeprecateLine(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgive me for being out of the loop, but is it not possible to put this in the ember-source addon itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right, and given that it's ember-source which is actually deprecating things (i.e. causing breaking changes in the future), it would make more sense to put it there. Especially that ember-source and ember-cli might not be used in lock step.

On the other hand, IIRC this was already added a while ago when we started to not include jQuery anymore (which historically ember-cli did, not ember-source!) when @ember/jquery is detected. So when we want to move that message to ember-source, we would probably have to check the ember-source version here, to not issue a deprecation message twice!?

A bit of shenanigans involved, but I can do it if we agree it's worth it!?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to print out where jquery is being included? We have a project with tons of dependencies and it would be a huge task to sift through all of those and figure out which one is using it.

'The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0. You can either' +
' opt-out of using jQuery, or install the `@ember/jquery` addon to provide the jQuery integration. Please' +
' consult the deprecation guide for further details: https://emberjs.com/deprecations/v3.x#toc_jquery-apis'
);
jqueryPath = ember.paths.jquery;
} else {
jqueryPath = `${this.bowerDirectory}/jquery/dist/jquery.js`;
Expand Down
93 changes: 75 additions & 18 deletions tests/unit/broccoli/ember-app-test.js
Expand Up @@ -468,6 +468,10 @@ describe('EmberApp', function() {
'bar': 'bar',
});

app = new EmberApp({
project,
});

app.trees.public = input.path();
app.addonTreesFor = function() {
return [
Expand Down Expand Up @@ -511,6 +515,10 @@ describe('EmberApp', function() {
'bar': 'bar',
});

app = new EmberApp({
project,
});

Copy link
Contributor Author

@simonihmig simonihmig Feb 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was required as app would be undefined otherwise. It accidentally worked before, as app was initialized and leaking from another test before.

app.trees.public = input.path();
app.addonTreesFor = function() {
return [
Expand Down Expand Up @@ -1644,27 +1652,76 @@ describe('EmberApp', function() {
});
});

it('shows ember-cli-shims deprecation', function() {
let root = path.resolve(__dirname, '../../fixtures/app/npm');
let project = setupProject(root);
project.require = function() {
return {
version: '5.0.0',

describe('deprecations', function() {
it('shows ember-cli-shims deprecation', function() {
let root = path.resolve(__dirname, '../../fixtures/app/npm');
let project = setupProject(root);
project.require = function() {
return {
version: '5.0.0',
};
};
project.initializeAddons = function() {
this.addons = [
{
name: 'ember-cli-babel',
pkg: { version: '5.0.0' },
},
];
};
};
project.initializeAddons = function() {
this.addons = [
{
name: 'ember-cli-babel',
pkg: { version: '5.0.0' },
},
];
};

app = new EmberApp({
project,
app = new EmberApp({
project,
});

expect(project.ui.output).to.contain("You have not included `ember-cli-shims` in your project's `bower.json` or `package.json`.");
});

expect(project.ui.output).to.contain("You have not included `ember-cli-shims` in your project's `bower.json` or `package.json`.");
describe('jQuery integration', function() {
it('shows deprecation', function() {
project.initializeAddons = function() {
this.addons = [
{ name: 'ember-source', paths: {} },
];
};
app = new EmberApp({ project });

expect(project.ui.output).to.contain(
'The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0'
);
});

it('does not show deprecation if the app has `@ember/jquery` installed', function() {
project.initializeAddons = function() {
this.addons = [
{ name: 'ember-source', paths: {} },
{ name: '@ember/jquery' },
];
};
app = new EmberApp({ project });
expect(project.ui.output).to.not.contain(
'The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0'
);
});

it('does not show deprecation if the app has `@ember/optional-features` with the `jquery-integration` FF turned off', function() {
project.initializeAddons = function() {
this.addons = [
{ name: 'ember-source', paths: {} },
{
name: '@ember/optional-features',
isFeatureEnabled() {
return false;
},
},
];
};
app = new EmberApp({ project, vendorFiles: { 'ember-testing.js': null } });
expect(project.ui.output).to.not.contain(
'The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0'
);
});
});
});
});