summaryrefslogtreecommitdiff
path: root/ext/node/lib.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-09-08 22:01:48 +0200
committerGitHub <noreply@github.com>2022-09-08 22:01:48 +0200
commit6c179daff07fe60d478142ea86231a34dc9ee1fd (patch)
tree39ff8701af61eec0674827b4ef62de1d4087e407 /ext/node/lib.rs
parent93cbac69e8a53fbb393fc7a2f12654b223cf01ad (diff)
fix(npm): recursive translation of reexports, remove window global in node code (#15806)
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'ext/node/lib.rs')
-rw-r--r--ext/node/lib.rs11
1 files changed, 11 insertions, 0 deletions
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<String> = 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<P: NodePermissions + 'static>(