Skip to content

Commit

Permalink
fix(error): polyfill AggregateError in older environments (#3129)
Browse files Browse the repository at this point in the history
Refs #3128
  • Loading branch information
char0n authored Sep 7, 2023
1 parent d2bb70c commit 484d9e6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
17 changes: 7 additions & 10 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ module.exports = {
'@babel/preset-env',
{
debug: false,
modules: false,
modules: "commonjs",
loose: true,
useBuiltIns: false,
corejs: 3,
targets: {
node: '12.22.0',
},
Expand All @@ -24,16 +27,10 @@ module.exports = {
'@babel/preset-typescript',
],
plugins: [
[
'@babel/plugin-transform-modules-commonjs',
{
loose: true,
},
],
[
'@babel/plugin-transform-runtime',
{
corejs: 3,
corejs: { version: 3 },
version: '^7',
},
],
Expand Down Expand Up @@ -64,7 +61,7 @@ module.exports = {
[
'@babel/plugin-transform-runtime',
{
corejs: 3,
corejs: { version: 3 },
version: '^7',
useESModules: true,
},
Expand All @@ -91,7 +88,7 @@ module.exports = {
[
'@babel/plugin-transform-runtime',
{
corejs: 3,
corejs: { version: 3 },
version: '^7',
useESModules: true,
},
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"@babel/core": "=7.22.15",
"@babel/plugin-proposal-class-properties": "=7.18.6",
"@babel/plugin-proposal-object-rest-spread": "=7.20.7",
"@babel/plugin-transform-modules-commonjs": "=7.22.15",
"@babel/plugin-transform-runtime": "=7.22.15",
"@babel/preset-env": "=7.22.15",
"@babel/preset-typescript": "=7.22.15",
Expand Down
11 changes: 9 additions & 2 deletions packages/apidom-error/src/ApiDOMAggregateError.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { isPlainObject } from 'ramda-adjunct';
import { hasIn } from 'ramda';
// @ts-ignore
import AggregateErrorPolyfill from '@babel/runtime-corejs3/core-js/aggregate-error';

import ApiDOMErrorOptions from './ApiDOMErrorOptions';

const AggregateError: AggregateErrorConstructor =
globalThis.AggregateError ?? AggregateErrorPolyfill;
/**
* ApiDOMAggregateError is using polyfill of AggregateError from core-js-pure
* in environments which don't support global AggregateError symbol.
*/
class ApiDOMAggregateError extends AggregateError {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(errors: Iterable<any>, message?: string, options?: ApiDOMErrorOptions) {
constructor(errors: Iterable<unknown>, message?: string, options?: ApiDOMErrorOptions) {
super(errors, message, options);

this.name = this.constructor.name;
Expand Down

0 comments on commit 484d9e6

Please sign in to comment.