mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
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>
This commit is contained in:
parent
544923afdc
commit
9534e6e113
38 changed files with 317 additions and 24 deletions
22
Cargo.lock
generated
22
Cargo.lock
generated
|
@ -1061,16 +1061,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_config"
|
||||
version = "0.5.0"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f4dd27020827a51857fbb47a21d2359f75db031e177821bff4e95368333a5a0"
|
||||
checksum = "40c6b9137fcc5c6f81d12214fc31cdddf2c64d0667a5458803e081ddd856d5b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap 2.0.2",
|
||||
"jsonc-parser",
|
||||
"log",
|
||||
"percent-encoding",
|
||||
"pretty_assertions",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"url",
|
||||
|
@ -1156,9 +1155,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_doc"
|
||||
version = "0.73.1"
|
||||
version = "0.73.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0caa44ce342fb69b449ae750f8bf66dea6730ce7a00cc4449766d47b8626faf9"
|
||||
checksum = "d2854646e9edfea295844b392ab64b7f4fb7b25b608c82d40a2c2d39655b71db"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if",
|
||||
|
@ -1179,9 +1178,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_emit"
|
||||
version = "0.31.3"
|
||||
version = "0.31.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "193d738bbe06f950a7be3f852f0d940839bba6f4c2cb1d2019eb0d6c727f7b03"
|
||||
checksum = "f8910a6da498d0eb2a28d9ea613c47291a86377a85b3771dd90d624004814aeb"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.13.1",
|
||||
|
@ -1246,9 +1245,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_graph"
|
||||
version = "0.61.0"
|
||||
version = "0.61.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bd6700dd3cec2a7763760168c952cc632246a1ae0fc52d6f297e2802b994e69"
|
||||
checksum = "076c0b611c10901456b78c837408b9c40fe0c3602e767307d986f46f0cc56b51"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
|
@ -2865,11 +2864,10 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed"
|
|||
|
||||
[[package]]
|
||||
name = "import_map"
|
||||
version = "0.15.0"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "632089ec08bd62e807311104122fb26d5c911ab172e2b9864be154a575979e29"
|
||||
checksum = "1e5bf51a0adfdc08afcb9e5a1c8f8c804227ec50d493c65e57e6d117d594bd1b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"indexmap 1.9.3",
|
||||
"log",
|
||||
"serde",
|
||||
|
|
|
@ -51,11 +51,11 @@ winres.workspace = true
|
|||
[dependencies]
|
||||
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||
deno_cache_dir = "=0.6.1"
|
||||
deno_config = "=0.5.0"
|
||||
deno_config = "=0.6.4"
|
||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||
deno_doc = { version = "=0.73.1", features = ["html"] }
|
||||
deno_emit = "=0.31.3"
|
||||
deno_graph = "=0.61.0"
|
||||
deno_doc = { version = "=0.73.2", features = ["html"] }
|
||||
deno_emit = "=0.31.4"
|
||||
deno_graph = "=0.61.1"
|
||||
deno_lint = { version = "=0.52.2", features = ["docs"] }
|
||||
deno_lockfile.workspace = true
|
||||
deno_npm = "0.15.2"
|
||||
|
@ -95,7 +95,7 @@ glob = "0.3.1"
|
|||
hex.workspace = true
|
||||
http.workspace = true
|
||||
hyper.workspace = true
|
||||
import_map = "=0.15.0"
|
||||
import_map = { version = "=0.17.0", features = ["ext"] }
|
||||
indexmap.workspace = true
|
||||
jsonc-parser = { version = "=0.21.1", features = ["serde"] }
|
||||
lazy-regex.workspace = true
|
||||
|
|
|
@ -431,6 +431,7 @@ pub struct Flags {
|
|||
pub unstable: bool,
|
||||
pub unstable_bare_node_builtins: bool,
|
||||
pub unstable_byonm: bool,
|
||||
pub unstable_workspaces: bool,
|
||||
pub unstable_features: Vec<String>,
|
||||
pub unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||
pub v8_flags: Vec<String>,
|
||||
|
@ -871,6 +872,7 @@ pub fn flags_from_vec(args: Vec<String>) -> clap::error::Result<Flags> {
|
|||
flags.unstable_bare_node_builtins =
|
||||
matches.get_flag("unstable-bare-node-builtins");
|
||||
flags.unstable_byonm = matches.get_flag("unstable-byonm");
|
||||
flags.unstable_workspaces = matches.get_flag("unstable-workspaces");
|
||||
|
||||
if matches.get_flag("quiet") {
|
||||
flags.log_level = Some(Level::Error);
|
||||
|
@ -984,6 +986,15 @@ fn clap_root() -> Command {
|
|||
.value_parser(FalseyValueParser::new())
|
||||
.action(ArgAction::SetTrue)
|
||||
.global(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("unstable-workspaces")
|
||||
.long("unstable-workspaces")
|
||||
.help("Enable unstable 'workspaces' feature")
|
||||
.env("DENO_UNSTABLE_WORKSPACES")
|
||||
.value_parser(FalseyValueParser::new())
|
||||
.action(ArgAction::SetTrue)
|
||||
.global(true),
|
||||
);
|
||||
|
||||
for (flag_name, help, _) in crate::UNSTABLE_GRANULAR_FLAGS {
|
||||
|
|
|
@ -36,7 +36,7 @@ pub async fn resolve_import_map_from_specifier(
|
|||
import_map_from_value(specifier, value)
|
||||
}
|
||||
|
||||
fn import_map_from_value(
|
||||
pub fn import_map_from_value(
|
||||
specifier: &Url,
|
||||
json_value: serde_json::Value,
|
||||
) -> Result<ImportMap, AnyError> {
|
||||
|
|
|
@ -29,6 +29,7 @@ pub use deno_config::TsConfig;
|
|||
pub use deno_config::TsConfigForEmit;
|
||||
pub use deno_config::TsConfigType;
|
||||
pub use deno_config::TsTypeLib;
|
||||
pub use deno_config::WorkspaceConfig;
|
||||
pub use flags::*;
|
||||
pub use lockfile::Lockfile;
|
||||
pub use lockfile::LockfileError;
|
||||
|
@ -619,6 +620,7 @@ pub struct CliOptions {
|
|||
maybe_package_json: Option<PackageJson>,
|
||||
maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
|
||||
overrides: CliOptionOverrides,
|
||||
maybe_workspace_config: Option<WorkspaceConfig>,
|
||||
}
|
||||
|
||||
impl CliOptions {
|
||||
|
@ -652,6 +654,20 @@ impl CliOptions {
|
|||
.with_context(|| "Resolving node_modules folder.")?;
|
||||
let maybe_vendor_folder =
|
||||
resolve_vendor_folder(&initial_cwd, &flags, maybe_config_file.as_ref());
|
||||
let maybe_workspace_config =
|
||||
if let Some(config_file) = maybe_config_file.as_ref() {
|
||||
config_file.to_workspace_config()?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// TODO(bartlomieju): remove in v1.39 or v1.40.
|
||||
if let Some(wsconfig) = &maybe_workspace_config {
|
||||
if !wsconfig.members.is_empty() && !flags.unstable_workspaces {
|
||||
eprintln!("Use of unstable 'workspaces' feature. The --unstable-workspaces flags must be provided.");
|
||||
std::process::exit(70);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(env_file_name) = &flags.env_file {
|
||||
if (from_filename(env_file_name)).is_err() {
|
||||
|
@ -668,6 +684,7 @@ impl CliOptions {
|
|||
maybe_node_modules_folder,
|
||||
maybe_vendor_folder,
|
||||
overrides: Default::default(),
|
||||
maybe_workspace_config,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -813,6 +830,41 @@ impl CliOptions {
|
|||
&self,
|
||||
file_fetcher: &FileFetcher,
|
||||
) -> Result<Option<ImportMap>, AnyError> {
|
||||
if let Some(workspace_config) = self.maybe_workspace_config.as_ref() {
|
||||
let base_import_map_config = ::import_map::ext::ImportMapConfig {
|
||||
base_url: self.maybe_config_file.as_ref().unwrap().specifier.clone(),
|
||||
import_map_value: workspace_config.base_import_map_value.clone(),
|
||||
};
|
||||
let children_configs = workspace_config
|
||||
.members
|
||||
.iter()
|
||||
.map(|member| {
|
||||
let import_map_value = member.config_file.to_import_map_value();
|
||||
::import_map::ext::ImportMapConfig {
|
||||
base_url: member.config_file.specifier.clone(),
|
||||
import_map_value,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let maybe_import_map = ::import_map::ext::create_synthetic_import_map(
|
||||
base_import_map_config,
|
||||
children_configs,
|
||||
);
|
||||
if let Some((_import_map_url, import_map)) = maybe_import_map {
|
||||
log::debug!(
|
||||
"Workspace config generated this import map {}",
|
||||
serde_json::to_string_pretty(&import_map).unwrap()
|
||||
);
|
||||
return import_map::import_map_from_value(
|
||||
// TODO(bartlomieju): maybe should be stored on the workspace config?
|
||||
&self.maybe_config_file.as_ref().unwrap().specifier,
|
||||
import_map,
|
||||
)
|
||||
.map(Some);
|
||||
}
|
||||
}
|
||||
|
||||
let import_map_specifier = match self.resolve_import_map_specifier()? {
|
||||
Some(specifier) => specifier,
|
||||
None => return Ok(None),
|
||||
|
@ -940,6 +992,7 @@ impl CliOptions {
|
|||
maybe_config_file: self.maybe_config_file.clone(),
|
||||
maybe_package_json: self.maybe_package_json.clone(),
|
||||
maybe_lockfile: self.maybe_lockfile.clone(),
|
||||
maybe_workspace_config: self.maybe_workspace_config.clone(),
|
||||
overrides: self.overrides.clone(),
|
||||
}
|
||||
}
|
||||
|
@ -1037,6 +1090,10 @@ impl CliOptions {
|
|||
&self.maybe_config_file
|
||||
}
|
||||
|
||||
pub fn maybe_workspace_config(&self) -> &Option<WorkspaceConfig> {
|
||||
&self.maybe_workspace_config
|
||||
}
|
||||
|
||||
pub fn maybe_package_json(&self) -> &Option<PackageJson> {
|
||||
&self.maybe_package_json
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ use crate::util::sync::TaskQueue;
|
|||
use crate::util::sync::TaskQueuePermit;
|
||||
|
||||
use deno_core::anyhow::bail;
|
||||
use deno_core::anyhow::Context;
|
||||
use deno_core::error::custom_error;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::parking_lot::Mutex;
|
||||
|
@ -269,6 +270,12 @@ impl ModuleGraphBuilder {
|
|||
options: CreateGraphOptions<'_>,
|
||||
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
||||
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 cli_resolver = self.resolver.clone();
|
||||
let graph_resolver = cli_resolver.as_graph_resolver();
|
||||
|
@ -291,8 +298,7 @@ impl ModuleGraphBuilder {
|
|||
npm_resolver: Some(graph_npm_resolver),
|
||||
module_analyzer: Some(options.analyzer),
|
||||
reporter: maybe_file_watcher_reporter,
|
||||
// todo(dsherret): workspace support
|
||||
workspace_members: vec![],
|
||||
workspace_members,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
@ -312,6 +318,12 @@ impl ModuleGraphBuilder {
|
|||
) -> Result<Arc<deno_graph::ModuleGraph>, AnyError> {
|
||||
let mut cache = self.create_graph_loader();
|
||||
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 cli_resolver = self.resolver.clone();
|
||||
let graph_resolver = cli_resolver.as_graph_resolver();
|
||||
let graph_npm_resolver = cli_resolver.as_graph_npm_resolver();
|
||||
|
@ -336,8 +348,7 @@ impl ModuleGraphBuilder {
|
|||
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?;
|
||||
|
@ -719,6 +730,46 @@ impl deno_graph::source::Reporter for FileWatcherReporter {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn workspace_config_to_workspace_members(
|
||||
workspace_config: &deno_config::WorkspaceConfig,
|
||||
) -> Result<Vec<deno_graph::WorkspaceMember>, AnyError> {
|
||||
workspace_config
|
||||
.members
|
||||
.iter()
|
||||
.map(|member| {
|
||||
workspace_member_config_try_into_workspace_member(member).with_context(
|
||||
|| {
|
||||
format!(
|
||||
"Failed to resolve configuration for '{}' workspace member at '{}'",
|
||||
member.member_name,
|
||||
member.config_file.specifier.as_str()
|
||||
)
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn workspace_member_config_try_into_workspace_member(
|
||||
config: &deno_config::WorkspaceMemberConfig,
|
||||
) -> Result<deno_graph::WorkspaceMember, AnyError> {
|
||||
let nv = deno_semver::package::PackageNv {
|
||||
name: config.package_name.clone(),
|
||||
version: deno_semver::Version::parse_standard(&config.package_version)?,
|
||||
};
|
||||
Ok(deno_graph::WorkspaceMember {
|
||||
base: ModuleSpecifier::from_directory_path(&config.path).unwrap(),
|
||||
nv,
|
||||
exports: config
|
||||
.config_file
|
||||
.to_exports_config()?
|
||||
.into_map()
|
||||
// todo(dsherret): deno_graph should use an IndexMap
|
||||
.into_iter()
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::sync::Arc;
|
||||
|
|
|
@ -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?;
|
||||
|
|
|
@ -4759,3 +4759,32 @@ itest!(explicit_resource_management {
|
|||
args: "run --quiet --check run/explicit_resource_management/main.ts",
|
||||
output: "run/explicit_resource_management/main.out",
|
||||
});
|
||||
|
||||
itest!(workspaces_basic {
|
||||
args: "run -L debug -A --unstable-workspaces main.ts",
|
||||
output: "run/workspaces/basic/main.out",
|
||||
cwd: Some("run/workspaces/basic/"),
|
||||
copy_temp_dir: Some("run/workspaces/basic/"),
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(workspaces_member_outside_root_dir {
|
||||
args: "run -A --unstable-workspaces main.ts",
|
||||
output: "run/workspaces/member_outside_root_dir/main.out",
|
||||
cwd: Some("run/workspaces/member_outside_root_dir/"),
|
||||
copy_temp_dir: Some("run/workspaces/member_outside_root_dir/"),
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(workspaces_nested_member {
|
||||
args: "run -A --unstable-workspaces main.ts",
|
||||
output: "run/workspaces/nested_member/main.out",
|
||||
cwd: Some("run/workspaces/nested_member/"),
|
||||
copy_temp_dir: Some("run/workspaces/nested_member/"),
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
exit_code: 1,
|
||||
});
|
||||
|
|
8
cli/tests/testdata/run/workspaces/basic/bar/deno.json
vendored
Normal file
8
cli/tests/testdata/run/workspaces/basic/bar/deno.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "asdfasdfasdf",
|
||||
"version": "0.0.0",
|
||||
"imports": {
|
||||
"@/": "./",
|
||||
"secret_mod/": "./some_mod/"
|
||||
}
|
||||
}
|
1
cli/tests/testdata/run/workspaces/basic/bar/fizz/buzz.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/basic/bar/fizz/buzz.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const buzz = "buzz from bar";
|
5
cli/tests/testdata/run/workspaces/basic/bar/mod.ts
vendored
Normal file
5
cli/tests/testdata/run/workspaces/basic/bar/mod.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { hello } from "secret_mod/hello.ts";
|
||||
import { buzz } from "@/fizz/buzz.ts";
|
||||
|
||||
console.log(hello);
|
||||
console.log(buzz);
|
1
cli/tests/testdata/run/workspaces/basic/bar/some_mod/hello.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/basic/bar/some_mod/hello.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const hello = "hello from bar";
|
9
cli/tests/testdata/run/workspaces/basic/deno.json
vendored
Normal file
9
cli/tests/testdata/run/workspaces/basic/deno.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"workspaces": [
|
||||
"foo",
|
||||
"bar"
|
||||
],
|
||||
"imports": {
|
||||
"chalk": "npm:chalk"
|
||||
}
|
||||
}
|
1
cli/tests/testdata/run/workspaces/basic/foo/bar/hello.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/basic/foo/bar/hello.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const hello = "hello from foo";
|
8
cli/tests/testdata/run/workspaces/basic/foo/deno.json
vendored
Normal file
8
cli/tests/testdata/run/workspaces/basic/foo/deno.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "qwerqwer",
|
||||
"version": "0.0.0",
|
||||
"imports": {
|
||||
"~/": "./",
|
||||
"foo/": "./bar/"
|
||||
}
|
||||
}
|
1
cli/tests/testdata/run/workspaces/basic/foo/fizz/buzz.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/basic/foo/fizz/buzz.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const buzz = "buzz from foo";
|
5
cli/tests/testdata/run/workspaces/basic/foo/mod.ts
vendored
Normal file
5
cli/tests/testdata/run/workspaces/basic/foo/mod.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { hello } from "foo/hello.ts";
|
||||
import { buzz } from "~/fizz/buzz.ts";
|
||||
|
||||
console.log(hello);
|
||||
console.log(buzz);
|
21
cli/tests/testdata/run/workspaces/basic/main.out
vendored
Normal file
21
cli/tests/testdata/run/workspaces/basic/main.out
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
[WILDCARD]Workspace config generated this import map {
|
||||
"imports": {
|
||||
"chalk": "npm:chalk"
|
||||
},
|
||||
"scopes": {
|
||||
"./foo/": {
|
||||
"~/": "./foo/",
|
||||
"foo/": "./foo/bar/"
|
||||
},
|
||||
"./bar/": {
|
||||
"@/": "./bar/",
|
||||
"secret_mod/": "./bar/some_mod/"
|
||||
}
|
||||
}
|
||||
}
|
||||
[WILDCARD]
|
||||
hello from foo
|
||||
buzz from foo
|
||||
hello from bar
|
||||
buzz from bar
|
||||
[Function: chalk][WILDCARD]
|
5
cli/tests/testdata/run/workspaces/basic/main.ts
vendored
Normal file
5
cli/tests/testdata/run/workspaces/basic/main.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import chalk from "chalk";
|
||||
import "./foo/mod.ts";
|
||||
import "./bar/mod.ts";
|
||||
|
||||
console.log(chalk);
|
9
cli/tests/testdata/run/workspaces/member_outside_root_dir/deno.json
vendored
Normal file
9
cli/tests/testdata/run/workspaces/member_outside_root_dir/deno.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"workspaces": [
|
||||
"foo",
|
||||
"../other_folder"
|
||||
],
|
||||
"imports": {
|
||||
"chalk": "npm:chalk"
|
||||
}
|
||||
}
|
1
cli/tests/testdata/run/workspaces/member_outside_root_dir/foo/bar/hello.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/member_outside_root_dir/foo/bar/hello.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const hello = "hello from foo";
|
8
cli/tests/testdata/run/workspaces/member_outside_root_dir/foo/deno.json
vendored
Normal file
8
cli/tests/testdata/run/workspaces/member_outside_root_dir/foo/deno.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "qwerqwer",
|
||||
"version": "0.0.0",
|
||||
"imports": {
|
||||
"~/": "./",
|
||||
"foo/": "./bar/"
|
||||
}
|
||||
}
|
1
cli/tests/testdata/run/workspaces/member_outside_root_dir/foo/fizz/buzz.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/member_outside_root_dir/foo/fizz/buzz.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const buzz = "buzz from foo";
|
5
cli/tests/testdata/run/workspaces/member_outside_root_dir/foo/mod.ts
vendored
Normal file
5
cli/tests/testdata/run/workspaces/member_outside_root_dir/foo/mod.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { hello } from "foo/hello.ts";
|
||||
import { buzz } from "~/fizz/buzz.ts";
|
||||
|
||||
console.log(hello);
|
||||
console.log(buzz);
|
1
cli/tests/testdata/run/workspaces/member_outside_root_dir/main.out
vendored
Normal file
1
cli/tests/testdata/run/workspaces/member_outside_root_dir/main.out
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
error: Workspace member '../other_folder' is outside root configuration directory[WILDCARD]
|
4
cli/tests/testdata/run/workspaces/member_outside_root_dir/main.ts
vendored
Normal file
4
cli/tests/testdata/run/workspaces/member_outside_root_dir/main.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
import chalk from "chalk";
|
||||
import "./foo/mod.ts";
|
||||
|
||||
console.log(chalk);
|
8
cli/tests/testdata/run/workspaces/nested_member/bar/deno.json
vendored
Normal file
8
cli/tests/testdata/run/workspaces/nested_member/bar/deno.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "asdfasdfasdf",
|
||||
"version": "0.0.0",
|
||||
"imports": {
|
||||
"@/": "./",
|
||||
"secret_mod/": "./some_mod/"
|
||||
}
|
||||
}
|
1
cli/tests/testdata/run/workspaces/nested_member/bar/fizz/buzz.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/nested_member/bar/fizz/buzz.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const buzz = "buzz from bar";
|
5
cli/tests/testdata/run/workspaces/nested_member/bar/mod.ts
vendored
Normal file
5
cli/tests/testdata/run/workspaces/nested_member/bar/mod.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { hello } from "secret_mod/hello.ts";
|
||||
import { buzz } from "@/fizz/buzz.ts";
|
||||
|
||||
console.log(hello);
|
||||
console.log(buzz);
|
1
cli/tests/testdata/run/workspaces/nested_member/bar/some_mod/hello.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/nested_member/bar/some_mod/hello.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const hello = "hello from bar";
|
6
cli/tests/testdata/run/workspaces/nested_member/deno.json
vendored
Normal file
6
cli/tests/testdata/run/workspaces/nested_member/deno.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"workspaces": [
|
||||
"foo",
|
||||
"foo/bar"
|
||||
]
|
||||
}
|
7
cli/tests/testdata/run/workspaces/nested_member/foo/bar/deno.json
vendored
Normal file
7
cli/tests/testdata/run/workspaces/nested_member/foo/bar/deno.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "bar",
|
||||
"version": "0.0.0",
|
||||
"imports": {
|
||||
"chalk": "npm:chalk"
|
||||
}
|
||||
}
|
3
cli/tests/testdata/run/workspaces/nested_member/foo/bar/hello.ts
vendored
Normal file
3
cli/tests/testdata/run/workspaces/nested_member/foo/bar/hello.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
import chalk from "chalk";
|
||||
|
||||
export default chalk;
|
7
cli/tests/testdata/run/workspaces/nested_member/foo/deno.json
vendored
Normal file
7
cli/tests/testdata/run/workspaces/nested_member/foo/deno.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "qwerqwer",
|
||||
"version": "0.0.0",
|
||||
"imports": {
|
||||
"~/": "./"
|
||||
}
|
||||
}
|
1
cli/tests/testdata/run/workspaces/nested_member/foo/fizz/buzz.ts
vendored
Normal file
1
cli/tests/testdata/run/workspaces/nested_member/foo/fizz/buzz.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const buzz = "buzz from foo";
|
3
cli/tests/testdata/run/workspaces/nested_member/foo/mod.ts
vendored
Normal file
3
cli/tests/testdata/run/workspaces/nested_member/foo/mod.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { buzz } from "~/fizz/buzz.ts";
|
||||
|
||||
console.log(buzz);
|
1
cli/tests/testdata/run/workspaces/nested_member/main.out
vendored
Normal file
1
cli/tests/testdata/run/workspaces/nested_member/main.out
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
error: Workspace member 'foo/bar' is nested within other workspace member 'foo'
|
4
cli/tests/testdata/run/workspaces/nested_member/main.ts
vendored
Normal file
4
cli/tests/testdata/run/workspaces/nested_member/main.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
import "./foo/mod.ts";
|
||||
import chalk from "./foo/bar/hello.ts";
|
||||
|
||||
console.log(chalk);
|
Loading…
Reference in a new issue