From 051552172c07e42bf666d04863bc511667471509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 4 Nov 2024 23:42:18 +0000 Subject: [PATCH] fix(workspace): support wildcard packages (#26568) This commit adds support for wildcard packages in `workspace` configuration option in `deno.json`. This is now supported: ``` { "workspace": [ "./packages/*" ] } ``` Closes https://github.com/denoland/deno/issues/25783 --- Cargo.lock | 4 ++-- cli/Cargo.toml | 2 +- .../run/workspaces/wildcard/__test__.jsonc | 5 +++++ tests/specs/run/workspaces/wildcard/deno.json | 8 +++++++ tests/specs/run/workspaces/wildcard/main.out | 22 +++++++++++++++++++ tests/specs/run/workspaces/wildcard/main.ts | 5 +++++ .../wildcard/packages/bar/deno.json | 8 +++++++ .../wildcard/packages/bar/fizz/buzz.ts | 1 + .../workspaces/wildcard/packages/bar/mod.ts | 5 +++++ .../wildcard/packages/bar/some_mod/hello.ts | 1 + .../wildcard/packages/foo/bar/hello.ts | 1 + .../wildcard/packages/foo/deno.json | 8 +++++++ .../wildcard/packages/foo/fizz/buzz.ts | 1 + .../workspaces/wildcard/packages/foo/mod.ts | 5 +++++ 14 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 tests/specs/run/workspaces/wildcard/__test__.jsonc create mode 100644 tests/specs/run/workspaces/wildcard/deno.json create mode 100644 tests/specs/run/workspaces/wildcard/main.out create mode 100644 tests/specs/run/workspaces/wildcard/main.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/bar/deno.json create mode 100644 tests/specs/run/workspaces/wildcard/packages/bar/fizz/buzz.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/bar/mod.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/bar/some_mod/hello.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/foo/bar/hello.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/foo/deno.json create mode 100644 tests/specs/run/workspaces/wildcard/packages/foo/fizz/buzz.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/foo/mod.ts diff --git a/Cargo.lock b/Cargo.lock index 40b0bc171b..c22d49c41c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1387,9 +1387,9 @@ dependencies = [ [[package]] name = "deno_config" -version = "0.37.2" +version = "0.38.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5900bfb37538d83b19ba0b157cdc785770e38422ee4632411e3bd3d90ac0f537" +checksum = "966825073480a6ac7e01977a3879d13edc8d6ea2d65ea164b37156a5fb206e9a" dependencies = [ "anyhow", "deno_package_json", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index b4f2e614f0..1fa9692a4d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -70,7 +70,7 @@ winres.workspace = true [dependencies] deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] } deno_cache_dir = { workspace = true } -deno_config = { version = "=0.37.2", features = ["workspace", "sync"] } +deno_config = { version = "=0.38.2", features = ["workspace", "sync"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_doc = { version = "0.156.0", default-features = false, features = ["rust", "html", "syntect"] } deno_graph = { version = "=0.84.1" } diff --git a/tests/specs/run/workspaces/wildcard/__test__.jsonc b/tests/specs/run/workspaces/wildcard/__test__.jsonc new file mode 100644 index 0000000000..ea467e51b4 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -L debug -A main.ts", + "output": "main.out", + "tempDir": true +} diff --git a/tests/specs/run/workspaces/wildcard/deno.json b/tests/specs/run/workspaces/wildcard/deno.json new file mode 100644 index 0000000000..8c39ec6564 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/deno.json @@ -0,0 +1,8 @@ +{ + "workspace": [ + "./packages/*" + ], + "imports": { + "chalk": "npm:chalk" + } +} diff --git a/tests/specs/run/workspaces/wildcard/main.out b/tests/specs/run/workspaces/wildcard/main.out new file mode 100644 index 0000000000..72165dbdea --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/main.out @@ -0,0 +1,22 @@ +[WILDCARD]Workspace config generated this import map { + "imports": { + "chalk": "npm:chalk", + "chalk/": "npm:/chalk/" + }, + "scopes": { + "./packages/bar/": { + "@/": "./packages/bar/", + "secret_mod/": "./packages/bar/some_mod/" + }, + "./packages/foo/": { + "~/": "./packages/foo/", + "foo/": "./packages/foo/bar/" + } + } +} +[WILDCARD] +hello from foo +buzz from foo +hello from bar +buzz from bar +[Function: chalk][WILDCARD] \ No newline at end of file diff --git a/tests/specs/run/workspaces/wildcard/main.ts b/tests/specs/run/workspaces/wildcard/main.ts new file mode 100644 index 0000000000..e69143370d --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/main.ts @@ -0,0 +1,5 @@ +import chalk from "chalk"; +import "./packages/foo/mod.ts"; +import "./packages/bar/mod.ts"; + +console.log(chalk); diff --git a/tests/specs/run/workspaces/wildcard/packages/bar/deno.json b/tests/specs/run/workspaces/wildcard/packages/bar/deno.json new file mode 100644 index 0000000000..ef3bfc37af --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/bar/deno.json @@ -0,0 +1,8 @@ +{ + "name": "asdfasdfasdf", + "version": "0.0.0", + "imports": { + "@/": "./", + "secret_mod/": "./some_mod/" + } +} diff --git a/tests/specs/run/workspaces/wildcard/packages/bar/fizz/buzz.ts b/tests/specs/run/workspaces/wildcard/packages/bar/fizz/buzz.ts new file mode 100644 index 0000000000..f88d62fcc8 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/bar/fizz/buzz.ts @@ -0,0 +1 @@ +export const buzz = "buzz from bar"; diff --git a/tests/specs/run/workspaces/wildcard/packages/bar/mod.ts b/tests/specs/run/workspaces/wildcard/packages/bar/mod.ts new file mode 100644 index 0000000000..6f898e3898 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/bar/mod.ts @@ -0,0 +1,5 @@ +import { hello } from "secret_mod/hello.ts"; +import { buzz } from "@/fizz/buzz.ts"; + +console.log(hello); +console.log(buzz); diff --git a/tests/specs/run/workspaces/wildcard/packages/bar/some_mod/hello.ts b/tests/specs/run/workspaces/wildcard/packages/bar/some_mod/hello.ts new file mode 100644 index 0000000000..1013de8d2e --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/bar/some_mod/hello.ts @@ -0,0 +1 @@ +export const hello = "hello from bar"; diff --git a/tests/specs/run/workspaces/wildcard/packages/foo/bar/hello.ts b/tests/specs/run/workspaces/wildcard/packages/foo/bar/hello.ts new file mode 100644 index 0000000000..c8a7e57c4d --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/foo/bar/hello.ts @@ -0,0 +1 @@ +export const hello = "hello from foo"; diff --git a/tests/specs/run/workspaces/wildcard/packages/foo/deno.json b/tests/specs/run/workspaces/wildcard/packages/foo/deno.json new file mode 100644 index 0000000000..46d84f06fa --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/foo/deno.json @@ -0,0 +1,8 @@ +{ + "name": "qwerqwer", + "version": "0.0.0", + "imports": { + "~/": "./", + "foo/": "./bar/" + } +} diff --git a/tests/specs/run/workspaces/wildcard/packages/foo/fizz/buzz.ts b/tests/specs/run/workspaces/wildcard/packages/foo/fizz/buzz.ts new file mode 100644 index 0000000000..4e03777d1b --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/foo/fizz/buzz.ts @@ -0,0 +1 @@ +export const buzz = "buzz from foo"; diff --git a/tests/specs/run/workspaces/wildcard/packages/foo/mod.ts b/tests/specs/run/workspaces/wildcard/packages/foo/mod.ts new file mode 100644 index 0000000000..d7b16dcc05 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/foo/mod.ts @@ -0,0 +1,5 @@ +import { hello } from "foo/hello.ts"; +import { buzz } from "~/fizz/buzz.ts"; + +console.log(hello); +console.log(buzz);