mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
refactor(ext/node): use a snapshottable global name for Node's globalThis (#18860)
This commit is contained in:
parent
7415aff983
commit
a8b4e346b4
3 changed files with 17 additions and 18 deletions
|
@ -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())?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue