Repository: ember-cli/ember-cli
Pull request #10195 (2023-02-25 19:25:45)

[CLEANUP] Remove automatic inclusion of jQuery in legacy Ember versions


Patch:
diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js
index 3769c8247..391b034ce 100644
--- a/lib/broccoli/ember-app.js
+++ b/lib/broccoli/ember-app.js
@@ -403,8 +403,6 @@ class EmberApp {
       isNull
     );
 
-    this._addJqueryInLegacyEmber();
-
     // If ember-testing.js is coming from Bower (not ember-source) and it does not
     // exist, then we remove it from vendor files. This is needed to support versions
     // of Ember older than 1.8.0 (when ember-testing.js was incldued in ember.js itself)
@@ -413,29 +411,6 @@ class EmberApp {
     }
   }
 
-  _addJqueryInLegacyEmber() {
-    if (this.project.findAddonByName('@ember/jquery')) {
-      return;
-    }
-    let ember = this.project.findAddonByName('ember-source');
-    let jqueryPath;
-    if (ember) {
-      let optionFeatures = this.project.findAddonByName('@ember/optional-features');
-      if (optionFeatures && !optionFeatures.isFeatureEnabled('jquery-integration')) {
-        return;
-      }
-      this.project.ui.writeDeprecateLine(
-        '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`;
-    }
-    this.vendorFiles = merge({ 'jquery.js': jqueryPath }, this.vendorFiles);
-  }
-
   /**
     Returns the environment name
 


Test patch:
diff --git a/tests/helpers/default-packager.js b/tests/helpers/default-packager.js
index 121b0a5c3..8ff3a1ee9 100644
--- a/tests/helpers/default-packager.js
+++ b/tests/helpers/default-packager.js
@@ -72,9 +72,6 @@ const DEFAULT_VENDOR = {
     'loader.js': 'W',
   },
   ember: {
-    jquery: {
-      'jquery.js': 'window.$ = function() {}',
-    },
     'ember.js': 'window.Ember = {};',
     'ember.debug.js': 'window.Ember = {};',
   },
diff --git a/tests/unit/broccoli/ember-app-test.js b/tests/unit/broccoli/ember-app-test.js
index bf274c4d1..583cf69c0 100644
--- a/tests/unit/broccoli/ember-app-test.js
+++ b/tests/unit/broccoli/ember-app-test.js
@@ -1196,7 +1196,7 @@ describe('EmberApp', function () {
   });
 
   describe('vendorFiles', function () {
-    let defaultVendorFiles = ['jquery.js', 'ember.js'];
+    let defaultVendorFiles = ['ember.js'];
 
     it('defines vendorFiles by default', function () {
       app = new EmberApp({
@@ -1227,35 +1227,6 @@ describe('EmberApp', function () {
       expect(Object.keys(app.vendorFiles)).to.deep.equal(defaultVendorFiles);
     });
 
-    it('does not include jquery if the app has `@ember/jquery` installed', function () {
-      project.initializeAddons = function () {
-        this.addons = [{ name: '@ember/jquery' }];
-      };
-      app = new EmberApp({ project });
-      let filesWithoutJQuery = defaultVendorFiles.filter((e) => e !== 'jquery.js');
-      expect(Object.keys(app.vendorFiles)).to.deep.equal(filesWithoutJQuery);
-    });
-
-    it('does not include jquery if the app has `@ember/optional-features` with the `jquery-integration` FF turned off', function () {
-      project.initializeAddons = function () {
-        this.addons = [
-          {
-            name: 'ember-source',
-            paths: { jquery: 'foo', testing: null },
-          },
-          {
-            name: '@ember/optional-features',
-            isFeatureEnabled() {
-              return false;
-            },
-          },
-        ];
-      };
-      app = new EmberApp({ project, vendorFiles: { 'ember-testing.js': null } });
-      let filesWithoutJQuery = defaultVendorFiles.filter((e) => e !== 'jquery.js');
-      expect(Object.keys(app.vendorFiles)).to.deep.equal(filesWithoutJQuery);
-    });
-
     it('removes dependency in vendorFiles', function () {
       app = new EmberApp({
         project,
@@ -1398,47 +1369,4 @@ describe('EmberApp', function () {
       });
     });
   });
-
-  describe('deprecations', function () {
-    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'
-        );
-      });
-    });
-  });
 });
diff --git a/tests/unit/broccoli/ember-app/import-test.js b/tests/unit/broccoli/ember-app/import-test.js
index ab07ee9b3..035b041f1 100644
--- a/tests/unit/broccoli/ember-app/import-test.js
+++ b/tests/unit/broccoli/ember-app/import-test.js
@@ -62,7 +62,6 @@ describe('EmberApp: Bower Dependencies', function () {
       validateDefaultPackagedDist('the-best-app-ever', results);
     }).not.to.throw();
     expect(results.assets['vendor.js']).to.contain('window.Ember = {');
-    expect(results.assets['vendor.js']).to.contain('window.$ = function() {');
     expect(results.assets['vendor.js']).to.not.contain('window.moment');
   });
 
@@ -91,7 +90,6 @@ describe('EmberApp: Bower Dependencies', function () {
       validateDefaultPackagedDist('the-best-app-ever', results);
     }).not.to.throw();
     expect(results.assets['vendor.js']).to.contain('window.Ember = {');
-    expect(results.assets['vendor.js']).to.contain('window.$ = function() {');
     expect(results.assets['vendor.js']).to.contain('window.moment');
   });