feat: support automatic workspace detection in Dev (#2985)

Adds support for [Automatic Workspace
Detection](https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md).

- Avoids 404's or middleware logging when this feature is active (e.g.
Chrome/Edge with DevTools open)
- Generates the same UUID based on root folder path (without writing
anything to disk)
- The middleware is lazy and does nothing until the path is opened for
`com.chrome.devtools.json`
This commit is contained in:
Christian Svensson
2025-05-21 11:09:43 +02:00
committed by GitHub
parent bc8cdb9c7b
commit db142115ec
5 changed files with 358 additions and 30 deletions
+35
View File
@@ -209,3 +209,38 @@ Deno.test({
sanitizeOps: false,
sanitizeResources: false,
});
Deno.test({
name: "Builder - workspace folder middleware on listen",
fn: async () => {
const builder = new Builder();
const tmp = await Deno.makeTempDir();
const app = new App({
staticDir: tmp,
build: {
outDir: path.join(tmp, "dist"),
},
});
const abort = new AbortController();
const port = 8011;
await builder.listen(app, { port, signal: abort.signal });
const res = await fetch(
`http://localhost:${port}/.well-known/appspecific/com.chrome.devtools.json`,
);
const json = await res.json();
await abort.abort();
expect(res.ok).toBe(true);
expect(res.status).toBe(200);
expect(res.headers.get("etag")).toEqual(expect.any(String));
expect(json).toEqual({
workspace: {
root: app.config.root,
uuid: expect.any(String),
},
});
},
sanitizeOps: false,
sanitizeResources: false,
});