diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-09-09 22:44:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-09 23:44:29 +0200 |
commit | 064a73f7a08eb12d99fcdf8844e9ce5db62be78b (patch) | |
tree | a1672b2151d3e7c5db490dad9fc3917064ee64aa /runtime/js/99_main.js | |
parent | 560ad0331bf99a2564f53201cd086ff902901bfe (diff) |
BREAKING: Remove `--unstable` flag (#25522)
This commit effectively removes the --unstable flag.
It's still being parsed, but it only prints a warning that a granular
flag should be used instead and doesn't actually enable any
unstable feature.
Closes https://github.com/denoland/deno/issues/25485
Closes https://github.com/denoland/deno/issues/23237
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r-- | runtime/js/99_main.js | 99 |
1 files changed, 35 insertions, 64 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 2d5c96f6a..f81ab3d8f 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -37,7 +37,6 @@ const { ObjectKeys, ObjectPrototypeIsPrototypeOf, ObjectSetPrototypeOf, - ObjectValues, PromisePrototypeThen, PromiseResolve, StringPrototypePadEnd, @@ -67,7 +66,6 @@ import * as fetch from "ext:deno_fetch/26_fetch.js"; import * as messagePort from "ext:deno_web/13_message_port.js"; import { denoNs, - denoNsUnstable, denoNsUnstableById, unstableIds, } from "ext:runtime/90_deno_ns.js"; @@ -439,28 +437,19 @@ ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope); // Set up global properties shared by main and worker runtime that are exposed // by unstable features if those are enabled. -function exposeUnstableFeaturesForWindowOrWorkerGlobalScope(options) { - const { unstableFlag, unstableFeatures } = options; - if (unstableFlag) { - const all = ObjectValues(unstableForWindowOrWorkerGlobalScope); - for (let i = 0; i <= all.length; i++) { - const props = all[i]; - ObjectDefineProperties(globalThis, { ...props }); - } - } else { - const featureIds = ArrayPrototypeMap( - ObjectKeys( - unstableForWindowOrWorkerGlobalScope, - ), - (k) => k | 0, - ); +function exposeUnstableFeaturesForWindowOrWorkerGlobalScope(unstableFeatures) { + const featureIds = ArrayPrototypeMap( + ObjectKeys( + unstableForWindowOrWorkerGlobalScope, + ), + (k) => k | 0, + ); - for (let i = 0; i <= featureIds.length; i++) { - const featureId = featureIds[i]; - if (ArrayPrototypeIncludes(unstableFeatures, featureId)) { - const props = unstableForWindowOrWorkerGlobalScope[featureId]; - ObjectDefineProperties(globalThis, { ...props }); - } + for (let i = 0; i <= featureIds.length; i++) { + const featureId = featureIds[i]; + if (ArrayPrototypeIncludes(unstableFeatures, featureId)) { + const props = unstableForWindowOrWorkerGlobalScope[featureId]; + ObjectDefineProperties(globalThis, { ...props }); } } } @@ -572,17 +561,16 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { const { 0: denoVersion, 1: location_, - 2: unstableFlag, - 3: unstableFeatures, - 4: inspectFlag, - 6: hasNodeModulesDir, - 7: argv0, - 8: nodeDebug, - 9: mode, - 10: servePort, - 11: serveHost, - 12: serveIsMain, - 13: serveWorkerCount, + 2: unstableFeatures, + 3: inspectFlag, + 5: hasNodeModulesDir, + 6: argv0, + 7: nodeDebug, + 8: mode, + 9: servePort, + 10: serveHost, + 11: serveIsMain, + 12: serveWorkerCount, } = runtimeOptions; if (mode === executionModes.serve) { @@ -692,10 +680,7 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { location.setLocationHref(location_); } - exposeUnstableFeaturesForWindowOrWorkerGlobalScope({ - unstableFlag, - unstableFeatures, - }); + exposeUnstableFeaturesForWindowOrWorkerGlobalScope(unstableFeatures); ObjectDefineProperties(globalThis, mainRuntimeGlobalProperties); ObjectDefineProperties(globalThis, { // TODO(bartlomieju): in the future we might want to change the @@ -742,14 +727,9 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { }, }); - // TODO(bartlomieju): deprecate --unstable - if (unstableFlag) { - ObjectAssign(finalDenoNs, denoNsUnstable); - } else { - for (let i = 0; i <= unstableFeatures.length; i++) { - const id = unstableFeatures[i]; - ObjectAssign(finalDenoNs, denoNsUnstableById[id]); - } + for (let i = 0; i <= unstableFeatures.length; i++) { + const id = unstableFeatures[i]; + ObjectAssign(finalDenoNs, denoNsUnstableById[id]); } if (!ArrayPrototypeIncludes(unstableFeatures, unstableIds.unsafeProto)) { @@ -825,12 +805,11 @@ function bootstrapWorkerRuntime( const { 0: denoVersion, 1: location_, - 2: unstableFlag, - 3: unstableFeatures, - 5: enableTestingFeaturesFlag, - 6: hasNodeModulesDir, - 7: argv0, - 8: nodeDebug, + 2: unstableFeatures, + 4: enableTestingFeaturesFlag, + 5: hasNodeModulesDir, + 6: argv0, + 7: nodeDebug, } = runtimeOptions; // TODO(iuioiua): remove in Deno v2. This allows us to dynamically delete @@ -846,10 +825,7 @@ function bootstrapWorkerRuntime( delete globalThis.bootstrap; hasBootstrapped = true; - exposeUnstableFeaturesForWindowOrWorkerGlobalScope({ - unstableFlag, - unstableFeatures, - }); + exposeUnstableFeaturesForWindowOrWorkerGlobalScope(unstableFeatures); ObjectDefineProperties(globalThis, workerRuntimeGlobalProperties); ObjectDefineProperties(globalThis, { name: core.propWritable(name), @@ -891,14 +867,9 @@ function bootstrapWorkerRuntime( globalThis.pollForMessages = pollForMessages; globalThis.hasMessageEventListener = hasMessageEventListener; - // TODO(bartlomieju): deprecate --unstable - if (unstableFlag) { - ObjectAssign(finalDenoNs, denoNsUnstable); - } else { - for (let i = 0; i <= unstableFeatures.length; i++) { - const id = unstableFeatures[i]; - ObjectAssign(finalDenoNs, denoNsUnstableById[id]); - } + for (let i = 0; i <= unstableFeatures.length; i++) { + const id = unstableFeatures[i]; + ObjectAssign(finalDenoNs, denoNsUnstableById[id]); } // Not available in workers |