From bef04584498e1d42b5b214e98e0271536b7d857a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 14 Sep 2026 10:19:58 +0000 Subject: [PATCH] docs(agents): the Vite rewrite claim does not reproduce anywhere MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test-path bullet declared the two-argument `new URL(…, import.meta.url)` form fatal on a named mechanism: Vite rewriting it to `http://localhost:3000/@fs/…` so `fileURLToPath` throws `ERR_INVALID_URL_SCHEME` under both cwds, taking the whole suite down rather than one assertion. Measured against every project `vitest.config.mts` declares -- `unit` on node, `dom`/`dom-heavy`/`dist` on happy-dom, and the `apps/console` project with its full plugin set -- under both the repo-root and the package-directory invocation. It does not reproduce: `import.meta.url` is a `file:` URL in each, the derived path resolves, and the read succeeds. The repo declares no vitest browser mode, which is the transform that produces the `@fs` shape. The prescription is kept (one spelling only, the bare `import.meta.url` form), now resting on spelling uniqueness rather than on a hazard this tree does not exhibit. The bullet's warning is corrected in the same hunk: the `process.cwd()` class it said nothing could stop is gated today by `scripts/check-test-path-roots.mjs`, which deliberately does not flag this spelling. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01DAcomhvR9kKizeYgg89Vo8 --- ...e-9191-new-url-import-meta-url-measured.md | 20 +++++++++++++++++++ AGENTS.md | 10 ++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .changeset/issue-9191-new-url-import-meta-url-measured.md diff --git a/.changeset/issue-9191-new-url-import-meta-url-measured.md b/.changeset/issue-9191-new-url-import-meta-url-measured.md new file mode 100644 index 0000000000..ed8ca1fb8c --- /dev/null +++ b/.changeset/issue-9191-new-url-import-meta-url-measured.md @@ -0,0 +1,20 @@ +--- +--- + +`AGENTS.md` only — no released package source is touched, so this declares **no release** with +an empty frontmatter rather than a bump. A `patch` here would version-bump the whole fixed +package group for a change no consumer can observe. + +objectui#9191: the test-path bullet declared the two-argument `new URL(…, import.meta.url)` +form fatal on a named mechanism — Vite rewriting it to an `http://localhost:3000/@fs/…` URL on +which `fileURLToPath` throws `ERR_INVALID_URL_SCHEME` under both cwds, taking the suite down. +Re-measured against every project `vitest.config.mts` declares (`unit` on node; `dom`, +`dom-heavy` and `dist` on happy-dom; the `apps/console` project with its full plugin set) under +both the repo-root and the package-directory invocation: it does not reproduce. `import.meta.url` +is a `file:` URL in each of them, the derived path resolves and the read succeeds. + +The prescription is kept — one spelling only, the bare `import.meta.url` form PR objectui#7796 +landed and objectui#7806 reused — but it now rests on spelling uniqueness rather than on a +hazard this tree does not exhibit. The bullet's ⚠️ is corrected in the same hunk: the +`process.cwd()` class it said nothing could stop is gated today by +`scripts/check-test-path-roots.mjs`, which deliberately does not flag this spelling. diff --git a/AGENTS.md b/AGENTS.md index 8f8ceba5c3..57c5eb4100 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -233,10 +233,12 @@ AGENTS.md 的「只跑受影响的包」指的是**用上面的路径过滤缩 objectui#7791(PR #7796)同一个文件仓根 `7 passed`、包级 `2 failed / 5 passed`,cwd 是唯一 变量;objectui#7799(PR #7806)按 `packages/*/src` 普查,命中 19 个同类、13 个确有缺陷。 拼法用 PR #7796 落地、#7806 沿用的那一个:从**裸** `import.meta.url` 逐段上溯到仓根, - ⛔ 不引入第三种;⛔ 尤其别写 `new URL(<相对路径>, import.meta.url)` —— 本仓的测试变换里它被 - Vite 重写成 `http://localhost:3000/@fs/…`,`fileURLToPath` 在**两种 cwd 下都**抛 - `ERR_INVALID_URL_SCHEME`,那是把一次假红换成整个套件根本加载不起来。 - ⚠️ **这一条今天没有任何门拦得住**:#7799 修掉的是 13 个实例,不是这一类。 + ⛔ 不引入第三种;`new URL(<相对路径>, import.meta.url)` 就是第三种,别写 —— 但理由只是「拼法唯一」。 + 这里曾断言它被 Vite 重写成 `http://localhost:3000/@fs/…`、`fileURLToPath` 在**两种 cwd 下都**抛 + `ERR_INVALID_URL_SCHEME`;objectui#9191 按 `vitest.config.mts` 声明的每个 project 逐一实测,未能复现 + —— node 与 happy-dom 两种 environment、两种 cwd 下 `import.meta.url` 都是 `file:` URL,文件读得到。 + `@fs` 那个形状是 Vite dev-server/浏览器变换的产物,本仓测试不声明 browser mode,不走那条路。 + ⚠️ **`process.cwd()` 那一类已由 `pnpm check:test-path-roots` 拦下,这个拼法它按设计不拦**(理由写在该脚本头部)。 ### 测试纪律(flaky 测试:先找竞态,别调超时)