diff --git a/cli/tests/testdata/run/internal_dynamic_import.ts b/cli/tests/testdata/run/internal_dynamic_import.ts index 940c22e597..9dd2ce2e1f 100644 --- a/cli/tests/testdata/run/internal_dynamic_import.ts +++ b/cli/tests/testdata/run/internal_dynamic_import.ts @@ -1 +1 @@ -await import("internal:runtime/01_build.js"); +await import("internal:runtime/01_errors.js"); diff --git a/cli/tests/testdata/run/internal_dynamic_import.ts.out b/cli/tests/testdata/run/internal_dynamic_import.ts.out index 3f74f95658..3deb9366eb 100644 --- a/cli/tests/testdata/run/internal_dynamic_import.ts.out +++ b/cli/tests/testdata/run/internal_dynamic_import.ts.out @@ -1,4 +1,4 @@ error: Uncaught TypeError: Cannot load internal module from external code -await import("internal:runtime/01_build.js"); +await import("internal:runtime/01_errors.js"); ^ at [WILDCARD]/internal_dynamic_import.ts:1:1 diff --git a/cli/tests/testdata/run/internal_import.ts b/cli/tests/testdata/run/internal_import.ts index eb38d973c5..2cb834d330 100644 --- a/cli/tests/testdata/run/internal_import.ts +++ b/cli/tests/testdata/run/internal_import.ts @@ -1 +1 @@ -import "internal:runtime/01_build.js"; +import "internal:runtime/01_errors.js"; diff --git a/cli/tests/testdata/run/internal_import.ts.out b/cli/tests/testdata/run/internal_import.ts.out index 5fba0dfc00..ca82cc21e8 100644 --- a/cli/tests/testdata/run/internal_import.ts.out +++ b/cli/tests/testdata/run/internal_import.ts.out @@ -1,4 +1,4 @@ -error: Unsupported scheme "internal" for module "internal:runtime/01_build.js". Supported schemes: [ +error: Unsupported scheme "internal" for module "internal:runtime/01_errors.js". Supported schemes: [ "data", "blob", "file", diff --git a/core/01_core.js b/core/01_core.js index 5a622b0ea8..07ab758f13 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -3,33 +3,57 @@ ((window) => { const { + Array, + ArrayPrototypeFill, + ArrayPrototypeMap, + ArrayPrototypePush, Error, + ErrorCaptureStackTrace, + Map, + MapPrototypeDelete, + MapPrototypeGet, + MapPrototypeHas, + MapPrototypeSet, + ObjectAssign, + ObjectFreeze, + ObjectFromEntries, + Promise, + PromisePrototypeThen, RangeError, ReferenceError, + SafePromisePrototypeFinally, + setQueueMicrotask, + StringPrototypeSlice, + StringPrototypeSplit, + SymbolFor, SyntaxError, TypeError, URIError, - Array, - ArrayPrototypeFill, - ArrayPrototypePush, - ArrayPrototypeMap, - ErrorCaptureStackTrace, - Promise, - ObjectAssign, - ObjectFromEntries, - Map, - MapPrototypeGet, - MapPrototypeHas, - MapPrototypeDelete, - MapPrototypeSet, - PromisePrototypeThen, - SafePromisePrototypeFinally, - StringPrototypeSlice, - SymbolFor, - setQueueMicrotask, } = window.__bootstrap.primordials; const { ops } = window.Deno.core; + const build = { + target: "unknown", + arch: "unknown", + os: "unknown", + vendor: "unknown", + env: undefined, + }; + + function setBuildInfo(target) { + const { 0: arch, 1: vendor, 2: os, 3: env } = StringPrototypeSplit( + target, + "-", + 4, + ); + build.target = target; + build.arch = arch; + build.vendor = vendor; + build.os = os; + build.env = env; + ObjectFreeze(build); + } + const errorMap = {}; // Builtin v8 / JS errors registerErrorClass("Error", Error); @@ -408,6 +432,8 @@ eventLoopHasMoreWork: () => ops.op_event_loop_has_more_work(), setPromiseRejectCallback: (fn) => ops.op_set_promise_reject_callback(fn), byteLength: (str) => ops.op_str_byte_length(str), + build, + setBuildInfo, }); ObjectAssign(globalThis.__bootstrap, { core }); diff --git a/ext/node/polyfills/_process/process.ts b/ext/node/polyfills/_process/process.ts index 3bcf6dcf99..bee65f9056 100644 --- a/ext/node/polyfills/_process/process.ts +++ b/ext/node/polyfills/_process/process.ts @@ -4,16 +4,16 @@ // 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 -import { build } from "internal:runtime/01_build.js"; +const core = globalThis.Deno.core; import { nextTick as _nextTick } from "internal:deno_node/_next_tick.ts"; import { _exiting } from "internal:deno_node/_process/exiting.ts"; import * as fs from "internal:runtime/30_fs.js"; /** Returns the operating system CPU architecture for which the Deno binary was compiled */ export function arch(): string { - if (build.arch == "x86_64") { + if (core.build.arch == "x86_64") { return "x64"; - } else if (build.arch == "aarch64") { + } else if (core.build.arch == "aarch64") { return "arm64"; } else { throw Error("unreachable"); diff --git a/runtime/build.rs b/runtime/build.rs index 153a856286..76c0534bf1 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -194,7 +194,6 @@ mod startup_snapshot { ]) .esm(include_js_files!( dir "js", - "01_build.js", "01_errors.js", "01_version.ts", "06_util.js", diff --git a/runtime/js/01_build.js b/runtime/js/01_build.js deleted file mode 100644 index a9515c5b84..0000000000 --- a/runtime/js/01_build.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. - -const primordials = globalThis.__bootstrap.primordials; -const { ObjectFreeze, StringPrototypeSplit } = primordials; - -const build = { - target: "unknown", - arch: "unknown", - os: "unknown", - vendor: "unknown", - env: undefined, -}; - -function setBuildInfo(target) { - const { 0: arch, 1: vendor, 2: os, 3: env } = StringPrototypeSplit( - target, - "-", - 4, - ); - build.target = target; - build.arch = arch; - build.vendor = vendor; - build.os = os; - build.env = env; - ObjectFreeze(build); -} - -export { build, setBuildInfo }; diff --git a/runtime/js/06_util.js b/runtime/js/06_util.js index d3c95edba4..fc134d52d9 100644 --- a/runtime/js/06_util.js +++ b/runtime/js/06_util.js @@ -1,5 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +const core = globalThis.Deno.core; const internals = globalThis.__bootstrap.internals; const primordials = globalThis.__bootstrap.primordials; const { @@ -11,7 +12,6 @@ const { StringPrototypeReplace, TypeError, } = primordials; -import { build } from "internal:runtime/01_build.js"; import { URLPrototype } from "internal:deno_url/00_url.js"; let logDebug = false; let logSource = "JS"; @@ -94,7 +94,7 @@ function pathFromURL(pathOrUrl) { throw new TypeError("Must be a file URL."); } - return build.os == "windows" + return core.build.os == "windows" ? pathFromURLWin32(pathOrUrl) : pathFromURLPosix(pathOrUrl); } diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js index a7936085ef..fc0bbdca51 100644 --- a/runtime/js/30_fs.js +++ b/runtime/js/30_fs.js @@ -25,7 +25,6 @@ import { writableStreamForRid, } from "internal:deno_web/06_streams.js"; import { pathFromURL } from "internal:runtime/06_util.js"; -import { build } from "internal:runtime/01_build.js"; function chmodSync(path, mode) { ops.op_chmod_sync(pathFromURL(path), mode); @@ -272,7 +271,7 @@ const { 0: statStruct, 1: statBuf } = createByteStruct({ }); function parseFileInfo(response) { - const unix = build.os === "darwin" || build.os === "linux"; + const unix = core.build.os === "darwin" || core.build.os === "linux"; return { isFile: response.isFile, isDirectory: response.isDirectory, diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index f83695952c..45db052923 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -10,7 +10,6 @@ import * as net from "internal:deno_net/01_net.js"; import * as tls from "internal:deno_net/02_tls.js"; import * as http from "internal:deno_http/01_http.js"; import * as flash from "internal:deno_flash/01_http.js"; -import * as build from "internal:runtime/01_build.js"; import * as errors from "internal:runtime/01_errors.js"; import * as version from "internal:runtime/01_version.ts"; import * as permissions from "internal:runtime/10_permissions.js"; @@ -65,7 +64,7 @@ const denoNs = { renameSync: fs.renameSync, rename: fs.rename, version: version.version, - build: build.build, + build: core.build, statSync: fs.statSync, lstatSync: fs.lstatSync, stat: fs.stat, diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 58465f3a2c..0199c5148a 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -42,7 +42,6 @@ const { import * as util from "internal:runtime/06_util.js"; import * as event from "internal:deno_web/02_event.js"; import * as location from "internal:deno_web/12_location.js"; -import * as build from "internal:runtime/01_build.js"; import * as version from "internal:runtime/01_version.ts"; import * as os from "internal:runtime/30_os.js"; import * as timers from "internal:deno_web/02_timers.js"; @@ -305,7 +304,7 @@ function runtimeStart(runtimeOptions, source) { runtimeOptions.v8Version, runtimeOptions.tsVersion, ); - build.setBuildInfo(runtimeOptions.target); + core.setBuildInfo(runtimeOptions.target); util.setLogDebug(runtimeOptions.debugFlag, source); colors.setNoColor(runtimeOptions.noColor || !runtimeOptions.isTty); // deno-lint-ignore prefer-primordials