summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/Cargo.toml12
-rw-r--r--cli/args/mod.rs50
-rw-r--r--cli/cache/module_info.rs4
-rw-r--r--cli/emit.rs29
-rw-r--r--cli/factory.rs7
-rw-r--r--cli/graph_util.rs9
-rw-r--r--cli/tools/bundle.rs9
-rw-r--r--cli/tools/compile.rs13
-rw-r--r--cli/tools/doc.rs14
-rw-r--r--cli/tools/registry/graph.rs2
-rw-r--r--cli/tools/registry/unfurl.rs4
-rw-r--r--cli/tools/repl/session.rs46
-rw-r--r--cli/tools/vendor/test.rs5
13 files changed, 129 insertions, 75 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 6e0e5f2bb..a9d7b707b 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -66,17 +66,17 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposa
deno_cache_dir = { workspace = true }
deno_config = "=0.15.0"
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
-deno_doc = { version = "=0.119.0", features = ["html"] }
-deno_emit = "=0.38.2"
-deno_graph = { version = "=0.69.10", features = ["tokio_executor"] }
-deno_lint = { version = "=0.58.0", features = ["docs"] }
+deno_doc = { version = "=0.123.1", features = ["html"] }
+deno_emit = "=0.39.0"
+deno_graph = { version = "=0.71.1", features = ["tokio_executor"] }
+deno_lint = { version = "=0.58.2", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm = "=0.17.0"
deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_semver = "=0.5.4"
deno_task_shell = "=0.16.0"
deno_terminal.workspace = true
-eszip = "=0.64.2"
+eszip = "=0.66.0"
napi_sym.workspace = true
async-trait.workspace = true
@@ -98,7 +98,7 @@ dotenvy = "0.15.7"
dprint-plugin-json = "=0.19.2"
dprint-plugin-jupyter = "=0.1.3"
dprint-plugin-markdown = "=0.16.4"
-dprint-plugin-typescript = "=0.89.3"
+dprint-plugin-typescript = "=0.90.1"
env_logger = "=0.10.0"
fancy-regex = "=0.10.0"
faster-hex.workspace = true
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 2d0df3d3c..d225b73f2 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -10,6 +10,7 @@ pub mod package_json;
pub use self::import_map::resolve_import_map;
use self::package_json::PackageJsonDeps;
use ::import_map::ImportMap;
+use deno_ast::SourceMapOption;
use deno_core::resolve_url_or_path;
use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
use deno_npm::NpmSystemInfo;
@@ -146,9 +147,9 @@ pub fn jsr_api_url() -> &'static Url {
&JSR_API_URL
}
-pub fn ts_config_to_emit_options(
+pub fn ts_config_to_transpile_and_emit_options(
config: deno_config::TsConfig,
-) -> deno_ast::EmitOptions {
+) -> (deno_ast::TranspileOptions, deno_ast::EmitOptions) {
let options: deno_config::EmitConfigOptions =
serde_json::from_value(config.0).unwrap();
let imports_not_used_as_values =
@@ -165,23 +166,34 @@ pub fn ts_config_to_emit_options(
"precompile" => (false, false, false, true),
_ => (false, false, false, false),
};
- deno_ast::EmitOptions {
- use_ts_decorators: options.experimental_decorators,
- use_decorators_proposal: !options.experimental_decorators,
- emit_metadata: options.emit_decorator_metadata,
- imports_not_used_as_values,
- inline_source_map: options.inline_source_map,
- inline_sources: options.inline_sources,
- source_map: options.source_map,
- jsx_automatic,
- jsx_development,
- jsx_factory: options.jsx_factory,
- jsx_fragment_factory: options.jsx_fragment_factory,
- jsx_import_source: options.jsx_import_source,
- precompile_jsx,
- transform_jsx,
- var_decl_imports: false,
- }
+ let source_map = if options.inline_source_map {
+ SourceMapOption::Inline
+ } else if options.source_map {
+ SourceMapOption::Separate
+ } else {
+ SourceMapOption::None
+ };
+ (
+ deno_ast::TranspileOptions {
+ use_ts_decorators: options.experimental_decorators,
+ use_decorators_proposal: !options.experimental_decorators,
+ emit_metadata: options.emit_decorator_metadata,
+ imports_not_used_as_values,
+ jsx_automatic,
+ jsx_development,
+ jsx_factory: options.jsx_factory,
+ jsx_fragment_factory: options.jsx_fragment_factory,
+ jsx_import_source: options.jsx_import_source,
+ precompile_jsx,
+ transform_jsx,
+ var_decl_imports: false,
+ },
+ deno_ast::EmitOptions {
+ inline_sources: options.inline_sources,
+ keep_comments: false,
+ source_map,
+ },
+ )
}
/// Indicates how cached source files should be handled.
diff --git a/cli/cache/module_info.rs b/cli/cache/module_info.rs
index 6bb718038..6d317b216 100644
--- a/cli/cache/module_info.rs
+++ b/cli/cache/module_info.rs
@@ -6,9 +6,9 @@ use deno_ast::MediaType;
use deno_ast::ModuleSpecifier;
use deno_core::error::AnyError;
use deno_core::serde_json;
-use deno_graph::DefaultModuleAnalyzer;
use deno_graph::ModuleInfo;
use deno_graph::ModuleParser;
+use deno_graph::ParserModuleAnalyzer;
use deno_runtime::deno_webstorage::rusqlite::params;
use super::cache_db::CacheDB;
@@ -169,7 +169,7 @@ impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> {
}
// otherwise, get the module info from the parsed source cache
- let analyzer = DefaultModuleAnalyzer::new(self.parser);
+ let analyzer = ParserModuleAnalyzer::new(self.parser);
let module_info = analyzer.analyze(specifier, source, media_type)?;
// then attempt to cache it
diff --git a/cli/emit.rs b/cli/emit.rs
index 2c267df67..0c79b11ee 100644
--- a/cli/emit.rs
+++ b/cli/emit.rs
@@ -4,6 +4,7 @@ use crate::cache::EmitCache;
use crate::cache::FastInsecureHasher;
use crate::cache::ParsedSourceCache;
+use deno_ast::SourceMapOption;
use deno_core::error::AnyError;
use deno_core::ModuleCodeString;
use deno_core::ModuleSpecifier;
@@ -15,23 +16,31 @@ use std::sync::Arc;
pub struct Emitter {
emit_cache: EmitCache,
parsed_source_cache: Arc<ParsedSourceCache>,
+ transpile_options: deno_ast::TranspileOptions,
emit_options: deno_ast::EmitOptions,
- // cached hash of the emit options
- emit_options_hash: u64,
+ // cached hash of the transpile and emit options
+ transpile_and_emit_options_hash: u64,
}
impl Emitter {
pub fn new(
emit_cache: EmitCache,
parsed_source_cache: Arc<ParsedSourceCache>,
+ transpile_options: deno_ast::TranspileOptions,
emit_options: deno_ast::EmitOptions,
) -> Self {
- let emit_options_hash = FastInsecureHasher::hash(&emit_options);
+ let transpile_and_emit_options_hash = {
+ let mut hasher = FastInsecureHasher::default();
+ hasher.write_hashable(&transpile_options);
+ hasher.write_hashable(emit_options);
+ hasher.finish()
+ };
Self {
emit_cache,
parsed_source_cache,
emit_options,
- emit_options_hash,
+ transpile_options,
+ transpile_and_emit_options_hash,
}
}
@@ -90,7 +99,8 @@ impl Emitter {
source.clone(),
media_type,
)?;
- let transpiled_source = parsed_source.transpile(&self.emit_options)?;
+ let transpiled_source =
+ parsed_source.transpile(&self.transpile_options, &self.emit_options)?;
debug_assert!(transpiled_source.source_map.is_none());
self.emit_cache.set_emit_code(
specifier,
@@ -115,9 +125,10 @@ impl Emitter {
let parsed_source = self
.parsed_source_cache
.get_or_parse_module(specifier, source_arc, media_type)?;
- let mut options = self.emit_options.clone();
- options.inline_source_map = false;
- let transpiled_source = parsed_source.transpile(&options)?;
+ let mut options = self.emit_options;
+ options.source_map = SourceMapOption::None;
+ let transpiled_source =
+ parsed_source.transpile(&self.transpile_options, &options)?;
Ok(transpiled_source.text)
}
@@ -127,7 +138,7 @@ impl Emitter {
fn get_source_hash(&self, source_text: &str) -> u64 {
FastInsecureHasher::new()
.write_str(source_text)
- .write_u64(self.emit_options_hash)
+ .write_u64(self.transpile_and_emit_options_hash)
.finish()
}
}
diff --git a/cli/factory.rs b/cli/factory.rs
index 18f6b6b2a..6e5db8a80 100644
--- a/cli/factory.rs
+++ b/cli/factory.rs
@@ -549,11 +549,14 @@ impl CliFactory {
if let Some(ignored_options) = ts_config_result.maybe_ignored_options {
warn!("{}", ignored_options);
}
- let emit_options =
- crate::args::ts_config_to_emit_options(ts_config_result.ts_config);
+ let (transpile_options, emit_options) =
+ crate::args::ts_config_to_transpile_and_emit_options(
+ ts_config_result.ts_config,
+ );
Ok(Arc::new(Emitter::new(
self.emit_cache()?.clone(),
self.parsed_source_cache().clone(),
+ transpile_options,
emit_options,
)))
})
diff --git a/cli/graph_util.rs b/cli/graph_util.rs
index b729a1b61..6214a1628 100644
--- a/cli/graph_util.rs
+++ b/cli/graph_util.rs
@@ -76,6 +76,7 @@ pub fn graph_valid(
check_js: options.check_js,
follow_type_only: options.follow_type_only,
follow_dynamic: options.is_vendoring,
+ prefer_fast_check_graph: false,
},
)
.errors()
@@ -441,14 +442,13 @@ impl ModuleGraphBuilder {
loader.as_mut_loader(),
deno_graph::BuildOptions {
is_dynamic: options.is_dynamic,
- jsr_url_provider: Some(&CliJsrUrlProvider),
+ jsr_url_provider: &CliJsrUrlProvider,
executor: Default::default(),
imports: maybe_imports,
resolver: Some(graph_resolver),
- file_system: Some(&DenoGraphFsAdapter(self.fs.as_ref())),
+ file_system: &DenoGraphFsAdapter(self.fs.as_ref()),
npm_resolver: Some(graph_npm_resolver),
- module_analyzer: Some(&analyzer),
- module_parser: Some(&parser),
+ module_analyzer: &analyzer,
reporter: maybe_file_watcher_reporter,
workspace_members: &workspace_members,
},
@@ -799,6 +799,7 @@ pub fn has_graph_root_local_dependent_changed(
deno_graph::WalkOptions {
follow_dynamic: true,
follow_type_only: true,
+ prefer_fast_check_graph: true,
check_js: true,
},
);
diff --git a/cli/tools/bundle.rs b/cli/tools/bundle.rs
index 23d5aacb1..e8b9076ea 100644
--- a/cli/tools/bundle.rs
+++ b/cli/tools/bundle.rs
@@ -144,15 +144,18 @@ fn bundle_module_graph(
}
}
+ let (transpile_options, emit_options) =
+ crate::args::ts_config_to_transpile_and_emit_options(
+ ts_config_result.ts_config,
+ );
deno_emit::bundle_graph(
graph,
deno_emit::BundleOptions {
minify: false,
bundle_type: deno_emit::BundleType::Module,
- emit_options: crate::args::ts_config_to_emit_options(
- ts_config_result.ts_config,
- ),
+ emit_options,
emit_ignore_directives: true,
+ transpile_options,
},
)
}
diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs
index 2825c92c7..75572cd42 100644
--- a/cli/tools/compile.rs
+++ b/cli/tools/compile.rs
@@ -73,10 +73,17 @@ pub async fn compile(
let ts_config_for_emit =
cli_options.resolve_ts_config_for_emit(deno_config::TsConfigType::Emit)?;
- let emit_options =
- crate::args::ts_config_to_emit_options(ts_config_for_emit.ts_config);
+ let (transpile_options, emit_options) =
+ crate::args::ts_config_to_transpile_and_emit_options(
+ ts_config_for_emit.ts_config,
+ );
let parser = parsed_source_cache.as_capturing_parser();
- let eszip = eszip::EszipV2::from_graph(graph, &parser, emit_options)?;
+ let eszip = eszip::EszipV2::from_graph(
+ graph,
+ &parser,
+ transpile_options,
+ emit_options,
+ )?;
log::info!(
"{} {} to {}",
diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs
index 91cede879..ac568ada4 100644
--- a/cli/tools/doc.rs
+++ b/cli/tools/doc.rs
@@ -18,6 +18,7 @@ use deno_core::anyhow::bail;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_doc as doc;
+use deno_graph::source::NullFileSystem;
use deno_graph::GraphKind;
use deno_graph::ModuleAnalyzer;
use deno_graph::ModuleParser;
@@ -53,8 +54,16 @@ async fn generate_doc_nodes_for_builtin_types(
vec![source_file_specifier.clone()],
&mut loader,
deno_graph::BuildOptions {
- module_analyzer: Some(analyzer),
- ..Default::default()
+ module_analyzer: analyzer,
+ file_system: &NullFileSystem,
+ is_dynamic: false,
+ imports: Vec::new(),
+ executor: Default::default(),
+ jsr_url_provider: Default::default(),
+ npm_resolver: None,
+ reporter: None,
+ resolver: None,
+ workspace_members: &[],
},
)
.await;
@@ -159,6 +168,7 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
kind_with_drilldown:
deno_doc::html::DocNodeKindWithDrilldown::Other(node.kind),
inner: std::sync::Arc::new(node),
+ drilldown_parent_kind: None,
})
.collect(),
&[],
diff --git a/cli/tools/registry/graph.rs b/cli/tools/registry/graph.rs
index 0310a97c6..001f85e76 100644
--- a/cli/tools/registry/graph.rs
+++ b/cli/tools/registry/graph.rs
@@ -59,6 +59,8 @@ pub fn collect_invalid_external_imports(
let options = WalkOptions {
check_js: true,
follow_dynamic: true,
+ // this being disabled will cause it to follow everything in the graph
+ prefer_fast_check_graph: false,
follow_type_only: true,
};
let mut iter = graph.walk(&graph.roots, options);
diff --git a/cli/tools/registry/unfurl.rs b/cli/tools/registry/unfurl.rs
index 2224d0870..f45b6ffc3 100644
--- a/cli/tools/registry/unfurl.rs
+++ b/cli/tools/registry/unfurl.rs
@@ -4,9 +4,9 @@ use deno_ast::ParsedSource;
use deno_ast::SourceRange;
use deno_ast::SourceTextInfo;
use deno_core::ModuleSpecifier;
-use deno_graph::DefaultModuleAnalyzer;
use deno_graph::DependencyDescriptor;
use deno_graph::DynamicTemplatePart;
+use deno_graph::ParserModuleAnalyzer;
use deno_graph::TypeScriptReference;
use deno_runtime::deno_node::is_builtin_node_module;
@@ -192,7 +192,7 @@ impl<'a> SpecifierUnfurler<'a> {
diagnostic_reporter: &mut dyn FnMut(SpecifierUnfurlerDiagnostic),
) -> String {
let mut text_changes = Vec::new();
- let module_info = DefaultModuleAnalyzer::module_info(parsed_source);
+ let module_info = ParserModuleAnalyzer::module_info(parsed_source);
let analyze_specifier =
|specifier: &str,
range: &deno_graph::PositionRange,
diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs
index 48614cfe5..e5f70df15 100644
--- a/cli/tools/repl/session.rs
+++ b/cli/tools/repl/session.rs
@@ -254,9 +254,11 @@ impl ReplSession {
})?;
let ts_config_for_emit = cli_options
.resolve_ts_config_for_emit(deno_config::TsConfigType::Emit)?;
- let emit_options =
- crate::args::ts_config_to_emit_options(ts_config_for_emit.ts_config);
- let experimental_decorators = emit_options.use_ts_decorators;
+ let (transpile_options, _) =
+ crate::args::ts_config_to_transpile_and_emit_options(
+ ts_config_for_emit.ts_config,
+ );
+ let experimental_decorators = transpile_options.use_ts_decorators;
let mut repl_session = ReplSession {
npm_resolver,
resolver,
@@ -619,23 +621,27 @@ impl ReplSession {
self.analyze_and_handle_jsx(&parsed_source);
let transpiled_src = parsed_source
- .transpile(&deno_ast::EmitOptions {
- use_ts_decorators: self.experimental_decorators,
- use_decorators_proposal: !self.experimental_decorators,
- emit_metadata: false,
- source_map: false,
- inline_source_map: false,
- inline_sources: false,
- imports_not_used_as_values: ImportsNotUsedAsValues::Preserve,
- transform_jsx: true,
- precompile_jsx: false,
- jsx_automatic: self.jsx.import_source.is_some(),
- jsx_development: false,
- jsx_factory: self.jsx.factory.clone(),
- jsx_fragment_factory: self.jsx.frag_factory.clone(),
- jsx_import_source: self.jsx.import_source.clone(),
- var_decl_imports: true,
- })?
+ .transpile(
+ &deno_ast::TranspileOptions {
+ use_ts_decorators: self.experimental_decorators,
+ use_decorators_proposal: !self.experimental_decorators,
+ emit_metadata: false,
+ imports_not_used_as_values: ImportsNotUsedAsValues::Preserve,
+ transform_jsx: true,
+ precompile_jsx: false,
+ jsx_automatic: self.jsx.import_source.is_some(),
+ jsx_development: false,
+ jsx_factory: self.jsx.factory.clone(),
+ jsx_fragment_factory: self.jsx.frag_factory.clone(),
+ jsx_import_source: self.jsx.import_source.clone(),
+ var_decl_imports: true,
+ },
+ &deno_ast::EmitOptions {
+ source_map: deno_ast::SourceMapOption::None,
+ inline_sources: false,
+ keep_comments: false,
+ },
+ )?
.text;
let value = self
diff --git a/cli/tools/vendor/test.rs b/cli/tools/vendor/test.rs
index d54bf5dc5..09e911277 100644
--- a/cli/tools/vendor/test.rs
+++ b/cli/tools/vendor/test.rs
@@ -236,13 +236,12 @@ impl VendorTestBuilder {
let resolver = resolver.clone();
move |entry_points| {
async move {
- let analyzer = DefaultModuleAnalyzer::default();
Ok(
build_test_graph(
entry_points,
loader,
resolver.as_graph_resolver(),
- &analyzer,
+ &DefaultModuleAnalyzer,
)
.await,
)
@@ -310,7 +309,7 @@ async fn build_test_graph(
&mut loader,
deno_graph::BuildOptions {
resolver: Some(resolver),
- module_analyzer: Some(analyzer),
+ module_analyzer: analyzer,
..Default::default()
},
)