From 1689cfbcf5c65bd6ec707029a4bdd6f068ac79e2 Mon Sep 17 00:00:00 2001 From: simonihmig Date: Thu, 22 Jul 2021 19:23:09 +0200 Subject: [PATCH] Remove jQuery from build Removes jQuery from dependencies, the build process and test runs. --- bin/run-tests.js | 6 ----- broccoli/packages.js | 8 ------- ember-cli-build.js | 9 +------- lib/index.js | 49 +++++----------------------------------- package.json | 1 - packages/jquery/index.js | 3 --- tests/index.html | 8 ------- yarn.lock | 15 ++++-------- 8 files changed, 12 insertions(+), 87 deletions(-) delete mode 100644 packages/jquery/index.js diff --git a/bin/run-tests.js b/bin/run-tests.js index d7cf15c0899..c414b603ec0 100755 --- a/bin/run-tests.js +++ b/bin/run-tests.js @@ -61,12 +61,6 @@ function generateTestsFor(packageName) { testFunctions.push(() => run('package=' + packageName + '&edition=classic')); testFunctions.push(() => run('package=' + packageName + '&prebuilt=true')); testFunctions.push(() => run('package=' + packageName + '&enableoptionalfeatures=true')); - - // TODO: this should ultimately be deleted (when all packages can run with and - // without jQuery) - if (packageName !== 'ember') { - testFunctions.push(() => run('package=' + packageName + '&jquery=none')); - } } function generateEachPackageTests() { diff --git a/broccoli/packages.js b/broccoli/packages.js index ab8f37c035f..7c19582105f 100644 --- a/broccoli/packages.js +++ b/broccoli/packages.js @@ -34,14 +34,6 @@ module.exports.routerES = function _routerES() { }); }; -module.exports.jquery = function _jquery() { - return new Funnel(findLib('jquery'), { - files: ['jquery.js'], - destDir: 'jquery', - annotation: 'jquery', - }); -}; - module.exports.loader = function _loader() { return new Funnel('packages/loader/lib', { files: ['index.js'], diff --git a/ember-cli-build.js b/ember-cli-build.js index d7587989b7c..cdf3daf58e6 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -249,14 +249,7 @@ function templateCompilerBundle(emberPackages, transpileTree) { } function testHarness() { - return new MergeTrees([ - emptyTestem(), - testPolyfills(), - testIndexHTML(), - loader(), - qunit(), - jquery(), - ]); + return new MergeTrees([emptyTestem(), testPolyfills(), testIndexHTML(), loader(), qunit()]); } function emptyTestem() { diff --git a/lib/index.js b/lib/index.js index 406ac88e808..19bf17a766f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -33,7 +33,6 @@ function add(paths, name, path) { add(paths, 'prod', 'vendor/ember/ember.js'); add(paths, 'debug', 'vendor/ember/ember.js'); add(paths, 'testing', 'vendor/ember/ember-testing.js'); -add(paths, 'jquery', 'vendor/ember/jquery/jquery.js'); add( absolutePaths, @@ -95,25 +94,6 @@ module.exports = { ); } - if ( - optionalFeaturesMissing || - typeof optionalFeatures.isFeatureExplicitlySet !== 'function' - ) { - message.push( - '* Unable to detect if jquery-integration is explicitly set to a value, please update `@ember/optional-features` to the latest version' - ); - } - - if ( - optionalFeaturesMissing || - (typeof optionalFeatures.isFeatureExplicitlySet === 'function' && - !optionalFeatures.isFeatureExplicitlySet('jquery-integration')) - ) { - message.push( - `* The jquery-integration optional feature should be explicitly set to a value under Octane, run \`ember feature:disable jquery-integration\` to disable it, or \`ember feature:enable jquery-integration\` to explicitly enable it` - ); - } - if ( optionalFeaturesMissing || optionalFeatures.isFeatureEnabled('application-template-wrapper') @@ -165,11 +145,12 @@ module.exports = { } this._jqueryIntegrationEnabled = - optionalFeaturesMissing || optionalFeatures.isFeatureEnabled('jquery-integration'); + !optionalFeaturesMissing && optionalFeatures.isFeatureEnabled('jquery-integration'); if (this._jqueryIntegrationEnabled) { - this.ui.writeWarnLine( - 'Setting the `jquery-integration` optional feature flag to `true`, or not providing a setting at all, has been deprecated. You must add the `@ember/optional-features` addon and set this feature to `false`. This warning will become an error in Ember 4.0.0.\n\nFor more information, see the deprecation guide: https://deprecations.emberjs.com/v3.x/#toc_optional-feature-jquery-integration' + const SilentError = require('silent-error'); + throw new SilentError( + 'Setting the `jquery-integration` optional feature flag to `true` was deprecated in Ember 3.x and removed in Ember 4.0.0. You must add the `@ember/optional-features` addon and set this feature to `false`.\n\nFor more information, see the deprecation guide: https://deprecations.emberjs.com/v3.x/#toc_optional-feature-jquery-integration' ); } }, @@ -237,10 +218,7 @@ module.exports = { false ); - let exclude = [ - isProduction ? 'ember-testing/**' : null, - !this._jqueryIntegrationEnabled ? 'jquery' : null, - ].filter((value) => value !== null); + let exclude = isProduction ? ['ember-testing/**'] : []; let emberFiles = new MergeTrees([new Funnel(packages, { exclude }), dependencies, headerFiles]); @@ -270,21 +248,6 @@ module.exports = { }, treeForVendor(tree) { - let jqueryPath; - - try { - jqueryPath = path.dirname( - resolve.sync('jquery/package.json', { basedir: this.project.root }) - ); - } catch (error) { - jqueryPath = path.dirname(require.resolve('jquery/package.json')); - } - - let jquery = new Funnel(jqueryPath + '/dist', { - destDir: 'ember/jquery', - files: ['jquery.js'], - }); - let templateCompiler = new Funnel(tree, { destDir: 'ember', include: ['ember-template-compiler.js', 'ember-template-compiler.map'], @@ -319,6 +282,6 @@ module.exports = { }); } - return debugTree(new MergeTrees([ember, templateCompiler, jquery]), 'vendor:final'); + return debugTree(new MergeTrees([ember, templateCompiler]), 'vendor:final'); }, }; diff --git a/package.json b/package.json index d3a51855060..8a2e320ae5d 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,6 @@ "ember-cli-version-checker": "^5.1.1", "ember-router-generator": "^2.0.0", "inflection": "^1.12.0", - "jquery": "^3.5.1", "resolve": "^1.17.0", "semver": "^7.3.4", "silent-error": "^1.1.1" diff --git a/packages/jquery/index.js b/packages/jquery/index.js deleted file mode 100644 index c8317ec057c..00000000000 --- a/packages/jquery/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { jQuery } from '@ember/-internals/views'; - -export default jQuery; diff --git a/tests/index.html b/tests/index.html index 663d9d1cb8d..0b8c9edf069 100644 --- a/tests/index.html +++ b/tests/index.html @@ -29,14 +29,6 @@ // Close the script tag to make sure document.write happens - -