@vertesia/build-tools 1.6.0-dev.20261022.120426Z → 1.6.0-dev.20261120.123957Z

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,11 +6,11 @@ JavaScript modules, with schema validation.
6
6
 
7
7
  Ships three entry points:
8
8
 
9
- | Entry point | Used for |
10
- | ----------- | -------- |
11
- | `vertesia-build` CLI | Build-time. Runs as a post-`tsc` step over the emitted `lib/`. |
12
- | `@vertesia/build-tools/vite` | Dev-time. Same transformers applied to sources at request time. |
13
- | `@vertesia/build-tools` | Programmatic. `transformImports()`, the transformers, the skill preprocessor. |
9
+ | Entry point | Used for |
10
+ | ---------------------------- | ----------------------------------------------------------------------------- |
11
+ | `vertesia-build` CLI | Build-time. Runs as a post-`tsc` step over the emitted `lib/`. |
12
+ | `@vertesia/build-tools/vite` | Dev-time. Same transformers applied to sources at request time. |
13
+ | `@vertesia/build-tools` | Programmatic. `transformImports()`, the transformers, the skill preprocessor. |
14
14
 
15
15
  > **Not a bundler plugin.** Earlier versions of this package were a Rollup plugin
16
16
  > (`vertesiaImportPlugin`). It is now a standalone post-`tsc` transformer: it reads the JavaScript
@@ -84,16 +84,16 @@ set. Asset copying and widget bundling are build-time concerns and are skipped i
84
84
 
85
85
  ## Transformers
86
86
 
87
- | Name | Matches | Produces |
88
- | ---- | ------- | -------- |
89
- | `skill` | `*.md?skill`, `*/SKILL.md` | `SkillDefinition` object |
90
- | `skills` | `<dir>/<name>?skills` | Array of `SkillDefinition`, one per `SKILL.md` in the subdirectories |
91
- | `template` | `*.md?template`, `*/TEMPLATE.md` | `RenderingTemplateDefinition` |
92
- | `templates` | `<dir>/<name>?templates` | Array of rendering templates |
93
- | `prompt` | `*?prompt` | `PromptDefinition` |
94
- | `raw` | `*?raw` | The file contents as a string |
87
+ | Name | Matches | Produces |
88
+ | ----------- | -------------------------------- | -------------------------------------------------------------------- |
89
+ | `skill` | `*.md?skill`, `*/SKILL.md` | `SkillDefinition` object |
90
+ | `skills` | `<dir>/<name>?skills` | Array of `SkillDefinition`, one per `SKILL.md` in the subdirectories |
91
+ | `template` | `*.md?template`, `*/TEMPLATE.md` | `RenderingTemplateDefinition` |
92
+ | `templates` | `<dir>/<name>?templates` | Array of rendering templates |
93
+ | `prompt` | `*?prompt` | `PromptDefinition` |
94
+ | `raw` | `*?raw` | The file contents as a string |
95
95
 
96
- The two collection transformers are *virtual*: there is no file at `./all?skills`, the name before
96
+ The two collection transformers are _virtual_: there is no file at `./all?skills`, the name before
97
97
  the query is simply the generated module's name. That name is required, so two collections in the
98
98
  same directory cannot collide.
99
99
 
@@ -195,12 +195,12 @@ preprocessor makes the references explicit so the build can verify them.
195
195
 
196
196
  Four constructs, all optional:
197
197
 
198
- | Written | Rendered | Verified |
199
- | ------- | -------- | -------- |
200
- | `{@tool fetch_document}` | `` `fetch_document` `` | tool exists, name unambiguous |
201
- | `{@skill web_search}` | `` `learn_web_search` `` | skill exists, name unambiguous |
202
- | `{@param fetch_document.format}` | `` `format` `` | that tool's schema declares the field |
203
- | ` ```json tool=fetch_document ` | plain ` ```json ` fence | payload validates against the tool's schema |
198
+ | Written | Rendered | Verified |
199
+ | -------------------------------- | ------------------------ | ------------------------------------------- |
200
+ | `{@tool fetch_document}` | `` `fetch_document` `` | tool exists, name unambiguous |
201
+ | `{@skill web_search}` | `` `learn_web_search` `` | skill exists, name unambiguous |
202
+ | `{@param fetch_document.format}` | `` `format` `` | that tool's schema declares the field |
203
+ | ` ```json tool=fetch_document ` | plain ` ```json ` fence | payload validates against the tool's schema |
204
204
 
