mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat: npm workspace and better Deno workspace support (#24334)
Adds much better support for the unstable Deno workspaces as well as support for npm workspaces. npm workspaces is still lacking in that we only install packages into the root node_modules folder. We'll make it smarter over time in order for it to figure out when to add node_modules folders within packages. This includes a breaking change in config file resolution where we stop searching for config files on the first found package.json unless it's in a workspace. For the previous behaviour, the root deno.json needs to be updated to be a workspace by adding `"workspace": ["./path-to-pkg-json-folder-goes-here"]`. See details in https://github.com/denoland/deno_config/pull/66 Closes #24340 Closes #24159 Closes #24161 Closes #22020 Closes #18546 Closes #16106 Closes #24160
This commit is contained in:
parent
dd6d19e120
commit
147411e64b
235 changed files with 4446 additions and 2451 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
use base64::Engine;
|
||||
use deno_ast::MediaType;
|
||||
use deno_config::workspace::Workspace;
|
||||
use deno_config::workspace::WorkspaceDiscoverOptions;
|
||||
use deno_core::anyhow::anyhow;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::resolve_url;
|
||||
|
@ -13,6 +15,7 @@ use deno_core::url;
|
|||
use deno_core::ModuleSpecifier;
|
||||
use deno_graph::GraphKind;
|
||||
use deno_graph::Resolution;
|
||||
use deno_runtime::deno_fs::DenoConfigFsAdapter;
|
||||
use deno_runtime::deno_tls::rustls::RootCertStore;
|
||||
use deno_runtime::deno_tls::RootCertStoreProvider;
|
||||
use deno_semver::jsr::JsrPackageReqReference;
|
||||
|
@ -3549,6 +3552,24 @@ impl Inner {
|
|||
}
|
||||
|
||||
let workspace_settings = self.config.workspace_settings();
|
||||
let initial_cwd = config_data
|
||||
.and_then(|d| d.scope.to_file_path().ok())
|
||||
.unwrap_or_else(|| self.initial_cwd.clone());
|
||||
// todo: we need a way to convert config data to a Workspace
|
||||
let workspace = Arc::new(Workspace::discover(
|
||||
deno_config::workspace::WorkspaceDiscoverStart::Dirs(&[
|
||||
initial_cwd.clone()
|
||||
]),
|
||||
&WorkspaceDiscoverOptions {
|
||||
fs: &DenoConfigFsAdapter::new(&deno_runtime::deno_fs::RealFs),
|
||||
pkg_json_cache: None,
|
||||
config_parse_options: deno_config::ConfigParseOptions {
|
||||
include_task_comments: false,
|
||||
},
|
||||
additional_config_file_names: &[],
|
||||
discover_pkg_json: true,
|
||||
},
|
||||
)?);
|
||||
let cli_options = CliOptions::new(
|
||||
Flags {
|
||||
cache_path: Some(self.cache.deno_dir().root.clone()),
|
||||
|
@ -3572,13 +3593,12 @@ impl Inner {
|
|||
type_check_mode: crate::args::TypeCheckMode::Local,
|
||||
..Default::default()
|
||||
},
|
||||
self.initial_cwd.clone(),
|
||||
config_data.and_then(|d| d.config_file.as_deref().cloned()),
|
||||
initial_cwd,
|
||||
config_data.and_then(|d| d.lockfile.clone()),
|
||||
config_data.and_then(|d| d.package_json.clone()),
|
||||
config_data
|
||||
.and_then(|d| d.npmrc.clone())
|
||||
.unwrap_or_else(create_default_npmrc),
|
||||
workspace,
|
||||
force_global_cache,
|
||||
)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue