From c1fc7b2cd511ce83566f696c8880d6718e5c6885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 Dec 2023 14:21:01 +0100 Subject: refactor: pull 'core', 'internals', 'primordials' from ES module (#21462) This commit refactors how we access "core", "internals" and "primordials" objects coming from `deno_core`, in our internal JavaScript code. Instead of capturing them from "globalThis.__bootstrap" namespace, we import them from recently added "ext:core/mod.js" file. --- ext/node/polyfills/internal/crypto/_randomInt.ts | 3 ++- ext/node/polyfills/internal/crypto/random.ts | 2 +- ext/node/polyfills/internal/process/report.ts | 2 +- ext/node/polyfills/internal/timers.mjs | 2 +- ext/node/polyfills/internal/util/parse_args/parse_args.js | 2 +- ext/node/polyfills/internal/util/parse_args/utils.js | 2 +- ext/node/polyfills/internal/validators.mjs | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) (limited to 'ext/node/polyfills/internal') diff --git a/ext/node/polyfills/internal/crypto/_randomInt.ts b/ext/node/polyfills/internal/crypto/_randomInt.ts index 9f161668d..e5ab41ee7 100644 --- a/ext/node/polyfills/internal/crypto/_randomInt.ts +++ b/ext/node/polyfills/internal/crypto/_randomInt.ts @@ -3,7 +3,8 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const ops = globalThis.Deno.core.ops; +import { core } from "ext:core/mod.js"; +const ops = core.ops; export default function randomInt(max: number): number; export default function randomInt(min: number, max: number): number; diff --git a/ext/node/polyfills/internal/crypto/random.ts b/ext/node/polyfills/internal/crypto/random.ts index e8776cdf0..4a4b68274 100644 --- a/ext/node/polyfills/internal/crypto/random.ts +++ b/ext/node/polyfills/internal/crypto/random.ts @@ -32,7 +32,7 @@ export { } from "ext:deno_node/internal/crypto/_randomFill.mjs"; export { default as randomInt } from "ext:deno_node/internal/crypto/_randomInt.ts"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { StringPrototypePadStart, StringPrototypeToString } = primordials; const { core } = globalThis.__bootstrap; diff --git a/ext/node/polyfills/internal/process/report.ts b/ext/node/polyfills/internal/process/report.ts index 7d178626c..cd77eeda5 100644 --- a/ext/node/polyfills/internal/process/report.ts +++ b/ext/node/polyfills/internal/process/report.ts @@ -3,7 +3,7 @@ import { arch, versions } from "ext:deno_node/_process/process.ts"; import { cpus, hostname, networkInterfaces } from "node:os"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { Error, StringPrototypeToUpperCase, diff --git a/ext/node/polyfills/internal/timers.mjs b/ext/node/polyfills/internal/timers.mjs index 3dc5073c6..92fb51d57 100644 --- a/ext/node/polyfills/internal/timers.mjs +++ b/ext/node/polyfills/internal/timers.mjs @@ -4,7 +4,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { MapPrototypeDelete, MapPrototypeSet, diff --git a/ext/node/polyfills/internal/util/parse_args/parse_args.js b/ext/node/polyfills/internal/util/parse_args/parse_args.js index 798039620..910eef436 100644 --- a/ext/node/polyfills/internal/util/parse_args/parse_args.js +++ b/ext/node/polyfills/internal/util/parse_args/parse_args.js @@ -1,7 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // Copyright Joyent and Node contributors. All rights reserved. MIT license. -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeForEach, ArrayPrototypeIncludes, diff --git a/ext/node/polyfills/internal/util/parse_args/utils.js b/ext/node/polyfills/internal/util/parse_args/utils.js index d101dd3fd..8cbbbc6c2 100644 --- a/ext/node/polyfills/internal/util/parse_args/utils.js +++ b/ext/node/polyfills/internal/util/parse_args/utils.js @@ -1,7 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // Copyright Joyent and Node contributors. All rights reserved. MIT license. -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeFind, ObjectEntries, diff --git a/ext/node/polyfills/internal/validators.mjs b/ext/node/polyfills/internal/validators.mjs index b5b539088..e728d40ad 100644 --- a/ext/node/polyfills/internal/validators.mjs +++ b/ext/node/polyfills/internal/validators.mjs @@ -9,7 +9,7 @@ import { hideStackFrames } from "ext:deno_node/internal/hide_stack_frames.ts"; import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts"; import { normalizeEncoding } from "ext:deno_node/internal/normalize_encoding.mjs"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeIncludes, ArrayPrototypeJoin, -- cgit v1.2.3