refactor: don't expose Deno[Deno.internal].core namespace (#18816)

This commit is contained in:
Bartek Iwańczuk 2023-04-26 19:57:38 +02:00 committed by GitHub
parent 2df6db36c8
commit 14aaa73c02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 95 additions and 61 deletions

View file

@ -391,12 +391,6 @@ function promiseRejectMacrotaskCallback() {
let hasBootstrapped = false;
// Set up global properties shared by main and worker runtime.
ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope);
// FIXME(bartlomieju): temporarily add whole `Deno.core` to
// `Deno[Deno.internal]` namespace. It should be removed and only necessary
// methods should be left there.
ObjectAssign(internals, {
core,
});
const internalSymbol = Symbol("Deno.internal");
const finalDenoNs = {
internal: internalSymbol,
@ -428,7 +422,7 @@ function bootstrapMainRuntime(runtimeOptions) {
13: v8Version,
14: userAgent,
15: inspectFlag,
// 16: enableTestingFeaturesFlag
16: enableTestingFeaturesFlag,
} = runtimeOptions;
performance.setTimeOrigin(DateNow());
@ -503,6 +497,12 @@ function bootstrapMainRuntime(runtimeOptions) {
ObjectAssign(finalDenoNs, denoNsUnstable);
}
// Add `Deno[Deno.internal].core` namespace if
// `--enable-testing-features-do-not-use` flag is set.
if (enableTestingFeaturesFlag) {
ObjectAssign(internals, { core });
}
// Setup `Deno` global - we're actually overriding already existing global
// `Deno` with `Deno` namespace from "./deno.ts".
ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs));
@ -612,6 +612,11 @@ function bootstrapWorkerRuntime(
noColor: util.readOnly(noColor),
args: util.readOnly(ObjectFreeze(args)),
});
// Add `Deno[Deno.internal].core` namespace if
// `--enable-testing-features-do-not-use` flag is set.
if (enableTestingFeaturesFlag) {
ObjectAssign(internals, { core });
}
// Setup `Deno` global - we're actually overriding already
// existing global `Deno` with `Deno` namespace from "./deno.ts".
ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs));