1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

use deno_config temp branch

This commit is contained in:
Nayeem Rahman 2024-11-27 19:11:45 +00:00
parent 874260d0ce
commit 6e3ceddf17
7 changed files with 42 additions and 55 deletions

3
Cargo.lock generated
View file

@ -1430,8 +1430,7 @@ dependencies = [
[[package]]
name = "deno_config"
version = "0.39.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38fb809500238be2b10eee42944a47b3ac38974e1edbb47f73afcfca7df143bf"
source = "git+https://github.com/denoland/deno_config.git?rev=1a5c07c05085f0cb922bdf0a899589b1c720ea60#1a5c07c05085f0cb922bdf0a899589b1c720ea60"
dependencies = [
"anyhow",
"deno_package_json",

View file

@ -50,7 +50,8 @@ deno_ast = { version = "=0.43.3", features = ["transpiling"] }
deno_core = { version = "0.323.0" }
deno_bench_util = { version = "0.173.0", path = "./bench_util" }
deno_config = { version = "=0.39.2", features = ["workspace", "sync"] }
# TODO(nayeemrmn): Use proper version when https://github.com/denoland/deno_config/pull/143 lands!
deno_config = { git = "https://github.com/denoland/deno_config.git", rev = "1a5c07c05085f0cb922bdf0a899589b1c720ea60", features = ["workspace", "sync"] }
deno_lockfile = "=0.23.1"
deno_media_type = { version = "0.2.0", features = ["module_specifier"] }
deno_npm = "=0.25.4"

View file

@ -1266,7 +1266,7 @@ impl CliOptions {
&self,
config_type: TsConfigType,
) -> Result<TsConfigForEmit, AnyError> {
self.workspace().resolve_ts_config_for_emit(config_type)
self.start_dir.to_ts_config_for_emit(config_type)
}
pub fn resolve_inspector_server(
@ -1296,7 +1296,7 @@ impl CliOptions {
&self,
) -> Result<Vec<deno_graph::ReferrerImports>, AnyError> {
self
.workspace()
.start_dir
.to_compiler_option_types()
.map(|maybe_imports| {
maybe_imports
@ -1347,6 +1347,17 @@ impl CliOptions {
WorkspaceLintOptions::resolve(&lint_config, lint_flags)
}
pub fn resolve_file_flags_for_members(
&self,
file_flags: &FileFlags,
) -> Result<Vec<(WorkspaceDirectory, FilePatterns)>, AnyError> {
let cli_arg_patterns = file_flags.as_file_patterns(self.initial_cwd())?;
let member_patterns = self
.workspace()
.resolve_file_patterns_for_members(&cli_arg_patterns)?;
Ok(member_patterns)
}
pub fn resolve_lint_options_for_members(
&self,
lint_flags: &LintFlags,
@ -1445,7 +1456,7 @@ impl CliOptions {
}
pub fn check_js(&self) -> bool {
self.workspace().check_js()
self.start_dir.check_js()
}
pub fn coverage_dir(&self) -> Option<String> {

View file

@ -750,7 +750,7 @@ impl ModuleGraphBuilder {
fn create_graph_resolver(&self) -> Result<CliGraphResolver, AnyError> {
let jsx_import_source_config = self
.cli_options
.workspace()
.start_dir
.to_maybe_jsx_import_source_config()?;
Ok(CliGraphResolver {
cjs_tracker: &self.cjs_tracker,

View file

@ -1410,17 +1410,11 @@ impl ConfigData {
.unwrap_or_default(),
);
// TODO(nayeemrmn): This is a hack to get member-specific compiler options.
let ts_config = if let Some(config_file) = member_dir
.maybe_deno_json()
.filter(|c| c.json.compiler_options.is_some())
{
LspTsConfig::new(Some(config_file))
} else {
LspTsConfig::new(
member_dir.workspace.root_deno_json().map(|c| c.as_ref()),
)
};
let ts_config = LspTsConfig::new(
member_dir
.deno_json_for_compiler_options()
.map(|c| c.as_ref()),
);
let deno_lint_config =
if ts_config.inner.0.get("jsx").and_then(|v| v.as_str()) == Some("react")
@ -1668,7 +1662,6 @@ impl ConfigData {
) -> Option<JsxImportSourceConfig> {
self
.member_dir
.workspace
.to_maybe_jsx_import_source_config()
.ok()
.flatten()

View file

@ -139,7 +139,7 @@ impl LspScopeResolver {
let maybe_jsx_import_source_config =
config_data.and_then(|d| d.maybe_jsx_import_source_config());
let graph_imports = config_data
.and_then(|d| d.member_dir.workspace.to_compiler_option_types().ok())
.and_then(|d| d.member_dir.to_compiler_option_types().ok())
.map(|imports| {
Arc::new(
imports

View file

@ -10,7 +10,6 @@ use std::sync::Arc;
use deno_ast::MediaType;
use deno_ast::ModuleSpecifier;
use deno_config::deno_json::get_ts_config_for_emit;
use deno_config::glob::FilePatterns;
use deno_config::glob::PathOrPattern;
use deno_core::anyhow::anyhow;
@ -30,7 +29,6 @@ use crate::args::CliOptions;
use crate::args::ConfigFlag;
use crate::args::FileFlags;
use crate::args::Flags;
use crate::args::LintFlags;
use crate::args::ScopeOptions;
use crate::args::TsConfig;
use crate::args::TsConfigType;
@ -74,25 +72,28 @@ pub async fn check(
|| f.starts_with("npm:")
|| f.starts_with("jsr:")
});
// TODO(nayeemrmn): Using lint options for now. Add proper API to deno_config.
let mut by_workspace_directory = cli_options
.resolve_lint_options_for_members(&LintFlags {
files: FileFlags {
ignore: Default::default(),
include: files,
},
..Default::default()
.resolve_file_flags_for_members(&FileFlags {
ignore: Default::default(),
include: files,
})?
.into_iter()
.flat_map(|(d, o)| {
Some((d.dir_url().clone(), (Arc::new(d), o.files.include?)))
})
.map(|(d, p)| (d.dir_url().clone(), (Arc::new(d), p)))
.collect::<BTreeMap<_, _>>();
if !remote_files.is_empty() {
by_workspace_directory
.entry(cli_options.start_dir.dir_url().clone())
.or_insert((cli_options.start_dir.clone(), Default::default()))
.or_insert((
cli_options.start_dir.clone(),
FilePatterns {
base: cli_options.initial_cwd().to_path_buf(),
include: None,
exclude: Default::default(),
},
))
.1
.include
.get_or_insert_with(Default::default)
.append(
remote_files
.iter()
@ -108,7 +109,6 @@ pub async fn check(
.collect::<BTreeSet<_>>(),
);
let dir_count = by_workspace_directory.len();
let initial_cwd = cli_options.initial_cwd().to_path_buf();
let mut diagnostics = vec![];
let mut all_errors = vec![];
let mut found_specifiers = false;
@ -125,7 +125,7 @@ pub async fn check(
});
let cli_options = CliOptions::new(
flags.clone(),
initial_cwd.clone(),
cli_options.initial_cwd().to_path_buf(),
lockfile.map(Arc::new),
npmrc,
workspace_directory,
@ -133,11 +133,7 @@ pub async fn check(
scope_options.map(Arc::new),
)?;
let specifiers = collect_specifiers(
FilePatterns {
include: Some(patterns),
exclude: cli_options.workspace().resolve_config_excludes()?,
base: initial_cwd.clone(),
},
patterns,
cli_options.vendor_dir_path().map(ToOwned::to_owned),
|e| is_script_ext(e.path),
)?;
@ -353,22 +349,9 @@ impl TypeChecker {
}
log::debug!("Type checking.");
// TODO(nayeemrmn): This is a hack to get member-specific compiler options.
let ts_config_result = if let Some(config_file) = self
let ts_config_result = self
.cli_options
.start_dir
.maybe_deno_json()
.filter(|c| c.json.compiler_options.is_some())
{
get_ts_config_for_emit(
TsConfigType::Check { lib: options.lib },
Some(config_file),
)?
} else {
self
.cli_options
.resolve_ts_config_for_emit(TsConfigType::Check { lib: options.lib })?
};
.resolve_ts_config_for_emit(TsConfigType::Check { lib: options.lib })?;
if options.log_ignored_options {
check_warn_tsconfig(&ts_config_result);
}