From 6c179daff07fe60d478142ea86231a34dc9ee1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 8 Sep 2022 22:01:48 +0200 Subject: fix(npm): recursive translation of reexports, remove window global in node code (#15806) Co-authored-by: David Sherret --- ext/node/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ext/node/lib.rs') diff --git a/ext/node/lib.rs b/ext/node/lib.rs index 99df93be5..753a11b5d 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -7,6 +7,7 @@ use deno_core::op; use deno_core::url::Url; use deno_core::Extension; use deno_core::OpState; +use once_cell::sync::Lazy; use std::path::Path; use std::path::PathBuf; use std::rc::Rc; @@ -48,6 +49,16 @@ pub trait DenoDirNpmResolver { pub const MODULE_ES_SHIM: &str = include_str!("./module_es_shim.js"); +pub static NODE_GLOBAL_THIS_NAME: Lazy = Lazy::new(|| { + let now = std::time::SystemTime::now(); + let seconds = now + .duration_since(std::time::SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs(); + // use a changing variable name to make it hard to depend on this + format!("__DENO_NODE_GLOBAL_THIS_{}__", seconds) +}); + struct Unstable(pub bool); pub fn init( -- cgit v1.2.3