diff --git a/Cargo.lock b/Cargo.lock
index b83f3b4425..4be228f921 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -853,18 +853,16 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
name = "cli_tests"
version = "0.0.0"
dependencies = [
+ "anyhow",
"bytes",
"chrono",
- "deno_ast",
"deno_bench_util",
"deno_cache_dir",
- "deno_core",
- "deno_fetch",
"deno_lockfile",
"deno_semver",
"deno_terminal 0.2.0",
- "deno_tls",
"deno_tower_lsp",
+ "deno_unsync",
"fastwebsockets",
"file_test_runner",
"flaky_test",
@@ -881,7 +879,11 @@ dependencies = [
"pretty_assertions",
"regex",
"reqwest",
+ "rustls",
+ "rustls-pemfile",
+ "rustls-tokio-stream",
"serde",
+ "serde_json",
"sys_traits",
"test_server",
"tokio",
@@ -1284,6 +1286,7 @@ dependencies = [
"deno_resolver",
"deno_runtime",
"deno_semver",
+ "deno_snapshots",
"deno_task_shell",
"deno_telemetry",
"deno_terminal 0.2.0",
@@ -1295,7 +1298,6 @@ dependencies = [
"dprint-plugin-jupyter",
"dprint-plugin-markdown",
"dprint-plugin-typescript",
- "env_logger",
"fancy-regex",
"faster-hex",
"flate2",
@@ -1898,24 +1900,33 @@ dependencies = [
name = "deno_lib"
version = "0.2.0"
dependencies = [
- "deno_cache_dir",
+ "capacity_builder 0.5.0",
+ "deno_config",
"deno_error",
"deno_fs",
+ "deno_media_type",
"deno_node",
+ "deno_npm",
"deno_path_util",
"deno_resolver",
"deno_runtime",
+ "deno_semver",
"deno_terminal 0.2.0",
+ "env_logger",
"faster-hex",
+ "indexmap 2.3.0",
+ "libsui",
"log",
"node_resolver",
"parking_lot",
"ring",
"serde",
+ "serde_json",
"sys_traits",
"test_server",
"thiserror 2.0.3",
"tokio",
+ "twox-hash",
"url",
]
@@ -1951,11 +1962,12 @@ dependencies = [
[[package]]
name = "deno_media_type"
-version = "0.2.3"
+version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a417f8bd3f1074185c4c8ccb6ea6261ae173781596cc358e68ad07aaac11009d"
+checksum = "577fe2bbe04f3e9b1b7c6fac6a75101a9fbd611c50a6b68789e69f4d63dcb2b4"
dependencies = [
"data-url",
+ "encoding_rs",
"serde",
"url",
]
@@ -2028,7 +2040,6 @@ dependencies = [
"deno_fetch",
"deno_fs",
"deno_io",
- "deno_media_type",
"deno_net",
"deno_package_json",
"deno_path_util",
@@ -2042,7 +2053,7 @@ dependencies = [
"ecdsa",
"ed25519-dalek",
"elliptic-curve",
- "errno 0.2.8",
+ "errno",
"faster-hex",
"h2 0.4.4",
"hkdf",
@@ -2331,7 +2342,6 @@ dependencies = [
"dlopen2",
"encoding_rs",
"fastwebsockets",
- "flate2",
"http 1.1.0",
"http-body-util",
"hyper 0.14.28",
@@ -2379,6 +2389,13 @@ dependencies = [
"url",
]
+[[package]]
+name = "deno_snapshots"
+version = "0.1.0"
+dependencies = [
+ "deno_runtime",
+]
+
[[package]]
name = "deno_task_shell"
version = "0.20.2"
@@ -2662,6 +2679,43 @@ dependencies = [
"v8_valueserializer",
]
+[[package]]
+name = "denort"
+version = "2.1.5"
+dependencies = [
+ "async-trait",
+ "bincode",
+ "deno_cache_dir",
+ "deno_config",
+ "deno_core",
+ "deno_error",
+ "deno_lib",
+ "deno_media_type",
+ "deno_npm",
+ "deno_package_json",
+ "deno_path_util",
+ "deno_resolver",
+ "deno_runtime",
+ "deno_semver",
+ "deno_snapshots",
+ "deno_terminal 0.2.0",
+ "import_map",
+ "indexmap 2.3.0",
+ "libsui",
+ "log",
+ "node_resolver",
+ "pretty_assertions",
+ "serde",
+ "serde_json",
+ "sys_traits",
+ "test_server",
+ "thiserror 2.0.3",
+ "tokio",
+ "tokio-util",
+ "twox-hash",
+ "url",
+]
+
[[package]]
name = "der"
version = "0.7.9"
@@ -3191,17 +3245,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
-[[package]]
-name = "errno"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
-dependencies = [
- "errno-dragonfly",
- "libc",
- "winapi",
-]
-
[[package]]
name = "errno"
version = "0.3.8"
@@ -3212,16 +3255,6 @@ dependencies = [
"windows-sys 0.52.0",
]
-[[package]]
-name = "errno-dragonfly"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
-dependencies = [
- "cc",
- "libc",
-]
-
[[package]]
name = "error-code"
version = "3.2.0"
@@ -5222,7 +5255,6 @@ dependencies = [
"async-trait",
"boxed_error",
"deno_error",
- "deno_media_type",
"deno_package_json",
"deno_path_util",
"futures",
@@ -5230,6 +5262,7 @@ dependencies = [
"once_cell",
"path-clean",
"regex",
+ "serde",
"serde_json",
"sys_traits",
"thiserror 2.0.3",
@@ -6633,7 +6666,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89"
dependencies = [
"bitflags 2.6.0",
- "errno 0.3.8",
+ "errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
diff --git a/Cargo.toml b/Cargo.toml
index 4f3563ce47..6137505aa7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,6 +6,8 @@ members = [
"bench_util",
"cli",
"cli/lib",
+ "cli/rt",
+ "cli/snapshot",
"ext/broadcast_channel",
"ext/cache",
"ext/canvas",
@@ -54,7 +56,7 @@ deno_core = { version = "0.331.0" }
deno_bench_util = { version = "0.180.0", path = "./bench_util" }
deno_config = { version = "=0.45.0", features = ["workspace", "sync"] }
deno_lockfile = "=0.24.0"
-deno_media_type = { version = "0.2.3", features = ["module_specifier"] }
+deno_media_type = { version = "0.2.4", features = ["module_specifier"] }
deno_npm = "=0.27.2"
deno_path_util = "=0.3.0"
deno_permissions = { version = "0.45.0", path = "./runtime/permissions" }
@@ -100,6 +102,7 @@ deno_webstorage = { version = "0.181.0", path = "./ext/webstorage" }
deno_lib = { version = "0.2.0", path = "./cli/lib" }
deno_npm_cache = { version = "0.5.0", path = "./resolvers/npm_cache" }
deno_resolver = { version = "0.17.0", path = "./resolvers/deno" }
+deno_snapshots = { version = "0.1.0", path = "./cli/snapshot" }
node_resolver = { version = "0.24.0", path = "./resolvers/node" }
aes = "=0.8.3"
@@ -154,6 +157,7 @@ ipnet = "2.3"
jsonc-parser = { version = "=0.26.2", features = ["serde"] }
lazy-regex = "3"
libc = "0.2.168"
+libsui = "0.5.0"
libz-sys = { version = "1.1.20", default-features = false }
log = { version = "0.4.20", features = ["kv"] }
lsp-types = "=0.97.0" # used by tower-lsp and "proposed" feature is unstable in patch releases
diff --git a/README.md b/README.md
index 19d4fa8a12..ca71529e28 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,8 @@
-[Deno](https://www.deno.com)
-([/ˈdiːnoʊ/](http://ipa-reader.xyz/?text=%CB%88di%CB%90no%CA%8A), pronounced
+[Deno](https://deno.com)
+([/ˈdiːnoʊ/](https://ipa-reader.com/?text=%CB%88di%CB%90no%CA%8A), pronounced
`dee-no`) is a JavaScript, TypeScript, and WebAssembly runtime with secure
defaults and a great developer experience. It's built on [V8](https://v8.dev/),
[Rust](https://www.rust-lang.org/), and [Tokio](https://tokio.rs/).
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index d71047cc63..29515b67b6 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -16,11 +16,6 @@ name = "deno"
path = "main.rs"
doc = false
-[[bin]]
-name = "denort"
-path = "mainrt.rs"
-doc = false
-
[[test]]
name = "integration"
path = "integration_tests_runner.rs"
@@ -49,7 +44,7 @@ dhat-heap = ["dhat"]
upgrade = []
# A dev feature to disable creations and loading of snapshots in favor of
# loading JS sources at runtime.
-hmr = ["deno_runtime/hmr"]
+hmr = ["deno_runtime/hmr", "deno_snapshots/disable"]
# Vendor zlib as zlib-ng
__vendored_zlib_ng = ["flate2/zlib-ng-compat", "libz-sys/zlib-ng"]
@@ -60,10 +55,12 @@ lazy-regex.workspace = true
serde.workspace = true
serde_json.workspace = true
zstd.workspace = true
-glibc_version = "0.1.2"
flate2 = { workspace = true, features = ["default"] }
deno_error.workspace = true
+[target.'cfg(unix)'.build-dependencies]
+glibc_version = "0.1.2"
+
[target.'cfg(windows)'.build-dependencies]
winapi.workspace = true
winres.workspace = true
@@ -86,10 +83,11 @@ deno_path_util.workspace = true
deno_resolver = { workspace = true, features = ["sync"] }
deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_semver.workspace = true
+deno_snapshots = { workspace = true }
deno_task_shell = "=0.20.2"
deno_telemetry.workspace = true
deno_terminal.workspace = true
-libsui = "0.5.0"
+libsui.workspace = true
node_resolver.workspace = true
anstream = "0.6.14"
@@ -115,7 +113,6 @@ dprint-plugin-json = "=0.19.4"
dprint-plugin-jupyter = "=0.1.5"
dprint-plugin-markdown = "=0.17.8"
dprint-plugin-typescript = "=0.93.3"
-env_logger = "=0.10.0"
fancy-regex = "=0.10.0"
faster-hex.workspace = true
# If you disable the default __vendored_zlib_ng feature above, you _must_ be able to link against `-lz`.
@@ -156,7 +153,6 @@ rustyline-derive = "=0.7.0"
serde.workspace = true
serde_repr.workspace = true
sha2.workspace = true
-shell-escape = "=0.1.5"
spki = { version = "0.7", features = ["pem"] }
sqlformat = "=0.3.2"
strsim = "0.11.1"
@@ -185,6 +181,7 @@ winapi = { workspace = true, features = ["knownfolders", "mswsock", "objbase", "
[target.'cfg(unix)'.dependencies]
nix.workspace = true
+shell-escape = "=0.1.5"
[dev-dependencies]
deno_bench_util.workspace = true
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index fb64b4eeaa..f86aa50186 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -31,6 +31,9 @@ use deno_core::error::AnyError;
use deno_core::resolve_url_or_path;
use deno_core::url::Url;
use deno_graph::GraphKind;
+use deno_lib::args::CaData;
+use deno_lib::args::UnstableConfig;
+use deno_lib::version::DENO_VERSION_INFO;
use deno_path_util::normalize_path;
use deno_path_util::url_to_file_path;
use deno_runtime::deno_permissions::SysDescriptor;
@@ -546,15 +549,6 @@ impl Default for TypeCheckMode {
}
}
-#[derive(Clone, Debug, Eq, PartialEq)]
-pub enum CaData {
- /// The string is a file path
- File(String),
- /// This variant is not exposed as an option in the CLI, it is used internally
- /// for standalone binaries.
- Bytes(Vec),
-}
-
// Info needed to run NPM lifecycle scripts
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct LifecycleScriptsConfig {
@@ -582,19 +576,6 @@ fn parse_packages_allowed_scripts(s: &str) -> Result {
}
}
-#[derive(
- Clone, Default, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize,
-)]
-pub struct UnstableConfig {
- // TODO(bartlomieju): remove in Deno 2.5
- pub legacy_flag_enabled: bool, // --unstable
- pub bare_node_builtins: bool,
- pub detect_cjs: bool,
- pub sloppy_imports: bool,
- pub npm_lazy_caching: bool,
- pub features: Vec, // --unstabe-kv --unstable-cron
-}
-
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct InternalFlags {
/// Used when the language server is configured with an
@@ -1484,14 +1465,15 @@ fn handle_repl_flags(flags: &mut Flags, repl_flags: ReplFlags) {
}
pub fn clap_root() -> Command {
+ debug_assert_eq!(DENO_VERSION_INFO.typescript, deno_snapshots::TS_VERSION);
let long_version = format!(
"{} ({}, {}, {})\nv8 {}\ntypescript {}",
- crate::version::DENO_VERSION_INFO.deno,
- crate::version::DENO_VERSION_INFO.release_channel.name(),
+ DENO_VERSION_INFO.deno,
+ DENO_VERSION_INFO.release_channel.name(),
env!("PROFILE"),
env!("TARGET"),
deno_core::v8::VERSION_STRING,
- crate::version::DENO_VERSION_INFO.typescript
+ DENO_VERSION_INFO.typescript
);
run_args(Command::new("deno"), true)
@@ -1507,7 +1489,7 @@ pub fn clap_root() -> Command {
)
.color(ColorChoice::Auto)
.term_width(800)
- .version(crate::version::DENO_VERSION_INFO.deno)
+ .version(DENO_VERSION_INFO.deno)
.long_version(long_version)
.disable_version_flag(true)
.disable_help_flag(true)
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 46ada5440f..e4f332a8bc 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -10,10 +10,6 @@ mod package_json;
use std::borrow::Cow;
use std::collections::HashMap;
use std::env;
-use std::io::BufReader;
-use std::io::Cursor;
-use std::io::Read;
-use std::io::Seek;
use std::net::SocketAddr;
use std::num::NonZeroUsize;
use std::path::Path;
@@ -58,8 +54,12 @@ use deno_core::serde_json;
use deno_core::url::Url;
use deno_graph::GraphKind;
pub use deno_json::check_warn_tsconfig;
-use deno_lib::cache::DenoDirProvider;
-use deno_lib::env::has_flag_env_var;
+use deno_lib::args::has_flag_env_var;
+use deno_lib::args::npm_pkg_req_ref_to_binary_command;
+use deno_lib::args::CaData;
+use deno_lib::args::NpmProcessStateKind;
+use deno_lib::args::NPM_PROCESS_STATE;
+use deno_lib::version::DENO_VERSION_INFO;
use deno_lib::worker::StorageKeyResolver;
use deno_lint::linter::LintConfig as DenoLintConfig;
use deno_npm::npm_rc::NpmRc;
@@ -68,16 +68,10 @@ use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
use deno_npm::NpmSystemInfo;
use deno_path_util::normalize_path;
use deno_runtime::deno_permissions::PermissionsOptions;
-use deno_runtime::deno_tls::deno_native_certs::load_native_certs;
-use deno_runtime::deno_tls::rustls;
-use deno_runtime::deno_tls::rustls::RootCertStore;
-use deno_runtime::deno_tls::rustls_pemfile;
-use deno_runtime::deno_tls::webpki_roots;
use deno_runtime::inspector_server::InspectorServer;
use deno_semver::npm::NpmPackageReqReference;
use deno_semver::StackString;
use deno_telemetry::OtelConfig;
-use deno_telemetry::OtelRuntimeConfig;
use deno_terminal::colors;
use dotenvy::from_filename;
pub use flags::*;
@@ -88,15 +82,13 @@ pub use lockfile::CliLockfileReadFromPathOptions;
use once_cell::sync::Lazy;
pub use package_json::NpmInstallDepsProvider;
pub use package_json::PackageJsonDepValueParseWithLocationError;
-use serde::Deserialize;
-use serde::Serialize;
use sys_traits::EnvHomeDir;
use thiserror::Error;
+use crate::cache::DenoDirProvider;
use crate::file_fetcher::CliFileFetcher;
use crate::sys::CliSys;
use crate::util::fs::canonicalize_path_maybe_not_exists;
-use crate::version;
pub fn npm_registry_url() -> &'static Url {
static NPM_REGISTRY_DEFAULT_URL: Lazy = Lazy::new(|| {
@@ -608,147 +600,6 @@ pub fn create_default_npmrc() -> Arc {
})
}
-#[derive(Error, Debug, Clone, deno_error::JsError)]
-#[class(generic)]
-pub enum RootCertStoreLoadError {
- #[error(
- "Unknown certificate store \"{0}\" specified (allowed: \"system,mozilla\")"
- )]
- UnknownStore(String),
- #[error("Unable to add pem file to certificate store: {0}")]
- FailedAddPemFile(String),
- #[error("Failed opening CA file: {0}")]
- CaFileOpenError(String),
-}
-
-/// Create and populate a root cert store based on the passed options and
-/// environment.
-pub fn get_root_cert_store(
- maybe_root_path: Option,
- maybe_ca_stores: Option>,
- maybe_ca_data: Option,
-) -> Result {
- let mut root_cert_store = RootCertStore::empty();
- let ca_stores: Vec = maybe_ca_stores
- .or_else(|| {
- let env_ca_store = env::var("DENO_TLS_CA_STORE").ok()?;
- Some(
- env_ca_store
- .split(',')
- .map(|s| s.trim().to_string())
- .filter(|s| !s.is_empty())
- .collect(),
- )
- })
- .unwrap_or_else(|| vec!["mozilla".to_string()]);
-
- for store in ca_stores.iter() {
- match store.as_str() {
- "mozilla" => {
- root_cert_store.extend(webpki_roots::TLS_SERVER_ROOTS.to_vec());
- }
- "system" => {
- let roots = load_native_certs().expect("could not load platform certs");
- for root in roots {
- if let Err(err) = root_cert_store
- .add(rustls::pki_types::CertificateDer::from(root.0.clone()))
- {
- log::error!(
- "{}",
- colors::yellow(&format!(
- "Unable to add system certificate to certificate store: {:?}",
- err
- ))
- );
- let hex_encoded_root = faster_hex::hex_string(&root.0);
- log::error!("{}", colors::gray(&hex_encoded_root));
- }
- }
- }
- _ => {
- return Err(RootCertStoreLoadError::UnknownStore(store.clone()));
- }
- }
- }
-
- let ca_data =
- maybe_ca_data.or_else(|| env::var("DENO_CERT").ok().map(CaData::File));
- if let Some(ca_data) = ca_data {
- let result = match ca_data {
- CaData::File(ca_file) => {
- let ca_file = if let Some(root) = &maybe_root_path {
- root.join(&ca_file)
- } else {
- PathBuf::from(ca_file)
- };
- let certfile = std::fs::File::open(ca_file).map_err(|err| {
- RootCertStoreLoadError::CaFileOpenError(err.to_string())
- })?;
- let mut reader = BufReader::new(certfile);
- rustls_pemfile::certs(&mut reader).collect::, _>>()
- }
- CaData::Bytes(data) => {
- let mut reader = BufReader::new(Cursor::new(data));
- rustls_pemfile::certs(&mut reader).collect::, _>>()
- }
- };
-
- match result {
- Ok(certs) => {
- root_cert_store.add_parsable_certificates(certs);
- }
- Err(e) => {
- return Err(RootCertStoreLoadError::FailedAddPemFile(e.to_string()));
- }
- }
- }
-
- Ok(root_cert_store)
-}
-
-/// State provided to the process via an environment variable.
-#[derive(Clone, Debug, Serialize, Deserialize)]
-pub struct NpmProcessState {
- pub kind: NpmProcessStateKind,
- pub local_node_modules_path: Option,
-}
-
-#[derive(Clone, Debug, Serialize, Deserialize)]
-pub enum NpmProcessStateKind {
- Snapshot(deno_npm::resolution::SerializedNpmResolutionSnapshot),
- Byonm,
-}
-
-static NPM_PROCESS_STATE: Lazy