summaryrefslogtreecommitdiff
path: root/cli/tsc/00_typescript.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-01-24 15:05:54 +0100
committerGitHub <noreply@github.com>2023-01-24 09:05:54 -0500
commitfc2e00152b162280e78b06028d51274e33275629 (patch)
treeee567a99cabc6633454de231939f7d898146f1d8 /cli/tsc/00_typescript.js
parentcadeaae045d2489fe125286b8c2c641c6d973c3f (diff)
feat: support node built-in module imports (#17264)
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'cli/tsc/00_typescript.js')
-rw-r--r--cli/tsc/00_typescript.js15
1 files changed, 14 insertions, 1 deletions
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) {