diff options
Diffstat (limited to 'runtime/build.rs')
-rw-r--r-- | runtime/build.rs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/runtime/build.rs b/runtime/build.rs index a813d63cb..4678eab99 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -1,24 +1,25 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use deno_core::include_js_files; use std::env; use std::path::PathBuf; -// This is a shim that allows to generate documentation on docs.rs -mod not_docs { +#[cfg(all( + not(feature = "docsrs"), + not(feature = "dont_create_runtime_snapshot") +))] +mod startup_snapshot { use std::path::Path; use super::*; - use deno_cache::SqliteBackedCache; - use deno_core::snapshot_util::*; - use deno_core::Extension; - use deno_ast::MediaType; use deno_ast::ParseParams; use deno_ast::SourceTextInfo; + use deno_cache::SqliteBackedCache; use deno_core::error::AnyError; + use deno_core::include_js_files; + use deno_core::snapshot_util::*; + use deno_core::Extension; use deno_core::ExtensionFileSource; - use deno_core::ExtensionFileSourceCode; fn transpile_ts_for_snapshotting( file_source: &ExtensionFileSource, @@ -34,16 +35,15 @@ mod not_docs { file_source.specifier ), }; - - let ExtensionFileSourceCode::IncludedInBinary(code) = file_source.code; + let code = file_source.code.load()?; if !should_transpile { - return Ok(code.to_string()); + return Ok(code); } let parsed = deno_ast::parse_module(ParseParams { specifier: file_source.specifier.to_string(), - text_info: SourceTextInfo::from_string(code.to_string()), + text_info: SourceTextInfo::from_string(code), media_type, capture_tokens: false, scope_analysis: false, @@ -281,6 +281,7 @@ mod not_docs { #[cfg(not(feature = "snapshot_from_snapshot"))] { + use deno_core::ExtensionFileSourceCode; maybe_additional_extension = Some( Extension::builder("runtime_main") .dependencies(vec!["runtime"]) @@ -314,9 +315,13 @@ fn main() { // doesn't actually compile on docs.rs if env::var_os("DOCS_RS").is_some() { let snapshot_slice = &[]; + #[allow(clippy::needless_borrow)] std::fs::write(&runtime_snapshot_path, snapshot_slice).unwrap(); } - #[cfg(not(feature = "docsrs"))] - not_docs::build_snapshot(runtime_snapshot_path) + #[cfg(all( + not(feature = "docsrs"), + not(feature = "dont_create_runtime_snapshot") + ))] + startup_snapshot::build_snapshot(runtime_snapshot_path) } |