mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 12:12:26 +08:00
DEV: Use patch-package to apply ember-jquery workaround
Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
parent
47eced2050
commit
c320c286f9
|
@ -1,46 +0,0 @@
|
|||
import { assert, deprecate } from "@ember/debug";
|
||||
import EmberObject from "@ember/object";
|
||||
import Component from "@ember/component";
|
||||
import jQuery from "jquery";
|
||||
|
||||
let done = false;
|
||||
|
||||
// Adapted from https://github.com/emberjs/ember-jquery/blob/master/vendor/jquery/component.dollar.js
|
||||
// but implemented in a module to avoid transpiled version triggering the Ember Global deprecation.
|
||||
// To be dropped when we remove the jquery integration as part of the 4.x update.
|
||||
export default {
|
||||
name: "deprecate-jquery-integration",
|
||||
|
||||
initialize() {
|
||||
if (done) {
|
||||
return;
|
||||
}
|
||||
|
||||
EmberObject.reopen.call(Component, {
|
||||
$(sel) {
|
||||
assert(
|
||||
"You cannot access this.$() on a component with `tagName: ''` specified.",
|
||||
this.tagName !== ""
|
||||
);
|
||||
|
||||
deprecate(
|
||||
"Using this.$() in a component has been deprecated, consider using this.element",
|
||||
false,
|
||||
{
|
||||
id: "ember-views.curly-components.jquery-element",
|
||||
since: "3.4.0",
|
||||
until: "4.0.0",
|
||||
url: "https://emberjs.com/deprecations/v3.x#toc_jquery-apis",
|
||||
for: "ember-source",
|
||||
}
|
||||
);
|
||||
|
||||
if (this.element) {
|
||||
return sel ? jQuery(sel, this.element) : jQuery(this.element);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
done = true;
|
||||
},
|
||||
};
|
|
@ -163,16 +163,6 @@ module.exports = function (defaults) {
|
|||
}
|
||||
};
|
||||
|
||||
// @ember/jquery introduces a shim which triggers the ember-global deprecation.
|
||||
// We remove that shim, and re-implement ourselves in the deprecate-jquery-integration pre-initializer
|
||||
const vendorScripts = app._scriptOutputFiles["/assets/vendor.js"];
|
||||
const componentDollarShimIndex = vendorScripts.indexOf(
|
||||
"vendor/jquery/component.dollar.js"
|
||||
);
|
||||
if (componentDollarShimIndex) {
|
||||
vendorScripts.splice(componentDollarShimIndex, 1);
|
||||
}
|
||||
|
||||
// WARNING: We should only import scripts here if they are not in NPM.
|
||||
// For example: our very specific version of bootstrap-modal.
|
||||
app.import(vendorJs + "bootbox.js");
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"postinstall": "patch-package"
|
||||
},
|
||||
"workspaces": [
|
||||
"admin",
|
||||
"bootstrap-json",
|
||||
|
@ -19,5 +22,9 @@
|
|||
"resolutions": {
|
||||
"**/babel-plugin-debug-macros": "npm:@discourse/babel-plugin-debug-macros@0.4.0-pre1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"patch-package": "^6.5.1",
|
||||
"postinstall-postinstall": "^2.1.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
32
app/assets/javascripts/patches/@ember+jquery+2.0.0.patch
Normal file
32
app/assets/javascripts/patches/@ember+jquery+2.0.0.patch
Normal file
|
@ -0,0 +1,32 @@
|
|||
diff --git a/node_modules/@ember/jquery/vendor/jquery/component.dollar.js b/node_modules/@ember/jquery/vendor/jquery/component.dollar.js
|
||||
index 8c0cfd5..4c211e2 100644
|
||||
--- a/node_modules/@ember/jquery/vendor/jquery/component.dollar.js
|
||||
+++ b/node_modules/@ember/jquery/vendor/jquery/component.dollar.js
|
||||
@@ -1,8 +1,16 @@
|
||||
import { assert, deprecate } from '@ember/debug';
|
||||
-import EmberObject from '@ember/object';
|
||||
-import Component from '@ember/component';
|
||||
|
||||
(function() {
|
||||
+ // importing these, specifically, is done so that we don't trigger the
|
||||
+ // ember-global deprecation
|
||||
+ //
|
||||
+ // We had tried to import at the top of this file, but there is a build time transform
|
||||
+ // removing those, and re-triggering the ember-global deprecation.
|
||||
+ // See: https://deprecations.emberjs.com/v3.x#toc_ember-global
|
||||
+ // for more information
|
||||
+ const EmberObject = require("@ember/object").default;
|
||||
+ const Component = require("@ember/component").default;
|
||||
+
|
||||
/*
|
||||
* This non-standard use of `reopen` and `call` allows the component
|
||||
* base class to be reopened without triggering the
|
||||
@@ -28,6 +36,8 @@ import Component from '@ember/component';
|
||||
);
|
||||
|
||||
if (this.element) {
|
||||
+ // same technique the shim uses
|
||||
+ let jQuery = self['jQuery'];
|
||||
return sel ? jQuery(sel, this.element) : jQuery(this.element);
|
||||
}
|
||||
}
|
|
@ -1845,6 +1845,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
|
||||
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
|
||||
|
||||
"@yarnpkg/lockfile@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
|
||||
integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==
|
||||
|
||||
a11y-dialog@7.5.2:
|
||||
version "7.5.2"
|
||||
resolved "https://registry.yarnpkg.com/a11y-dialog/-/a11y-dialog-7.5.2.tgz#8174d3f71a05d8d5a02ebae515384c747910391c"
|
||||
|
@ -3079,7 +3084,7 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4
|
|||
escape-string-regexp "^1.0.5"
|
||||
supports-color "^5.3.0"
|
||||
|
||||
chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1:
|
||||
chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
|
||||
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
|
||||
|
@ -3470,7 +3475,7 @@ cors@~2.8.5:
|
|||
object-assign "^4"
|
||||
vary "^1"
|
||||
|
||||
cross-spawn@^6.0.0:
|
||||
cross-spawn@^6.0.0, cross-spawn@^6.0.5:
|
||||
version "6.0.5"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
|
||||
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
|
||||
|
@ -5304,7 +5309,7 @@ fs-extra@^8.0.0, fs-extra@^8.0.1, fs-extra@^8.1.0:
|
|||
jsonfile "^4.0.0"
|
||||
universalify "^0.1.0"
|
||||
|
||||
fs-extra@^9.0.1, fs-extra@^9.1.0:
|
||||
fs-extra@^9.0.0, fs-extra@^9.0.1, fs-extra@^9.1.0:
|
||||
version "9.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
|
||||
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
|
||||
|
@ -5574,6 +5579,11 @@ gopd@^1.0.1:
|
|||
dependencies:
|
||||
get-intrinsic "^1.1.3"
|
||||
|
||||
graceful-fs@^4.1.11:
|
||||
version "4.2.11"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
|
||||
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
|
||||
|
||||
graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.9:
|
||||
version "4.2.9"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96"
|
||||
|
@ -6033,6 +6043,13 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.4:
|
|||
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
|
||||
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==
|
||||
|
||||
is-ci@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c"
|
||||
integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==
|
||||
dependencies:
|
||||
ci-info "^2.0.0"
|
||||
|
||||
is-core-module@^2.9.0:
|
||||
version "2.9.0"
|
||||
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.9.0.tgz#e1c34429cd51c6dd9e09e0799e396e27b19a9c69"
|
||||
|
@ -6259,7 +6276,7 @@ is-windows@^1.0.1, is-windows@^1.0.2:
|
|||
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
|
||||
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
|
||||
|
||||
is-wsl@^2.2.0:
|
||||
is-wsl@^2.1.1, is-wsl@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
|
||||
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
|
||||
|
@ -6508,6 +6525,13 @@ kind-of@^6.0.0, kind-of@^6.0.2:
|
|||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
|
||||
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
|
||||
|
||||
klaw-sync@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
|
||||
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
|
||||
dependencies:
|
||||
graceful-fs "^4.1.11"
|
||||
|
||||
leek@0.0.24:
|
||||
version "0.0.24"
|
||||
resolved "https://registry.yarnpkg.com/leek/-/leek-0.0.24.tgz#e400e57f0e60d8ef2bd4d068dc428a54345dbcda"
|
||||
|
@ -7088,6 +7112,11 @@ minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
|
|||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
|
||||
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==
|
||||
|
||||
minimist@^1.2.6:
|
||||
version "1.2.8"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
|
||||
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
|
||||
|
||||
minipass@^2.2.0:
|
||||
version "2.9.0"
|
||||
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6"
|
||||
|
@ -7452,6 +7481,14 @@ onetime@^5.1.0, onetime@^5.1.2:
|
|||
dependencies:
|
||||
mimic-fn "^2.1.0"
|
||||
|
||||
open@^7.4.2:
|
||||
version "7.4.2"
|
||||
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
|
||||
integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
|
||||
dependencies:
|
||||
is-docker "^2.0.0"
|
||||
is-wsl "^2.1.1"
|
||||
|
||||
optionator@^0.8.1:
|
||||
version "0.8.3"
|
||||
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"
|
||||
|
@ -7619,6 +7656,26 @@ pascalcase@^0.1.1:
|
|||
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
|
||||
integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=
|
||||
|
||||
patch-package@^6.5.1:
|
||||
version "6.5.1"
|
||||
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.5.1.tgz#3e5d00c16997e6160291fee06a521c42ac99b621"
|
||||
integrity sha512-I/4Zsalfhc6bphmJTlrLoOcAF87jcxko4q0qsv4bGcurbr8IskEOtdnt9iCmsQVGL1B+iUhSQqweyTLJfCF9rA==
|
||||
dependencies:
|
||||
"@yarnpkg/lockfile" "^1.1.0"
|
||||
chalk "^4.1.2"
|
||||
cross-spawn "^6.0.5"
|
||||
find-yarn-workspace-root "^2.0.0"
|
||||
fs-extra "^9.0.0"
|
||||
is-ci "^2.0.0"
|
||||
klaw-sync "^6.0.0"
|
||||
minimist "^1.2.6"
|
||||
open "^7.4.2"
|
||||
rimraf "^2.6.3"
|
||||
semver "^5.6.0"
|
||||
slash "^2.0.0"
|
||||
tmp "^0.0.33"
|
||||
yaml "^1.10.2"
|
||||
|
||||
path-exists@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
|
||||
|
@ -7790,6 +7847,11 @@ postcss@^8.2.15:
|
|||
picocolors "^1.0.0"
|
||||
source-map-js "^1.0.1"
|
||||
|
||||
postinstall-postinstall@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
|
||||
integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==
|
||||
|
||||
preact@^10.5.13:
|
||||
version "10.5.14"
|
||||
resolved "https://registry.yarnpkg.com/preact/-/preact-10.5.14.tgz#0b14a2eefba3c10a57116b90d1a65f5f00cd2701"
|
||||
|
@ -8503,6 +8565,11 @@ sinon@^15.0.3:
|
|||
nise "^5.1.4"
|
||||
supports-color "^7.2.0"
|
||||
|
||||
slash@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
|
||||
integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==
|
||||
|
||||
slash@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
|
||||
|
@ -9746,6 +9813,11 @@ yam@^1.0.0:
|
|||
fs-extra "^4.0.2"
|
||||
lodash.merge "^4.6.0"
|
||||
|
||||
yaml@^1.10.2:
|
||||
version "1.10.2"
|
||||
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
|
||||
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
|
||||
|
||||
yocto-queue@^0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
|
||||
|
|
Loading…
Reference in New Issue
Block a user