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
This commit is contained in:
Bartek Iwańczuk 2024-09-09 22:44:29 +01:00 committed by GitHub
parent 560ad0331b
commit 064a73f7a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 60 additions and 179 deletions

View file

@ -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