summaryrefslogtreecommitdiff
path: root/cli/module_loader.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-11-17 02:28:38 +0100
committerGitHub <noreply@github.com>2023-11-17 01:28:38 +0000
commit9534e6e1131542653c4e266f712c4067af2c8ec0 (patch)
tree1a74cccdcdb6bb12c10ab3e2a34d93fd8c4ccc55 /cli/module_loader.rs
parent544923afdc67e9946453901642746f37f22c8e24 (diff)
feat(unstable): Workspaces support (#20410)
This commit adds unstable workspace support. This is extremely bare-bones and minimal first-pass at this. With this change `deno.json` supports specifying `workspaces` key, that accepts a list of subdirectories. Each workspace can have its own import map. It's required to specify a `"name"` and `"version"` properties in the configuration file for the workspace: ```jsonc // deno.json { "workspaces": [ "a", "b" }, "imports": { "express": "npm:express@5" } } ``` ``` jsonc // a/deno.json { "name": "a", "version": "1.0.2", "imports": { "kleur": "npm:kleur" } } ``` ```jsonc // b/deno.json { "name": "b", "version": "0.51.0", "imports": { "chalk": "npm:chalk" } } ``` `--unstable-workspaces` flag is required to use this feature: ``` $ deno run --unstable-workspaces mod.ts ``` --------- Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'cli/module_loader.rs')
-rw-r--r--cli/module_loader.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs
index c8b2a36df..d8ab2d8c9 100644
--- a/cli/module_loader.rs
+++ b/cli/module_loader.rs
@@ -8,6 +8,7 @@ use crate::cache::ParsedSourceCache;
use crate::emit::Emitter;
use crate::graph_util::graph_lock_or_exit;
use crate::graph_util::graph_valid_with_cli_options;
+use crate::graph_util::workspace_config_to_workspace_members;
use crate::graph_util::FileWatcherReporter;
use crate::graph_util::ModuleGraphBuilder;
use crate::graph_util::ModuleGraphContainer;
@@ -119,6 +120,12 @@ impl ModuleLoadPreparer {
let mut cache = self.module_graph_builder.create_fetch_cacher(permissions);
let maybe_imports = self.options.to_maybe_imports()?;
+ let maybe_workspace_config = self.options.maybe_workspace_config();
+ let workspace_members = if let Some(wc) = maybe_workspace_config {
+ workspace_config_to_workspace_members(wc)?
+ } else {
+ vec![]
+ };
let graph_resolver = self.resolver.as_graph_resolver();
let graph_npm_resolver = self.resolver.as_graph_npm_resolver();
let maybe_file_watcher_reporter = self
@@ -152,8 +159,7 @@ impl ModuleLoadPreparer {
npm_resolver: Some(graph_npm_resolver),
module_analyzer: Some(&analyzer),
reporter: maybe_file_watcher_reporter,
- // todo(dsherret): workspace support
- workspace_members: vec![],
+ workspace_members,
},
)
.await?;