diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-12-07 14:21:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-07 14:21:01 +0100 |
commit | c1fc7b2cd511ce83566f696c8880d6718e5c6885 (patch) | |
tree | 6430faa4996b1022c0e1ae1e78cb3b9e196029eb /ext/node | |
parent | 5dd9b26155ceed514364f92fe4fdacb6b8cc8182 (diff) |
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.
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/polyfills/01_require.js | 4 | ||||
-rw-r--r-- | ext/node/polyfills/_process/process.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/http2.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/_randomInt.ts | 3 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/random.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal/process/report.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal/timers.mjs | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal/util/parse_args/parse_args.js | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal/util/parse_args/utils.js | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal/validators.mjs | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/stream_wrap.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/udp_wrap.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/util.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/timers.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/util.ts | 2 |
15 files changed, 16 insertions, 17 deletions
diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js index eb845f237..c6b84543a 100644 --- a/ext/node/polyfills/01_require.js +++ b/ext/node/polyfills/01_require.js @@ -2,10 +2,8 @@ // deno-lint-ignore-file -const core = globalThis.Deno.core; +import { core, internals, primordials } from "ext:core/mod.js"; const ops = core.ops; -const internals = globalThis.__bootstrap.internals; -const primordials = globalThis.__bootstrap.primordials; const { ArrayIsArray, ArrayPrototypeIncludes, diff --git a/ext/node/polyfills/_process/process.ts b/ext/node/polyfills/_process/process.ts index 062effe07..b153c8e19 100644 --- a/ext/node/polyfills/_process/process.ts +++ b/ext/node/polyfills/_process/process.ts @@ -7,7 +7,7 @@ // The following are all the process APIs that don't depend on the stream module // They have to be split this way to prevent a circular dependency -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; import { nextTick as _nextTick } from "ext:deno_node/_next_tick.ts"; import { _exiting } from "ext:deno_node/_process/exiting.ts"; import * as fs from "ext:deno_fs/30_fs.js"; diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts index afd9a22bc..bab607b80 100644 --- a/ext/node/polyfills/http2.ts +++ b/ext/node/polyfills/http2.ts @@ -4,7 +4,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts"; import { EventEmitter } from "node:events"; import { Buffer } from "node:buffer"; 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, diff --git a/ext/node/polyfills/internal_binding/stream_wrap.ts b/ext/node/polyfills/internal_binding/stream_wrap.ts index 3e4d0be6a..f381b21ce 100644 --- a/ext/node/polyfills/internal_binding/stream_wrap.ts +++ b/ext/node/polyfills/internal_binding/stream_wrap.ts @@ -40,7 +40,7 @@ import { } from "ext:deno_node/internal_binding/async_wrap.ts"; import { codeMap } from "ext:deno_node/internal_binding/uv.ts"; -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const { ops } = core; interface Reader { diff --git a/ext/node/polyfills/internal_binding/udp_wrap.ts b/ext/node/polyfills/internal_binding/udp_wrap.ts index d8b0bf059..98ca5bb3a 100644 --- a/ext/node/polyfills/internal_binding/udp_wrap.ts +++ b/ext/node/polyfills/internal_binding/udp_wrap.ts @@ -23,7 +23,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const ops = core.ops; import { AsyncWrap, diff --git a/ext/node/polyfills/internal_binding/util.ts b/ext/node/polyfills/internal_binding/util.ts index 59f1246fc..302b2d57c 100644 --- a/ext/node/polyfills/internal_binding/util.ts +++ b/ext/node/polyfills/internal_binding/util.ts @@ -28,7 +28,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const ops = core.ops; const handleTypes = ["TCP", "TTY", "UDP", "FILE", "PIPE", "UNKNOWN"]; diff --git a/ext/node/polyfills/timers.ts b/ext/node/polyfills/timers.ts index 2bedbe65b..a9953a1e7 100644 --- a/ext/node/polyfills/timers.ts +++ b/ext/node/polyfills/timers.ts @@ -3,7 +3,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 { MapPrototypeGet, MapPrototypeDelete, diff --git a/ext/node/polyfills/util.ts b/ext/node/polyfills/util.ts index 68c9626c9..a77167253 100644 --- a/ext/node/polyfills/util.ts +++ b/ext/node/polyfills/util.ts @@ -16,7 +16,7 @@ import { isDeepStrictEqual } from "ext:deno_node/internal/util/comparisons.ts"; import process from "node:process"; import { validateString } from "ext:deno_node/internal/validators.mjs"; import { parseArgs } from "ext:deno_node/internal/util/parse_args/parse_args.js"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayIsArray, ArrayPrototypeJoin, |