From fc2e00152b162280e78b06028d51274e33275629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 24 Jan 2023 15:05:54 +0100 Subject: feat: support node built-in module imports (#17264) Co-authored-by: David Sherret --- cli/tsc/00_typescript.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'cli/tsc/00_typescript.js') diff --git a/cli/tsc/00_typescript.js b/cli/tsc/00_typescript.js index 789de3a66..3fbf4624a 100644 --- a/cli/tsc/00_typescript.js +++ b/cli/tsc/00_typescript.js @@ -91389,10 +91389,15 @@ var ts; var deno; (function (deno) { var isNodeSourceFile = function () { return false; }; + var nodeBuiltInModuleNames = new ts.Set(); function setIsNodeSourceFileCallback(callback) { isNodeSourceFile = callback; } deno.setIsNodeSourceFileCallback = setIsNodeSourceFileCallback; + function setNodeBuiltInModuleNames(names) { + nodeBuiltInModuleNames = new ts.Set(names); + } + deno.setNodeBuiltInModuleNames = setNodeBuiltInModuleNames; // When upgrading: // 1. Inspect all usages of "globals" and "globalThisSymbol" in checker.ts // - Beware that `globalThisType` might refer to the global `this` type @@ -91452,8 +91457,16 @@ var ts; function getGlobalsForName(id) { // Node ambient modules are only accessible in the node code, // so put them on the node globals - if (ambientModuleSymbolRegex.test(id)) + if (ambientModuleSymbolRegex.test(id)) { + if (id.startsWith('"node:')) { + // check if it's a node specifier that we support + var name = id.slice(6, -1); + if (nodeBuiltInModuleNames.has(name)) { + return globals; + } + } return nodeGlobals; + } return nodeOnlyGlobalNames.has(id) ? nodeGlobals : globals; } function mergeGlobalSymbolTable(node, source, unidirectional) { -- cgit v1.2.3