From b5f40398af0d5b461a757c94ae4ab7133a7c1e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 21 Dec 2021 17:55:21 +0100 Subject: [PATCH 1/2] Fix derived classes in Chrome <= 36 --- packages/babel-helpers/src/helpers.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/babel-helpers/src/helpers.ts b/packages/babel-helpers/src/helpers.ts index 891aad0d2815..b5c0ac830532 100644 --- a/packages/babel-helpers/src/helpers.ts +++ b/packages/babel-helpers/src/helpers.ts @@ -335,16 +335,16 @@ helpers.inherits = helper("7.0.0-beta.0")` if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } - Object.defineProperty(subClass, "prototype", { - value: Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }), - writable: false, + // We can't use defineProperty to set the prototype in a single step because it + // doesn't work in Chrome <= 36. https://github.com/babel/babel/issues/14056 + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } }); + Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) setPrototypeOf(subClass, superClass); } `; From 10e73c8d14b123ab67481ab610247c0cacde35fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 23 Dec 2021 18:25:21 +0100 Subject: [PATCH 2/2] Update packages/babel-helpers/src/helpers.ts --- packages/babel-helpers/src/helpers.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/babel-helpers/src/helpers.ts b/packages/babel-helpers/src/helpers.ts index b5c0ac830532..80ee32905a72 100644 --- a/packages/babel-helpers/src/helpers.ts +++ b/packages/babel-helpers/src/helpers.ts @@ -337,6 +337,7 @@ helpers.inherits = helper("7.0.0-beta.0")` } // We can't use defineProperty to set the prototype in a single step because it // doesn't work in Chrome <= 36. https://github.com/babel/babel/issues/14056 + // V8 bug: https://bugs.chromium.org/p/v8/issues/detail?id=3334 subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass,