From 1638c826bec65866e4a7321193e76e03e5778f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Fri, 20 Sep 2024 14:16:47 +0900 Subject: [PATCH 01/23] yarn lockfile --- yarn.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index dacc1b37e32b..cacdebeed9b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -152,10 +152,10 @@ __metadata: languageName: node linkType: hard -"@babel/compat-data@npm:^7.25.2": - version: 7.25.2 - resolution: "@babel/compat-data@npm:7.25.2" - checksum: fd61de9303db3177fc98173571f81f3f551eac5c9f839c05ad02818b11fe77a74daa632abebf7f423fbb4a29976ae9141e0d2bd7517746a0ff3d74cb659ad33a +"@babel/compat-data@npm:^7.25.4": + version: 7.25.4 + resolution: "@babel/compat-data@npm:7.25.4" + checksum: d37a8936cc355a9ca3050102e03d179bdae26bd2e5c99a977637376c192b23637a039795f153c849437a086727628c9860e2c6af92d7151396e2362c09176337 languageName: node linkType: hard @@ -4749,7 +4749,7 @@ __metadata: version: 0.0.0-use.local resolution: "@swc/workspace@workspace:." dependencies: - "@babel/compat-data": "npm:^7.25.2" + "@babel/compat-data": "npm:^7.25.4" "@babel/core": "npm:^7.13.16" "@babel/generator": "npm:^7.18.13" "@babel/plugin-proposal-class-properties": "npm:^7.13.0" @@ -4773,7 +4773,7 @@ __metadata: bootstrap: "npm:^5.2.1" class-validator: "npm:^0.13.1" core-js: "npm:^2.6.11" - core-js-compat: "npm:^3.38.0" + core-js-compat: "npm:^3.38.1" cross-env: "npm:^7.0.3" cspell: "npm:^5.12.3" expect: "npm:^27.4.2" @@ -7538,12 +7538,12 @@ __metadata: languageName: node linkType: hard -"core-js-compat@npm:^3.38.0": - version: 3.38.0 - resolution: "core-js-compat@npm:3.38.0" +"core-js-compat@npm:^3.38.1": + version: 3.38.1 + resolution: "core-js-compat@npm:3.38.1" dependencies: browserslist: "npm:^4.23.3" - checksum: 7ebdca6b305c9c470980e1f7e7a3d759add7cb754bff62926242907ee4d1d4e8bb13f70eb9a7d7769e0f63aec3f4cca83abf60f502286853b45d4b63a01c25ed + checksum: 4e2f219354fd268895f79486461a12df96f24ed307321482fe2a43529c5a64e7c16bcba654980ba217d603444f5141d43a79058aeac77511085f065c5da72207 languageName: node linkType: hard From 6c690527906d4038374dd9d59c4e00d6a3a8c250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Fri, 20 Sep 2024 14:17:57 +0900 Subject: [PATCH 02/23] Add a test --- .../tests/fixture/issues-9xxx/9544/input/.swcrc | 15 +++++++++++++++ .../swc/tests/fixture/issues-9xxx/9544/input/1.js | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 crates/swc/tests/fixture/issues-9xxx/9544/input/.swcrc create mode 100644 crates/swc/tests/fixture/issues-9xxx/9544/input/1.js diff --git a/crates/swc/tests/fixture/issues-9xxx/9544/input/.swcrc b/crates/swc/tests/fixture/issues-9xxx/9544/input/.swcrc new file mode 100644 index 000000000000..5287e4163c17 --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9544/input/.swcrc @@ -0,0 +1,15 @@ +{ + "$schema": "https://swc.rs/schema.json", + "jsc": { + "parser": { + "syntax": "ecmascript", + }, + }, + "env": { + "targets": { + "chrome": "40" + }, + "mode": "usage", + "coreJs": "3.22" + } +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-9xxx/9544/input/1.js b/crates/swc/tests/fixture/issues-9xxx/9544/input/1.js new file mode 100644 index 000000000000..672d60a1c05d --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9544/input/1.js @@ -0,0 +1,3 @@ +document.querySelectorAll('div').forEach(el => { + console.log(el); +}) \ No newline at end of file From 14ba090f827719480897e52a8a6e092ec11a08d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Fri, 20 Sep 2024 14:41:00 +0900 Subject: [PATCH 03/23] Update builtin --- .../src/corejs3/builtin.rs | 911 ++++-------------- 1 file changed, 202 insertions(+), 709 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index dedc38978cd7..0cd07a83842a 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -44,26 +44,18 @@ pub static COMMON_ITERATORS: &[&str] = &concat2::<3>(ARRAY_NATURE_ITERATORS, &["es.string.iterator"]); static ARRAY_NATURE_ITERATORS_WITH_TAG: &[&str] = - &concat2::<3>(ARRAY_NATURE_ITERATORS, &["es.object.to-string"]); + &concat2::<3>(&["es.object.to-string"], ARRAY_NATURE_ITERATORS); static COMMON_ITERATORS_WITH_TAG: &[&str] = - &concat2::<4>(COMMON_ITERATORS, &["es.object.to-string"]); - -static ERROR_DEPENDENCIES: &[&str] = &["es.error.cause", "es.error.to-string"]; - -static SUPPRESSED_ERROR_DEPENDENCIES: &[&str] = - &concat2::<3>(&["esnext.suppressed-error.constructor"], ERROR_DEPENDENCIES); + &concat2::<4>(&["es.object.to-string"], COMMON_ITERATORS); static TYPED_ARRAY_DEPENDENCIES: &[&str] = &[ - "es.typed-array.at", "es.typed-array.copy-within", "es.typed-array.every", "es.typed-array.fill", "es.typed-array.filter", "es.typed-array.find", "es.typed-array.find-index", - "es.typed-array.find-last", - "es.typed-array.find-last-index", "es.typed-array.for-each", "es.typed-array.includes", "es.typed-array.index-of", @@ -80,22 +72,17 @@ static TYPED_ARRAY_DEPENDENCIES: &[&str] = &[ "es.typed-array.sort", "es.typed-array.subarray", "es.typed-array.to-locale-string", - "es.typed-array.to-reversed", - "es.typed-array.to-sorted", "es.typed-array.to-string", - "es.typed-array.with", "es.object.to-string", "es.array.iterator", "es.array-buffer.slice", - "esnext.array-buffer.detached", - "esnext.array-buffer.transfer", - "esnext.array-buffer.transfer-to-fixed-length", - "esnext.typed-array.filter-reject", - "esnext.typed-array.group-by", - "esnext.typed-array.to-spliced", - "esnext.typed-array.unique-by", ]; +static TYPED_ARRAY_STATIC_METHODS: Lazy> = lazy_map!(Map { + from: define(null, ["es.typed-array.from"]), + of: define(null, ["es.typed-array.of"]), +}); + pub static PROMISE_DEPENDENCIES: &[&str] = &["es.promise", "es.object.to-string"]; static PROMISE_DEPENDENCIES_WITH_ITERATORS: &[&str] = @@ -104,11 +91,10 @@ static PROMISE_DEPENDENCIES_WITH_ITERATORS: &[&str] = static SYMBOL_DEPENDENCIES: &[&str] = &["es.symbol", "es.symbol.description", "es.object.to-string"]; -static MAP_DEPENDENCIES: &[&str] = &concat2::<19>( +static MAP_DEPENDENCIES: &[&str] = &concat2::<18>( &[ "es.map", "esnext.map.delete-all", - "esnext.map.emplace", "esnext.map.every", "esnext.map.filter", "esnext.map.find", @@ -125,42 +111,31 @@ static MAP_DEPENDENCIES: &[&str] = &concat2::<19>( COMMON_ITERATORS_WITH_TAG, ); -static SET_DEPENDENCIES: &[&str] = &concat2::<28>( +static SET_DEPENDENCIES: &[&str] = &concat2::<21>( &[ "es.set", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", - "esnext.set.difference.v2", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", - "esnext.set.intersection.v2", "esnext.set.is-disjoint-from", - "esnext.set.is-disjoint-from.v2", "esnext.set.is-subset-of", - "esnext.set.is-subset-of.v2", "esnext.set.is-superset-of", - "esnext.set.is-superset-of.v2", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", - "esnext.set.symmetric-difference.v2", "esnext.set.union", - "esnext.set.union.v2", ], COMMON_ITERATORS_WITH_TAG, ); -static WEAK_MAP_DEPENDENCIES: &[&str] = &concat2::<7>( - &[ - "es.weak-map", - "esnext.weak-map.delete-all", - "esnext.weak-map.emplace", - ], +static WEAK_MAP_DEPENDENCIES: &[&str] = &concat2::<6>( + &["es.weak-map", "esnext.weak-map.delete-all"], COMMON_ITERATORS_WITH_TAG, ); @@ -173,506 +148,245 @@ static WEAK_SET_DEPENDENCIES: &[&str] = &concat2::<7>( COMMON_ITERATORS_WITH_TAG, ); -static DOM_EXCEPTION_DEPENDENCIES: &[&str] = &[ - "web.dom-exception.constructor", - "web.dom-exception.stack", - "web.dom-exception.to-string-tag", - "es.error.to-string", -]; +static URL_SEARCH_PARAMS_DEPENDENCIES: &[&str] = + &concat2::<5>(&["web.url"], COMMON_ITERATORS_WITH_TAG); -static URL_SEARCH_PARAMS_DEPENDENCIES: &[&str] = &concat2::<8>( - &[ - "web.url-search-params", - "web.url-search-params.delete", - "web.url-search-params.has", - "web.url-search-params.size", - ], - COMMON_ITERATORS_WITH_TAG, -); - -static ASYNC_ITERATOR_DEPENDENCIES: &[&str] = - &concat2::<3>(&["esnext.async-iterator.constructor"], PROMISE_DEPENDENCIES); - -static ASYNC_ITERATOR_PROBLEM_METHODS: &[&str] = &[ - "esnext.async-iterator.every", - "esnext.async-iterator.filter", - "esnext.async-iterator.find", - "esnext.async-iterator.flat-map", - "esnext.async-iterator.for-each", - "esnext.async-iterator.map", - "esnext.async-iterator.reduce", - "esnext.async-iterator.some", -]; - -static ITERATOR_DEPENDENCIES: &[&str] = &["esnext.iterator.constructor", "es.object.to-string"]; - -static TYPED_ARRAY_STATIC_METHODS: Lazy> = lazy_map!(Map { - from: define(null, ["es.typed-array.from"]), - fromAsync: define( +pub(crate) static BUILT_INS: Lazy> = lazy_map!(Map { + AggregateError: define( + "aggregate-error", + ["esnext.aggregate-error", COMMON_ITERATORS] + ), + ArrayBuffer: define( null, [ - "esnext.typed-array.from-async", - PROMISE_DEPENDENCIES_WITH_ITERATORS, + "es.array-buffer.constructor", + "es.array-buffer.slice", + "es.object.to-string", ] ), - of: define(null, ["es.typed-array.of"]), -}); - -static DATA_VIEW_DEPENDENCIES: &[&str] = &[ - "es.data-view", - "es.array-buffer.slice", - "es.object.to-string", -]; - -pub(crate) static BUILT_INS: Lazy> = lazy_map!(Map{ - AsyncDisposableStack: define("async-disposable-stack", [ - "esnext.async-disposable-stack.constructor", - "es.object.to-string", - "esnext.async-iterator.async-dispose", - "esnext.iterator.dispose", - PROMISE_DEPENDENCIES, - SuppressedERROR_DEPENDENCIES, - ]), - AsyncIterator: define("async-iterator/index", ASYNC_ITERATOR_DEPENDENCIES), - AggregateError: define("aggregate-error", [ - "es.aggregate-error", - ERROR_DEPENDENCIES, - CommonIteratorsWithTag, - "es.aggregate-error.cause", - ]), - ArrayBuffer: define(null, [ - "es.array-buffer.constructor", - "es.array-buffer.slice", - "es.object.to-string", - ]), - DataView: define(null, [ - "es.data-view", - "es.array-buffer.slice", - "es.object.to-string", - ]), - DataView: define(null, DATA_VIEW_DEPENDENCIES), - Date: define(null, ["es.date.to-string"]), - DOMException: define("dom-exception", DOM_EXCEPTION_DEPENDENCIES), - DisposableStack: define("disposable-stack", [ - "esnext.disposable-stack.constructor", - "es.object.to-string", - "esnext.iterator.dispose", - SUPPRESSED_ERROR_DEPENDENCIES, - ]), - Error: define(null, ERROR_DEPENDENCIES), - EvalError: define(null, ERROR_DEPENDENCIES), - Float32Array: typed("es.typed-array.float32-array"), - Float64Array: typed("es.typed-array.float64-array"), - Int8Array: typed("es.typed-array.int8-array"), - Int16Array: typed("es.typed-array.int16-array"), - Int32Array: typed("es.typed-array.int32-array"), - Iterator: define("iterator/index", ITERATOR_DEPENDENCIES), - Uint8Array: typed("es.typed-array.uint8-array"), - Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"), - Uint16Array: typed("es.typed-array.uint16-array"), - Uint32Array: typed("es.typed-array.uint32-array"), - Map: define("map/index", MAP_DEPENDENCIES), - Number: define(null, ["es.number.constructor"]), - Observable: define("observable/index", [ - "esnext.observable", - "esnext.symbol.observable", - "es.object.to-string", - COMMON_ITERATORS_WITH_TAG, - ]), - Promise: define("promise/index", PROMISE_DEPENDENCIES), - RangeError: define(null, ERROR_DEPENDENCIES), - ReferenceError: define(null, ERROR_DEPENDENCIES), - Reflect: define(null, ["es.reflect.to-string-tag", "es.object.to-string"]), - RegExp: define(null, [ - "es.regexp.constructor", - "es.regexp.dot-all", - "es.regexp.exec", - "es.regexp.sticky", - "es.regexp.to-string", - ]), - Set: define("set/index", SET_DEPENDENCIES), - SuppressedError: define("suppressed-error", SUPPRESSED_ERROR_DEPENDENCIES), - Symbol: define("symbol/index", SYMBOL_DEPENDENCIES), - SyntaxError: define(null, ERROR_DEPENDENCIES), - TypeError: define(null, ERROR_DEPENDENCIES), - URIError: define(null, ERROR_DEPENDENCIES), - URL: define("url/index", ["web.url", URL_SEARCH_PARAMS_DEPENDENCIES]), - URLSearchParams: define( - "url-search-params/index", - URL_SEARCH_PARAMS_DEPENDENCIES - ), - WeakMap: define("weak-map/index", WEAK_MAP_DEPENDENCIES), - WeakSet: define("weak-set/index", WEAK_SET_DEPENDENCIES), - - atob: define("atob", ["web.atob", DOM_EXCEPTION_DEPENDENCIES]), - btoa: define("btoa", ["web.btoa", DOM_EXCEPTION_DEPENDENCIES]), - clearImmediate: define("clear-immediate", ["web.immediate"]), - compositeKey: define("composite-key", ["esnext.composite-key"]), - compositeSymbol: define("composite-symbol", ["esnext.composite-symbol"]), - escape: define("escape", ["es.escape"]), - fetch: define(null, PROMISE_DEPENDENCIES), - globalThis: define("global-this", ["es.global-this"]), - parseFloat: define("parse-float", ["es.parse-float"]), - parseInt: define("parse-int", ["es.parse-int"]), - queueMicrotask: define("queue-microtask", ["web.queue-microtask"]), - self: define("self", ["web.self"]), - setImmediate: define("set-immediate", ["web.immediate"]), - setInterval: define("set-interval", ["web.timers"]), - setTimeout: define("set-timeout", ["web.timers"]), - structuredClone: define("structured-clone", [ - "web.structured-clone", - DOM_EXCEPTION_DEPENDENCIES, - "es.array.iterator", - "es.object.keys", - "es.object.to-string", - "es.map", - "es.set", - ]), - unescape: define("unescape", ["es.unescape"]), + DataView: define( + null, + [ + "es.data-view", + "es.array-buffer.slice", + "es.object.to-string", + ] + ), + Date: define(null, ["es.date.to-string"]), + Float32Array: typed("es.typed-array.float32-array"), + Float64Array: typed("es.typed-array.float64-array"), + Int8Array: typed("es.typed-array.int8-array"), + Int16Array: typed("es.typed-array.int16-array"), + Int32Array: typed("es.typed-array.int32-array"), + Uint8Array: typed("es.typed-array.uint8-array"), + Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"), + Uint16Array: typed("es.typed-array.uint16-array"), + Uint32Array: typed("es.typed-array.uint32-array"), + Map: define("map/index", MAP_DEPENDENCIES), + Number: define(null, ["es.number.constructor"]), + Observable: define( + "observable/index", + [ + "esnext.observable", + "esnext.symbol.observable", + "es.object.to-string", + COMMON_ITERATORS_WITH_TAG, + ] + ), + Promise: define("promise/index", PROMISE_DEPENDENCIES), + RegExp: define( + null, + [ + "es.regexp.constructor", + "es.regexp.exec", + "es.regexp.to-string", + ] + ), + Set: define("set/index", SET_DEPENDENCIES), + Symbol: define("symbol/index", SYMBOL_DEPENDENCIES), + URL: define("url/index", ["web.url", URL_SEARCH_PARAMS_DEPENDENCIES]), + URLSearchParams: define("url-search-params/index", URL_SEARCH_PARAMS_DEPENDENCIES), + WeakMap: define("weak-map/index", WEAK_MAP_DEPENDENCIES), + WeakSet: define("weak-set/index", WEAK_SET_DEPENDENCIES), + clearImmediate: define("clear-immediate", ["web.immediate"]), + compositeKey: define("composite-key", ["esnext.composite-key"]), + compositeSymbol: define( + "composite-symbol", + ["esnext.composite-symbol", SYMBOL_DEPENDENCIES] + ), + fetch: define(null, PROMISE_DEPENDENCIES), + globalThis: define("global-this", ["es.global-this", "esnext.global-this"]), + parseFloat: define("parse-float", ["es.parse-float"]), + parseInt: define("parse-int", ["es.parse-int"]), + queueMicrotask: define("queue-microtask", ["web.queue-microtask"]), + setTimeout: define("set-timeout", ["web.timers"]), + setInterval: define("set-interval", ["web.timers"]), + setImmediate: define("set-immediate", ["web.immediate"]), }); pub(crate) static STATIC_PROPERTIES: Lazy> = lazy_map!(Map{ - AsyncIterator: Map { - from: define("async-iterator/from", [ - "esnext.async-iterator.from", - ASYNC_ITERATOR_DEPENDENCIES, - AsyncIteratorProblemMethods, - CommonIterators, - ]), - }, Array: Map { from: define("array/from", ["es.array.from", "es.string.iterator"]), - fromAsync: define("array/from-async", [ - "esnext.array.from-async", - PROMISE_DEPENDENCIES_WITH_ITERATORS, - ]), isArray: define("array/is-array", ["es.array.is-array"]), - isTemplateObject: define("array/is-template-object", [ - "esnext.array.is-template-object", - ]), of: define("array/of", ["es.array.of"]), }, - ArrayBuffer: Map { - isView: define(null, ["es.array-buffer.is-view"]), - }, - - BigInt: Map { - range: define("bigint/range", [ - "esnext.bigint.range", - "es.object.to-string", - ]), - }, - Date: Map { now: define("date/now", ["es.date.now"]), }, - Function: Map { - isCallable: define("function/is-callable", ["esnext.function.is-callable"]), - isConstructor: define("function/is-constructor", [ - "esnext.function.is-constructor", - ]), - }, - - Iterator: Map { - from: define("iterator/from", [ - "esnext.iterator.from", - ITERATOR_DEPENDENCIES, - CommonIterators, - ]), - range: define("iterator/range", [ - "esnext.iterator.range", - "es.object.to-string", - ]), - }, - - JSON: Map { - isRawJSON: define("json/is-raw-json", ["esnext.json.is-raw-json"]), - parse: define("json/parse", ["esnext.json.parse", "es.object.keys"]), - rawJSON: define("json/raw-json", [ - "esnext.json.raw-json", - "es.object.create", - "es.object.freeze", - ]), - stringify: define("json/stringify", ["es.json.stringify"], "es.symbol"), + Object: Map { + assign: define("object/assign", ["es.object.assign"]), + create: define("object/create", ["es.object.create"]), + defineProperty: define("object/define-property", ["es.object.define-property"]), + defineProperties: define("object/define-properties", ["es.object.define-properties"]), + entries: define("object/entries", ["es.object.entries"]), + freeze: define("object/freeze", ["es.object.freeze"]), + fromEntries: define("object/from-entries", ["es.object.from-entries", "es.array.iterator"]), + getOwnPropertyDescriptor: define("object/get-own-property-descriptor", ["es.object.get-own-property-descriptor"]), + getOwnPropertyDescriptors: define("object/get-own-property-descriptors", ["es.object.get-own-property-descriptors"]), + getOwnPropertyNames: define("object/get-own-property-names", ["es.object.get-own-property-names"]), + getOwnPropertySymbols: define("object/get-own-property-symbols", ["es.symbol"]), + getPrototypeOf: define("object/get-prototype-of", ["es.object.get-prototype-of"]), + is: define("object/is", ["es.object.is"]), + isExtensible: define("object/is-extensible", ["es.object.is-extensible"]), + isFrozen: define("object/is-frozen", ["es.object.is-frozen"]), + isSealed: define("object/is-sealed", ["es.object.is-sealed"]), + keys: define("object/keys", ["es.object.keys"]), + preventExtensions: define("object/prevent-extensions", ["es.object.prevent-extensions"]), + seal: define("object/seal", ["es.object.seal"]), + setPrototypeOf: define("object/set-prototype-of", ["es.object.set-prototype-of"]), + values: define("object/values", ["es.object.values"]), }, Math: Map { - DEG_PER_RAD: define("math/deg-per-rad", ["esnext.math.deg-per-rad"]), - RAD_PER_DEG: define("math/rad-per-deg", ["esnext.math.rad-per-deg"]), acosh: define("math/acosh", ["es.math.acosh"]), asinh: define("math/asinh", ["es.math.asinh"]), atanh: define("math/atanh", ["es.math.atanh"]), cbrt: define("math/cbrt", ["es.math.cbrt"]), - clamp: define("math/clamp", ["esnext.math.clamp"]), clz32: define("math/clz32", ["es.math.clz32"]), cosh: define("math/cosh", ["es.math.cosh"]), - degrees: define("math/degrees", ["esnext.math.degrees"]), expm1: define("math/expm1", ["es.math.expm1"]), fround: define("math/fround", ["es.math.fround"]), - f16round: define("math/f16round", ["esnext.math.f16round"]), - fscale: define("math/fscale", ["esnext.math.fscale"]), hypot: define("math/hypot", ["es.math.hypot"]), - iaddh: define("math/iaddh", ["esnext.math.iaddh"]), imul: define("math/imul", ["es.math.imul"]), - imulh: define("math/imulh", ["esnext.math.imulh"]), - isubh: define("math/isubh", ["esnext.math.isubh"]), log10: define("math/log10", ["es.math.log10"]), log1p: define("math/log1p", ["es.math.log1p"]), log2: define("math/log2", ["es.math.log2"]), - radians: define("math/radians", ["esnext.math.radians"]), - scale: define("math/scale", ["esnext.math.scale"]), - seededPRNG: define("math/seeded-prng", ["esnext.math.seeded-prng"]), sign: define("math/sign", ["es.math.sign"]), - signbit: define("math/signbit", ["esnext.math.signbit"]), sinh: define("math/sinh", ["es.math.sinh"]), tanh: define("math/tanh", ["es.math.tanh"]), trunc: define("math/trunc", ["es.math.trunc"]), + DEG_PER_RAD: define("math/deg-per-rad", ["esnext.math.deg-per-rad"]), + RAD_PER_DEG: define("math/rad-per-deg", ["esnext.math.rad-per-deg"]), + clamp: define("math/clamp", ["esnext.math.clamp"]), + degrees: define("math/degrees", ["esnext.math.degrees"]), + fscale: define("math/fscale", ["esnext.math.fscale"]), + iaddh: define("math/iaddh", ["esnext.math.iaddh"]), + imulh: define("math/imulh", ["esnext.math.imulh"]), + isubh: define("math/isubh", ["esnext.math.isubh"]), + radians: define("math/radians", ["esnext.math.radians"]), + scale: define("math/scale", ["esnext.math.scale"]), + seededPRNG: define("math/seeded-prng", ["esnext.math.seeded-prng"]), + signbit: define("math/signbit", ["esnext.math.signbit"]), umulh: define("math/umulh", ["esnext.math.umulh"]), }, - Map: Map { - from: define(null, ["esnext.map.from", MAP_DEPENDENCIES]), - groupBy: define(null, ["esnext.map.group-by", MAP_DEPENDENCIES]), - keyBy: define(null, ["esnext.map.key-by", MAP_DEPENDENCIES]), - of: define(null, ["esnext.map.of", MAP_DEPENDENCIES]), + String: Map { + fromCodePoint: define("string/from-code-point", ["es.string.from-code-point"]), + raw: define("string/raw", ["es.string.raw"]), }, Number: Map { EPSILON: define("number/epsilon", ["es.number.epsilon"]), - MAX_SAFE_INTEGER: define("number/max-safe-integer", [ - "es.number.max-safe-integer", - ]), - MIN_SAFE_INTEGER: define("number/min-safe-integer", [ - "es.number.min-safe-integer", - ]), + MIN_SAFE_INTEGER: define("number/min-safe-integer", ["es.number.min-safe-integer"]), + MAX_SAFE_INTEGER: define("number/max-safe-integer", ["es.number.max-safe-integer"]), fromString: define("number/from-string", ["esnext.number.from-string"]), isFinite: define("number/is-finite", ["es.number.is-finite"]), isInteger: define("number/is-integer", ["es.number.is-integer"]), + isSafeInteger: define("number/is-safe-integer", ["es.number.is-safe-integer"]), isNaN: define("number/is-nan", ["es.number.is-nan"]), - isSafeInteger: define("number/is-safe-integer", [ - "es.number.is-safe-integer", - ]), parseFloat: define("number/parse-float", ["es.number.parse-float"]), parseInt: define("number/parse-int", ["es.number.parse-int"]), - range: define("number/range", [ - "esnext.number.range", - "es.object.to-string", - ]), }, - Object: Map { - assign: define("object/assign", ["es.object.assign"]), - create: define("object/create", ["es.object.create"]), - defineProperties: define("object/define-properties", [ - "es.object.define-properties", - ]), - defineProperty: define("object/define-property", [ - "es.object.define-property", - ]), - entries: define("object/entries", ["es.object.entries"]), - freeze: define("object/freeze", ["es.object.freeze"]), - fromEntries: define("object/from-entries", [ - "es.object.from-entries", - "es.array.iterator", - ]), - getOwnPropertyDescriptor: define("object/get-own-property-descriptor", [ - "es.object.get-own-property-descriptor", - ]), - getOwnPropertyDescriptors: define("object/get-own-property-descriptors", [ - "es.object.get-own-property-descriptors", - ]), - getOwnPropertyNames: define("object/get-own-property-names", [ - "es.object.get-own-property-names", - ]), - getOwnPropertySymbols: define("object/get-own-property-symbols", [ - "es.symbol", - ]), - getPrototypeOf: define("object/get-prototype-of", [ - "es.object.get-prototype-of", - ]), - groupBy: define("object/group-by", [ - "esnext.object.group-by", - "es.object.create", - ]), - hasOwn: define("object/has-own", ["es.object.has-own"]), - is: define("object/is", ["es.object.is"]), - isExtensible: define("object/is-extensible", ["es.object.is-extensible"]), - isFrozen: define("object/is-frozen", ["es.object.is-frozen"]), - isSealed: define("object/is-sealed", ["es.object.is-sealed"]), - keys: define("object/keys", ["es.object.keys"]), - preventExtensions: define("object/prevent-extensions", [ - "es.object.prevent-extensions", - ]), - seal: define("object/seal", ["es.object.seal"]), - setPrototypeOf: define("object/set-prototype-of", [ - "es.object.set-prototype-of", - ]), - values: define("object/values", ["es.object.values"]), + Map: Map { + from: define(null, ["esnext.map.from", MAP_DEPENDENCIES]), + groupBy: define(null, ["esnext.map.group-by", MAP_DEPENDENCIES]), + keyBy: define(null, ["esnext.map.key-by", MAP_DEPENDENCIES]), + of: define(null, ["esnext.map.of", MAP_DEPENDENCIES]), + }, + + Set: Map { + from: define(null, ["esnext.set.from", SET_DEPENDENCIES]), + of: define(null, ["esnext.set.of", SET_DEPENDENCIES]), + }, + + WeakMap: Map { + from: define(null, ["esnext.weak-map.from", WEAK_MAP_DEPENDENCIES]), + of: define(null, ["esnext.weak-map.of", WEAK_MAP_DEPENDENCIES]), + }, + + WeakSet: Map { + from: define(null, ["esnext.weak-set.from", WEAK_SET_DEPENDENCIES]), + of: define(null, ["esnext.weak-set.of", WEAK_SET_DEPENDENCIES]), }, Promise: Map { all: define(null, PROMISE_DEPENDENCIES_WITH_ITERATORS), allSettled: define(null, [ "es.promise.all-settled", + "esnext.promise.all-settled", PROMISE_DEPENDENCIES_WITH_ITERATORS, ]), any: define(null, [ - "es.promise.any", - "es.aggregate-error", + "esnext.promise.any", + "esnext.aggregate-error", PROMISE_DEPENDENCIES_WITH_ITERATORS, ]), race: define(null, PROMISE_DEPENDENCIES_WITH_ITERATORS), - try: define(null, ["esnext.promise.try", PROMISE_DEPENDENCIES]), - withResolvers: define(null, [ - "esnext.promise.with-resolvers", - PROMISE_DEPENDENCIES, - ]), + try: define(null, ["esnext.promise.try", PROMISE_DEPENDENCIES_WITH_ITERATORS]), }, Reflect: Map { apply: define("reflect/apply", ["es.reflect.apply"]), construct: define("reflect/construct", ["es.reflect.construct"]), - defineMetadata: define("reflect/define-metadata", [ - "esnext.reflect.define-metadata", - ]), - defineProperty: define("reflect/define-property", [ - "es.reflect.define-property", - ]), - deleteMetadata: define("reflect/delete-metadata", [ - "esnext.reflect.delete-metadata", - ]), - deleteProperty: define("reflect/delete-property", [ - "es.reflect.delete-property", - ]), + defineMetadata: define("reflect/define-metadata", ["esnext.reflect.define-metadata"]), + defineProperty: define("reflect/define-property", ["es.reflect.define-property"]), + deleteMetadata: define("reflect/delete-metadata", ["esnext.reflect.delete-metadata"]), + deleteProperty: define("reflect/delete-property", ["es.reflect.delete-property"]), get: define("reflect/get", ["es.reflect.get"]), - getMetadata: define("reflect/get-metadata", [ - "esnext.reflect.get-metadata", - ]), - getMetadataKeys: define("reflect/get-metadata-keys", [ - "esnext.reflect.get-metadata-keys", - ]), - getOwnMetadata: define("reflect/get-own-metadata", [ - "esnext.reflect.get-own-metadata", - ]), - getOwnMetadataKeys: define("reflect/get-own-metadata-keys", [ - "esnext.reflect.get-own-metadata-keys", - ]), - getOwnPropertyDescriptor: define("reflect/get-own-property-descriptor", [ - "es.reflect.get-own-property-descriptor", - ]), - getPrototypeOf: define("reflect/get-prototype-of", [ - "es.reflect.get-prototype-of", - ]), + getMetadata: define("reflect/get-metadata", ["esnext.reflect.get-metadata"]), + getMetadataKeys: define("reflect/get-metadata-keys", ["esnext.reflect.get-metadata-keys"]), + getOwnMetadata: define("reflect/get-own-metadata", ["esnext.reflect.get-own-metadata"]), + getOwnMetadataKeys: define("reflect/get-own-metadata-keys", ["esnext.reflect.get-own-metadata-keys"]), + getOwnPropertyDescriptor: define("reflect/get-own-property-descriptor", ["es.reflect.get-own-property-descriptor"]), + getPrototypeOf: define("reflect/get-prototype-of", ["es.reflect.get-prototype-of"]), has: define("reflect/has", ["es.reflect.has"]), - hasMetadata: define("reflect/has-metadata", [ - "esnext.reflect.has-metadata", - ]), - hasOwnMetadata: define("reflect/has-own-metadata", [ - "esnext.reflect.has-own-metadata", - ]), + hasMetadata: define("reflect/has-metadata", ["esnext.reflect.has-metadata"]), + hasOwnMetadata: define("reflect/has-own-metadata", ["esnext.reflect.has-own-metadata"]), isExtensible: define("reflect/is-extensible", ["es.reflect.is-extensible"]), metadata: define("reflect/metadata", ["esnext.reflect.metadata"]), ownKeys: define("reflect/own-keys", ["es.reflect.own-keys"]), - preventExtensions: define("reflect/prevent-extensions", [ - "es.reflect.prevent-extensions", - ]), + preventExtensions: define("reflect/prevent-extensions", ["es.reflect.prevent-extensions"]), set: define("reflect/set", ["es.reflect.set"]), - setPrototypeOf: define("reflect/set-prototype-of", [ - "es.reflect.set-prototype-of", - ]), - }, - - Set: Map { - from: define(null, ["esnext.set.from", SET_DEPENDENCIES]), - of: define(null, ["esnext.set.of", SET_DEPENDENCIES]), - }, - - String: Map { - cooked: define("string/cooked", ["esnext.string.cooked"]), - dedent: define("string/dedent", [ - "esnext.string.dedent", - "es.string.from-code-point", - "es.weak-map", - ]), - fromCodePoint: define("string/from-code-point", [ - "es.string.from-code-point", - ]), - raw: define("string/raw", ["es.string.raw"]), + setPrototypeOf: define("reflect/set-prototype-of", ["es.reflect.set-prototype-of"]), }, Symbol: Map { - asyncDispose: define("symbol/async-dispose", [ - "esnext.symbol.async-dispose", - "esnext.async-iterator.async-dispose", - ]), - asyncIterator: define("symbol/async-iterator", [ - "es.symbol.async-iterator", - ]), - dispose: define("symbol/dispose", [ - "esnext.symbol.dispose", - "esnext.iterator.dispose", - ]), - for: define("symbol/for", [], "es.symbol"), - hasInstance: define("symbol/has-instance", [ - "es.symbol.has-instance", - "es.function.has-instance", - ]), - isConcatSpreadable: define("symbol/is-concat-spreadable", [ - "es.symbol.is-concat-spreadable", - "es.array.concat", - ]), - isRegistered: define("symbol/is-registered", [ - "esnext.symbol.is-registered", - "es.symbol", - ]), - isRegisteredSymbol: define("symbol/is-registered-symbol", [ - "esnext.symbol.is-registered-symbol", - "es.symbol", - ]), - isWellKnown: define("symbol/is-well-known", [ - "esnext.symbol.is-well-known", - "es.symbol", - ]), - isWellKnownSymbol: define("symbol/is-well-known-symbol", [ - "esnext.symbol.is-well-known-symbol", - "es.symbol", - ]), - iterator: define("symbol/iterator", [ - "es.symbol.iterator", - COMMON_ITERATORS_WITH_TAG, - ]), - keyFor: define("symbol/key-for", [], "es.symbol"), + asyncIterator: define("symbol/async-iterator", ["es.symbol.async-iterator"]), + dispose: define("symbol/dispose", ["esnext.symbol.dispose"]), + hasInstance: define("symbol/has-instance", ["es.symbol.has-instance", "es.function.has-instance"]), + isConcatSpreadable: define("symbol/is-concat-spreadable", ["es.symbol.is-concat-spreadable", "es.array.concat"]), + iterator: define("symbol/iterator", ["es.symbol.iterator", COMMON_ITERATORS_WITH_TAG]), match: define("symbol/match", ["es.symbol.match", "es.string.match"]), - matcher: define("symbol/matcher", ["esnext.symbol.matcher"]), - matchAll: define("symbol/match-all", [ - "es.symbol.match-all", - "es.string.match-all", - ]), - metadata: define("symbol/metadata", [ - "esnext.symbol.metadata", - "esnext.function.metadata", - ]), - metadataKey: define("symbol/metadata-key", ["esnext.symbol.metadata-key"]), observable: define("symbol/observable", ["esnext.symbol.observable"]), - patternMatch: define("symbol/pattern-match", [ - "esnext.symbol.pattern-match", - ]), - replace: define("symbol/replace", [ - "es.symbol.replace", - "es.string.replace", - ]), + patternMatch: define("symbol/pattern-match", ["esnext.symbol.pattern-match"]), + replace: define("symbol/replace", ["es.symbol.replace", "es.string.replace"]), search: define("symbol/search", ["es.symbol.search", "es.string.search"]), - species: define("symbol/species", [ - "es.symbol.species", - "es.array.species", - ]), + species: define("symbol/species", ["es.symbol.species", "es.array.species"]), split: define("symbol/split", ["es.symbol.split", "es.string.split"]), - toPrimitive: define("symbol/to-primitive", [ - "es.symbol.to-primitive", - "es.date.to-primitive", - ]), + toPrimitive: define("symbol/to-primitive", ["es.symbol.to-primitive", "es.date.to-primitive"]), toStringTag: define("symbol/to-string-tag", [ "es.symbol.to-string-tag", "es.object.to-string", @@ -682,18 +396,8 @@ pub(crate) static STATIC_PROPERTIES: Lazy> unscopables: define("symbol/unscopables", ["es.symbol.unscopables"]), }, - URL: Map { - canParse: define("url/can-parse", ["web.url.can-parse", "web.url"]), - }, - - WeakMap: Map { - from: define(null, ["esnext.weak-map.from", WEAK_MAP_DEPENDENCIES]), - of: define(null, ["esnext.weak-map.of", WEAK_MAP_DEPENDENCIES]), - }, - - WeakSet: Map { - from: define(null, ["esnext.weak-set.from", WEAK_SET_DEPENDENCIES]), - of: define(null, ["esnext.weak-set.of", WEAK_SET_DEPENDENCIES]), + ArrayBuffer: Map { + isView: define(null, ["es.array-buffer.is-view"]), }, Int8Array: *TYPED_ARRAY_STATIC_METHODS, @@ -705,38 +409,10 @@ pub(crate) static STATIC_PROPERTIES: Lazy> Uint32Array: *TYPED_ARRAY_STATIC_METHODS, Float32Array: *TYPED_ARRAY_STATIC_METHODS, Float64Array: *TYPED_ARRAY_STATIC_METHODS, - - WebAssembly: Map { - CompileError: define(null, ERROR_DEPENDENCIES), - LinkError: define(null, ERROR_DEPENDENCIES), - RuntimeError: define(null, ERROR_DEPENDENCIES), - }, }); pub(crate) static INSTANCE_PROPERTIES: Lazy> = lazy_map!(Map { - asIndexedPairs: define( - "instance/asIndexedPairs", - [ - "esnext.async-iterator.as-indexed-pairs", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.as-indexed-pairs", - ITERATOR_DEPENDENCIES, - ] - ), - at: define( - "instance/at", - [ - // TODO: We should introduce overloaded instance methods definition - // Before that is implemented, the `esnext.string.at` must be the first - // In pure mode, the provider resolves the descriptor as a "pure" `esnext.string.at` - // and treats the compat-data of `esnext.string.at` as the compat-data of - // pure import `instance/at`. The first polyfill here should have the lowest corejs - // supported versions. - "esnext.string.at", - "es.string.at-alternative", - "es.array.at", - ] - ), + at: define("instance/at", ["es.string.at", "es.array.at"]), anchor: define(null, ["es.string.anchor"]), big: define(null, ["es.string.big"]), bind: define("instance/bind", ["es.function.bind"]), @@ -744,269 +420,86 @@ pub(crate) static INSTANCE_PROPERTIES: Lazy> bold: define(null, ["es.string.bold"]), codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]), codePoints: define("instance/code-points", ["esnext.string.code-points"]), - concat: define("instance/concat", ["es.array.concat"], None, ["String"]), + concat: define("instance/concat", ["es.array.concat"]), copyWithin: define("instance/copy-within", ["es.array.copy-within"]), - demethodize: define("instance/demethodize", ["esnext.function.demethodize"]), - description: define(null, ["es.symbol", "es.symbol.description"]), - dotAll: define(null, ["es.regexp.dot-all"]), - drop: define( - "instance/drop", - [ - "esnext.async-iterator.drop", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.drop", - ITERATOR_DEPENDENCIES, - ] - ), - emplace: define( - "instance/emplace", - ["esnext.map.emplace", "esnext.weak-map.emplace",] - ), endsWith: define("instance/ends-with", ["es.string.ends-with"]), entries: define("instance/entries", ARRAY_NATURE_ITERATORS_WITH_TAG), - every: define( - "instance/every", - [ - "es.array.every", - "esnext.async-iterator.every", - // TODO: add async iterator dependencies when we support sub-dependencies - // esnext.async-iterator.every depends on es.promise - // but we don't want to pull es.promise when esnext.async-iterator is disabled - // - // ASYNC_ITERATOR_DEPENDENCIES - "esnext.iterator.every", - ITERATOR_DEPENDENCIES, - ] - ), + every: define("instance/every", ["es.array.every"]), exec: define(null, ["es.regexp.exec"]), fill: define("instance/fill", ["es.array.fill"]), - filter: define( - "instance/filter", - [ - "es.array.filter", - "esnext.async-iterator.filter", - "esnext.iterator.filter", - ITERATOR_DEPENDENCIES, - ] - ), - filterReject: define("instance/filterReject", ["esnext.array.filter-reject"]), + filter: define("instance/filter", ["es.array.filter"]), finally: define(null, ["es.promise.finally", PROMISE_DEPENDENCIES]), - find: define( - "instance/find", - [ - "es.array.find", - "esnext.async-iterator.find", - "esnext.iterator.find", - ITERATOR_DEPENDENCIES, - ] - ), + find: define("instance/find", ["es.array.find"]), findIndex: define("instance/find-index", ["es.array.find-index"]), - findLast: define("instance/find-last", ["es.array.find-last"]), - findLastIndex: define("instance/find-last-index", ["es.array.find-last-index",]), fixed: define(null, ["es.string.fixed"]), flags: define("instance/flags", ["es.regexp.flags"]), - flatMap: define( - "instance/flat-map", - [ - "es.array.flat-map", - "es.array.unscopables.flat-map", - "esnext.async-iterator.flat-map", - "esnext.iterator.flat-map", - ITERATOR_DEPENDENCIES, - ] - ), - flat: define( - "instance/flat", - ["es.array.flat", "es.array.unscopables.flat"] - ), - getFloat16: define( - null, - ["esnext.data-view.get-float16", DATA_VIEW_DEPENDENCIES] - ), - getUint8Clamped: define( - null, - ["esnext.data-view.get-uint8-clamped", DATA_VIEW_DEPENDENCIES] - ), - getYear: define(null, ["es.date.get-year"]), - group: define("instance/group", ["esnext.array.group"]), - groupBy: define("instance/group-by", ["esnext.array.group-by"]), - groupByToMap: define( - "instance/group-by-to-map", - [ - "esnext.array.group-by-to-map", - "es.map", - "es.object.to-string", - ] - ), - groupToMap: define( - "instance/group-to-map", - ["esnext.array.group-to-map", "es.map", "es.object.to-string",] - ), + flat: define("instance/flat", ["es.array.flat", "es.array.unscopables.flat"]), + flatMap: define("instance/flat-map", ["es.array.flat-map", "es.array.unscopables.flat-map"]), fontcolor: define(null, ["es.string.fontcolor"]), fontsize: define(null, ["es.string.fontsize"]), - forEach: define( - "instance/for-each", - [ - "es.array.for-each", - "esnext.async-iterator.for-each", - "esnext.iterator.for-each", - ITERATOR_DEPENDENCIES, - "web.dom-collections.for-each", - ] - ), - includes: define( - "instance/includes", - ["es.array.includes", "es.string.includes",] - ), - indexed: define( - "instance/indexed", - [ - "esnext.async-iterator.indexed", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.indexed", - ITERATOR_DEPENDENCIES, - ] - ), + forEach: define("instance/for-each", ["es.array.for-each", "web.dom-collections.for-each"]), + includes: define("instance/includes", ["es.array.includes", "es.string.includes"]), indexOf: define("instance/index-of", ["es.array.index-of"]), - isWellFormed: define("instance/is-well-formed", ["es.string.is-well-formed"]), - italic: define(null, ["es.string.italics"]), + italics: define(null, ["es.string.italics"]), join: define(null, ["es.array.join"]), keys: define("instance/keys", ARRAY_NATURE_ITERATORS_WITH_TAG), lastIndex: define(null, ["esnext.array.last-index"]), lastIndexOf: define("instance/last-index-of", ["es.array.last-index-of"]), lastItem: define(null, ["esnext.array.last-item"]), link: define(null, ["es.string.link"]), - map: define( - "instance/map", - [ - "es.array.map", - "esnext.async-iterator.map", - "esnext.iterator.map", - ] - ), + map: define("instance/map", ["es.array.map"]), match: define(null, ["es.string.match", "es.regexp.exec"]), - matchAll: define( - "instance/match-all", - ["es.string.match-all", "es.regexp.exec",] - ), + matchAll: define("instance/match-all", ["es.string.match-all", "esnext.string.match-all"]), name: define(null, ["es.function.name"]), padEnd: define("instance/pad-end", ["es.string.pad-end"]), padStart: define("instance/pad-start", ["es.string.pad-start"]), - push: define("instance/push", ["es.array.push"]), - reduce: define( - "instance/reduce", - [ - "es.array.reduce", - "esnext.async-iterator.reduce", - "esnext.iterator.reduce", - ITERATOR_DEPENDENCIES, - ] - ), + reduce: define("instance/reduce", ["es.array.reduce"]), reduceRight: define("instance/reduce-right", ["es.array.reduce-right"]), repeat: define("instance/repeat", ["es.string.repeat"]), replace: define(null, ["es.string.replace", "es.regexp.exec"]), - replaceAll: define( - "instance/replace-all", - [ - "es.string.replace-all", - "es.string.replace", - "es.regexp.exec", - ] - ), + replaceAll: define("instance/replace-all", ["esnext.string.replace-all"]), reverse: define("instance/reverse", ["es.array.reverse"]), search: define(null, ["es.string.search", "es.regexp.exec"]), - setFloat16: define( - null, - ["esnext.data-view.set-float16", DATA_VIEW_DEPENDENCIES] - ), - setUint8Clamped: define( - null, - ["esnext.data-view.set-uint8-clamped", DATA_VIEW_DEPENDENCIES] - ), - setYear: define(null, ["es.date.set-year"]), slice: define("instance/slice", ["es.array.slice"]), small: define(null, ["es.string.small"]), - some: define( - "instance/some", - [ - "es.array.some", - "esnext.async-iterator.some", - "esnext.iterator.some", - ITERATOR_DEPENDENCIES, - ] - ), + some: define("instance/some", ["es.array.some"]), sort: define("instance/sort", ["es.array.sort"]), splice: define("instance/splice", ["es.array.splice"]), split: define(null, ["es.string.split", "es.regexp.exec"]), startsWith: define("instance/starts-with", ["es.string.starts-with"]), - sticky: define(null, ["es.regexp.sticky"]), strike: define(null, ["es.string.strike"]), sub: define(null, ["es.string.sub"]), - substr: define(null, ["es.string.substr"]), sup: define(null, ["es.string.sup"]), - take: define( - "instance/take", - [ - "esnext.async-iterator.take", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.take", - ITERATOR_DEPENDENCIES, - ] - ), - test: define(null, ["es.regexp.test", "es.regexp.exec"]), - toArray: define( - "instance/to-array", - [ - "esnext.async-iterator.to-array", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.to-array", - ITERATOR_DEPENDENCIES, - ] - ), - toAsync: define( - null, - [ - "esnext.iterator.to-async", - ITERATOR_DEPENDENCIES, - ASYNC_ITERATOR_DEPENDENCIES, - AsyncIteratorProblemMethods, - ] - ), - toExponential: define(null, ["es.number.to-exponential"]), toFixed: define(null, ["es.number.to-fixed"]), - toGMTString: define(null, ["es.date.to-gmt-string"]), toISOString: define(null, ["es.date.to-iso-string"]), toJSON: define(null, ["es.date.to-json", "web.url.to-json"]), toPrecision: define(null, ["es.number.to-precision"]), - toReversed: define("instance/to-reversed", ["es.array.to-reversed"]), - toSorted: define( - "instance/to-sorted", - ["es.array.to-sorted", "es.array.sort",] - ), - toSpliced: define("instance/to-spliced", ["es.array.to-spliced"]), - toString: define( - null, - [ - "es.object.to-string", - "es.error.to-string", - "es.date.to-string", - "es.regexp.to-string", - ] - ), - toWellFormed: define("instance/to-well-formed", ["es.string.to-well-formed"]), + toString: define(null, ["es.object.to-string", "es.regexp.to-string", "es.date.to-string"]), trim: define("instance/trim", ["es.string.trim"]), trimEnd: define("instance/trim-end", ["es.string.trim-end"]), trimLeft: define("instance/trim-left", ["es.string.trim-start"]), trimRight: define("instance/trim-right", ["es.string.trim-end"]), trimStart: define("instance/trim-start", ["es.string.trim-start"]), - uniqueBy: define("instance/unique-by", ["esnext.array.unique-by", "es.map"]), - unshift: define("instance/unshift", ["es.array.unshift"]), - unThis: define("instance/un-this", ["esnext.function.un-this"]), values: define("instance/values", ARRAY_NATURE_ITERATORS_WITH_TAG), - with: define("instance/with", ["es.array.with"]), __defineGetter__: define(null, ["es.object.define-getter"]), __defineSetter__: define(null, ["es.object.define-setter"]), __lookupGetter__: define(null, ["es.object.lookup-getter"]), __lookupSetter__: define(null, ["es.object.lookup-setter"]), - __proto__: define(null, ["es.object.proto"]), +}); + +pub static COMMON_INSTANCE_DEPENDENCIES: Lazy> = + lazy_map!(Map { + es_object_to_string: define(null, ["es.object.to-string"]), + es_object_define_getter: define(null, ["es.object.define-getter"]), + es_object_define_setter: define(null, ["es.object.define-setter"]), + es_object_lookup_getter: define(null, ["es.object.lookup-getter"]), + es_object_lookup_setter: define(null, ["es.object.lookup-setter"]), + es_regexp_exec: define(null, ["es.regexp.exec"]), + }); + +pub static POSSIBLE_GLOBAL_OBJECTS: Lazy> = lazy_map!(Map { + global: define(null, []), + globalThis: define(null, []), + self: define(null, []), + window: define(null, []), }); From f60a2fe02e31ed55ebe0f7474c102c18c3435362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Fri, 20 Sep 2024 14:42:18 +0900 Subject: [PATCH 04/23] Update test refs --- crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js | 2 +- crates/swc/tests/fixture/issues-6xxx/6888/output/index.js | 4 +--- crates/swc/tests/fixture/issues-8xxx/8193/output/1.js | 2 -- crates/swc/tests/fixture/issues-9xxx/9544/output/1.js | 4 ++++ 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 crates/swc/tests/fixture/issues-9xxx/9544/output/1.js diff --git a/crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js b/crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js index f7eefeb17964..5cd3e93d3899 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js +++ b/crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js @@ -1,6 +1,6 @@ require("core-js/modules/es.array.at.js"); require("core-js/modules/es.regexp.exec.js"); -require("core-js/modules/es.string.at-alternative.js"); +require("core-js/modules/es.string.at.js"); require("core-js/modules/es.string.split.js"); '1.2.3'.split('.').at(-1); [ diff --git a/crates/swc/tests/fixture/issues-6xxx/6888/output/index.js b/crates/swc/tests/fixture/issues-6xxx/6888/output/index.js index 9c9863d1964d..bd79dd12d935 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6888/output/index.js +++ b/crates/swc/tests/fixture/issues-6xxx/6888/output/index.js @@ -1,8 +1,6 @@ require("core-js/modules/es.array.at.js"); require("core-js/modules/es.regexp.exec.js"); -require("core-js/modules/es.string.at-alternative.js"); -require("core-js/modules/es.string.replace-all.js"); -require("core-js/modules/es.string.replace.js"); +require("core-js/modules/es.string.at.js"); require("core-js/modules/es.string.split.js"); 'test'.replaceAll('', ''); '1.2.3'.split('.').at(-1); diff --git a/crates/swc/tests/fixture/issues-8xxx/8193/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8193/output/1.js index e911a0407a35..30c7f2ce0718 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8193/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8193/output/1.js @@ -1,5 +1,3 @@ -require("core-js/modules/es.object.create.js"); -require("core-js/modules/esnext.object.group-by.js"); var data = [ { name: 'a', diff --git a/crates/swc/tests/fixture/issues-9xxx/9544/output/1.js b/crates/swc/tests/fixture/issues-9xxx/9544/output/1.js new file mode 100644 index 000000000000..6fad7029c384 --- /dev/null +++ b/crates/swc/tests/fixture/issues-9xxx/9544/output/1.js @@ -0,0 +1,4 @@ +require("core-js/modules/web.dom-collections.for-each.js"); +document.querySelectorAll('div').forEach(function(el) { + console.log(el); +}); From eafc54fd28af39f5e2d1fdab2fabadc72b323c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Mon, 30 Sep 2024 11:18:31 +0900 Subject: [PATCH 05/23] Update data --- .../data/@babel/compat-data/data/plugins.json | 3 +- .../data/core-js-compat/data.json | 85 +++++++++++++++++-- package.json | 4 +- 3 files changed, 81 insertions(+), 11 deletions(-) diff --git a/crates/swc_ecma_preset_env/data/@babel/compat-data/data/plugins.json b/crates/swc_ecma_preset_env/data/@babel/compat-data/data/plugins.json index 0b269f84600e..50fe80e58251 100644 --- a/crates/swc_ecma_preset_env/data/@babel/compat-data/data/plugins.json +++ b/crates/swc_ecma_preset_env/data/@babel/compat-data/data/plugins.json @@ -1,6 +1,7 @@ { "transform-duplicate-named-capturing-groups-regex": { "chrome": "126", + "opera": "112", "edge": "126", "firefox": "129", "safari": "17.4", @@ -22,7 +23,7 @@ "chrome": "98", "opera": "84", "edge": "98", - "firefox": "95", + "firefox": "75", "safari": "15", "node": "12", "deno": "1.18", diff --git a/crates/swc_ecma_preset_env/data/core-js-compat/data.json b/crates/swc_ecma_preset_env/data/core-js-compat/data.json index c53e85e7988e..da2818ae5db1 100755 --- a/crates/swc_ecma_preset_env/data/core-js-compat/data.json +++ b/crates/swc_ecma_preset_env/data/core-js-compat/data.json @@ -389,6 +389,7 @@ "electron": "10.0", "firefox": "79", "firefox-android": "79", + "hermes": "0.13", "ios": "14.0", "node": "15.0", "oculus": "12.0", @@ -410,6 +411,7 @@ "electron": "15.0", "firefox": "91", "firefox-android": "91", + "hermes": "0.13", "ios": "15.0", "node": "16.11", "oculus": "18.0", @@ -431,6 +433,7 @@ "electron": "14.0", "firefox": "90", "firefox-android": "90", + "hermes": "0.13", "ios": "15.4", "node": "16.6", "oculus": "17.0", @@ -711,6 +714,7 @@ "electron": "1.2", "firefox": "53", "firefox-android": "53", + "hermes": "0.13", "ios": "9.0", "node": "6.5", "oculus": "3.0", @@ -1113,6 +1117,7 @@ "electron": "23.0", "firefox": "115", "firefox-android": "115", + "hermes": "0.13", "ios": "16.0", "node": "20.0", "oculus": "26.0", @@ -1154,6 +1159,7 @@ "electron": "23.0", "firefox": "115", "firefox-android": "115", + "hermes": "0.13", "ios": "16.0", "node": "20.0", "oculus": "26.0", @@ -1238,6 +1244,7 @@ "electron": "23.0", "firefox": "115", "firefox-android": "115", + "hermes": "0.13", "ios": "16.0", "node": "20.0", "oculus": "26.0", @@ -1726,6 +1733,7 @@ "electron": "5.0", "firefox": "64", "firefox-android": "64", + "hermes": "0.13", "ios": "12.2", "node": "12.0", "oculus": "6.0", @@ -1770,6 +1778,7 @@ "electron": "1.2", "firefox": "53", "firefox-android": "53", + "hermes": "0.13", "ios": "10.0", "node": "6.5", "oculus": "3.0", @@ -3673,6 +3682,7 @@ "electron": "3.0", "firefox": "78", "firefox-android": "78", + "hermes": "0.13", "ios": "11.3", "node": "10.0", "oculus": "5.0", @@ -3782,6 +3792,7 @@ "electron": "1.2", "firefox": "53", "firefox-android": "53", + "hermes": "0.13", "ios": "10.0", "node": "6.5", "oculus": "3.0", @@ -3944,6 +3955,7 @@ "electron": "14.0", "firefox": "90", "firefox-android": "90", + "hermes": "0.13", "ios": "15.4", "node": "16.6", "oculus": "17.0", @@ -4237,6 +4249,7 @@ "electron": "3.0", "firefox": "78", "firefox-android": "78", + "hermes": "0.13", "ios": "14.0", "node": "10.0", "oculus": "5.0", @@ -4923,6 +4936,7 @@ "electron": "14.0", "firefox": "90", "firefox-android": "90", + "hermes": "0.13", "ios": "15.4", "node": "16.6", "oculus": "17.0", @@ -5620,6 +5634,7 @@ "electron": "1.2", "firefox": "53", "firefox-android": "53", + "hermes": "0.13", "ios": "10.0", "node": "6.5", "oculus": "3.0", @@ -5642,6 +5657,7 @@ "electron": "1.2", "firefox": "53", "firefox-android": "53", + "hermes": "0.13", "ios": "10.0", "node": "6.5", "oculus": "3.0", @@ -5664,6 +5680,7 @@ "electron": "10.0", "firefox": "79", "firefox-android": "79", + "hermes": "0.13", "ios": "14.0", "node": "15.0", "oculus": "12.0", @@ -5706,6 +5723,7 @@ "electron": "14.0", "firefox": "90", "firefox-android": "90", + "hermes": "0.13", "ios": "15.4", "node": "16.6", "oculus": "17.0", @@ -5781,6 +5799,7 @@ "electron": "23.0", "firefox": "115", "firefox-android": "115", + "hermes": "0.13", "ios": "16.0", "node": "20.0", "oculus": "26.0", @@ -5822,6 +5841,7 @@ "electron": "23.0", "firefox": "115", "firefox-android": "115", + "hermes": "0.13", "ios": "16.0", "node": "20.0", "oculus": "26.0", @@ -5844,6 +5864,7 @@ "electron": "23.0", "firefox": "115", "firefox-android": "115", + "hermes": "0.13", "ios": "16.0", "node": "20.0", "oculus": "26.0", @@ -5936,12 +5957,14 @@ "esnext.composite-key": {}, "esnext.composite-symbol": {}, "esnext.data-view.get-float16": { + "bun": "1.1.23", "deno": "1.43", "firefox": "129", "firefox-android": "129" }, "esnext.data-view.get-uint8-clamped": {}, "esnext.data-view.set-float16": { + "bun": "1.1.23", "deno": "1.43", "firefox": "129", "firefox-android": "129" @@ -5983,6 +6006,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6000,6 +6025,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6015,6 +6042,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6030,6 +6059,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6045,6 +6076,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6060,6 +6093,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6075,6 +6110,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6090,6 +6127,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6106,6 +6145,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6122,6 +6163,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6137,6 +6180,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6152,6 +6197,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6167,6 +6214,8 @@ "deno": "1.37", "edge": "122", "electron": "29.0", + "firefox": "131", + "firefox-android": "131", "node": "22.0", "oculus": "32.0", "opera": "108", @@ -6265,6 +6314,7 @@ "esnext.math.degrees": {}, "esnext.math.fscale": {}, "esnext.math.f16round": { + "bun": "1.1.23", "deno": "1.43", "firefox": "129", "firefox-android": "129" @@ -6371,6 +6421,7 @@ }, "esnext.promise.try": { "android": "128", + "bun": "1.1.22", "chrome": "128", "chrome-android": "128", "edge": "128", @@ -6406,7 +6457,9 @@ "esnext.reflect.has-metadata": {}, "esnext.reflect.has-own-metadata": {}, "esnext.reflect.metadata": {}, - "esnext.regexp.escape": {}, + "esnext.regexp.escape": { + "bun": "1.1.22" + }, "esnext.set.add-all": {}, "esnext.set.delete-all": {}, "esnext.set.difference.v2": { @@ -6663,7 +6716,9 @@ "edge": "127", "electron": "32.0", "node": "20.5.0", - "opera": "113" + "opera": "113", + "opera-android": "84", + "opera_mobile": "84" }, "esnext.symbol.custom-matcher": {}, "esnext.symbol.dispose": { @@ -6705,6 +6760,7 @@ "electron": "14.0", "firefox": "90", "firefox-android": "90", + "hermes": "0.13", "ios": "15.4", "node": "16.6", "oculus": "17.0", @@ -6826,12 +6882,24 @@ "safari": "16.4", "samsung": "21.0" }, - "esnext.uint8-array.from-base64": {}, - "esnext.uint8-array.from-hex": {}, - "esnext.uint8-array.set-from-base64": {}, - "esnext.uint8-array.set-from-hex": {}, - "esnext.uint8-array.to-base64": {}, - "esnext.uint8-array.to-hex": {}, + "esnext.uint8-array.from-base64": { + "bun": "1.1.22" + }, + "esnext.uint8-array.from-hex": { + "bun": "1.1.22" + }, + "esnext.uint8-array.set-from-base64": { + "bun": "1.1.22" + }, + "esnext.uint8-array.set-from-hex": { + "bun": "1.1.22" + }, + "esnext.uint8-array.to-base64": { + "bun": "1.1.22" + }, + "esnext.uint8-array.to-hex": { + "bun": "1.1.22" + }, "esnext.weak-map.delete-all": {}, "esnext.weak-map.from": {}, "esnext.weak-map.of": {}, @@ -6851,6 +6919,7 @@ "electron": "0.20", "firefox": "27", "firefox-android": "27", + "hermes": "0.13", "ios": "10.3", "node": "18.0", "oculus": "3.0", diff --git a/package.json b/package.json index e07fee5443f6..5457d2f73bd9 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test:html": "cd ./packages/html && yarn test" }, "devDependencies": { - "@babel/compat-data": "^7.25.2", + "@babel/compat-data": "^7.25.4", "@babel/core": "^7.13.16", "@babel/generator": "^7.18.13", "@babel/plugin-proposal-class-properties": "^7.13.0", @@ -46,7 +46,7 @@ "bootstrap": "^5.2.1", "class-validator": "^0.13.1", "core-js": "^2.6.11", - "core-js-compat": "^3.38.0", + "core-js-compat": "^3.38.1", "cross-env": "^7.0.3", "cspell": "^5.12.3", "expect": "^27.4.2", From 73605c6dc7bb2640c4bc22b759b9bc8e50f401ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 4 Oct 2024 15:12:14 +0900 Subject: [PATCH 06/23] Discard changes to crates/swc_ecma_preset_env/src/corejs3/builtin.rs --- .../src/corejs3/builtin.rs | 911 ++++++++++++++---- 1 file changed, 709 insertions(+), 202 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 0cd07a83842a..dedc38978cd7 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -44,18 +44,26 @@ pub static COMMON_ITERATORS: &[&str] = &concat2::<3>(ARRAY_NATURE_ITERATORS, &["es.string.iterator"]); static ARRAY_NATURE_ITERATORS_WITH_TAG: &[&str] = - &concat2::<3>(&["es.object.to-string"], ARRAY_NATURE_ITERATORS); + &concat2::<3>(ARRAY_NATURE_ITERATORS, &["es.object.to-string"]); static COMMON_ITERATORS_WITH_TAG: &[&str] = - &concat2::<4>(&["es.object.to-string"], COMMON_ITERATORS); + &concat2::<4>(COMMON_ITERATORS, &["es.object.to-string"]); + +static ERROR_DEPENDENCIES: &[&str] = &["es.error.cause", "es.error.to-string"]; + +static SUPPRESSED_ERROR_DEPENDENCIES: &[&str] = + &concat2::<3>(&["esnext.suppressed-error.constructor"], ERROR_DEPENDENCIES); static TYPED_ARRAY_DEPENDENCIES: &[&str] = &[ + "es.typed-array.at", "es.typed-array.copy-within", "es.typed-array.every", "es.typed-array.fill", "es.typed-array.filter", "es.typed-array.find", "es.typed-array.find-index", + "es.typed-array.find-last", + "es.typed-array.find-last-index", "es.typed-array.for-each", "es.typed-array.includes", "es.typed-array.index-of", @@ -72,17 +80,22 @@ static TYPED_ARRAY_DEPENDENCIES: &[&str] = &[ "es.typed-array.sort", "es.typed-array.subarray", "es.typed-array.to-locale-string", + "es.typed-array.to-reversed", + "es.typed-array.to-sorted", "es.typed-array.to-string", + "es.typed-array.with", "es.object.to-string", "es.array.iterator", "es.array-buffer.slice", + "esnext.array-buffer.detached", + "esnext.array-buffer.transfer", + "esnext.array-buffer.transfer-to-fixed-length", + "esnext.typed-array.filter-reject", + "esnext.typed-array.group-by", + "esnext.typed-array.to-spliced", + "esnext.typed-array.unique-by", ]; -static TYPED_ARRAY_STATIC_METHODS: Lazy> = lazy_map!(Map { - from: define(null, ["es.typed-array.from"]), - of: define(null, ["es.typed-array.of"]), -}); - pub static PROMISE_DEPENDENCIES: &[&str] = &["es.promise", "es.object.to-string"]; static PROMISE_DEPENDENCIES_WITH_ITERATORS: &[&str] = @@ -91,10 +104,11 @@ static PROMISE_DEPENDENCIES_WITH_ITERATORS: &[&str] = static SYMBOL_DEPENDENCIES: &[&str] = &["es.symbol", "es.symbol.description", "es.object.to-string"]; -static MAP_DEPENDENCIES: &[&str] = &concat2::<18>( +static MAP_DEPENDENCIES: &[&str] = &concat2::<19>( &[ "es.map", "esnext.map.delete-all", + "esnext.map.emplace", "esnext.map.every", "esnext.map.filter", "esnext.map.find", @@ -111,31 +125,42 @@ static MAP_DEPENDENCIES: &[&str] = &concat2::<18>( COMMON_ITERATORS_WITH_TAG, ); -static SET_DEPENDENCIES: &[&str] = &concat2::<21>( +static SET_DEPENDENCIES: &[&str] = &concat2::<28>( &[ "es.set", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", + "esnext.set.difference.v2", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", + "esnext.set.intersection.v2", "esnext.set.is-disjoint-from", + "esnext.set.is-disjoint-from.v2", "esnext.set.is-subset-of", + "esnext.set.is-subset-of.v2", "esnext.set.is-superset-of", + "esnext.set.is-superset-of.v2", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", + "esnext.set.symmetric-difference.v2", "esnext.set.union", + "esnext.set.union.v2", ], COMMON_ITERATORS_WITH_TAG, ); -static WEAK_MAP_DEPENDENCIES: &[&str] = &concat2::<6>( - &["es.weak-map", "esnext.weak-map.delete-all"], +static WEAK_MAP_DEPENDENCIES: &[&str] = &concat2::<7>( + &[ + "es.weak-map", + "esnext.weak-map.delete-all", + "esnext.weak-map.emplace", + ], COMMON_ITERATORS_WITH_TAG, ); @@ -148,245 +173,506 @@ static WEAK_SET_DEPENDENCIES: &[&str] = &concat2::<7>( COMMON_ITERATORS_WITH_TAG, ); -static URL_SEARCH_PARAMS_DEPENDENCIES: &[&str] = - &concat2::<5>(&["web.url"], COMMON_ITERATORS_WITH_TAG); +static DOM_EXCEPTION_DEPENDENCIES: &[&str] = &[ + "web.dom-exception.constructor", + "web.dom-exception.stack", + "web.dom-exception.to-string-tag", + "es.error.to-string", +]; -pub(crate) static BUILT_INS: Lazy> = lazy_map!(Map { - AggregateError: define( - "aggregate-error", - ["esnext.aggregate-error", COMMON_ITERATORS] - ), - ArrayBuffer: define( - null, - [ - "es.array-buffer.constructor", - "es.array-buffer.slice", - "es.object.to-string", - ] - ), - DataView: define( - null, - [ - "es.data-view", - "es.array-buffer.slice", - "es.object.to-string", - ] - ), - Date: define(null, ["es.date.to-string"]), - Float32Array: typed("es.typed-array.float32-array"), - Float64Array: typed("es.typed-array.float64-array"), - Int8Array: typed("es.typed-array.int8-array"), - Int16Array: typed("es.typed-array.int16-array"), - Int32Array: typed("es.typed-array.int32-array"), - Uint8Array: typed("es.typed-array.uint8-array"), - Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"), - Uint16Array: typed("es.typed-array.uint16-array"), - Uint32Array: typed("es.typed-array.uint32-array"), - Map: define("map/index", MAP_DEPENDENCIES), - Number: define(null, ["es.number.constructor"]), - Observable: define( - "observable/index", - [ - "esnext.observable", - "esnext.symbol.observable", - "es.object.to-string", - COMMON_ITERATORS_WITH_TAG, - ] - ), - Promise: define("promise/index", PROMISE_DEPENDENCIES), - RegExp: define( +static URL_SEARCH_PARAMS_DEPENDENCIES: &[&str] = &concat2::<8>( + &[ + "web.url-search-params", + "web.url-search-params.delete", + "web.url-search-params.has", + "web.url-search-params.size", + ], + COMMON_ITERATORS_WITH_TAG, +); + +static ASYNC_ITERATOR_DEPENDENCIES: &[&str] = + &concat2::<3>(&["esnext.async-iterator.constructor"], PROMISE_DEPENDENCIES); + +static ASYNC_ITERATOR_PROBLEM_METHODS: &[&str] = &[ + "esnext.async-iterator.every", + "esnext.async-iterator.filter", + "esnext.async-iterator.find", + "esnext.async-iterator.flat-map", + "esnext.async-iterator.for-each", + "esnext.async-iterator.map", + "esnext.async-iterator.reduce", + "esnext.async-iterator.some", +]; + +static ITERATOR_DEPENDENCIES: &[&str] = &["esnext.iterator.constructor", "es.object.to-string"]; + +static TYPED_ARRAY_STATIC_METHODS: Lazy> = lazy_map!(Map { + from: define(null, ["es.typed-array.from"]), + fromAsync: define( null, [ - "es.regexp.constructor", - "es.regexp.exec", - "es.regexp.to-string", + "esnext.typed-array.from-async", + PROMISE_DEPENDENCIES_WITH_ITERATORS, ] ), - Set: define("set/index", SET_DEPENDENCIES), - Symbol: define("symbol/index", SYMBOL_DEPENDENCIES), - URL: define("url/index", ["web.url", URL_SEARCH_PARAMS_DEPENDENCIES]), - URLSearchParams: define("url-search-params/index", URL_SEARCH_PARAMS_DEPENDENCIES), - WeakMap: define("weak-map/index", WEAK_MAP_DEPENDENCIES), - WeakSet: define("weak-set/index", WEAK_SET_DEPENDENCIES), - clearImmediate: define("clear-immediate", ["web.immediate"]), - compositeKey: define("composite-key", ["esnext.composite-key"]), - compositeSymbol: define( - "composite-symbol", - ["esnext.composite-symbol", SYMBOL_DEPENDENCIES] - ), - fetch: define(null, PROMISE_DEPENDENCIES), - globalThis: define("global-this", ["es.global-this", "esnext.global-this"]), - parseFloat: define("parse-float", ["es.parse-float"]), - parseInt: define("parse-int", ["es.parse-int"]), - queueMicrotask: define("queue-microtask", ["web.queue-microtask"]), - setTimeout: define("set-timeout", ["web.timers"]), - setInterval: define("set-interval", ["web.timers"]), - setImmediate: define("set-immediate", ["web.immediate"]), + of: define(null, ["es.typed-array.of"]), +}); + +static DATA_VIEW_DEPENDENCIES: &[&str] = &[ + "es.data-view", + "es.array-buffer.slice", + "es.object.to-string", +]; + +pub(crate) static BUILT_INS: Lazy> = lazy_map!(Map{ + AsyncDisposableStack: define("async-disposable-stack", [ + "esnext.async-disposable-stack.constructor", + "es.object.to-string", + "esnext.async-iterator.async-dispose", + "esnext.iterator.dispose", + PROMISE_DEPENDENCIES, + SuppressedERROR_DEPENDENCIES, + ]), + AsyncIterator: define("async-iterator/index", ASYNC_ITERATOR_DEPENDENCIES), + AggregateError: define("aggregate-error", [ + "es.aggregate-error", + ERROR_DEPENDENCIES, + CommonIteratorsWithTag, + "es.aggregate-error.cause", + ]), + ArrayBuffer: define(null, [ + "es.array-buffer.constructor", + "es.array-buffer.slice", + "es.object.to-string", + ]), + DataView: define(null, [ + "es.data-view", + "es.array-buffer.slice", + "es.object.to-string", + ]), + DataView: define(null, DATA_VIEW_DEPENDENCIES), + Date: define(null, ["es.date.to-string"]), + DOMException: define("dom-exception", DOM_EXCEPTION_DEPENDENCIES), + DisposableStack: define("disposable-stack", [ + "esnext.disposable-stack.constructor", + "es.object.to-string", + "esnext.iterator.dispose", + SUPPRESSED_ERROR_DEPENDENCIES, + ]), + Error: define(null, ERROR_DEPENDENCIES), + EvalError: define(null, ERROR_DEPENDENCIES), + Float32Array: typed("es.typed-array.float32-array"), + Float64Array: typed("es.typed-array.float64-array"), + Int8Array: typed("es.typed-array.int8-array"), + Int16Array: typed("es.typed-array.int16-array"), + Int32Array: typed("es.typed-array.int32-array"), + Iterator: define("iterator/index", ITERATOR_DEPENDENCIES), + Uint8Array: typed("es.typed-array.uint8-array"), + Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"), + Uint16Array: typed("es.typed-array.uint16-array"), + Uint32Array: typed("es.typed-array.uint32-array"), + Map: define("map/index", MAP_DEPENDENCIES), + Number: define(null, ["es.number.constructor"]), + Observable: define("observable/index", [ + "esnext.observable", + "esnext.symbol.observable", + "es.object.to-string", + COMMON_ITERATORS_WITH_TAG, + ]), + Promise: define("promise/index", PROMISE_DEPENDENCIES), + RangeError: define(null, ERROR_DEPENDENCIES), + ReferenceError: define(null, ERROR_DEPENDENCIES), + Reflect: define(null, ["es.reflect.to-string-tag", "es.object.to-string"]), + RegExp: define(null, [ + "es.regexp.constructor", + "es.regexp.dot-all", + "es.regexp.exec", + "es.regexp.sticky", + "es.regexp.to-string", + ]), + Set: define("set/index", SET_DEPENDENCIES), + SuppressedError: define("suppressed-error", SUPPRESSED_ERROR_DEPENDENCIES), + Symbol: define("symbol/index", SYMBOL_DEPENDENCIES), + SyntaxError: define(null, ERROR_DEPENDENCIES), + TypeError: define(null, ERROR_DEPENDENCIES), + URIError: define(null, ERROR_DEPENDENCIES), + URL: define("url/index", ["web.url", URL_SEARCH_PARAMS_DEPENDENCIES]), + URLSearchParams: define( + "url-search-params/index", + URL_SEARCH_PARAMS_DEPENDENCIES + ), + WeakMap: define("weak-map/index", WEAK_MAP_DEPENDENCIES), + WeakSet: define("weak-set/index", WEAK_SET_DEPENDENCIES), + + atob: define("atob", ["web.atob", DOM_EXCEPTION_DEPENDENCIES]), + btoa: define("btoa", ["web.btoa", DOM_EXCEPTION_DEPENDENCIES]), + clearImmediate: define("clear-immediate", ["web.immediate"]), + compositeKey: define("composite-key", ["esnext.composite-key"]), + compositeSymbol: define("composite-symbol", ["esnext.composite-symbol"]), + escape: define("escape", ["es.escape"]), + fetch: define(null, PROMISE_DEPENDENCIES), + globalThis: define("global-this", ["es.global-this"]), + parseFloat: define("parse-float", ["es.parse-float"]), + parseInt: define("parse-int", ["es.parse-int"]), + queueMicrotask: define("queue-microtask", ["web.queue-microtask"]), + self: define("self", ["web.self"]), + setImmediate: define("set-immediate", ["web.immediate"]), + setInterval: define("set-interval", ["web.timers"]), + setTimeout: define("set-timeout", ["web.timers"]), + structuredClone: define("structured-clone", [ + "web.structured-clone", + DOM_EXCEPTION_DEPENDENCIES, + "es.array.iterator", + "es.object.keys", + "es.object.to-string", + "es.map", + "es.set", + ]), + unescape: define("unescape", ["es.unescape"]), }); pub(crate) static STATIC_PROPERTIES: Lazy> = lazy_map!(Map{ + AsyncIterator: Map { + from: define("async-iterator/from", [ + "esnext.async-iterator.from", + ASYNC_ITERATOR_DEPENDENCIES, + AsyncIteratorProblemMethods, + CommonIterators, + ]), + }, Array: Map { from: define("array/from", ["es.array.from", "es.string.iterator"]), + fromAsync: define("array/from-async", [ + "esnext.array.from-async", + PROMISE_DEPENDENCIES_WITH_ITERATORS, + ]), isArray: define("array/is-array", ["es.array.is-array"]), + isTemplateObject: define("array/is-template-object", [ + "esnext.array.is-template-object", + ]), of: define("array/of", ["es.array.of"]), }, + ArrayBuffer: Map { + isView: define(null, ["es.array-buffer.is-view"]), + }, + + BigInt: Map { + range: define("bigint/range", [ + "esnext.bigint.range", + "es.object.to-string", + ]), + }, + Date: Map { now: define("date/now", ["es.date.now"]), }, - Object: Map { - assign: define("object/assign", ["es.object.assign"]), - create: define("object/create", ["es.object.create"]), - defineProperty: define("object/define-property", ["es.object.define-property"]), - defineProperties: define("object/define-properties", ["es.object.define-properties"]), - entries: define("object/entries", ["es.object.entries"]), - freeze: define("object/freeze", ["es.object.freeze"]), - fromEntries: define("object/from-entries", ["es.object.from-entries", "es.array.iterator"]), - getOwnPropertyDescriptor: define("object/get-own-property-descriptor", ["es.object.get-own-property-descriptor"]), - getOwnPropertyDescriptors: define("object/get-own-property-descriptors", ["es.object.get-own-property-descriptors"]), - getOwnPropertyNames: define("object/get-own-property-names", ["es.object.get-own-property-names"]), - getOwnPropertySymbols: define("object/get-own-property-symbols", ["es.symbol"]), - getPrototypeOf: define("object/get-prototype-of", ["es.object.get-prototype-of"]), - is: define("object/is", ["es.object.is"]), - isExtensible: define("object/is-extensible", ["es.object.is-extensible"]), - isFrozen: define("object/is-frozen", ["es.object.is-frozen"]), - isSealed: define("object/is-sealed", ["es.object.is-sealed"]), - keys: define("object/keys", ["es.object.keys"]), - preventExtensions: define("object/prevent-extensions", ["es.object.prevent-extensions"]), - seal: define("object/seal", ["es.object.seal"]), - setPrototypeOf: define("object/set-prototype-of", ["es.object.set-prototype-of"]), - values: define("object/values", ["es.object.values"]), + Function: Map { + isCallable: define("function/is-callable", ["esnext.function.is-callable"]), + isConstructor: define("function/is-constructor", [ + "esnext.function.is-constructor", + ]), + }, + + Iterator: Map { + from: define("iterator/from", [ + "esnext.iterator.from", + ITERATOR_DEPENDENCIES, + CommonIterators, + ]), + range: define("iterator/range", [ + "esnext.iterator.range", + "es.object.to-string", + ]), + }, + + JSON: Map { + isRawJSON: define("json/is-raw-json", ["esnext.json.is-raw-json"]), + parse: define("json/parse", ["esnext.json.parse", "es.object.keys"]), + rawJSON: define("json/raw-json", [ + "esnext.json.raw-json", + "es.object.create", + "es.object.freeze", + ]), + stringify: define("json/stringify", ["es.json.stringify"], "es.symbol"), }, Math: Map { + DEG_PER_RAD: define("math/deg-per-rad", ["esnext.math.deg-per-rad"]), + RAD_PER_DEG: define("math/rad-per-deg", ["esnext.math.rad-per-deg"]), acosh: define("math/acosh", ["es.math.acosh"]), asinh: define("math/asinh", ["es.math.asinh"]), atanh: define("math/atanh", ["es.math.atanh"]), cbrt: define("math/cbrt", ["es.math.cbrt"]), + clamp: define("math/clamp", ["esnext.math.clamp"]), clz32: define("math/clz32", ["es.math.clz32"]), cosh: define("math/cosh", ["es.math.cosh"]), + degrees: define("math/degrees", ["esnext.math.degrees"]), expm1: define("math/expm1", ["es.math.expm1"]), fround: define("math/fround", ["es.math.fround"]), + f16round: define("math/f16round", ["esnext.math.f16round"]), + fscale: define("math/fscale", ["esnext.math.fscale"]), hypot: define("math/hypot", ["es.math.hypot"]), + iaddh: define("math/iaddh", ["esnext.math.iaddh"]), imul: define("math/imul", ["es.math.imul"]), + imulh: define("math/imulh", ["esnext.math.imulh"]), + isubh: define("math/isubh", ["esnext.math.isubh"]), log10: define("math/log10", ["es.math.log10"]), log1p: define("math/log1p", ["es.math.log1p"]), log2: define("math/log2", ["es.math.log2"]), - sign: define("math/sign", ["es.math.sign"]), - sinh: define("math/sinh", ["es.math.sinh"]), - tanh: define("math/tanh", ["es.math.tanh"]), - trunc: define("math/trunc", ["es.math.trunc"]), - DEG_PER_RAD: define("math/deg-per-rad", ["esnext.math.deg-per-rad"]), - RAD_PER_DEG: define("math/rad-per-deg", ["esnext.math.rad-per-deg"]), - clamp: define("math/clamp", ["esnext.math.clamp"]), - degrees: define("math/degrees", ["esnext.math.degrees"]), - fscale: define("math/fscale", ["esnext.math.fscale"]), - iaddh: define("math/iaddh", ["esnext.math.iaddh"]), - imulh: define("math/imulh", ["esnext.math.imulh"]), - isubh: define("math/isubh", ["esnext.math.isubh"]), radians: define("math/radians", ["esnext.math.radians"]), scale: define("math/scale", ["esnext.math.scale"]), seededPRNG: define("math/seeded-prng", ["esnext.math.seeded-prng"]), + sign: define("math/sign", ["es.math.sign"]), signbit: define("math/signbit", ["esnext.math.signbit"]), + sinh: define("math/sinh", ["es.math.sinh"]), + tanh: define("math/tanh", ["es.math.tanh"]), + trunc: define("math/trunc", ["es.math.trunc"]), umulh: define("math/umulh", ["esnext.math.umulh"]), }, - String: Map { - fromCodePoint: define("string/from-code-point", ["es.string.from-code-point"]), - raw: define("string/raw", ["es.string.raw"]), + Map: Map { + from: define(null, ["esnext.map.from", MAP_DEPENDENCIES]), + groupBy: define(null, ["esnext.map.group-by", MAP_DEPENDENCIES]), + keyBy: define(null, ["esnext.map.key-by", MAP_DEPENDENCIES]), + of: define(null, ["esnext.map.of", MAP_DEPENDENCIES]), }, Number: Map { EPSILON: define("number/epsilon", ["es.number.epsilon"]), - MIN_SAFE_INTEGER: define("number/min-safe-integer", ["es.number.min-safe-integer"]), - MAX_SAFE_INTEGER: define("number/max-safe-integer", ["es.number.max-safe-integer"]), + MAX_SAFE_INTEGER: define("number/max-safe-integer", [ + "es.number.max-safe-integer", + ]), + MIN_SAFE_INTEGER: define("number/min-safe-integer", [ + "es.number.min-safe-integer", + ]), fromString: define("number/from-string", ["esnext.number.from-string"]), isFinite: define("number/is-finite", ["es.number.is-finite"]), isInteger: define("number/is-integer", ["es.number.is-integer"]), - isSafeInteger: define("number/is-safe-integer", ["es.number.is-safe-integer"]), isNaN: define("number/is-nan", ["es.number.is-nan"]), + isSafeInteger: define("number/is-safe-integer", [ + "es.number.is-safe-integer", + ]), parseFloat: define("number/parse-float", ["es.number.parse-float"]), parseInt: define("number/parse-int", ["es.number.parse-int"]), + range: define("number/range", [ + "esnext.number.range", + "es.object.to-string", + ]), }, - Map: Map { - from: define(null, ["esnext.map.from", MAP_DEPENDENCIES]), - groupBy: define(null, ["esnext.map.group-by", MAP_DEPENDENCIES]), - keyBy: define(null, ["esnext.map.key-by", MAP_DEPENDENCIES]), - of: define(null, ["esnext.map.of", MAP_DEPENDENCIES]), - }, - - Set: Map { - from: define(null, ["esnext.set.from", SET_DEPENDENCIES]), - of: define(null, ["esnext.set.of", SET_DEPENDENCIES]), - }, - - WeakMap: Map { - from: define(null, ["esnext.weak-map.from", WEAK_MAP_DEPENDENCIES]), - of: define(null, ["esnext.weak-map.of", WEAK_MAP_DEPENDENCIES]), - }, - - WeakSet: Map { - from: define(null, ["esnext.weak-set.from", WEAK_SET_DEPENDENCIES]), - of: define(null, ["esnext.weak-set.of", WEAK_SET_DEPENDENCIES]), + Object: Map { + assign: define("object/assign", ["es.object.assign"]), + create: define("object/create", ["es.object.create"]), + defineProperties: define("object/define-properties", [ + "es.object.define-properties", + ]), + defineProperty: define("object/define-property", [ + "es.object.define-property", + ]), + entries: define("object/entries", ["es.object.entries"]), + freeze: define("object/freeze", ["es.object.freeze"]), + fromEntries: define("object/from-entries", [ + "es.object.from-entries", + "es.array.iterator", + ]), + getOwnPropertyDescriptor: define("object/get-own-property-descriptor", [ + "es.object.get-own-property-descriptor", + ]), + getOwnPropertyDescriptors: define("object/get-own-property-descriptors", [ + "es.object.get-own-property-descriptors", + ]), + getOwnPropertyNames: define("object/get-own-property-names", [ + "es.object.get-own-property-names", + ]), + getOwnPropertySymbols: define("object/get-own-property-symbols", [ + "es.symbol", + ]), + getPrototypeOf: define("object/get-prototype-of", [ + "es.object.get-prototype-of", + ]), + groupBy: define("object/group-by", [ + "esnext.object.group-by", + "es.object.create", + ]), + hasOwn: define("object/has-own", ["es.object.has-own"]), + is: define("object/is", ["es.object.is"]), + isExtensible: define("object/is-extensible", ["es.object.is-extensible"]), + isFrozen: define("object/is-frozen", ["es.object.is-frozen"]), + isSealed: define("object/is-sealed", ["es.object.is-sealed"]), + keys: define("object/keys", ["es.object.keys"]), + preventExtensions: define("object/prevent-extensions", [ + "es.object.prevent-extensions", + ]), + seal: define("object/seal", ["es.object.seal"]), + setPrototypeOf: define("object/set-prototype-of", [ + "es.object.set-prototype-of", + ]), + values: define("object/values", ["es.object.values"]), }, Promise: Map { all: define(null, PROMISE_DEPENDENCIES_WITH_ITERATORS), allSettled: define(null, [ "es.promise.all-settled", - "esnext.promise.all-settled", PROMISE_DEPENDENCIES_WITH_ITERATORS, ]), any: define(null, [ - "esnext.promise.any", - "esnext.aggregate-error", + "es.promise.any", + "es.aggregate-error", PROMISE_DEPENDENCIES_WITH_ITERATORS, ]), race: define(null, PROMISE_DEPENDENCIES_WITH_ITERATORS), - try: define(null, ["esnext.promise.try", PROMISE_DEPENDENCIES_WITH_ITERATORS]), + try: define(null, ["esnext.promise.try", PROMISE_DEPENDENCIES]), + withResolvers: define(null, [ + "esnext.promise.with-resolvers", + PROMISE_DEPENDENCIES, + ]), }, Reflect: Map { apply: define("reflect/apply", ["es.reflect.apply"]), construct: define("reflect/construct", ["es.reflect.construct"]), - defineMetadata: define("reflect/define-metadata", ["esnext.reflect.define-metadata"]), - defineProperty: define("reflect/define-property", ["es.reflect.define-property"]), - deleteMetadata: define("reflect/delete-metadata", ["esnext.reflect.delete-metadata"]), - deleteProperty: define("reflect/delete-property", ["es.reflect.delete-property"]), + defineMetadata: define("reflect/define-metadata", [ + "esnext.reflect.define-metadata", + ]), + defineProperty: define("reflect/define-property", [ + "es.reflect.define-property", + ]), + deleteMetadata: define("reflect/delete-metadata", [ + "esnext.reflect.delete-metadata", + ]), + deleteProperty: define("reflect/delete-property", [ + "es.reflect.delete-property", + ]), get: define("reflect/get", ["es.reflect.get"]), - getMetadata: define("reflect/get-metadata", ["esnext.reflect.get-metadata"]), - getMetadataKeys: define("reflect/get-metadata-keys", ["esnext.reflect.get-metadata-keys"]), - getOwnMetadata: define("reflect/get-own-metadata", ["esnext.reflect.get-own-metadata"]), - getOwnMetadataKeys: define("reflect/get-own-metadata-keys", ["esnext.reflect.get-own-metadata-keys"]), - getOwnPropertyDescriptor: define("reflect/get-own-property-descriptor", ["es.reflect.get-own-property-descriptor"]), - getPrototypeOf: define("reflect/get-prototype-of", ["es.reflect.get-prototype-of"]), + getMetadata: define("reflect/get-metadata", [ + "esnext.reflect.get-metadata", + ]), + getMetadataKeys: define("reflect/get-metadata-keys", [ + "esnext.reflect.get-metadata-keys", + ]), + getOwnMetadata: define("reflect/get-own-metadata", [ + "esnext.reflect.get-own-metadata", + ]), + getOwnMetadataKeys: define("reflect/get-own-metadata-keys", [ + "esnext.reflect.get-own-metadata-keys", + ]), + getOwnPropertyDescriptor: define("reflect/get-own-property-descriptor", [ + "es.reflect.get-own-property-descriptor", + ]), + getPrototypeOf: define("reflect/get-prototype-of", [ + "es.reflect.get-prototype-of", + ]), has: define("reflect/has", ["es.reflect.has"]), - hasMetadata: define("reflect/has-metadata", ["esnext.reflect.has-metadata"]), - hasOwnMetadata: define("reflect/has-own-metadata", ["esnext.reflect.has-own-metadata"]), + hasMetadata: define("reflect/has-metadata", [ + "esnext.reflect.has-metadata", + ]), + hasOwnMetadata: define("reflect/has-own-metadata", [ + "esnext.reflect.has-own-metadata", + ]), isExtensible: define("reflect/is-extensible", ["es.reflect.is-extensible"]), metadata: define("reflect/metadata", ["esnext.reflect.metadata"]), ownKeys: define("reflect/own-keys", ["es.reflect.own-keys"]), - preventExtensions: define("reflect/prevent-extensions", ["es.reflect.prevent-extensions"]), + preventExtensions: define("reflect/prevent-extensions", [ + "es.reflect.prevent-extensions", + ]), set: define("reflect/set", ["es.reflect.set"]), - setPrototypeOf: define("reflect/set-prototype-of", ["es.reflect.set-prototype-of"]), + setPrototypeOf: define("reflect/set-prototype-of", [ + "es.reflect.set-prototype-of", + ]), + }, + + Set: Map { + from: define(null, ["esnext.set.from", SET_DEPENDENCIES]), + of: define(null, ["esnext.set.of", SET_DEPENDENCIES]), + }, + + String: Map { + cooked: define("string/cooked", ["esnext.string.cooked"]), + dedent: define("string/dedent", [ + "esnext.string.dedent", + "es.string.from-code-point", + "es.weak-map", + ]), + fromCodePoint: define("string/from-code-point", [ + "es.string.from-code-point", + ]), + raw: define("string/raw", ["es.string.raw"]), }, Symbol: Map { - asyncIterator: define("symbol/async-iterator", ["es.symbol.async-iterator"]), - dispose: define("symbol/dispose", ["esnext.symbol.dispose"]), - hasInstance: define("symbol/has-instance", ["es.symbol.has-instance", "es.function.has-instance"]), - isConcatSpreadable: define("symbol/is-concat-spreadable", ["es.symbol.is-concat-spreadable", "es.array.concat"]), - iterator: define("symbol/iterator", ["es.symbol.iterator", COMMON_ITERATORS_WITH_TAG]), + asyncDispose: define("symbol/async-dispose", [ + "esnext.symbol.async-dispose", + "esnext.async-iterator.async-dispose", + ]), + asyncIterator: define("symbol/async-iterator", [ + "es.symbol.async-iterator", + ]), + dispose: define("symbol/dispose", [ + "esnext.symbol.dispose", + "esnext.iterator.dispose", + ]), + for: define("symbol/for", [], "es.symbol"), + hasInstance: define("symbol/has-instance", [ + "es.symbol.has-instance", + "es.function.has-instance", + ]), + isConcatSpreadable: define("symbol/is-concat-spreadable", [ + "es.symbol.is-concat-spreadable", + "es.array.concat", + ]), + isRegistered: define("symbol/is-registered", [ + "esnext.symbol.is-registered", + "es.symbol", + ]), + isRegisteredSymbol: define("symbol/is-registered-symbol", [ + "esnext.symbol.is-registered-symbol", + "es.symbol", + ]), + isWellKnown: define("symbol/is-well-known", [ + "esnext.symbol.is-well-known", + "es.symbol", + ]), + isWellKnownSymbol: define("symbol/is-well-known-symbol", [ + "esnext.symbol.is-well-known-symbol", + "es.symbol", + ]), + iterator: define("symbol/iterator", [ + "es.symbol.iterator", + COMMON_ITERATORS_WITH_TAG, + ]), + keyFor: define("symbol/key-for", [], "es.symbol"), match: define("symbol/match", ["es.symbol.match", "es.string.match"]), + matcher: define("symbol/matcher", ["esnext.symbol.matcher"]), + matchAll: define("symbol/match-all", [ + "es.symbol.match-all", + "es.string.match-all", + ]), + metadata: define("symbol/metadata", [ + "esnext.symbol.metadata", + "esnext.function.metadata", + ]), + metadataKey: define("symbol/metadata-key", ["esnext.symbol.metadata-key"]), observable: define("symbol/observable", ["esnext.symbol.observable"]), - patternMatch: define("symbol/pattern-match", ["esnext.symbol.pattern-match"]), - replace: define("symbol/replace", ["es.symbol.replace", "es.string.replace"]), + patternMatch: define("symbol/pattern-match", [ + "esnext.symbol.pattern-match", + ]), + replace: define("symbol/replace", [ + "es.symbol.replace", + "es.string.replace", + ]), search: define("symbol/search", ["es.symbol.search", "es.string.search"]), - species: define("symbol/species", ["es.symbol.species", "es.array.species"]), + species: define("symbol/species", [ + "es.symbol.species", + "es.array.species", + ]), split: define("symbol/split", ["es.symbol.split", "es.string.split"]), - toPrimitive: define("symbol/to-primitive", ["es.symbol.to-primitive", "es.date.to-primitive"]), + toPrimitive: define("symbol/to-primitive", [ + "es.symbol.to-primitive", + "es.date.to-primitive", + ]), toStringTag: define("symbol/to-string-tag", [ "es.symbol.to-string-tag", "es.object.to-string", @@ -396,8 +682,18 @@ pub(crate) static STATIC_PROPERTIES: Lazy> unscopables: define("symbol/unscopables", ["es.symbol.unscopables"]), }, - ArrayBuffer: Map { - isView: define(null, ["es.array-buffer.is-view"]), + URL: Map { + canParse: define("url/can-parse", ["web.url.can-parse", "web.url"]), + }, + + WeakMap: Map { + from: define(null, ["esnext.weak-map.from", WEAK_MAP_DEPENDENCIES]), + of: define(null, ["esnext.weak-map.of", WEAK_MAP_DEPENDENCIES]), + }, + + WeakSet: Map { + from: define(null, ["esnext.weak-set.from", WEAK_SET_DEPENDENCIES]), + of: define(null, ["esnext.weak-set.of", WEAK_SET_DEPENDENCIES]), }, Int8Array: *TYPED_ARRAY_STATIC_METHODS, @@ -409,10 +705,38 @@ pub(crate) static STATIC_PROPERTIES: Lazy> Uint32Array: *TYPED_ARRAY_STATIC_METHODS, Float32Array: *TYPED_ARRAY_STATIC_METHODS, Float64Array: *TYPED_ARRAY_STATIC_METHODS, + + WebAssembly: Map { + CompileError: define(null, ERROR_DEPENDENCIES), + LinkError: define(null, ERROR_DEPENDENCIES), + RuntimeError: define(null, ERROR_DEPENDENCIES), + }, }); pub(crate) static INSTANCE_PROPERTIES: Lazy> = lazy_map!(Map { - at: define("instance/at", ["es.string.at", "es.array.at"]), + asIndexedPairs: define( + "instance/asIndexedPairs", + [ + "esnext.async-iterator.as-indexed-pairs", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.as-indexed-pairs", + ITERATOR_DEPENDENCIES, + ] + ), + at: define( + "instance/at", + [ + // TODO: We should introduce overloaded instance methods definition + // Before that is implemented, the `esnext.string.at` must be the first + // In pure mode, the provider resolves the descriptor as a "pure" `esnext.string.at` + // and treats the compat-data of `esnext.string.at` as the compat-data of + // pure import `instance/at`. The first polyfill here should have the lowest corejs + // supported versions. + "esnext.string.at", + "es.string.at-alternative", + "es.array.at", + ] + ), anchor: define(null, ["es.string.anchor"]), big: define(null, ["es.string.big"]), bind: define("instance/bind", ["es.function.bind"]), @@ -420,86 +744,269 @@ pub(crate) static INSTANCE_PROPERTIES: Lazy> bold: define(null, ["es.string.bold"]), codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]), codePoints: define("instance/code-points", ["esnext.string.code-points"]), - concat: define("instance/concat", ["es.array.concat"]), + concat: define("instance/concat", ["es.array.concat"], None, ["String"]), copyWithin: define("instance/copy-within", ["es.array.copy-within"]), + demethodize: define("instance/demethodize", ["esnext.function.demethodize"]), + description: define(null, ["es.symbol", "es.symbol.description"]), + dotAll: define(null, ["es.regexp.dot-all"]), + drop: define( + "instance/drop", + [ + "esnext.async-iterator.drop", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.drop", + ITERATOR_DEPENDENCIES, + ] + ), + emplace: define( + "instance/emplace", + ["esnext.map.emplace", "esnext.weak-map.emplace",] + ), endsWith: define("instance/ends-with", ["es.string.ends-with"]), entries: define("instance/entries", ARRAY_NATURE_ITERATORS_WITH_TAG), - every: define("instance/every", ["es.array.every"]), + every: define( + "instance/every", + [ + "es.array.every", + "esnext.async-iterator.every", + // TODO: add async iterator dependencies when we support sub-dependencies + // esnext.async-iterator.every depends on es.promise + // but we don't want to pull es.promise when esnext.async-iterator is disabled + // + // ASYNC_ITERATOR_DEPENDENCIES + "esnext.iterator.every", + ITERATOR_DEPENDENCIES, + ] + ), exec: define(null, ["es.regexp.exec"]), fill: define("instance/fill", ["es.array.fill"]), - filter: define("instance/filter", ["es.array.filter"]), + filter: define( + "instance/filter", + [ + "es.array.filter", + "esnext.async-iterator.filter", + "esnext.iterator.filter", + ITERATOR_DEPENDENCIES, + ] + ), + filterReject: define("instance/filterReject", ["esnext.array.filter-reject"]), finally: define(null, ["es.promise.finally", PROMISE_DEPENDENCIES]), - find: define("instance/find", ["es.array.find"]), + find: define( + "instance/find", + [ + "es.array.find", + "esnext.async-iterator.find", + "esnext.iterator.find", + ITERATOR_DEPENDENCIES, + ] + ), findIndex: define("instance/find-index", ["es.array.find-index"]), + findLast: define("instance/find-last", ["es.array.find-last"]), + findLastIndex: define("instance/find-last-index", ["es.array.find-last-index",]), fixed: define(null, ["es.string.fixed"]), flags: define("instance/flags", ["es.regexp.flags"]), - flat: define("instance/flat", ["es.array.flat", "es.array.unscopables.flat"]), - flatMap: define("instance/flat-map", ["es.array.flat-map", "es.array.unscopables.flat-map"]), + flatMap: define( + "instance/flat-map", + [ + "es.array.flat-map", + "es.array.unscopables.flat-map", + "esnext.async-iterator.flat-map", + "esnext.iterator.flat-map", + ITERATOR_DEPENDENCIES, + ] + ), + flat: define( + "instance/flat", + ["es.array.flat", "es.array.unscopables.flat"] + ), + getFloat16: define( + null, + ["esnext.data-view.get-float16", DATA_VIEW_DEPENDENCIES] + ), + getUint8Clamped: define( + null, + ["esnext.data-view.get-uint8-clamped", DATA_VIEW_DEPENDENCIES] + ), + getYear: define(null, ["es.date.get-year"]), + group: define("instance/group", ["esnext.array.group"]), + groupBy: define("instance/group-by", ["esnext.array.group-by"]), + groupByToMap: define( + "instance/group-by-to-map", + [ + "esnext.array.group-by-to-map", + "es.map", + "es.object.to-string", + ] + ), + groupToMap: define( + "instance/group-to-map", + ["esnext.array.group-to-map", "es.map", "es.object.to-string",] + ), fontcolor: define(null, ["es.string.fontcolor"]), fontsize: define(null, ["es.string.fontsize"]), - forEach: define("instance/for-each", ["es.array.for-each", "web.dom-collections.for-each"]), - includes: define("instance/includes", ["es.array.includes", "es.string.includes"]), + forEach: define( + "instance/for-each", + [ + "es.array.for-each", + "esnext.async-iterator.for-each", + "esnext.iterator.for-each", + ITERATOR_DEPENDENCIES, + "web.dom-collections.for-each", + ] + ), + includes: define( + "instance/includes", + ["es.array.includes", "es.string.includes",] + ), + indexed: define( + "instance/indexed", + [ + "esnext.async-iterator.indexed", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.indexed", + ITERATOR_DEPENDENCIES, + ] + ), indexOf: define("instance/index-of", ["es.array.index-of"]), - italics: define(null, ["es.string.italics"]), + isWellFormed: define("instance/is-well-formed", ["es.string.is-well-formed"]), + italic: define(null, ["es.string.italics"]), join: define(null, ["es.array.join"]), keys: define("instance/keys", ARRAY_NATURE_ITERATORS_WITH_TAG), lastIndex: define(null, ["esnext.array.last-index"]), lastIndexOf: define("instance/last-index-of", ["es.array.last-index-of"]), lastItem: define(null, ["esnext.array.last-item"]), link: define(null, ["es.string.link"]), - map: define("instance/map", ["es.array.map"]), + map: define( + "instance/map", + [ + "es.array.map", + "esnext.async-iterator.map", + "esnext.iterator.map", + ] + ), match: define(null, ["es.string.match", "es.regexp.exec"]), - matchAll: define("instance/match-all", ["es.string.match-all", "esnext.string.match-all"]), + matchAll: define( + "instance/match-all", + ["es.string.match-all", "es.regexp.exec",] + ), name: define(null, ["es.function.name"]), padEnd: define("instance/pad-end", ["es.string.pad-end"]), padStart: define("instance/pad-start", ["es.string.pad-start"]), - reduce: define("instance/reduce", ["es.array.reduce"]), + push: define("instance/push", ["es.array.push"]), + reduce: define( + "instance/reduce", + [ + "es.array.reduce", + "esnext.async-iterator.reduce", + "esnext.iterator.reduce", + ITERATOR_DEPENDENCIES, + ] + ), reduceRight: define("instance/reduce-right", ["es.array.reduce-right"]), repeat: define("instance/repeat", ["es.string.repeat"]), replace: define(null, ["es.string.replace", "es.regexp.exec"]), - replaceAll: define("instance/replace-all", ["esnext.string.replace-all"]), + replaceAll: define( + "instance/replace-all", + [ + "es.string.replace-all", + "es.string.replace", + "es.regexp.exec", + ] + ), reverse: define("instance/reverse", ["es.array.reverse"]), search: define(null, ["es.string.search", "es.regexp.exec"]), + setFloat16: define( + null, + ["esnext.data-view.set-float16", DATA_VIEW_DEPENDENCIES] + ), + setUint8Clamped: define( + null, + ["esnext.data-view.set-uint8-clamped", DATA_VIEW_DEPENDENCIES] + ), + setYear: define(null, ["es.date.set-year"]), slice: define("instance/slice", ["es.array.slice"]), small: define(null, ["es.string.small"]), - some: define("instance/some", ["es.array.some"]), + some: define( + "instance/some", + [ + "es.array.some", + "esnext.async-iterator.some", + "esnext.iterator.some", + ITERATOR_DEPENDENCIES, + ] + ), sort: define("instance/sort", ["es.array.sort"]), splice: define("instance/splice", ["es.array.splice"]), split: define(null, ["es.string.split", "es.regexp.exec"]), startsWith: define("instance/starts-with", ["es.string.starts-with"]), + sticky: define(null, ["es.regexp.sticky"]), strike: define(null, ["es.string.strike"]), sub: define(null, ["es.string.sub"]), + substr: define(null, ["es.string.substr"]), sup: define(null, ["es.string.sup"]), + take: define( + "instance/take", + [ + "esnext.async-iterator.take", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.take", + ITERATOR_DEPENDENCIES, + ] + ), + test: define(null, ["es.regexp.test", "es.regexp.exec"]), + toArray: define( + "instance/to-array", + [ + "esnext.async-iterator.to-array", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.to-array", + ITERATOR_DEPENDENCIES, + ] + ), + toAsync: define( + null, + [ + "esnext.iterator.to-async", + ITERATOR_DEPENDENCIES, + ASYNC_ITERATOR_DEPENDENCIES, + AsyncIteratorProblemMethods, + ] + ), + toExponential: define(null, ["es.number.to-exponential"]), toFixed: define(null, ["es.number.to-fixed"]), + toGMTString: define(null, ["es.date.to-gmt-string"]), toISOString: define(null, ["es.date.to-iso-string"]), toJSON: define(null, ["es.date.to-json", "web.url.to-json"]), toPrecision: define(null, ["es.number.to-precision"]), - toString: define(null, ["es.object.to-string", "es.regexp.to-string", "es.date.to-string"]), + toReversed: define("instance/to-reversed", ["es.array.to-reversed"]), + toSorted: define( + "instance/to-sorted", + ["es.array.to-sorted", "es.array.sort",] + ), + toSpliced: define("instance/to-spliced", ["es.array.to-spliced"]), + toString: define( + null, + [ + "es.object.to-string", + "es.error.to-string", + "es.date.to-string", + "es.regexp.to-string", + ] + ), + toWellFormed: define("instance/to-well-formed", ["es.string.to-well-formed"]), trim: define("instance/trim", ["es.string.trim"]), trimEnd: define("instance/trim-end", ["es.string.trim-end"]), trimLeft: define("instance/trim-left", ["es.string.trim-start"]), trimRight: define("instance/trim-right", ["es.string.trim-end"]), trimStart: define("instance/trim-start", ["es.string.trim-start"]), + uniqueBy: define("instance/unique-by", ["esnext.array.unique-by", "es.map"]), + unshift: define("instance/unshift", ["es.array.unshift"]), + unThis: define("instance/un-this", ["esnext.function.un-this"]), values: define("instance/values", ARRAY_NATURE_ITERATORS_WITH_TAG), + with: define("instance/with", ["es.array.with"]), __defineGetter__: define(null, ["es.object.define-getter"]), __defineSetter__: define(null, ["es.object.define-setter"]), __lookupGetter__: define(null, ["es.object.lookup-getter"]), __lookupSetter__: define(null, ["es.object.lookup-setter"]), -}); - -pub static COMMON_INSTANCE_DEPENDENCIES: Lazy> = - lazy_map!(Map { - es_object_to_string: define(null, ["es.object.to-string"]), - es_object_define_getter: define(null, ["es.object.define-getter"]), - es_object_define_setter: define(null, ["es.object.define-setter"]), - es_object_lookup_getter: define(null, ["es.object.lookup-getter"]), - es_object_lookup_setter: define(null, ["es.object.lookup-setter"]), - es_regexp_exec: define(null, ["es.regexp.exec"]), - }); - -pub static POSSIBLE_GLOBAL_OBJECTS: Lazy> = lazy_map!(Map { - global: define(null, []), - globalThis: define(null, []), - self: define(null, []), - window: define(null, []), + __proto__: define(null, ["es.object.proto"]), }); From 83157d1477d4e9c594d9371844a9ca3f16f42550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:16:03 +0900 Subject: [PATCH 07/23] ARRAY_BUFFER_DEPENDENCIES --- crates/swc_ecma_preset_env/src/corejs3/builtin.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index dedc38978cd7..72eda4593d58 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -54,6 +54,16 @@ static ERROR_DEPENDENCIES: &[&str] = &["es.error.cause", "es.error.to-string"]; static SUPPRESSED_ERROR_DEPENDENCIES: &[&str] = &concat2::<3>(&["esnext.suppressed-error.constructor"], ERROR_DEPENDENCIES); +static ARRAY_BUFFER_DEPENDENCIES: &[&str] = &[ + "es.array-buffer.constructor", + "es.array-buffer.slice", + "es.data-view", + "es.array-buffer.detached", + "es.array-buffer.transfer", + "es.array-buffer.transfer-to-fixed-length", + "es.object.to-string", +]; + static TYPED_ARRAY_DEPENDENCIES: &[&str] = &[ "es.typed-array.at", "es.typed-array.copy-within", From ebbadb98f82a03a9df9108d15cfd017c9f8454f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:19:10 +0900 Subject: [PATCH 08/23] port --- .../src/corejs3/builtin.rs | 81 +++++++++---------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 72eda4593d58..4028318863c9 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -64,47 +64,46 @@ static ARRAY_BUFFER_DEPENDENCIES: &[&str] = &[ "es.object.to-string", ]; -static TYPED_ARRAY_DEPENDENCIES: &[&str] = &[ - "es.typed-array.at", - "es.typed-array.copy-within", - "es.typed-array.every", - "es.typed-array.fill", - "es.typed-array.filter", - "es.typed-array.find", - "es.typed-array.find-index", - "es.typed-array.find-last", - "es.typed-array.find-last-index", - "es.typed-array.for-each", - "es.typed-array.includes", - "es.typed-array.index-of", - "es.typed-array.iterator", - "es.typed-array.join", - "es.typed-array.last-index-of", - "es.typed-array.map", - "es.typed-array.reduce", - "es.typed-array.reduce-right", - "es.typed-array.reverse", - "es.typed-array.set", - "es.typed-array.slice", - "es.typed-array.some", - "es.typed-array.sort", - "es.typed-array.subarray", - "es.typed-array.to-locale-string", - "es.typed-array.to-reversed", - "es.typed-array.to-sorted", - "es.typed-array.to-string", - "es.typed-array.with", - "es.object.to-string", - "es.array.iterator", - "es.array-buffer.slice", - "esnext.array-buffer.detached", - "esnext.array-buffer.transfer", - "esnext.array-buffer.transfer-to-fixed-length", - "esnext.typed-array.filter-reject", - "esnext.typed-array.group-by", - "esnext.typed-array.to-spliced", - "esnext.typed-array.unique-by", -]; +static TYPED_ARRAY_DEPENDENCIES: &[&str] = &concat2::<40>( + &[ + "es.typed-array.at", + "es.typed-array.copy-within", + "es.typed-array.every", + "es.typed-array.fill", + "es.typed-array.filter", + "es.typed-array.find", + "es.typed-array.find-index", + "es.typed-array.find-last", + "es.typed-array.find-last-index", + "es.typed-array.for-each", + "es.typed-array.includes", + "es.typed-array.index-of", + "es.typed-array.iterator", + "es.typed-array.join", + "es.typed-array.last-index-of", + "es.typed-array.map", + "es.typed-array.reduce", + "es.typed-array.reduce-right", + "es.typed-array.reverse", + "es.typed-array.set", + "es.typed-array.slice", + "es.typed-array.some", + "es.typed-array.sort", + "es.typed-array.subarray", + "es.typed-array.to-locale-string", + "es.typed-array.to-reversed", + "es.typed-array.to-sorted", + "es.typed-array.to-string", + "es.typed-array.with", + "es.object.to-string", + "es.array.iterator", + "esnext.typed-array.filter-reject", + "esnext.typed-array.group-by", + "esnext.typed-array.to-spliced", + "esnext.typed-array.unique-by", + ], + ARRAY_BUFFER_DEPENDENCIES, +); pub static PROMISE_DEPENDENCIES: &[&str] = &["es.promise", "es.object.to-string"]; From 3b598a4f0a50b213eff83222e2698a7daed390dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:20:53 +0900 Subject: [PATCH 09/23] SET_DEPENDENCIES --- .../swc_ecma_preset_env/src/corejs3/builtin.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 4028318863c9..21bd55e59e0e 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -134,32 +134,32 @@ static MAP_DEPENDENCIES: &[&str] = &concat2::<19>( COMMON_ITERATORS_WITH_TAG, ); -static SET_DEPENDENCIES: &[&str] = &concat2::<28>( +static SET_DEPENDENCIES: &[&str] = &concat2::<25>( &[ "es.set", + "es.set.difference.v2", + "es.set.intersection.v2", + "es.set.is-disjoint-from.v2", + "es.set.is-subset-of.v2", + "es.set.is-superset-of.v2", + "es.set.symmetric-difference.v2", + "es.set.union.v2", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", - "esnext.set.difference.v2", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", - "esnext.set.intersection.v2", "esnext.set.is-disjoint-from", - "esnext.set.is-disjoint-from.v2", "esnext.set.is-subset-of", - "esnext.set.is-subset-of.v2", "esnext.set.is-superset-of", - "esnext.set.is-superset-of.v2", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", - "esnext.set.symmetric-difference.v2", "esnext.set.union", - "esnext.set.union.v2", ], COMMON_ITERATORS_WITH_TAG, ); From 93b248904c80910a50ad3b9fa19c1d17afa81c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:25:04 +0900 Subject: [PATCH 10/23] port mor --- .../src/corejs3/builtin.rs | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 21bd55e59e0e..6e01e7e0e021 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -215,23 +215,33 @@ static ASYNC_ITERATOR_PROBLEM_METHODS: &[&str] = &[ static ITERATOR_DEPENDENCIES: &[&str] = &["esnext.iterator.constructor", "es.object.to-string"]; -static TYPED_ARRAY_STATIC_METHODS: Lazy> = lazy_map!(Map { - from: define(null, ["es.typed-array.from"]), - fromAsync: define( - null, - [ - "esnext.typed-array.from-async", - PROMISE_DEPENDENCIES_WITH_ITERATORS, - ] - ), - of: define(null, ["es.typed-array.of"]), -}); +static DECORATOR_METADATA_DEPENDENCIES: &[&str] = + &["esnext.symbol.metadata", "esnext.function.metadata"]; -static DATA_VIEW_DEPENDENCIES: &[&str] = &[ - "es.data-view", - "es.array-buffer.slice", - "es.object.to-string", -]; +fn typed_array_static_methods(base: &str) -> ObjectMap { + lazy_map!(Map { + from: define( + null, + &concat2::<3>(&["es.typed-array.from", base], TYPED_ARRAY_DEPENDENCIES) + ), + fromAsync: define( + null, + &concat2::<4>(&[ + "esnext.typed-array.from-async", + base, + PROMISE_DEPENDENCIES_WITH_ITERATORS, + TYPED_ARRAY_DEPENDENCIES, + ]) + ), + of: define( + null, + &concat2::<3>(&["es.typed-array.of", base], TYPED_ARRAY_DEPENDENCIES) + ), + }) +} + +static DATA_VIEW_DEPENDENCIES: &[&str] = + &concat2::<2>(&["es.data-view"], ARRAY_BUFFER_DEPENDENCIES); pub(crate) static BUILT_INS: Lazy> = lazy_map!(Map{ AsyncDisposableStack: define("async-disposable-stack", [ From 8c6749fa930a2198b2b25ca4b45a466566872891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:29:26 +0900 Subject: [PATCH 11/23] BUILT_INS --- .../src/corejs3/builtin.rs | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 6e01e7e0e021..fe1c6f587cc4 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -30,12 +30,12 @@ const fn concat2(a: &[&'static str], b: &[&'static str]) -> [&'s res } -fn typed(name: &'static str) -> CoreJSPolyfillDescriptor { - let mut global = Vec::with_capacity(1 + TYPED_ARRAY_DEPENDENCIES.len()); - global.push(name); +fn typed(names: &'static [&'static str]) -> CoreJSPolyfillDescriptor { + let mut global = Vec::with_capacity(names.len() + TYPED_ARRAY_DEPENDENCIES.len()); + global.extend_from_slice(names); global.extend_from_slice(TYPED_ARRAY_DEPENDENCIES); - descriptor(None, global.leak(), Some(name), &[]) + descriptor(None, global.leak(), Some(names[0]), &[]) } static ARRAY_NATURE_ITERATORS: &[&str] = &["es.array.iterator", "web.dom-collections.iterator"]; @@ -244,35 +244,26 @@ static DATA_VIEW_DEPENDENCIES: &[&str] = &concat2::<2>(&["es.data-view"], ARRAY_BUFFER_DEPENDENCIES); pub(crate) static BUILT_INS: Lazy> = lazy_map!(Map{ - AsyncDisposableStack: define("async-disposable-stack", [ + AsyncDisposableStack: define("async-disposable-stack/index", [ "esnext.async-disposable-stack.constructor", "es.object.to-string", "esnext.async-iterator.async-dispose", "esnext.iterator.dispose", PROMISE_DEPENDENCIES, - SuppressedERROR_DEPENDENCIES, + SUPPRESSED_ERROR_DEPENDENCIES, ]), AsyncIterator: define("async-iterator/index", ASYNC_ITERATOR_DEPENDENCIES), AggregateError: define("aggregate-error", [ "es.aggregate-error", ERROR_DEPENDENCIES, - CommonIteratorsWithTag, + COMMON_ITERATORS_WITH_TAG, "es.aggregate-error.cause", ]), - ArrayBuffer: define(null, [ - "es.array-buffer.constructor", - "es.array-buffer.slice", - "es.object.to-string", - ]), - DataView: define(null, [ - "es.data-view", - "es.array-buffer.slice", - "es.object.to-string", - ]), + ArrayBuffer: define(null, ARRAY_BUFFER_DEPENDENCIES), DataView: define(null, DATA_VIEW_DEPENDENCIES), Date: define(null, ["es.date.to-string"]), - DOMException: define("dom-exception", DOM_EXCEPTION_DEPENDENCIES), - DisposableStack: define("disposable-stack", [ + DOMException: define("dom-exception/index", DOM_EXCEPTION_DEPENDENCIES), + DisposableStack: define("disposable-stack/index", [ "esnext.disposable-stack.constructor", "es.object.to-string", "esnext.iterator.dispose", @@ -286,7 +277,13 @@ pub(crate) static BUILT_INS: Lazy> = lazy_ma Int16Array: typed("es.typed-array.int16-array"), Int32Array: typed("es.typed-array.int32-array"), Iterator: define("iterator/index", ITERATOR_DEPENDENCIES), - Uint8Array: typed("es.typed-array.uint8-array"), + Uint8Array: typed( + "es.typed-array.uint8-array", + "esnext.uint8-array.set-from-base64", + "esnext.uint8-array.set-from-hex", + "esnext.uint8-array.to-base64", + "esnext.uint8-array.to-hex", + ), Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"), Uint16Array: typed("es.typed-array.uint16-array"), Uint32Array: typed("es.typed-array.uint32-array"), @@ -315,7 +312,11 @@ pub(crate) static BUILT_INS: Lazy> = lazy_ma SyntaxError: define(null, ERROR_DEPENDENCIES), TypeError: define(null, ERROR_DEPENDENCIES), URIError: define(null, ERROR_DEPENDENCIES), - URL: define("url/index", ["web.url", URL_SEARCH_PARAMS_DEPENDENCIES]), + URL: define("url/index", [ + "web.url", + "web.url.to-json", + URL_SEARCH_PARAMS_DEPENDENCIES, + ]), URLSearchParams: define( "url-search-params/index", URL_SEARCH_PARAMS_DEPENDENCIES From e7b2d40e49bf8f5fd24e1d1913a6eabede5e4d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:31:26 +0900 Subject: [PATCH 12/23] STATIC_PROPERTIES --- .../src/corejs3/builtin.rs | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index fe1c6f587cc4..a32672395f82 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -351,7 +351,7 @@ pub(crate) static BUILT_INS: Lazy> = lazy_ma unescape: define("unescape", ["es.unescape"]), }); -pub(crate) static STATIC_PROPERTIES: Lazy> = lazy_map!(Map{ +pub(crate) static STATIC_PROPERTIES: Lazy> = lazy_map!(Map { AsyncIterator: Map { from: define("async-iterator/from", [ "esnext.async-iterator.from", @@ -704,6 +704,7 @@ pub(crate) static STATIC_PROPERTIES: Lazy> URL: Map { canParse: define("url/can-parse", ["web.url.can-parse", "web.url"]), + parse: define("url/parse", ["web.url.parse", "web.url"]), }, WeakMap: Map { @@ -716,15 +717,27 @@ pub(crate) static STATIC_PROPERTIES: Lazy> of: define(null, ["esnext.weak-set.of", WEAK_SET_DEPENDENCIES]), }, - Int8Array: *TYPED_ARRAY_STATIC_METHODS, - Uint8Array: *TYPED_ARRAY_STATIC_METHODS, - Uint8ClampedArray: *TYPED_ARRAY_STATIC_METHODS, - Int16Array: *TYPED_ARRAY_STATIC_METHODS, - Uint16Array: *TYPED_ARRAY_STATIC_METHODS, - Int32Array: *TYPED_ARRAY_STATIC_METHODS, - Uint32Array: *TYPED_ARRAY_STATIC_METHODS, - Float32Array: *TYPED_ARRAY_STATIC_METHODS, - Float64Array: *TYPED_ARRAY_STATIC_METHODS, + Int8Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.int8-array"), + Uint8Array: Map { + fromBase64: define(null, [ + "esnext.uint8-array.from-base64", + TYPED_ARRAY_DEPENDENCIES, + ]), + fromHex: define(null, [ + "esnext.uint8-array.from-hex", + TYPED_ARRAY_DEPENDENCIES, + ]), + ...*TYPED_ARRAY_STATIC_METHODS("es.typed-array.uint8-array"), + }, + Uint8ClampedArray: TYPED_ARRAY_STATIC_METHODS( + "es.typed-array.uint8-clamped-array", + ), + Int16Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.int16-array"), + Uint16Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.uint16-array"), + Int32Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.int32-array"), + Uint32Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.uint32-array"), + Float32Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.float32-array"), + Float64Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.float64-array"), WebAssembly: Map { CompileError: define(null, ERROR_DEPENDENCIES), From 00fda2a6fe2f302e49a3bef1c84d49271f3e4bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:33:00 +0900 Subject: [PATCH 13/23] Port all --- .../src/corejs3/builtin.rs | 372 ++++++++---------- 1 file changed, 159 insertions(+), 213 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index a32672395f82..64cb2a24a91a 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -747,29 +747,23 @@ pub(crate) static STATIC_PROPERTIES: Lazy> }); pub(crate) static INSTANCE_PROPERTIES: Lazy> = lazy_map!(Map { - asIndexedPairs: define( - "instance/asIndexedPairs", - [ - "esnext.async-iterator.as-indexed-pairs", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.as-indexed-pairs", - ITERATOR_DEPENDENCIES, - ] - ), - at: define( - "instance/at", - [ - // TODO: We should introduce overloaded instance methods definition - // Before that is implemented, the `esnext.string.at` must be the first - // In pure mode, the provider resolves the descriptor as a "pure" `esnext.string.at` - // and treats the compat-data of `esnext.string.at` as the compat-data of - // pure import `instance/at`. The first polyfill here should have the lowest corejs - // supported versions. - "esnext.string.at", - "es.string.at-alternative", - "es.array.at", - ] - ), + asIndexedPairs: define(null, [ + "esnext.async-iterator.as-indexed-pairs", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.as-indexed-pairs", + ITERATOR_DEPENDENCIES, + ]), + at: define("instance/at", [ + // TODO: We should introduce overloaded instance methods definition + // Before that is implemented, the `esnext.string.at` must be the first + // In pure mode, the provider resolves the descriptor as a "pure" `esnext.string.at` + // and treats the compat-data of `esnext.string.at` as the compat-data of + // pure import `instance/at`. The first polyfill here should have the lowest corejs + // supported versions. + "esnext.string.at", + "es.string.at-alternative", + "es.array.at", + ]), anchor: define(null, ["es.string.anchor"]), big: define(null, ["es.string.big"]), bind: define("instance/bind", ["es.function.bind"]), @@ -777,129 +771,105 @@ pub(crate) static INSTANCE_PROPERTIES: Lazy> bold: define(null, ["es.string.bold"]), codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]), codePoints: define("instance/code-points", ["esnext.string.code-points"]), - concat: define("instance/concat", ["es.array.concat"], None, ["String"]), + concat: define("instance/concat", ["es.array.concat"], None, Some(vec!["String".to_string()])), copyWithin: define("instance/copy-within", ["es.array.copy-within"]), demethodize: define("instance/demethodize", ["esnext.function.demethodize"]), description: define(null, ["es.symbol", "es.symbol.description"]), dotAll: define(null, ["es.regexp.dot-all"]), - drop: define( - "instance/drop", - [ - "esnext.async-iterator.drop", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.drop", - ITERATOR_DEPENDENCIES, - ] - ), - emplace: define( - "instance/emplace", - ["esnext.map.emplace", "esnext.weak-map.emplace",] - ), + drop: define(null, [ + "esnext.async-iterator.drop", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.drop", + ITERATOR_DEPENDENCIES, + ]), + emplace: define("instance/emplace", [ + "esnext.map.emplace", + "esnext.weak-map.emplace", + ]), endsWith: define("instance/ends-with", ["es.string.ends-with"]), entries: define("instance/entries", ARRAY_NATURE_ITERATORS_WITH_TAG), - every: define( - "instance/every", - [ - "es.array.every", - "esnext.async-iterator.every", - // TODO: add async iterator dependencies when we support sub-dependencies - // esnext.async-iterator.every depends on es.promise - // but we don't want to pull es.promise when esnext.async-iterator is disabled - // - // ASYNC_ITERATOR_DEPENDENCIES - "esnext.iterator.every", - ITERATOR_DEPENDENCIES, - ] - ), + every: define("instance/every", [ + "es.array.every", + "esnext.async-iterator.every", + // TODO: add async iterator dependencies when we support sub-dependencies + // esnext.async-iterator.every depends on es.promise + // but we don't want to pull es.promise when esnext.async-iterator is disabled + // + // ASYNC_ITERATOR_DEPENDENCIES + "esnext.iterator.every", + ITERATOR_DEPENDENCIES, + ]), exec: define(null, ["es.regexp.exec"]), fill: define("instance/fill", ["es.array.fill"]), - filter: define( - "instance/filter", - [ - "es.array.filter", - "esnext.async-iterator.filter", - "esnext.iterator.filter", - ITERATOR_DEPENDENCIES, - ] - ), + filter: define("instance/filter", [ + "es.array.filter", + "esnext.async-iterator.filter", + "esnext.iterator.filter", + ITERATOR_DEPENDENCIES, + ]), filterReject: define("instance/filterReject", ["esnext.array.filter-reject"]), finally: define(null, ["es.promise.finally", PROMISE_DEPENDENCIES]), - find: define( - "instance/find", - [ - "es.array.find", - "esnext.async-iterator.find", - "esnext.iterator.find", - ITERATOR_DEPENDENCIES, - ] - ), + find: define("instance/find", [ + "es.array.find", + "esnext.async-iterator.find", + "esnext.iterator.find", + ITERATOR_DEPENDENCIES, + ]), findIndex: define("instance/find-index", ["es.array.find-index"]), findLast: define("instance/find-last", ["es.array.find-last"]), - findLastIndex: define("instance/find-last-index", ["es.array.find-last-index",]), + findLastIndex: define("instance/find-last-index", [ + "es.array.find-last-index", + ]), fixed: define(null, ["es.string.fixed"]), flags: define("instance/flags", ["es.regexp.flags"]), - flatMap: define( - "instance/flat-map", - [ - "es.array.flat-map", - "es.array.unscopables.flat-map", - "esnext.async-iterator.flat-map", - "esnext.iterator.flat-map", - ITERATOR_DEPENDENCIES, - ] - ), - flat: define( - "instance/flat", - ["es.array.flat", "es.array.unscopables.flat"] - ), - getFloat16: define( - null, - ["esnext.data-view.get-float16", DATA_VIEW_DEPENDENCIES] - ), - getUint8Clamped: define( - null, - ["esnext.data-view.get-uint8-clamped", DATA_VIEW_DEPENDENCIES] - ), + flatMap: define("instance/flat-map", [ + "es.array.flat-map", + "es.array.unscopables.flat-map", + "esnext.async-iterator.flat-map", + "esnext.iterator.flat-map", + ITERATOR_DEPENDENCIES, + ]), + flat: define("instance/flat", ["es.array.flat", "es.array.unscopables.flat"]), + getFloat16: define(null, [ + "esnext.data-view.get-float16", + DATA_VIEW_DEPENDENCIES, + ]), + getUint8Clamped: define(null, [ + "esnext.data-view.get-uint8-clamped", + DATA_VIEW_DEPENDENCIES, + ]), getYear: define(null, ["es.date.get-year"]), group: define("instance/group", ["esnext.array.group"]), groupBy: define("instance/group-by", ["esnext.array.group-by"]), - groupByToMap: define( - "instance/group-by-to-map", - [ - "esnext.array.group-by-to-map", - "es.map", - "es.object.to-string", - ] - ), - groupToMap: define( - "instance/group-to-map", - ["esnext.array.group-to-map", "es.map", "es.object.to-string",] - ), + groupByToMap: define("instance/group-by-to-map", [ + "esnext.array.group-by-to-map", + "es.map", + "es.object.to-string", + ]), + groupToMap: define("instance/group-to-map", [ + "esnext.array.group-to-map", + "es.map", + "es.object.to-string", + ]), fontcolor: define(null, ["es.string.fontcolor"]), fontsize: define(null, ["es.string.fontsize"]), - forEach: define( - "instance/for-each", - [ - "es.array.for-each", - "esnext.async-iterator.for-each", - "esnext.iterator.for-each", - ITERATOR_DEPENDENCIES, - "web.dom-collections.for-each", - ] - ), - includes: define( - "instance/includes", - ["es.array.includes", "es.string.includes",] - ), - indexed: define( - "instance/indexed", - [ - "esnext.async-iterator.indexed", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.indexed", - ITERATOR_DEPENDENCIES, - ] - ), + forEach: define("instance/for-each", [ + "es.array.for-each", + "esnext.async-iterator.for-each", + "esnext.iterator.for-each", + ITERATOR_DEPENDENCIES, + "web.dom-collections.for-each", + ]), + includes: define("instance/includes", [ + "es.array.includes", + "es.string.includes", + ]), + indexed: define(null, [ + "esnext.async-iterator.indexed", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.indexed", + ITERATOR_DEPENDENCIES, + ]), indexOf: define("instance/index-of", ["es.array.index-of"]), isWellFormed: define("instance/is-well-formed", ["es.string.is-well-formed"]), italic: define(null, ["es.string.italics"]), @@ -909,65 +879,53 @@ pub(crate) static INSTANCE_PROPERTIES: Lazy> lastIndexOf: define("instance/last-index-of", ["es.array.last-index-of"]), lastItem: define(null, ["esnext.array.last-item"]), link: define(null, ["es.string.link"]), - map: define( - "instance/map", - [ - "es.array.map", - "esnext.async-iterator.map", - "esnext.iterator.map", - ] - ), + map: define("instance/map", [ + "es.array.map", + "esnext.async-iterator.map", + "esnext.iterator.map", + ]), match: define(null, ["es.string.match", "es.regexp.exec"]), - matchAll: define( - "instance/match-all", - ["es.string.match-all", "es.regexp.exec",] - ), + matchAll: define("instance/match-all", [ + "es.string.match-all", + "es.regexp.exec", + ]), name: define(null, ["es.function.name"]), padEnd: define("instance/pad-end", ["es.string.pad-end"]), padStart: define("instance/pad-start", ["es.string.pad-start"]), push: define("instance/push", ["es.array.push"]), - reduce: define( - "instance/reduce", - [ - "es.array.reduce", - "esnext.async-iterator.reduce", - "esnext.iterator.reduce", - ITERATOR_DEPENDENCIES, - ] - ), + reduce: define("instance/reduce", [ + "es.array.reduce", + "esnext.async-iterator.reduce", + "esnext.iterator.reduce", + ITERATOR_DEPENDENCIES, + ]), reduceRight: define("instance/reduce-right", ["es.array.reduce-right"]), repeat: define("instance/repeat", ["es.string.repeat"]), replace: define(null, ["es.string.replace", "es.regexp.exec"]), - replaceAll: define( - "instance/replace-all", - [ - "es.string.replace-all", - "es.string.replace", - "es.regexp.exec", - ] - ), + replaceAll: define("instance/replace-all", [ + "es.string.replace-all", + "es.string.replace", + "es.regexp.exec", + ]), reverse: define("instance/reverse", ["es.array.reverse"]), search: define(null, ["es.string.search", "es.regexp.exec"]), - setFloat16: define( - null, - ["esnext.data-view.set-float16", DATA_VIEW_DEPENDENCIES] - ), - setUint8Clamped: define( - null, - ["esnext.data-view.set-uint8-clamped", DATA_VIEW_DEPENDENCIES] - ), + setFloat16: define(null, [ + "esnext.data-view.set-float16", + DATA_VIEW_DEPENDENCIES, + ]), + setUint8Clamped: define(null, [ + "esnext.data-view.set-uint8-clamped", + DATA_VIEW_DEPENDENCIES, + ]), setYear: define(null, ["es.date.set-year"]), slice: define("instance/slice", ["es.array.slice"]), small: define(null, ["es.string.small"]), - some: define( - "instance/some", - [ - "es.array.some", - "esnext.async-iterator.some", - "esnext.iterator.some", - ITERATOR_DEPENDENCIES, - ] - ), + some: define("instance/some", [ + "es.array.some", + "esnext.async-iterator.some", + "esnext.iterator.some", + ITERATOR_DEPENDENCIES, + ]), sort: define("instance/sort", ["es.array.sort"]), splice: define("instance/splice", ["es.array.splice"]), split: define(null, ["es.string.split", "es.regexp.exec"]), @@ -977,34 +935,25 @@ pub(crate) static INSTANCE_PROPERTIES: Lazy> sub: define(null, ["es.string.sub"]), substr: define(null, ["es.string.substr"]), sup: define(null, ["es.string.sup"]), - take: define( - "instance/take", - [ - "esnext.async-iterator.take", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.take", - ITERATOR_DEPENDENCIES, - ] - ), + take: define(null, [ + "esnext.async-iterator.take", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.take", + ITERATOR_DEPENDENCIES, + ]), test: define(null, ["es.regexp.test", "es.regexp.exec"]), - toArray: define( - "instance/to-array", - [ - "esnext.async-iterator.to-array", - ASYNC_ITERATOR_DEPENDENCIES, - "esnext.iterator.to-array", - ITERATOR_DEPENDENCIES, - ] - ), - toAsync: define( - null, - [ - "esnext.iterator.to-async", - ITERATOR_DEPENDENCIES, - ASYNC_ITERATOR_DEPENDENCIES, - AsyncIteratorProblemMethods, - ] - ), + toArray: define(null, [ + "esnext.async-iterator.to-array", + ASYNC_ITERATOR_DEPENDENCIES, + "esnext.iterator.to-array", + ITERATOR_DEPENDENCIES, + ]), + toAsync: define(null, [ + "esnext.iterator.to-async", + ITERATOR_DEPENDENCIES, + ASYNC_ITERATOR_DEPENDENCIES, + ASYNC_ITERATOR_PROBLEM_METHODS, + ]), toExponential: define(null, ["es.number.to-exponential"]), toFixed: define(null, ["es.number.to-fixed"]), toGMTString: define(null, ["es.date.to-gmt-string"]), @@ -1012,20 +961,17 @@ pub(crate) static INSTANCE_PROPERTIES: Lazy> toJSON: define(null, ["es.date.to-json", "web.url.to-json"]), toPrecision: define(null, ["es.number.to-precision"]), toReversed: define("instance/to-reversed", ["es.array.to-reversed"]), - toSorted: define( - "instance/to-sorted", - ["es.array.to-sorted", "es.array.sort",] - ), + toSorted: define("instance/to-sorted", [ + "es.array.to-sorted", + "es.array.sort", + ]), toSpliced: define("instance/to-spliced", ["es.array.to-spliced"]), - toString: define( - null, - [ - "es.object.to-string", - "es.error.to-string", - "es.date.to-string", - "es.regexp.to-string", - ] - ), + toString: define(null, [ + "es.object.to-string", + "es.error.to-string", + "es.date.to-string", + "es.regexp.to-string", + ]), toWellFormed: define("instance/to-well-formed", ["es.string.to-well-formed"]), trim: define("instance/trim", ["es.string.trim"]), trimEnd: define("instance/trim-end", ["es.string.trim-end"]), From 9fbf4e6d54bd1e6def6e1f09719943fa89ad472a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:39:15 +0900 Subject: [PATCH 14/23] fix --- crates/swc_ecma_preset_env/src/corejs3/builtin.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 64cb2a24a91a..251395f70e8a 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -222,21 +222,18 @@ fn typed_array_static_methods(base: &str) -> ObjectMap lazy_map!(Map { from: define( null, - &concat2::<3>(&["es.typed-array.from", base], TYPED_ARRAY_DEPENDENCIES) + ["es.typed-array.from", base, TYPED_ARRAY_DEPENDENCIES] ), fromAsync: define( null, - &concat2::<4>(&[ + [ "esnext.typed-array.from-async", base, PROMISE_DEPENDENCIES_WITH_ITERATORS, TYPED_ARRAY_DEPENDENCIES, - ]) - ), - of: define( - null, - &concat2::<3>(&["es.typed-array.of", base], TYPED_ARRAY_DEPENDENCIES) + ] ), + of: define(null, ["es.typed-array.of", base, TYPED_ARRAY_DEPENDENCIES]), }) } @@ -277,13 +274,13 @@ pub(crate) static BUILT_INS: Lazy> = lazy_ma Int16Array: typed("es.typed-array.int16-array"), Int32Array: typed("es.typed-array.int32-array"), Iterator: define("iterator/index", ITERATOR_DEPENDENCIES), - Uint8Array: typed( + Uint8Array: typed(&[ "es.typed-array.uint8-array", "esnext.uint8-array.set-from-base64", "esnext.uint8-array.set-from-hex", "esnext.uint8-array.to-base64", "esnext.uint8-array.to-hex", - ), + ]), Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"), Uint16Array: typed("es.typed-array.uint16-array"), Uint32Array: typed("es.typed-array.uint32-array"), From 516a58dc383da75778cc4123480a1f262d926ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:41:56 +0900 Subject: [PATCH 15/23] Fix more --- .../src/corejs3/builtin.rs | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 251395f70e8a..d19bf3809af1 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -218,7 +218,7 @@ static ITERATOR_DEPENDENCIES: &[&str] = &["esnext.iterator.constructor", "es.obj static DECORATOR_METADATA_DEPENDENCIES: &[&str] = &["esnext.symbol.metadata", "esnext.function.metadata"]; -fn typed_array_static_methods(base: &str) -> ObjectMap { +fn typed_array_static_methods(base: &str) -> Lazy> { lazy_map!(Map { from: define( null, @@ -268,11 +268,11 @@ pub(crate) static BUILT_INS: Lazy> = lazy_ma ]), Error: define(null, ERROR_DEPENDENCIES), EvalError: define(null, ERROR_DEPENDENCIES), - Float32Array: typed("es.typed-array.float32-array"), - Float64Array: typed("es.typed-array.float64-array"), - Int8Array: typed("es.typed-array.int8-array"), - Int16Array: typed("es.typed-array.int16-array"), - Int32Array: typed("es.typed-array.int32-array"), + Float32Array: typed(&["es.typed-array.float32-array"]), + Float64Array: typed(&["es.typed-array.float64-array"]), + Int8Array: typed(&["es.typed-array.int8-array"]), + Int16Array: typed(&["es.typed-array.int16-array"]), + Int32Array: typed(&["es.typed-array.int32-array"]), Iterator: define("iterator/index", ITERATOR_DEPENDENCIES), Uint8Array: typed(&[ "es.typed-array.uint8-array", @@ -714,7 +714,7 @@ pub(crate) static STATIC_PROPERTIES: Lazy> of: define(null, ["esnext.weak-set.of", WEAK_SET_DEPENDENCIES]), }, - Int8Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.int8-array"), + Int8Array: typed_array_static_methods("es.typed-array.int8-array"), Uint8Array: Map { fromBase64: define(null, [ "esnext.uint8-array.from-base64", @@ -724,17 +724,15 @@ pub(crate) static STATIC_PROPERTIES: Lazy> "esnext.uint8-array.from-hex", TYPED_ARRAY_DEPENDENCIES, ]), - ...*TYPED_ARRAY_STATIC_METHODS("es.typed-array.uint8-array"), + ...*typed_array_static_methods("es.typed-array.uint8-array"), }, - Uint8ClampedArray: TYPED_ARRAY_STATIC_METHODS( - "es.typed-array.uint8-clamped-array", - ), - Int16Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.int16-array"), - Uint16Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.uint16-array"), - Int32Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.int32-array"), - Uint32Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.uint32-array"), - Float32Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.float32-array"), - Float64Array: TYPED_ARRAY_STATIC_METHODS("es.typed-array.float64-array"), + Uint8ClampedArray: typed_array_static_methods(&["es.typed-array.uint8-clamped-array"]), + Int16Array: typed_array_static_methods(&["es.typed-array.int16-array"]), + Uint16Array: typed_array_static_methods(&["es.typed-array.uint16-array"]), + Int32Array: typed_array_static_methods(&["es.typed-array.int32-array"]), + Uint32Array: typed_array_static_methods(&["es.typed-array.uint32-array"]), + Float32Array: typed_array_static_methods(&["es.typed-array.float32-array"]), + Float64Array: typed_array_static_methods(&["es.typed-array.float64-array"]), WebAssembly: Map { CompileError: define(null, ERROR_DEPENDENCIES), From 8ddeeff7876d4f1f921d992f3603788f3d678792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:45:43 +0900 Subject: [PATCH 16/23] more --- .../swc_ecma_preset_env/src/corejs3/builtin.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index d19bf3809af1..41f7b3f9c3b8 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -12,7 +12,12 @@ fn dynamic_concat(a: &[&'static str], b: &[&'static str]) -> &'static [&'static } const fn concat2(a: &[&'static str], b: &[&'static str]) -> [&'static str; N] { - assert!(N == a.len() + b.len()); + assert!( + N == a.len() + b.len(), + "Expected to be {} but {}", + a.len() + b.len(), + N + ); let mut res = [""; N]; let mut idx = 0; @@ -218,7 +223,7 @@ static ITERATOR_DEPENDENCIES: &[&str] = &["esnext.iterator.constructor", "es.obj static DECORATOR_METADATA_DEPENDENCIES: &[&str] = &["esnext.symbol.metadata", "esnext.function.metadata"]; -fn typed_array_static_methods(base: &str) -> Lazy> { +fn typed_array_static_methods(base: &str) -> ObjectMap { lazy_map!(Map { from: define( null, @@ -281,9 +286,9 @@ pub(crate) static BUILT_INS: Lazy> = lazy_ma "esnext.uint8-array.to-base64", "esnext.uint8-array.to-hex", ]), - Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"), - Uint16Array: typed("es.typed-array.uint16-array"), - Uint32Array: typed("es.typed-array.uint32-array"), + Uint8ClampedArray: typed(&["es.typed-array.uint8-clamped-array"]), + Uint16Array: typed(&["es.typed-array.uint16-array"]), + Uint32Array: typed(&["es.typed-array.uint32-array"]), Map: define("map/index", MAP_DEPENDENCIES), Number: define(null, ["es.number.constructor"]), Observable: define("observable/index", [ @@ -724,7 +729,7 @@ pub(crate) static STATIC_PROPERTIES: Lazy> "esnext.uint8-array.from-hex", TYPED_ARRAY_DEPENDENCIES, ]), - ...*typed_array_static_methods("es.typed-array.uint8-array"), + typed_array_static_methods("es.typed-array.uint8-array"), }, Uint8ClampedArray: typed_array_static_methods(&["es.typed-array.uint8-clamped-array"]), Int16Array: typed_array_static_methods(&["es.typed-array.int16-array"]), From 36ba9c3098edc07f851b4a13ddcea09621e74d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:53:42 +0900 Subject: [PATCH 17/23] m,ore fix --- .../swc_ecma_preset_env/src/corejs3/builtin.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 41f7b3f9c3b8..3b62041a5670 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -12,12 +12,7 @@ fn dynamic_concat(a: &[&'static str], b: &[&'static str]) -> &'static [&'static } const fn concat2(a: &[&'static str], b: &[&'static str]) -> [&'static str; N] { - assert!( - N == a.len() + b.len(), - "Expected to be {} but {}", - a.len() + b.len(), - N - ); + assert!(N == a.len() + b.len()); let mut res = [""; N]; let mut idx = 0; @@ -223,8 +218,10 @@ static ITERATOR_DEPENDENCIES: &[&str] = &["esnext.iterator.constructor", "es.obj static DECORATOR_METADATA_DEPENDENCIES: &[&str] = &["esnext.symbol.metadata", "esnext.function.metadata"]; -fn typed_array_static_methods(base: &str) -> ObjectMap { - lazy_map!(Map { +const fn typed_array_static_methods( + base: &'static [&'static str], +) -> ObjectMap { + map!(Map { from: define( null, ["es.typed-array.from", base, TYPED_ARRAY_DEPENDENCIES] @@ -729,7 +726,7 @@ pub(crate) static STATIC_PROPERTIES: Lazy> "esnext.uint8-array.from-hex", TYPED_ARRAY_DEPENDENCIES, ]), - typed_array_static_methods("es.typed-array.uint8-array"), + typed_array_static_methods(&["es.typed-array.uint8-array"]), }, Uint8ClampedArray: typed_array_static_methods(&["es.typed-array.uint8-clamped-array"]), Int16Array: typed_array_static_methods(&["es.typed-array.int16-array"]), @@ -771,7 +768,7 @@ pub(crate) static INSTANCE_PROPERTIES: Lazy> bold: define(null, ["es.string.bold"]), codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]), codePoints: define("instance/code-points", ["esnext.string.code-points"]), - concat: define("instance/concat", ["es.array.concat"], None, Some(vec!["String".to_string()])), + concat: define("instance/concat", ["es.array.concat"], None, "String"), copyWithin: define("instance/copy-within", ["es.array.copy-within"]), demethodize: define("instance/demethodize", ["esnext.function.demethodize"]), description: define(null, ["es.symbol", "es.symbol.description"]), From 9de2f6ecfb5d15d8bf061886bd7ebf633745af73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:56:20 +0900 Subject: [PATCH 18/23] non-const --- crates/swc_ecma_preset_env/src/corejs3/builtin.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 3b62041a5670..b1d2b6e687f0 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -218,7 +218,7 @@ static ITERATOR_DEPENDENCIES: &[&str] = &["esnext.iterator.constructor", "es.obj static DECORATOR_METADATA_DEPENDENCIES: &[&str] = &["esnext.symbol.metadata", "esnext.function.metadata"]; -const fn typed_array_static_methods( +fn typed_array_static_methods( base: &'static [&'static str], ) -> ObjectMap { map!(Map { @@ -716,7 +716,7 @@ pub(crate) static STATIC_PROPERTIES: Lazy> of: define(null, ["esnext.weak-set.of", WEAK_SET_DEPENDENCIES]), }, - Int8Array: typed_array_static_methods("es.typed-array.int8-array"), + Int8Array: typed_array_static_methods(&["es.typed-array.int8-array"]), Uint8Array: Map { fromBase64: define(null, [ "esnext.uint8-array.from-base64", From af2e76d254fb23c0d736fd2901e842a5299d1797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 11:59:50 +0900 Subject: [PATCH 19/23] fix --- .../src/corejs3/builtin.rs | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index b1d2b6e687f0..bdc68e39b45a 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -239,6 +239,22 @@ fn typed_array_static_methods( }) } +fn uint8_typed_array_static_methods() -> ObjectMap { + let mut map = typed_array_static_methods(&["es.typed-array.uint8-array"]); + + map.extend(map!(Map { + fromBase64: define( + null, + ["esnext.uint8-array.from-base64", TYPED_ARRAY_DEPENDENCIES,] + ), + fromHex: define( + null, + ["esnext.uint8-array.from-hex", TYPED_ARRAY_DEPENDENCIES,] + ), + })); + map +} + static DATA_VIEW_DEPENDENCIES: &[&str] = &concat2::<2>(&["es.data-view"], ARRAY_BUFFER_DEPENDENCIES); @@ -717,17 +733,7 @@ pub(crate) static STATIC_PROPERTIES: Lazy> }, Int8Array: typed_array_static_methods(&["es.typed-array.int8-array"]), - Uint8Array: Map { - fromBase64: define(null, [ - "esnext.uint8-array.from-base64", - TYPED_ARRAY_DEPENDENCIES, - ]), - fromHex: define(null, [ - "esnext.uint8-array.from-hex", - TYPED_ARRAY_DEPENDENCIES, - ]), - typed_array_static_methods(&["es.typed-array.uint8-array"]), - }, + Uint8Array: uint8_typed_array_static_methods(), Uint8ClampedArray: typed_array_static_methods(&["es.typed-array.uint8-clamped-array"]), Int16Array: typed_array_static_methods(&["es.typed-array.int16-array"]), Uint16Array: typed_array_static_methods(&["es.typed-array.uint16-array"]), From 517f16a48f15055fd04323fffc1a1615b556a259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 12:06:08 +0900 Subject: [PATCH 20/23] more --- crates/swc_ecma_preset_env/src/corejs3/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index bdc68e39b45a..851383f7f811 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -774,7 +774,7 @@ pub(crate) static INSTANCE_PROPERTIES: Lazy> bold: define(null, ["es.string.bold"]), codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]), codePoints: define("instance/code-points", ["esnext.string.code-points"]), - concat: define("instance/concat", ["es.array.concat"], None, "String"), + concat: define("instance/concat", ["es.array.concat"], None, ["String"]), copyWithin: define("instance/copy-within", ["es.array.copy-within"]), demethodize: define("instance/demethodize", ["esnext.function.demethodize"]), description: define(null, ["es.symbol", "es.symbol.description"]), From a7f8503af0c3e44dc6019af1e9b61d7627ec054c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 12:08:42 +0900 Subject: [PATCH 21/23] done --- crates/swc_ecma_preset_env/src/corejs3/builtin.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs index 851383f7f811..c02e8f539dc6 100644 --- a/crates/swc_ecma_preset_env/src/corejs3/builtin.rs +++ b/crates/swc_ecma_preset_env/src/corejs3/builtin.rs @@ -64,7 +64,7 @@ static ARRAY_BUFFER_DEPENDENCIES: &[&str] = &[ "es.object.to-string", ]; -static TYPED_ARRAY_DEPENDENCIES: &[&str] = &concat2::<40>( +static TYPED_ARRAY_DEPENDENCIES: &[&str] = &concat2::<42>( &[ "es.typed-array.at", "es.typed-array.copy-within", @@ -134,7 +134,7 @@ static MAP_DEPENDENCIES: &[&str] = &concat2::<19>( COMMON_ITERATORS_WITH_TAG, ); -static SET_DEPENDENCIES: &[&str] = &concat2::<25>( +static SET_DEPENDENCIES: &[&str] = &concat2::<28>( &[ "es.set", "es.set.difference.v2", @@ -256,7 +256,7 @@ fn uint8_typed_array_static_methods() -> ObjectMap { } static DATA_VIEW_DEPENDENCIES: &[&str] = - &concat2::<2>(&["es.data-view"], ARRAY_BUFFER_DEPENDENCIES); + &concat2::<8>(&["es.data-view"], ARRAY_BUFFER_DEPENDENCIES); pub(crate) static BUILT_INS: Lazy> = lazy_map!(Map{ AsyncDisposableStack: define("async-disposable-stack/index", [ From aa9e767a441dcfbcffe8d1d5f9ce3512a6deb130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 8 Oct 2024 12:09:24 +0900 Subject: [PATCH 22/23] Update test refs --- crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js | 2 +- crates/swc/tests/fixture/issues-6xxx/6888/output/index.js | 4 +++- crates/swc/tests/fixture/issues-8xxx/8193/output/1.js | 2 ++ crates/swc/tests/fixture/issues-9xxx/9544/output/1.js | 2 +- .../fixtures/corejs3/usage-typed-array-edge-13/output.mjs | 1 + .../fixtures/corejs3/usage-typed-array-static/output.mjs | 2 ++ .../tests/fixtures/corejs3/usage-typed-array/output.mjs | 2 ++ 7 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js b/crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js index 5cd3e93d3899..f7eefeb17964 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js +++ b/crates/swc/tests/fixture/issues-6xxx/6460/1/output/index.js @@ -1,6 +1,6 @@ require("core-js/modules/es.array.at.js"); require("core-js/modules/es.regexp.exec.js"); -require("core-js/modules/es.string.at.js"); +require("core-js/modules/es.string.at-alternative.js"); require("core-js/modules/es.string.split.js"); '1.2.3'.split('.').at(-1); [ diff --git a/crates/swc/tests/fixture/issues-6xxx/6888/output/index.js b/crates/swc/tests/fixture/issues-6xxx/6888/output/index.js index bd79dd12d935..9c9863d1964d 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6888/output/index.js +++ b/crates/swc/tests/fixture/issues-6xxx/6888/output/index.js @@ -1,6 +1,8 @@ require("core-js/modules/es.array.at.js"); require("core-js/modules/es.regexp.exec.js"); -require("core-js/modules/es.string.at.js"); +require("core-js/modules/es.string.at-alternative.js"); +require("core-js/modules/es.string.replace-all.js"); +require("core-js/modules/es.string.replace.js"); require("core-js/modules/es.string.split.js"); 'test'.replaceAll('', ''); '1.2.3'.split('.').at(-1); diff --git a/crates/swc/tests/fixture/issues-8xxx/8193/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8193/output/1.js index 30c7f2ce0718..e911a0407a35 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8193/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8193/output/1.js @@ -1,3 +1,5 @@ +require("core-js/modules/es.object.create.js"); +require("core-js/modules/esnext.object.group-by.js"); var data = [ { name: 'a', diff --git a/crates/swc/tests/fixture/issues-9xxx/9544/output/1.js b/crates/swc/tests/fixture/issues-9xxx/9544/output/1.js index 6fad7029c384..adfe3d9c8afb 100644 --- a/crates/swc/tests/fixture/issues-9xxx/9544/output/1.js +++ b/crates/swc/tests/fixture/issues-9xxx/9544/output/1.js @@ -1,4 +1,4 @@ -require("core-js/modules/web.dom-collections.for-each.js"); +require("core-js/modules/es.object.to-string.js"); document.querySelectorAll('div').forEach(function(el) { console.log(el); }); diff --git a/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array-edge-13/output.mjs b/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array-edge-13/output.mjs index c1933a7b1559..8cb3e00b0a94 100644 --- a/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array-edge-13/output.mjs +++ b/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array-edge-13/output.mjs @@ -1,3 +1,4 @@ +import "core-js/modules/es.array-buffer.constructor.js"; import "core-js/modules/es.array.iterator.js"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.typed-array.fill.js"; diff --git a/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array-static/output.mjs b/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array-static/output.mjs index 473e3ecb800f..a6be53545139 100644 --- a/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array-static/output.mjs +++ b/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array-static/output.mjs @@ -1,5 +1,7 @@ +import "core-js/modules/es.array-buffer.constructor.js"; import "core-js/modules/es.array-buffer.slice.js"; import "core-js/modules/es.array.iterator.js"; +import "core-js/modules/es.data-view.js"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.typed-array.copy-within.js"; import "core-js/modules/es.typed-array.every.js"; diff --git a/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array/output.mjs b/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array/output.mjs index 67805b2b8989..97b53bfdb383 100644 --- a/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array/output.mjs +++ b/crates/swc_ecma_preset_env/tests/fixtures/corejs3/usage-typed-array/output.mjs @@ -1,5 +1,7 @@ +import "core-js/modules/es.array-buffer.constructor.js"; import "core-js/modules/es.array-buffer.slice.js"; import "core-js/modules/es.array.iterator.js"; +import "core-js/modules/es.data-view.js"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.typed-array.copy-within.js"; import "core-js/modules/es.typed-array.every.js"; From e402f9e328e40f19e36c4a190ec3898530b5395a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 8 Oct 2024 12:10:40 +0900 Subject: [PATCH 23/23] Create sharp-apricots-tease.md --- .changeset/sharp-apricots-tease.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/sharp-apricots-tease.md diff --git a/.changeset/sharp-apricots-tease.md b/.changeset/sharp-apricots-tease.md new file mode 100644 index 000000000000..ff21ac2c8e51 --- /dev/null +++ b/.changeset/sharp-apricots-tease.md @@ -0,0 +1,6 @@ +--- +swc_ecma_preset_env: patch +swc_core: patch +--- + +feat(es/preset-env): Update preset-env data