205
205
  ````markdown
206
206
  Call {@tool fetch_document} to load the object — {@param fetch_document.format} selects the
@@ -251,7 +251,7 @@ export const exampleLanguages = new Set(['json']); // default
251
251
  ```
252
252
 
253
253
  `createSchemaExampleValidator` (also exported from this package) validates a payload against the
254
- tool's AJV schema, and additionally resolves *dispatcher* fields — a `string` parameter that carries
254
+ tool's AJV schema, and additionally resolves _dispatcher_ fields — a `string` parameter that carries
255
255
  another tool's name, such as `batch_execute.tool_name` — which JSON Schema alone cannot check.
256
256
  `createSchemaFieldValidator` walks a `{@param …}` path through the same schemas, descending into
257
257
  `anyOf`/`oneOf`/`allOf` branches and following local `$ref`s (resolved against the innermost
@@ -268,15 +268,15 @@ fails, rather than shipping a raw `{@tool …}` to the model.
268
268
 
269
269
  All paths are resolved relative to the package directory.
270
270
 
271
- | Key | Type | Default | Meaning |
272
- | --- | ---- | ------- | ------- |
273
- | `libDir` | string | *required* | Root of the compiled output to transform. |
274
- | `srcDir` | string | *required* | Root of the sources, mirroring `libDir`. |
275
- | `transformers` | string[] | *required* | Names from the table above. Non-empty. |
276
- | `assetsDir` | string \| false | `libDir` | Where scripts and widgets are emitted; `false` disables both. |
277
- | `widgetsDir` | string | `'widgets'` | Sub-directory of `assetsDir` for widget bundles. |
278
- | `widgetConfig` | object | — | Options forwarded to the esbuild widget bundler, e.g. `{ "minify": true }`. |
279
- | `skillCatalog` | string | — | Module supplying `{ tools, skills, … }` for the preprocessor. |
271
+ | Key | Type | Default | Meaning |
272
+ | -------------- | --------------- | ----------- | --------------------------------------------------------------------------- |
273
+ | `libDir` | string | _required_ | Root of the compiled output to transform. |
274
+ | `srcDir` | string | _required_ | Root of the sources, mirroring `libDir`. |
275
+ | `transformers` | string[] | _required_ | Names from the table above. Non-empty. |
276
+ | `assetsDir` | string \| false | `libDir` | Where scripts and widgets are emitted; `false` disables both. |
277
+ | `widgetsDir` | string | `'widgets'` | Sub-directory of `assetsDir` for widget bundles. |
278
+ | `widgetConfig` | object | — | Options forwarded to the esbuild widget bundler, e.g. `{ "minify": true }`. |
279
+ | `skillCatalog` | string | — | Module supplying `{ tools, skills, … }` for the preprocessor. |
280
280
 
281
281
  ## Programmatic API
282
282
 
@@ -336,13 +336,13 @@ await transformImports({
336
336
 
337
337
  `transform` returns a `TransformResult`:
338
338
 
339
- | Field | Meaning |
340
- | ----- | ------- |
341
- | `data` | Value to export as the module default (serialized to JSON). |
342
- | `code` | Custom module source, used *instead* of the JSON export. |
339
+ | Field | Meaning |
340
+ | --------- | ---------------------------------------------------------------- |
341
+ | `data` | Value to export as the module default (serialized to JSON). |
342
+ | `code` | Custom module source, used _instead_ of the JSON export. |
343
343
  | `imports` | Extra import lines to inject at the top of the generated module. |
344
- | `assets` | Files to copy into `assetsDir`. |
345
- | `widgets` | Widget entries to bundle. |
344
+ | `assets` | Files to copy into `assetsDir`. |
345
+ | `widgets` | Widget entries to bundle. |
346
346
 
347
347
  Set `virtual: true` on the rule when the specifier does not name a real file, as the collection
348
348
  transformers do.
@@ -351,7 +351,7 @@ transformers do.
351
351
 
352
352
  1. **Scan** — walk `libDir` for `.js` files containing a query-import marker.
353
353
  2. **Detect** — lex each file with `es-module-lexer` and match the specifiers against the
354
- transformers. A real lexer rather than a regex, because a regex matches anything that *looks*
354
+ transformers. A real lexer rather than a regex, because a regex matches anything that _looks_
355
355
  like a specifier: a doc comment mentioning `` `?skill` ``, or a plain constant holding a path,
356
356
  were both picked up as imports.
357
357
  3. **Resolve** — map the specifier back to its source asset under `srcDir`.
@@ -29,7 +29,7 @@
29
29
  * vertesiaDevServerPlugin({ transformers: ['skill', 'raw'] });
30
30
  * ```
