Skip to content

Commit

Permalink
Remove jQuery from build
Browse files Browse the repository at this point in the history
Removes jQuery from dependencies, the build process and test runs.
  • Loading branch information
simonihmig committed Jul 22, 2021
1 parent 860f334 commit 1689cfb
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 87 deletions.
6 changes: 0 additions & 6 deletions bin/run-tests.js
Expand Up @@ -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() {
Expand Down
8 changes: 0 additions & 8 deletions broccoli/packages.js
Expand Up @@ -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'],
Expand Down
9 changes: 1 addition & 8 deletions ember-cli-build.js
Expand Up @@ -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() {
Expand Down
49 changes: 6 additions & 43 deletions lib/index.js
Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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'
);
}
},
Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -319,6 +282,6 @@ module.exports = {
});
}

return debugTree(new MergeTrees([ember, templateCompiler, jquery]), 'vendor:final');
return debugTree(new MergeTrees([ember, templateCompiler]), 'vendor:final');
},
};
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions packages/jquery/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions tests/index.html
Expand Up @@ -29,14 +29,6 @@
// Close the script tag to make sure document.write happens
</script>

<script type="text/javascript">
// Fallback to default jQuery
if (jQueryVersion !== 'none' && !window.jQuery) {
loadScript('./jquery/jquery.js');
}
// Close the script tag to make sure document.write happens
</script>

<script>
(function() {
window.EmberENV = window.EmberENV || {};
Expand Down
15 changes: 5 additions & 10 deletions yarn.lock
Expand Up @@ -955,6 +955,8 @@
version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.12.1.tgz#07640f28867ed16f9511c99c888291f560921cfa"
integrity sha512-Zaeq10naAsuHo7heQvyV0ptj4dlZJwZgNAtBYBnu5nNKJoW62m0zKcIEyVECrUKErkUkg6ajMy4ZfnVZciSBhg==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-transform-for-of@^7.9.0":
version "7.9.0"
Expand Down Expand Up @@ -5232,6 +5234,9 @@ find-babel-config@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/find-babel-config/-/find-babel-config-1.2.0.tgz#a9b7b317eb5b9860cda9d54740a8c8337a2283a2"
integrity sha512-jB2CHJeqy6a820ssiqwrKMeyC6nNdmrcgkKWJWmpoxpE8RKciYJXCcXRq1h2AzCo5I5BJeN2tkGEO3hLTuePRA==
dependencies:
json5 "^0.5.1"
path-exists "^3.0.0"

find-index@^1.1.0:
version "1.1.0"
Expand Down Expand Up @@ -6526,11 +6531,6 @@ jmespath@0.15.0:
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217"
integrity "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc= sha512-+kHj8HXArPfpPEKGLZ+kB5ONRTCiGQXo8RQYL0hH8t6pWXUBBK5KkkQmTNOwKK4LEsd0yTsgtjJVm4UBSZea4w=="

jquery@^3.5.1:
version "3.5.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==

js-reporters@1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/js-reporters/-/js-reporters-1.2.3.tgz#8febcab370539df62e09b95da133da04b11f6168"
Expand Down Expand Up @@ -6601,11 +6601,6 @@ json-stringify-safe@~5.0.0:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="

json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=

json5@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"
Expand Down

0 comments on commit 1689cfb

Please sign in to comment.