Skip to content

Commit

Permalink
add a workaround for Bun ~ 0.1.1 bug that define some globals with in…
Browse files Browse the repository at this point in the history
…correct property descriptors

https://github.com/Jarred-Sumner/bun/issues/399
  • Loading branch information
zloirock committed Jul 8, 2022
1 parent aeb28b6 commit cb8d8e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
## Changelog
##### Unreleased
- Added a workaround for Bun ~ 0.1.1 [bug](https://github.com/Jarred-Sumner/bun/issues/399) that define some globals with incorrect property descriptors
- Fixed order of errors throwing on iterator helpers

##### [3.23.3 - 2022.06.26](https://github.com/zloirock/core-js/releases/tag/v3.23.3)
Expand Down
12 changes: 11 additions & 1 deletion packages/core-js/modules/web.dom-exception.stack.js
@@ -1,5 +1,6 @@
'use strict';
var $ = require('../internals/export');
var global = require('../internals/global');
var getBuiltIn = require('../internals/get-built-in');
var createPropertyDescriptor = require('../internals/create-property-descriptor');
var defineProperty = require('../internals/object-define-property').f;
Expand All @@ -9,6 +10,7 @@ var inheritIfRequired = require('../internals/inherit-if-required');
var normalizeStringArgument = require('../internals/normalize-string-argument');
var DOMExceptionConstants = require('../internals/dom-exception-constants');
var clearErrorStack = require('../internals/clear-error-stack');
var DESCRIPTORS = require('../internals/descriptors');
var IS_PURE = require('../internals/is-pure');

var DOM_EXCEPTION = 'DOMException';
Expand All @@ -32,7 +34,15 @@ var DOMExceptionPrototype = $DOMException.prototype = NativeDOMException.prototy

var ERROR_HAS_STACK = 'stack' in Error(DOM_EXCEPTION);
var DOM_EXCEPTION_HAS_STACK = 'stack' in new NativeDOMException(1, 2);
var FORCED_CONSTRUCTOR = ERROR_HAS_STACK && !DOM_EXCEPTION_HAS_STACK;

// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
var descriptor = NativeDOMException && DESCRIPTORS && Object.getOwnPropertyDescriptor(global, DOM_EXCEPTION);

// Bun ~ 0.1.1 DOMException have incorrect descriptor and we can't redefine it
// https://github.com/Jarred-Sumner/bun/issues/399
var BUGGY_DESCRIPTOR = !!descriptor && !(descriptor.writable && descriptor.configurable);

var FORCED_CONSTRUCTOR = ERROR_HAS_STACK && !BUGGY_DESCRIPTOR && !DOM_EXCEPTION_HAS_STACK;

// `DOMException` constructor patch for `.stack` where it's required
// https://webidl.spec.whatwg.org/#es-DOMException-specialness
Expand Down

0 comments on commit cb8d8e0

Please sign in to comment.