31
31
  */
32
- import type { Plugin } from 'vite';
32
+ import { type Plugin } from 'vite';
33
33
  import type { PreprocessSkillMarkdownOptions } from '../core/skill-markdown/preprocess.js';
34
34
  export interface VertesiaDevServerPluginOptions {
35
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/vite/dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAK3F,MAAM,WAAW,8BAA8B;IAC3C;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAEjC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,8BAA8B,GAAG,KAAK,CAAC;CAClE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,8BAAmC,GAAG,MAAM,CAuG5F"}
1
+ {"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/vite/dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAElD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAK3F,MAAM,WAAW,8BAA8B;IAC3C;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAEjC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,8BAA8B,GAAG,KAAK,CAAC;CAClE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,8BAAmC,GAAG,MAAM,CAkH5F"}
@@ -29,8 +29,9 @@
29
29
  * vertesiaDevServerPlugin({ transformers: ['skill', 'raw'] });
30
30
  * ```
31
31
  */
32
- import { readFileSync } from 'node:fs';
32
+ import { existsSync, readFileSync } from 'node:fs';
33
33
  import path from 'node:path';
34
+ import { normalizePath } from 'vite';
34
35
  import { loadSkillCatalog, readPackageJson, resolveSkillCatalogPath } from '../core/skill-markdown/load-catalog.js';
35
36
  import { createSkillTransformer, isSkillTransformer } from '../core/transformers/skill.js';
36
37
  import { BUILTIN_TRANSFORMER_NAMES, resolveTransformerNames } from '../import-transform/builtins.js';
@@ -39,7 +40,7 @@ export function vertesiaDevServerPlugin(options = {}) {
39
40
  const transformers = resolveTransformerNames([...names]);
40
41
  // Resolved once, lazily: the catalog module is compiled output, so it may not exist when the
41
42
  // config is first evaluated.
42
- let root = process.cwd();
43
+ let root = normalizePath(process.cwd());
43
44
  let boundPromise;
44
45
  /** The catalog-bound skill transformer, or null when this package configures no catalog. */
45
46
  const boundSkillTransformer = () => {
@@ -65,31 +66,43 @@ export function vertesiaDevServerPlugin(options = {}) {
65
66
  enforce: 'pre',
66
67
  configResolved(config) {
67
68
  if (config.root)
68
- root = config.root;
69
+ root = normalizePath(config.root);
69
70
  },
70
71
  /**
71
- * Map relative query-style imports to absolute paths so Vite's loader
72
- * sees a stable id keyed by the original file location. The query
73
- * suffix is preserved in the id and used by `load` to pick the right
74
- * transformer.
72
+ * Map relative and root-relative query-style imports to absolute paths so Vite's loader
73
+ * sees a stable id keyed by the original file location. The query suffix is preserved in
74
+ * the id and used by `load` to pick the right transformer.
75
75
  */
76
76
  resolveId(source, importer) {
77
77
  for (const transformer of transformers) {
78
78
  if (!transformer.pattern.test(source))
79
79
  continue;
80
+ const suffix = source.match(transformer.pattern)?.[0] ?? '';
81
+ // `/@fs/<abs>` is Vite's URL for a file outside the root; this hook runs before
82
+ // Vite's resolver, so the prefix is still on the id here.
83
+ let base = source.slice(0, source.length - suffix.length);
84
+ if (base.startsWith(FS_PREFIX)) {
85
+ // Keep the leading `/` of a POSIX path, but not before a Windows drive letter.
86
+ const fsPath = base.slice(FS_PREFIX.length);
87
+ base = WINDOWS_VOLUME.test(fsPath) ? fsPath : `/${fsPath}`;
88
+ }
80
89
  // Only relative specifiers can be resolved meaningfully against an importer.
81
- if (source.startsWith('.') && importer) {
82
- const cleanSource = source.replace(transformer.pattern, '');
83
- const cleanImporter = importer.includes('?')
84
- ? importer.substring(0, importer.indexOf('?'))
85
- : importer;
86
- const baseDir = path.dirname(cleanImporter);
87
- const resolved = path.resolve(baseDir, cleanSource);
88
- const suffix = source.match(transformer.pattern)?.[0] ?? '';
89
- return resolved + suffix;
90
+ if (base.startsWith('.') && importer) {
91
+ base = normalizePath(path.resolve(path.dirname(stripQuery(importer)), base));
92
+ }
93
+ // Vite also requests modules by their root-relative URL (`/src/x.md?skill`), e.g.
94
+ // when it replays a cached transform, and may hand such a URL over as the importer
95
+ // of a relative import. Like Vite's own resolver, read a `/` id under the root
96
+ // first, and as a filesystem path only when nothing exists there.
97
+ if (base.startsWith('/') && !base.startsWith(`${root}/`)) {
98
+ const underRoot = normalizePath(path.join(root, base)) + suffix;
99
+ // A collection id names a module that does not exist inside the directory it scans.
100
+ const target = transformer.virtual ? path.dirname(stripQuery(underRoot)) : stripQuery(underRoot);
101
+ if (existsSync(target))
102
+ return underRoot;
90
103
  }
91
104
  // Bare or absolute matches are returned as-is.
92
- return source;
105
+ return base + suffix;
93
106
  }
94
107
  return null;
95
108
  },
@@ -129,6 +142,9 @@ export function vertesiaDevServerPlugin(options = {}) {
129
142
  },
130
143
  };
131
144
  }
145
+ // Vite's prefix for ids outside the root; it is not part of Vite's public exports.
146
+ const FS_PREFIX = '/@fs/';
147
+ const WINDOWS_VOLUME = /^[A-Za-z]:/;
132
148
  function findMatchingTransformer(id, transformers) {
133
149
  for (const t of transformers) {
134
150
  if (t.pattern.test(id))
@@ -1 +1 @@
1
- {"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../../src/vite/dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEpH,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAqBrG,MAAM,UAAU,uBAAuB,CAAC,OAAO,GAAmC,EAAE;IAChF,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,IAAI,yBAAyB,CAAC;IAChE,MAAM,YAAY,GAAG,uBAAuB,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC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ED,mFAAmF;AACnF,MAAM,SAAS,GAAG,OAAO,CAAC;AAC1B,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,SAAS,uBAAuB,CAAC,EAAU,EAAE,YAA+B;IACxE,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,EAAU;IAC1B,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertesia/build-tools",
3
- "version": "1.6.0-dev.20261022.120426Z",
3
+ "version": "1.6.0-dev.20261120.123957Z",
4
4
  "description": "Build tools for Vertesia projects - import transformers (skill / template / prompt / raw), esbuild widget bundler, vertesia-build CLI, and a Vite dev plugin",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -25,27 +25,27 @@
25
25
  }
26
26
  },
27
27
  "devDependencies": {
28
- "@hono/node-server": "^2.1.5",
28
+ "@hono/node-server": "^2.1.6",
29
29
  "@types/js-yaml": "^4.0.9",
30
30
  "@types/node": "^24.19.2",
31
31
  "@vertesia/tsconfig": "0.1.0",
32
32
  "typescript": "7.0.2",
33
- "vite": "8.3.4",
34
- "vitest": "5.0.4"
33
+ "vite": "8.3.5",
34
+ "vitest": "5.1.0"
35
35
  },
36
36
  "dependencies": {
37
- "@llumiverse/common": "1.6.0-dev.20261022.120426Z",
38
- "@vertesia/common": "1.6.0-dev.20261022.120426Z",
39
- "@vertesia/studio-utils": "1.6.0-dev.20261022.120426Z",
37
+ "@llumiverse/common": "1.6.0-dev.20261120.123957Z",
38
+ "@vertesia/common": "1.6.0-dev.20261120.123957Z",
39
+ "@vertesia/studio-utils": "1.6.0-dev.20261120.123957Z",
40
40
  "ajv": "^8.20.0",
41
- "es-module-lexer": "^3.0.3",
41
+ "es-module-lexer": "^3.0.4",
42
42
  "esbuild": "^0.28.2",
43
- "js-yaml": "^5.4.3",
43
+ "js-yaml": "^5.5.0",
44
44
  "zod": "4.6.7"
45
45
  },
46
46
  "peerDependencies": {
47
- "@hono/node-server": "^2.1.5",
48
- "vite": "^8.3.4"
47
+ "@hono/node-server": "^2.1.6",
48
+ "vite": "^8.3.5"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "@hono/node-server": {
@@ -76,11 +76,11 @@
76
76
  "zod",
77
77
  "validation"
78
78
  ],
79
- "gitHead": "bcaa7879b601ce9ccc394bcd3257822da13869cd",
79
+ "gitHead": "175a3f272cae5dc0273eff3fd198463106331045",
80
80
  "releaseIdentity": {
81
- "source_sha": "bcaa7879b601ce9ccc394bcd3257822da13869cd",
82
- "dependency_sha": "93466e47b06db23ac3c800e248d170afe65e5006",
83
- "lock_sha256": "117e1c8068aa07d59117323a51ceccfc96cab543e50c03eb7efc19709d6f5e6b"
81
+ "source_sha": "175a3f272cae5dc0273eff3fd198463106331045",
82
+ "dependency_sha": "b44c036a234f16aeba50fd4fb810121ac7dbf59f",
83
+ "lock_sha256": "e43dc89b7d72f8da4ece104946da392bfbb1376c67a47c4ab03a11eda2946ba8"
84
84
  },
85
85
  "scripts": {
86
86
  "lint": "biome lint src",
@@ -30,9 +30,9 @@
30
30
  * ```
31
31
  */
32
32
 
33
- import { readFileSync } from 'node:fs';
33
+ import { existsSync, readFileSync } from 'node:fs';
34
34
  import path from 'node:path';
35
- import type { Plugin } from 'vite';
35
+ import { normalizePath, type Plugin } from 'vite';
36
36
  import { loadSkillCatalog, readPackageJson, resolveSkillCatalogPath } from '../core/skill-markdown/load-catalog.js';
37
37
  import type { PreprocessSkillMarkdownOptions } from '../core/skill-markdown/preprocess.js';
38
38
  import { createSkillTransformer, isSkillTransformer } from '../core/transformers/skill.js';
@@ -64,7 +64,7 @@ export function vertesiaDevServerPlugin(options: VertesiaDevServerPluginOptions
64
64
 
65
65
  // Resolved once, lazily: the catalog module is compiled output, so it may not exist when the
66
66
  // config is first evaluated.
67
- let root = process.cwd();
67
+ let root = normalizePath(process.cwd());
68
68
 
69
69
  let boundPromise: Promise<TransformerRule | null> | undefined;
70
70
 
@@ -94,31 +94,42 @@ export function vertesiaDevServerPlugin(options: VertesiaDevServerPluginOptions
94
94
  enforce: 'pre',
95
95
 
96
96
  configResolved(config: { root?: string }) {
97
- if (config.root) root = config.root;
97
+ if (config.root) root = normalizePath(config.root);
98
98
  },
99
99
 
100
100
  /**
101
- * Map relative query-style imports to absolute paths so Vite's loader
102
- * sees a stable id keyed by the original file location. The query
103
- * suffix is preserved in the id and used by `load` to pick the right
104
- * transformer.
101
+ * Map relative and root-relative query-style imports to absolute paths so Vite's loader
102
+ * sees a stable id keyed by the original file location. The query suffix is preserved in
103
+ * the id and used by `load` to pick the right transformer.
105
104
  */
106
105
  resolveId(source: string, importer: string | undefined) {
107
106
  for (const transformer of transformers) {
108
107
  if (!transformer.pattern.test(source)) continue;
108
+ const suffix = source.match(transformer.pattern)?.[0] ?? '';
109
+ // `/@fs/<abs>` is Vite's URL for a file outside the root; this hook runs before
110
+ // Vite's resolver, so the prefix is still on the id here.
111
+ let base = source.slice(0, source.length - suffix.length);
112
+ if (base.startsWith(FS_PREFIX)) {
113
+ // Keep the leading `/` of a POSIX path, but not before a Windows drive letter.
114
+ const fsPath = base.slice(FS_PREFIX.length);
115
+ base = WINDOWS_VOLUME.test(fsPath) ? fsPath : `/${fsPath}`;
116
+ }
109
117
  // Only relative specifiers can be resolved meaningfully against an importer.
110
- if (source.startsWith('.') && importer) {
111
- const cleanSource = source.replace(transformer.pattern, '');
112
- const cleanImporter = importer.includes('?')
113
- ? importer.substring(0, importer.indexOf('?'))
114
- : importer;
115
- const baseDir = path.dirname(cleanImporter);
116
- const resolved = path.resolve(baseDir, cleanSource);
117
- const suffix = source.match(transformer.pattern)?.[0] ?? '';
118
- return resolved + suffix;
118
+ if (base.startsWith('.') && importer) {
119
+ base = normalizePath(path.resolve(path.dirname(stripQuery(importer)), base));
120
+ }
121
+ // Vite also requests modules by their root-relative URL (`/src/x.md?skill`), e.g.
122
+ // when it replays a cached transform, and may hand such a URL over as the importer
123
+ // of a relative import. Like Vite's own resolver, read a `/` id under the root
124
+ // first, and as a filesystem path only when nothing exists there.
125
+ if (base.startsWith('/') && !base.startsWith(`${root}/`)) {
126
+ const underRoot = normalizePath(path.join(root, base)) + suffix;
127
+ // A collection id names a module that does not exist inside the directory it scans.
128
+ const target = transformer.virtual ? path.dirname(stripQuery(underRoot)) : stripQuery(underRoot);
129
+ if (existsSync(target)) return underRoot;
119
130
  }
120
131
  // Bare or absolute matches are returned as-is.
121
- return source;
132
+ return base + suffix;
122
133
  }
123
134
  return null;
124
135
  },
@@ -163,6 +174,10 @@ export function vertesiaDevServerPlugin(options: VertesiaDevServerPluginOptions
163
174
  };
164
175
  }
165
176
 
177
+ // Vite's prefix for ids outside the root; it is not part of Vite's public exports.
178
+ const FS_PREFIX = '/@fs/';
179
+ const WINDOWS_VOLUME = /^[A-Za-z]:/;
180
+
166
181
  function findMatchingTransformer(id: string, transformers: TransformerRule[]): TransformerRule | undefined {
167
182
  for (const t of transformers) {
168
183
  if (t.pattern.test(id)) return t;