summaryrefslogtreecommitdiff
path: root/ext/node/lib.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-04-26 18:53:13 -0400
committerGitHub <noreply@github.com>2023-04-26 18:53:13 -0400
commita8b4e346b4477e340f36a59f83a0974afd541f4b (patch)
tree4a8cd39cc63fcec888e350509806de3b5121df85 /ext/node/lib.rs
parent7415aff983333ae45badfd43c3db35d39ad37b79 (diff)
refactor(ext/node): use a snapshottable global name for Node's globalThis (#18860)
Diffstat (limited to 'ext/node/lib.rs')
-rw-r--r--ext/node/lib.rs14
1 files changed, 2 insertions, 12 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs
index 84530423f..cc4afb2b8 100644
--- a/ext/node/lib.rs
+++ b/ext/node/lib.rs
@@ -169,15 +169,7 @@ pub trait NpmResolver: std::fmt::Debug + Send + Sync {
) -> Result<(), AnyError>;
}
-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}__")
-});
+pub const NODE_GLOBAL_THIS_NAME: &str = env!("NODE_GLOBAL_THIS_NAME");
pub static NODE_ENV_VAR_ALLOWLIST: Lazy<HashSet<String>> = Lazy::new(|| {
// The full list of environment variables supported by Node.js is available
@@ -557,9 +549,7 @@ pub fn initialize_runtime(
argv0
);
}})('{}', {}, {});"#,
- NODE_GLOBAL_THIS_NAME.as_str(),
- uses_local_node_modules_dir,
- argv0
+ NODE_GLOBAL_THIS_NAME, uses_local_node_modules_dir, argv0
);
js_runtime.execute_script(located_script_name!(), source_code.into())?;