From 75209e12f19ca5d4a2a7c9008fba63a487ad8e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 15 Feb 2023 19:44:52 +0100 Subject: feat: wire up ext/node to the Node compatibility layer (#17785) This PR changes Node.js/npm compatibility layer to use polyfills for built-in Node.js embedded in the snapshot (that are coming from "ext/node" extension). As a result loading `std/node`, either from "https://deno.land/std@/" or from "DENO_NODE_COMPAT_URL" env variable were removed. All code that is imported via "npm:" specifiers now uses code embedded in the snapshot. Several fixes were applied to various modules in "ext/node" to make tests pass. --------- Co-authored-by: Yoshiya Hinosawa Co-authored-by: Divy Srivastava --- ext/node/polyfills/_util/os.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'ext/node/polyfills/_util') diff --git a/ext/node/polyfills/_util/os.ts b/ext/node/polyfills/_util/os.ts index 66d18534c..a3cb396bd 100644 --- a/ext/node/polyfills/_util/os.ts +++ b/ext/node/polyfills/_util/os.ts @@ -1,22 +1,10 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -export type OSType = "windows" | "linux" | "darwin" | "freebsd"; - -export const osType: OSType = (() => { - // deno-lint-ignore no-explicit-any - const { Deno } = globalThis as any; - if (typeof Deno?.build?.os === "string") { - return Deno.build.os; - } +const { ops } = globalThis.__bootstrap.core; - // deno-lint-ignore no-explicit-any - const { navigator } = globalThis as any; - if (navigator?.appVersion?.includes?.("Win")) { - return "windows"; - } +export type OSType = "windows" | "linux" | "darwin" | "freebsd"; - return "linux"; -})(); +export const osType: OSType = ops.op_node_build_os(); export const isWindows = osType === "windows"; export const isLinux = osType === "linux"; -- cgit v1.2.3