From 9534e6e1131542653c4e266f712c4067af2c8ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 17 Nov 2023 02:28:38 +0100 Subject: 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 --- cli/tests/testdata/run/workspaces/basic/bar/deno.json | 8 ++++++++ cli/tests/testdata/run/workspaces/basic/bar/fizz/buzz.ts | 1 + cli/tests/testdata/run/workspaces/basic/bar/mod.ts | 5 +++++ cli/tests/testdata/run/workspaces/basic/bar/some_mod/hello.ts | 1 + 4 files changed, 15 insertions(+) create mode 100644 cli/tests/testdata/run/workspaces/basic/bar/deno.json create mode 100644 cli/tests/testdata/run/workspaces/basic/bar/fizz/buzz.ts create mode 100644 cli/tests/testdata/run/workspaces/basic/bar/mod.ts create mode 100644 cli/tests/testdata/run/workspaces/basic/bar/some_mod/hello.ts (limited to 'cli/tests/testdata/run/workspaces/basic/bar') diff --git a/cli/tests/testdata/run/workspaces/basic/bar/deno.json b/cli/tests/testdata/run/workspaces/basic/bar/deno.json new file mode 100644 index 000000000..ef3bfc37a --- /dev/null +++ b/cli/tests/testdata/run/workspaces/basic/bar/deno.json @@ -0,0 +1,8 @@ +{ + "name": "asdfasdfasdf", + "version": "0.0.0", + "imports": { + "@/": "./", + "secret_mod/": "./some_mod/" + } +} diff --git a/cli/tests/testdata/run/workspaces/basic/bar/fizz/buzz.ts b/cli/tests/testdata/run/workspaces/basic/bar/fizz/buzz.ts new file mode 100644 index 000000000..f88d62fcc --- /dev/null +++ b/cli/tests/testdata/run/workspaces/basic/bar/fizz/buzz.ts @@ -0,0 +1 @@ +export const buzz = "buzz from bar"; diff --git a/cli/tests/testdata/run/workspaces/basic/bar/mod.ts b/cli/tests/testdata/run/workspaces/basic/bar/mod.ts new file mode 100644 index 000000000..6f898e389 --- /dev/null +++ b/cli/tests/testdata/run/workspaces/basic/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/cli/tests/testdata/run/workspaces/basic/bar/some_mod/hello.ts b/cli/tests/testdata/run/workspaces/basic/bar/some_mod/hello.ts new file mode 100644 index 000000000..1013de8d2 --- /dev/null +++ b/cli/tests/testdata/run/workspaces/basic/bar/some_mod/hello.ts @@ -0,0 +1 @@ +export const hello = "hello from bar"; -- cgit v1.2.3