2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2022-08-09 15:06:01 -04:00
|
|
|
|
2022-11-07 21:16:24 -05:00
|
|
|
use deno_core::error::generic_error;
|
2022-08-09 15:06:01 -04:00
|
|
|
use deno_core::error::AnyError;
|
|
|
|
use deno_core::include_js_files;
|
|
|
|
use deno_core::normalize_path;
|
|
|
|
use deno_core::op;
|
2022-08-20 11:31:33 -04:00
|
|
|
use deno_core::url::Url;
|
2022-08-09 15:06:01 -04:00
|
|
|
use deno_core::Extension;
|
2022-11-28 15:59:36 -05:00
|
|
|
use deno_core::JsRuntimeInspector;
|
2022-08-09 22:09:51 -04:00
|
|
|
use deno_core::OpState;
|
2022-09-08 16:01:48 -04:00
|
|
|
use once_cell::sync::Lazy;
|
2022-09-14 11:59:20 -04:00
|
|
|
use std::collections::HashSet;
|
2022-08-20 11:31:33 -04:00
|
|
|
use std::path::Path;
|
2022-08-09 15:06:01 -04:00
|
|
|
use std::path::PathBuf;
|
2022-08-20 11:31:33 -04:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
2022-09-05 06:36:35 -04:00
|
|
|
pub mod errors;
|
|
|
|
mod package_json;
|
2022-09-22 11:17:02 -04:00
|
|
|
mod path;
|
2022-09-05 06:36:35 -04:00
|
|
|
mod resolution;
|
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
pub use package_json::PackageJson;
|
2022-09-22 11:17:02 -04:00
|
|
|
pub use path::PathClean;
|
2022-08-30 14:09:22 -04:00
|
|
|
pub use resolution::get_closest_package_json;
|
2022-08-20 11:31:33 -04:00
|
|
|
pub use resolution::get_package_scope_config;
|
|
|
|
pub use resolution::legacy_main_resolve;
|
|
|
|
pub use resolution::package_exports_resolve;
|
|
|
|
pub use resolution::package_imports_resolve;
|
|
|
|
pub use resolution::package_resolve;
|
2022-11-16 14:41:27 -05:00
|
|
|
pub use resolution::path_to_declaration_path;
|
2022-08-30 14:09:22 -04:00
|
|
|
pub use resolution::NodeModuleKind;
|
2022-11-30 18:07:32 -05:00
|
|
|
pub use resolution::NodeResolutionMode;
|
2022-08-20 11:31:33 -04:00
|
|
|
pub use resolution::DEFAULT_CONDITIONS;
|
2022-11-28 15:59:36 -05:00
|
|
|
use std::cell::RefCell;
|
2022-08-20 11:31:33 -04:00
|
|
|
|
2022-08-24 12:07:49 -04:00
|
|
|
pub trait NodePermissions {
|
|
|
|
fn check_read(&mut self, path: &Path) -> Result<(), AnyError>;
|
|
|
|
}
|
|
|
|
|
2022-09-13 11:59:01 -04:00
|
|
|
pub trait RequireNpmResolver {
|
2022-08-20 11:31:33 -04:00
|
|
|
fn resolve_package_folder_from_package(
|
|
|
|
&self,
|
|
|
|
specifier: &str,
|
|
|
|
referrer: &Path,
|
2022-11-30 18:07:32 -05:00
|
|
|
mode: NodeResolutionMode,
|
2022-08-20 11:31:33 -04:00
|
|
|
) -> Result<PathBuf, AnyError>;
|
|
|
|
|
|
|
|
fn resolve_package_folder_from_path(
|
|
|
|
&self,
|
|
|
|
path: &Path,
|
|
|
|
) -> Result<PathBuf, AnyError>;
|
|
|
|
|
|
|
|
fn in_npm_package(&self, path: &Path) -> bool;
|
|
|
|
|
2023-01-10 08:35:44 -05:00
|
|
|
fn ensure_read_permission(
|
|
|
|
&self,
|
|
|
|
permissions: &mut dyn NodePermissions,
|
|
|
|
path: &Path,
|
|
|
|
) -> Result<(), AnyError>;
|
2022-08-20 11:31:33 -04:00
|
|
|
}
|
|
|
|
|
2022-08-24 08:54:20 -04:00
|
|
|
pub const MODULE_ES_SHIM: &str = include_str!("./module_es_shim.js");
|
|
|
|
|
2022-09-08 16:01:48 -04:00
|
|
|
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
|
2023-01-27 10:43:16 -05:00
|
|
|
format!("__DENO_NODE_GLOBAL_THIS_{seconds}__")
|
2022-09-08 16:01:48 -04:00
|
|
|
});
|
|
|
|
|
2022-09-14 11:59:20 -04:00
|
|
|
pub static NODE_ENV_VAR_ALLOWLIST: Lazy<HashSet<String>> = Lazy::new(|| {
|
|
|
|
// The full list of environment variables supported by Node.js is available
|
|
|
|
// at https://nodejs.org/api/cli.html#environment-variables
|
|
|
|
let mut set = HashSet::new();
|
|
|
|
set.insert("NODE_DEBUG".to_string());
|
|
|
|
set.insert("NODE_OPTIONS".to_string());
|
|
|
|
set
|
|
|
|
});
|
|
|
|
|
2022-08-24 12:07:49 -04:00
|
|
|
pub fn init<P: NodePermissions + 'static>(
|
2022-09-13 11:59:01 -04:00
|
|
|
maybe_npm_resolver: Option<Rc<dyn RequireNpmResolver>>,
|
2022-08-20 11:31:33 -04:00
|
|
|
) -> Extension {
|
2023-01-08 17:48:46 -05:00
|
|
|
Extension::builder(env!("CARGO_PKG_NAME"))
|
2023-02-10 06:40:45 -05:00
|
|
|
.esm(include_js_files!(
|
|
|
|
"01_node.js",
|
|
|
|
"02_require.js",
|
|
|
|
"module_es_shim.js",
|
|
|
|
))
|
2022-08-09 15:06:01 -04:00
|
|
|
.ops(vec![
|
|
|
|
op_require_init_paths::decl(),
|
2022-08-24 12:07:49 -04:00
|
|
|
op_require_node_module_paths::decl::<P>(),
|
2022-08-09 15:06:01 -04:00
|
|
|
op_require_proxy_path::decl(),
|
2022-08-20 11:31:33 -04:00
|
|
|
op_require_is_deno_dir_package::decl(),
|
|
|
|
op_require_resolve_deno_dir::decl(),
|
2022-08-09 15:06:01 -04:00
|
|
|
op_require_is_request_relative::decl(),
|
|
|
|
op_require_resolve_lookup_paths::decl(),
|
2022-08-24 12:07:49 -04:00
|
|
|
op_require_try_self_parent_path::decl::<P>(),
|
2023-01-10 08:35:44 -05:00
|
|
|
op_require_try_self::decl::<P>(),
|
2022-08-24 12:07:49 -04:00
|
|
|
op_require_real_path::decl::<P>(),
|
2022-08-09 15:06:01 -04:00
|
|
|
op_require_path_is_absolute::decl(),
|
|
|
|
op_require_path_dirname::decl(),
|
2022-08-24 12:07:49 -04:00
|
|
|
op_require_stat::decl::<P>(),
|
2022-08-09 15:06:01 -04:00
|
|
|
op_require_path_resolve::decl(),
|
|
|
|
op_require_path_basename::decl(),
|
2022-08-24 12:07:49 -04:00
|
|
|
op_require_read_file::decl::<P>(),
|
2022-08-20 11:31:33 -04:00
|
|
|
op_require_as_file_path::decl(),
|
2023-01-10 08:35:44 -05:00
|
|
|
op_require_resolve_exports::decl::<P>(),
|
2022-08-30 14:09:22 -04:00
|
|
|
op_require_read_closest_package_json::decl::<P>(),
|
2023-01-10 08:35:44 -05:00
|
|
|
op_require_read_package_scope::decl::<P>(),
|
2022-08-24 12:07:49 -04:00
|
|
|
op_require_package_imports_resolve::decl::<P>(),
|
2022-11-28 15:59:36 -05:00
|
|
|
op_require_break_on_next_statement::decl(),
|
2022-08-09 15:06:01 -04:00
|
|
|
])
|
2022-08-09 22:09:51 -04:00
|
|
|
.state(move |state| {
|
2022-08-20 11:31:33 -04:00
|
|
|
if let Some(npm_resolver) = maybe_npm_resolver.clone() {
|
|
|
|
state.put(npm_resolver);
|
|
|
|
}
|
2022-08-09 22:09:51 -04:00
|
|
|
Ok(())
|
|
|
|
})
|
2022-08-09 15:06:01 -04:00
|
|
|
.build()
|
|
|
|
}
|
|
|
|
|
2022-08-24 12:07:49 -04:00
|
|
|
fn ensure_read_permission<P>(
|
2022-08-20 11:31:33 -04:00
|
|
|
state: &mut OpState,
|
|
|
|
file_path: &Path,
|
2022-08-24 12:07:49 -04:00
|
|
|
) -> Result<(), AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-08-20 11:31:33 -04:00
|
|
|
let resolver = {
|
2022-09-13 11:59:01 -04:00
|
|
|
let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>();
|
2022-08-20 11:31:33 -04:00
|
|
|
resolver.clone()
|
|
|
|
};
|
2023-01-10 08:35:44 -05:00
|
|
|
let permissions = state.borrow_mut::<P>();
|
|
|
|
resolver.ensure_read_permission(permissions, file_path)
|
2022-08-20 11:31:33 -04:00
|
|
|
}
|
|
|
|
|
2022-08-09 15:06:01 -04:00
|
|
|
#[op]
|
2022-11-10 11:57:10 -05:00
|
|
|
pub fn op_require_init_paths() -> Vec<String> {
|
2022-08-20 11:31:33 -04:00
|
|
|
// todo(dsherret): this code is node compat mode specific and
|
|
|
|
// we probably don't want it for small mammal, so ignore it for now
|
|
|
|
|
|
|
|
// let (home_dir, node_path) = if cfg!(windows) {
|
|
|
|
// (
|
|
|
|
// std::env::var("USERPROFILE").unwrap_or_else(|_| "".into()),
|
|
|
|
// std::env::var("NODE_PATH").unwrap_or_else(|_| "".into()),
|
|
|
|
// )
|
|
|
|
// } else {
|
|
|
|
// (
|
|
|
|
// std::env::var("HOME").unwrap_or_else(|_| "".into()),
|
|
|
|
// std::env::var("NODE_PATH").unwrap_or_else(|_| "".into()),
|
|
|
|
// )
|
|
|
|
// };
|
|
|
|
|
|
|
|
// let mut prefix_dir = std::env::current_exe().unwrap();
|
|
|
|
// if cfg!(windows) {
|
|
|
|
// prefix_dir = prefix_dir.join("..").join("..")
|
|
|
|
// } else {
|
|
|
|
// prefix_dir = prefix_dir.join("..")
|
|
|
|
// }
|
2022-08-09 15:06:01 -04:00
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
// let mut paths = vec![prefix_dir.join("lib").join("node")];
|
2022-08-09 15:06:01 -04:00
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
// if !home_dir.is_empty() {
|
|
|
|
// paths.insert(0, PathBuf::from(&home_dir).join(".node_libraries"));
|
|
|
|
// paths.insert(0, PathBuf::from(&home_dir).join(".nod_modules"));
|
|
|
|
// }
|
2022-08-09 15:06:01 -04:00
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
// let mut paths = paths
|
|
|
|
// .into_iter()
|
|
|
|
// .map(|p| p.to_string_lossy().to_string())
|
|
|
|
// .collect();
|
|
|
|
|
|
|
|
// if !node_path.is_empty() {
|
|
|
|
// let delimiter = if cfg!(windows) { ";" } else { ":" };
|
|
|
|
// let mut node_paths: Vec<String> = node_path
|
|
|
|
// .split(delimiter)
|
|
|
|
// .filter(|e| !e.is_empty())
|
|
|
|
// .map(|s| s.to_string())
|
|
|
|
// .collect();
|
|
|
|
// node_paths.append(&mut paths);
|
|
|
|
// paths = node_paths;
|
|
|
|
// }
|
2022-08-09 15:06:01 -04:00
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
vec![]
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-08-24 12:07:49 -04:00
|
|
|
pub fn op_require_node_module_paths<P>(
|
2022-08-09 22:09:51 -04:00
|
|
|
state: &mut OpState,
|
|
|
|
from: String,
|
2022-08-24 12:07:49 -04:00
|
|
|
) -> Result<Vec<String>, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-08-09 15:06:01 -04:00
|
|
|
// Guarantee that "from" is absolute.
|
|
|
|
let from = deno_core::resolve_path(&from)
|
|
|
|
.unwrap()
|
|
|
|
.to_file_path()
|
|
|
|
.unwrap();
|
|
|
|
|
2022-08-24 12:07:49 -04:00
|
|
|
ensure_read_permission::<P>(state, &from)?;
|
2022-08-20 11:31:33 -04:00
|
|
|
|
2022-08-09 15:06:01 -04:00
|
|
|
if cfg!(windows) {
|
|
|
|
// return root node_modules when path is 'D:\\'.
|
|
|
|
let from_str = from.to_str().unwrap();
|
|
|
|
if from_str.len() >= 3 {
|
|
|
|
let bytes = from_str.as_bytes();
|
|
|
|
if bytes[from_str.len() - 1] == b'\\' && bytes[from_str.len() - 2] == b':'
|
|
|
|
{
|
|
|
|
let p = from_str.to_owned() + "node_modules";
|
2022-08-20 11:31:33 -04:00
|
|
|
return Ok(vec![p]);
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Return early not only to avoid unnecessary work, but to *avoid* returning
|
|
|
|
// an array of two items for a root: [ '//node_modules', '/node_modules' ]
|
|
|
|
if from.to_string_lossy() == "/" {
|
2022-08-20 11:31:33 -04:00
|
|
|
return Ok(vec!["/node_modules".to_string()]);
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut paths = vec![];
|
|
|
|
let mut current_path = from.as_path();
|
|
|
|
let mut maybe_parent = Some(current_path);
|
|
|
|
while let Some(parent) = maybe_parent {
|
|
|
|
if !parent.ends_with("/node_modules") {
|
|
|
|
paths.push(parent.join("node_modules").to_string_lossy().to_string());
|
|
|
|
current_path = parent;
|
|
|
|
maybe_parent = current_path.parent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !cfg!(windows) {
|
|
|
|
// Append /node_modules to handle root paths.
|
|
|
|
paths.push("/node_modules".to_string());
|
|
|
|
}
|
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
Ok(paths)
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-11-10 11:57:10 -05:00
|
|
|
fn op_require_proxy_path(filename: String) -> String {
|
2022-08-09 15:06:01 -04:00
|
|
|
// Allow a directory to be passed as the filename
|
|
|
|
let trailing_slash = if cfg!(windows) {
|
2022-11-29 00:13:14 -05:00
|
|
|
// Node also counts a trailing forward slash as a
|
|
|
|
// directory for node on Windows, but not backslashes
|
|
|
|
// on non-Windows platforms
|
|
|
|
filename.ends_with('\\') || filename.ends_with('/')
|
2022-08-09 15:06:01 -04:00
|
|
|
} else {
|
|
|
|
filename.ends_with('/')
|
|
|
|
};
|
|
|
|
|
|
|
|
if trailing_slash {
|
|
|
|
let p = PathBuf::from(filename);
|
|
|
|
p.join("noop.js").to_string_lossy().to_string()
|
|
|
|
} else {
|
|
|
|
filename
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-12-15 10:26:10 -05:00
|
|
|
fn op_require_is_request_relative(request: String) -> bool {
|
2022-08-20 11:31:33 -04:00
|
|
|
if request.starts_with("./") || request.starts_with("../") || request == ".."
|
|
|
|
{
|
2022-08-09 15:06:01 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg!(windows) {
|
|
|
|
if request.starts_with(".\\") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if request.starts_with("..\\") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
#[op]
|
|
|
|
fn op_require_resolve_deno_dir(
|
|
|
|
state: &mut OpState,
|
|
|
|
request: String,
|
|
|
|
parent_filename: String,
|
|
|
|
) -> Option<String> {
|
2022-09-13 11:59:01 -04:00
|
|
|
let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>();
|
2022-08-20 11:31:33 -04:00
|
|
|
resolver
|
|
|
|
.resolve_package_folder_from_package(
|
|
|
|
&request,
|
|
|
|
&PathBuf::from(parent_filename),
|
2022-11-30 18:07:32 -05:00
|
|
|
NodeResolutionMode::Execution,
|
2022-08-20 11:31:33 -04:00
|
|
|
)
|
|
|
|
.ok()
|
|
|
|
.map(|p| p.to_string_lossy().to_string())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
|
|
|
fn op_require_is_deno_dir_package(state: &mut OpState, path: String) -> bool {
|
2022-09-13 11:59:01 -04:00
|
|
|
let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>();
|
2022-08-20 11:31:33 -04:00
|
|
|
resolver.in_npm_package(&PathBuf::from(path))
|
|
|
|
}
|
|
|
|
|
2022-08-09 15:06:01 -04:00
|
|
|
#[op]
|
|
|
|
fn op_require_resolve_lookup_paths(
|
|
|
|
request: String,
|
|
|
|
maybe_parent_paths: Option<Vec<String>>,
|
|
|
|
parent_filename: String,
|
|
|
|
) -> Option<Vec<String>> {
|
|
|
|
if !request.starts_with('.')
|
|
|
|
|| (request.len() > 1
|
|
|
|
&& !request.starts_with("..")
|
|
|
|
&& !request.starts_with("./")
|
|
|
|
&& (!cfg!(windows) || !request.starts_with(".\\")))
|
|
|
|
{
|
|
|
|
let module_paths = vec![];
|
|
|
|
let mut paths = module_paths;
|
|
|
|
if let Some(mut parent_paths) = maybe_parent_paths {
|
|
|
|
if !parent_paths.is_empty() {
|
|
|
|
paths.append(&mut parent_paths);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !paths.is_empty() {
|
|
|
|
return Some(paths);
|
|
|
|
} else {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// In REPL, parent.filename is null.
|
|
|
|
// if (!parent || !parent.id || !parent.filename) {
|
|
|
|
// // Make require('./path/to/foo') work - normally the path is taken
|
|
|
|
// // from realpath(__filename) but in REPL there is no filename
|
|
|
|
// const mainPaths = ['.'];
|
|
|
|
|
|
|
|
// debug('looking for %j in %j', request, mainPaths);
|
|
|
|
// return mainPaths;
|
|
|
|
// }
|
|
|
|
|
|
|
|
let p = PathBuf::from(parent_filename);
|
|
|
|
Some(vec![p.parent().unwrap().to_string_lossy().to_string()])
|
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-11-10 11:57:10 -05:00
|
|
|
fn op_require_path_is_absolute(p: String) -> bool {
|
2022-08-09 15:06:01 -04:00
|
|
|
PathBuf::from(p).is_absolute()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-08-24 12:07:49 -04:00
|
|
|
fn op_require_stat<P>(
|
|
|
|
state: &mut OpState,
|
|
|
|
path: String,
|
|
|
|
) -> Result<i32, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-08-20 11:31:33 -04:00
|
|
|
let path = PathBuf::from(path);
|
2022-08-24 12:07:49 -04:00
|
|
|
ensure_read_permission::<P>(state, &path)?;
|
2022-08-20 11:31:33 -04:00
|
|
|
if let Ok(metadata) = std::fs::metadata(&path) {
|
2022-08-09 15:06:01 -04:00
|
|
|
if metadata.is_file() {
|
2022-08-20 11:31:33 -04:00
|
|
|
return Ok(0);
|
2022-08-09 15:06:01 -04:00
|
|
|
} else {
|
2022-08-20 11:31:33 -04:00
|
|
|
return Ok(1);
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
Ok(-1)
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-08-24 12:07:49 -04:00
|
|
|
fn op_require_real_path<P>(
|
2022-08-09 22:09:51 -04:00
|
|
|
state: &mut OpState,
|
|
|
|
request: String,
|
2022-08-24 12:07:49 -04:00
|
|
|
) -> Result<String, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-08-20 11:31:33 -04:00
|
|
|
let path = PathBuf::from(request);
|
2022-08-24 12:07:49 -04:00
|
|
|
ensure_read_permission::<P>(state, &path)?;
|
2022-08-20 11:31:33 -04:00
|
|
|
let mut canonicalized_path = path.canonicalize()?;
|
2022-08-09 15:06:01 -04:00
|
|
|
if cfg!(windows) {
|
|
|
|
canonicalized_path = PathBuf::from(
|
|
|
|
canonicalized_path
|
|
|
|
.display()
|
|
|
|
.to_string()
|
|
|
|
.trim_start_matches("\\\\?\\"),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
Ok(canonicalized_path.to_string_lossy().to_string())
|
|
|
|
}
|
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
fn path_resolve(parts: Vec<String>) -> String {
|
2022-08-09 15:06:01 -04:00
|
|
|
assert!(!parts.is_empty());
|
|
|
|
let mut p = PathBuf::from(&parts[0]);
|
|
|
|
if parts.len() > 1 {
|
|
|
|
for part in &parts[1..] {
|
|
|
|
p = p.join(part);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
normalize_path(p).to_string_lossy().to_string()
|
|
|
|
}
|
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
#[op]
|
2022-11-10 11:57:10 -05:00
|
|
|
fn op_require_path_resolve(parts: Vec<String>) -> String {
|
2022-08-20 11:31:33 -04:00
|
|
|
path_resolve(parts)
|
|
|
|
}
|
|
|
|
|
2022-08-09 15:06:01 -04:00
|
|
|
#[op]
|
2022-11-10 11:57:10 -05:00
|
|
|
fn op_require_path_dirname(request: String) -> Result<String, AnyError> {
|
2022-08-09 15:06:01 -04:00
|
|
|
let p = PathBuf::from(request);
|
2022-11-07 21:16:24 -05:00
|
|
|
if let Some(parent) = p.parent() {
|
|
|
|
Ok(parent.to_string_lossy().to_string())
|
|
|
|
} else {
|
|
|
|
Err(generic_error("Path doesn't have a parent"))
|
|
|
|
}
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-11-10 11:57:10 -05:00
|
|
|
fn op_require_path_basename(request: String) -> Result<String, AnyError> {
|
2022-08-09 15:06:01 -04:00
|
|
|
let p = PathBuf::from(request);
|
2022-11-07 21:16:24 -05:00
|
|
|
if let Some(path) = p.file_name() {
|
|
|
|
Ok(path.to_string_lossy().to_string())
|
|
|
|
} else {
|
|
|
|
Err(generic_error("Path doesn't have a file name"))
|
|
|
|
}
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-08-24 12:07:49 -04:00
|
|
|
fn op_require_try_self_parent_path<P>(
|
2022-08-09 22:09:51 -04:00
|
|
|
state: &mut OpState,
|
2022-08-09 15:06:01 -04:00
|
|
|
has_parent: bool,
|
|
|
|
maybe_parent_filename: Option<String>,
|
|
|
|
maybe_parent_id: Option<String>,
|
2022-08-24 12:07:49 -04:00
|
|
|
) -> Result<Option<String>, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-08-09 15:06:01 -04:00
|
|
|
if !has_parent {
|
2022-08-20 11:31:33 -04:00
|
|
|
return Ok(None);
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(parent_filename) = maybe_parent_filename {
|
2022-08-20 11:31:33 -04:00
|
|
|
return Ok(Some(parent_filename));
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(parent_id) = maybe_parent_id {
|
|
|
|
if parent_id == "<repl>" || parent_id == "internal/preload" {
|
|
|
|
if let Ok(cwd) = std::env::current_dir() {
|
2022-08-24 12:07:49 -04:00
|
|
|
ensure_read_permission::<P>(state, &cwd)?;
|
2022-08-20 11:31:33 -04:00
|
|
|
return Ok(Some(cwd.to_string_lossy().to_string()));
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-20 11:31:33 -04:00
|
|
|
Ok(None)
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2023-01-10 08:35:44 -05:00
|
|
|
fn op_require_try_self<P>(
|
2022-08-09 22:09:51 -04:00
|
|
|
state: &mut OpState,
|
2022-08-20 11:31:33 -04:00
|
|
|
parent_path: Option<String>,
|
|
|
|
request: String,
|
2023-01-10 08:35:44 -05:00
|
|
|
) -> Result<Option<String>, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-08-20 11:31:33 -04:00
|
|
|
if parent_path.is_none() {
|
|
|
|
return Ok(None);
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
2022-09-13 11:59:01 -04:00
|
|
|
let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>().clone();
|
2023-01-10 08:35:44 -05:00
|
|
|
let permissions = state.borrow_mut::<P>();
|
2022-08-20 11:31:33 -04:00
|
|
|
let pkg = resolution::get_package_scope_config(
|
|
|
|
&Url::from_file_path(parent_path.unwrap()).unwrap(),
|
|
|
|
&*resolver,
|
2023-01-10 08:35:44 -05:00
|
|
|
permissions,
|
2022-08-20 11:31:33 -04:00
|
|
|
)
|
|
|
|
.ok();
|
|
|
|
if pkg.is_none() {
|
|
|
|
return Ok(None);
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
let pkg = pkg.unwrap();
|
|
|
|
if pkg.exports.is_none() {
|
|
|
|
return Ok(None);
|
|
|
|
}
|
|
|
|
if pkg.name.is_none() {
|
|
|
|
return Ok(None);
|
|
|
|
}
|
|
|
|
|
|
|
|
let pkg_name = pkg.name.as_ref().unwrap().to_string();
|
|
|
|
let mut expansion = ".".to_string();
|
|
|
|
|
|
|
|
if request == pkg_name {
|
|
|
|
// pass
|
2023-01-27 10:43:16 -05:00
|
|
|
} else if request.starts_with(&format!("{pkg_name}/")) {
|
2022-08-20 11:31:33 -04:00
|
|
|
expansion += &request[pkg_name.len()..];
|
|
|
|
} else {
|
|
|
|
return Ok(None);
|
|
|
|
}
|
|
|
|
|
2022-08-30 14:09:22 -04:00
|
|
|
let referrer = deno_core::url::Url::from_file_path(&pkg.path).unwrap();
|
2022-08-20 11:31:33 -04:00
|
|
|
if let Some(exports) = &pkg.exports {
|
|
|
|
resolution::package_exports_resolve(
|
2022-08-30 14:09:22 -04:00
|
|
|
&pkg.path,
|
2022-08-20 11:31:33 -04:00
|
|
|
expansion,
|
|
|
|
exports,
|
2022-08-30 14:09:22 -04:00
|
|
|
&referrer,
|
|
|
|
NodeModuleKind::Cjs,
|
2022-08-20 11:31:33 -04:00
|
|
|
resolution::REQUIRE_CONDITIONS,
|
2022-11-30 18:07:32 -05:00
|
|
|
NodeResolutionMode::Execution,
|
2022-08-20 11:31:33 -04:00
|
|
|
&*resolver,
|
2023-01-10 08:35:44 -05:00
|
|
|
permissions,
|
2022-08-20 11:31:33 -04:00
|
|
|
)
|
2022-08-30 14:09:22 -04:00
|
|
|
.map(|r| Some(r.to_string_lossy().to_string()))
|
2022-08-20 11:31:33 -04:00
|
|
|
} else {
|
|
|
|
Ok(None)
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-08-24 12:07:49 -04:00
|
|
|
fn op_require_read_file<P>(
|
2022-08-09 22:09:51 -04:00
|
|
|
state: &mut OpState,
|
2022-08-20 11:31:33 -04:00
|
|
|
file_path: String,
|
2022-08-24 12:07:49 -04:00
|
|
|
) -> Result<String, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-08-20 11:31:33 -04:00
|
|
|
let file_path = PathBuf::from(file_path);
|
2022-08-24 12:07:49 -04:00
|
|
|
ensure_read_permission::<P>(state, &file_path)?;
|
2022-08-20 11:31:33 -04:00
|
|
|
Ok(std::fs::read_to_string(file_path)?)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-11-10 11:57:10 -05:00
|
|
|
pub fn op_require_as_file_path(file_or_url: String) -> String {
|
2022-11-07 21:16:24 -05:00
|
|
|
if let Ok(url) = Url::parse(&file_or_url) {
|
|
|
|
if let Ok(p) = url.to_file_path() {
|
|
|
|
return p.to_string_lossy().to_string();
|
|
|
|
}
|
2022-08-20 11:31:33 -04:00
|
|
|
}
|
2022-11-07 21:16:24 -05:00
|
|
|
|
|
|
|
file_or_url
|
2022-08-20 11:31:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2023-01-10 08:35:44 -05:00
|
|
|
fn op_require_resolve_exports<P>(
|
2022-08-20 11:31:33 -04:00
|
|
|
state: &mut OpState,
|
2022-12-19 11:09:54 -05:00
|
|
|
uses_local_node_modules_dir: bool,
|
2022-08-20 11:31:33 -04:00
|
|
|
modules_path: String,
|
|
|
|
_request: String,
|
|
|
|
name: String,
|
|
|
|
expansion: String,
|
|
|
|
parent_path: String,
|
2023-01-10 08:35:44 -05:00
|
|
|
) -> Result<Option<String>, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-09-13 11:59:01 -04:00
|
|
|
let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>().clone();
|
2023-01-10 08:35:44 -05:00
|
|
|
let permissions = state.borrow_mut::<P>();
|
2022-08-20 11:31:33 -04:00
|
|
|
|
2022-12-19 11:09:54 -05:00
|
|
|
let pkg_path = if resolver.in_npm_package(&PathBuf::from(&modules_path))
|
|
|
|
&& !uses_local_node_modules_dir
|
|
|
|
{
|
2022-08-20 11:31:33 -04:00
|
|
|
modules_path
|
|
|
|
} else {
|
|
|
|
path_resolve(vec![modules_path, name])
|
|
|
|
};
|
|
|
|
let pkg = PackageJson::load(
|
|
|
|
&*resolver,
|
2023-01-10 08:35:44 -05:00
|
|
|
permissions,
|
2022-08-20 11:31:33 -04:00
|
|
|
PathBuf::from(&pkg_path).join("package.json"),
|
|
|
|
)?;
|
|
|
|
|
|
|
|
if let Some(exports) = &pkg.exports {
|
2022-08-30 14:09:22 -04:00
|
|
|
let referrer = Url::from_file_path(parent_path).unwrap();
|
2022-08-20 11:31:33 -04:00
|
|
|
resolution::package_exports_resolve(
|
2022-08-30 14:09:22 -04:00
|
|
|
&pkg.path,
|
2023-01-27 10:43:16 -05:00
|
|
|
format!(".{expansion}"),
|
2022-08-20 11:31:33 -04:00
|
|
|
exports,
|
2022-08-30 14:09:22 -04:00
|
|
|
&referrer,
|
|
|
|
NodeModuleKind::Cjs,
|
2022-08-20 11:31:33 -04:00
|
|
|
resolution::REQUIRE_CONDITIONS,
|
2022-11-30 18:07:32 -05:00
|
|
|
NodeResolutionMode::Execution,
|
2022-08-20 11:31:33 -04:00
|
|
|
&*resolver,
|
2023-01-10 08:35:44 -05:00
|
|
|
permissions,
|
2022-08-20 11:31:33 -04:00
|
|
|
)
|
2022-08-30 14:09:22 -04:00
|
|
|
.map(|r| Some(r.to_string_lossy().to_string()))
|
2022-08-20 11:31:33 -04:00
|
|
|
} else {
|
|
|
|
Ok(None)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-30 14:09:22 -04:00
|
|
|
#[op]
|
|
|
|
fn op_require_read_closest_package_json<P>(
|
|
|
|
state: &mut OpState,
|
|
|
|
filename: String,
|
|
|
|
) -> Result<PackageJson, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
|
|
|
ensure_read_permission::<P>(
|
|
|
|
state,
|
|
|
|
PathBuf::from(&filename).parent().unwrap(),
|
|
|
|
)?;
|
2022-09-13 11:59:01 -04:00
|
|
|
let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>().clone();
|
2023-01-10 08:35:44 -05:00
|
|
|
let permissions = state.borrow_mut::<P>();
|
2022-08-30 14:09:22 -04:00
|
|
|
resolution::get_closest_package_json(
|
|
|
|
&Url::from_file_path(filename).unwrap(),
|
|
|
|
&*resolver,
|
2023-01-10 08:35:44 -05:00
|
|
|
permissions,
|
2022-08-30 14:09:22 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-08-20 11:31:33 -04:00
|
|
|
#[op]
|
2023-01-10 08:35:44 -05:00
|
|
|
fn op_require_read_package_scope<P>(
|
2022-08-20 11:31:33 -04:00
|
|
|
state: &mut OpState,
|
2022-09-12 15:47:54 -04:00
|
|
|
package_json_path: String,
|
2023-01-10 08:35:44 -05:00
|
|
|
) -> Option<PackageJson>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-09-13 11:59:01 -04:00
|
|
|
let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>().clone();
|
2023-01-10 08:35:44 -05:00
|
|
|
let permissions = state.borrow_mut::<P>();
|
2022-09-12 15:47:54 -04:00
|
|
|
let package_json_path = PathBuf::from(package_json_path);
|
2023-01-10 08:35:44 -05:00
|
|
|
PackageJson::load(&*resolver, permissions, package_json_path).ok()
|
2022-08-20 11:31:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[op]
|
2022-08-24 12:07:49 -04:00
|
|
|
fn op_require_package_imports_resolve<P>(
|
2022-08-20 11:31:33 -04:00
|
|
|
state: &mut OpState,
|
|
|
|
parent_filename: String,
|
|
|
|
request: String,
|
2022-08-24 12:07:49 -04:00
|
|
|
) -> Result<Option<String>, AnyError>
|
|
|
|
where
|
|
|
|
P: NodePermissions + 'static,
|
|
|
|
{
|
2022-08-20 11:31:33 -04:00
|
|
|
let parent_path = PathBuf::from(&parent_filename);
|
2022-08-24 12:07:49 -04:00
|
|
|
ensure_read_permission::<P>(state, &parent_path)?;
|
2022-09-13 11:59:01 -04:00
|
|
|
let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>().clone();
|
2023-01-10 08:35:44 -05:00
|
|
|
let permissions = state.borrow_mut::<P>();
|
|
|
|
let pkg = PackageJson::load(
|
|
|
|
&*resolver,
|
|
|
|
permissions,
|
|
|
|
parent_path.join("package.json"),
|
|
|
|
)?;
|
2022-08-20 11:31:33 -04:00
|
|
|
|
|
|
|
if pkg.imports.is_some() {
|
|
|
|
let referrer =
|
|
|
|
deno_core::url::Url::from_file_path(&parent_filename).unwrap();
|
|
|
|
let r = resolution::package_imports_resolve(
|
|
|
|
&request,
|
|
|
|
&referrer,
|
2022-08-30 14:09:22 -04:00
|
|
|
NodeModuleKind::Cjs,
|
2022-08-20 11:31:33 -04:00
|
|
|
resolution::REQUIRE_CONDITIONS,
|
2022-11-30 18:07:32 -05:00
|
|
|
NodeResolutionMode::Execution,
|
2022-08-20 11:31:33 -04:00
|
|
|
&*resolver,
|
2023-01-10 08:35:44 -05:00
|
|
|
permissions,
|
2022-08-20 11:31:33 -04:00
|
|
|
)
|
2022-08-30 14:09:22 -04:00
|
|
|
.map(|r| Some(Url::from_file_path(r).unwrap().to_string()));
|
2022-08-20 11:31:33 -04:00
|
|
|
state.put(resolver);
|
|
|
|
r
|
|
|
|
} else {
|
|
|
|
Ok(None)
|
|
|
|
}
|
2022-08-09 15:06:01 -04:00
|
|
|
}
|
2022-11-28 15:59:36 -05:00
|
|
|
|
|
|
|
#[op]
|
|
|
|
fn op_require_break_on_next_statement(state: &mut OpState) {
|
|
|
|
let inspector = state.borrow::<Rc<RefCell<JsRuntimeInspector>>>();
|
|
|
|
inspector
|
|
|
|
.borrow_mut()
|
|
|
|
.wait_for_session_and_break_on_next_statement()
|
|
|
|
}
|
2023-01-24 09:05:54 -05:00
|
|
|
|
2023-02-10 06:40:45 -05:00
|
|
|
pub enum NodeModulePolyfillSpecifier {
|
|
|
|
/// An internal module specifier, like "internal:deno_node/assert.ts". The
|
|
|
|
/// module must be either embedded in the binary or snapshotted.
|
|
|
|
Embedded(&'static str),
|
|
|
|
|
|
|
|
/// Specifier relative to the root of `deno_std` repo, like "node/assert.ts"
|
|
|
|
StdNode(&'static str),
|
|
|
|
}
|
|
|
|
|
2023-01-24 09:05:54 -05:00
|
|
|
pub struct NodeModulePolyfill {
|
|
|
|
/// Name of the module like "assert" or "timers/promises"
|
|
|
|
pub name: &'static str,
|
2023-02-10 06:40:45 -05:00
|
|
|
pub specifier: NodeModulePolyfillSpecifier,
|
2023-01-24 09:05:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub static SUPPORTED_BUILTIN_NODE_MODULES: &[NodeModulePolyfill] = &[
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "assert",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/assert.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "assert/strict",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/assert/strict.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "async_hooks",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/async_hooks.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "buffer",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/buffer.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "child_process",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/child_process.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "cluster",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/cluster.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "console",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/console.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "constants",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/constants.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "crypto",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/crypto.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "dgram",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/dgram.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "dns",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/dns.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "dns/promises",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/dns/promises.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "domain",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/domain.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "events",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/events.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "fs",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/fs.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "fs/promises",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/fs/promises.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "http",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/http.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "https",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/https.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "module",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::Embedded(
|
|
|
|
"internal:deno_node/module_es_shim.js",
|
|
|
|
),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "net",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/net.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "os",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/os.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "path",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/path.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "path/posix",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/path/posix.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "path/win32",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/path/win32.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "perf_hooks",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/perf_hooks.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "process",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/process.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "querystring",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/querystring.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "readline",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/readline.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "stream",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/stream.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "stream/consumers",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode(
|
|
|
|
"node/stream/consumers.mjs",
|
|
|
|
),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "stream/promises",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/stream/promises.mjs"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "stream/web",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/stream/web.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "string_decoder",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/string_decoder.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "sys",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/sys.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "timers",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/timers.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "timers/promises",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/timers/promises.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "tls",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/tls.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "tty",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/tty.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "url",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/url.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "util",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/util.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "util/types",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/util/types.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "v8",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/v8.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "vm",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/vm.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "worker_threads",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/worker_threads.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "zlib",
|
2023-02-10 06:40:45 -05:00
|
|
|
specifier: NodeModulePolyfillSpecifier::StdNode("node/zlib.ts"),
|
2023-01-24 09:05:54 -05:00
|
|
|
},
|
|
|
|
];
|