@analogjs/vite-plugin-angular 3.0.0-alpha.44 → 3.0.0-alpha.46

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.
@@ -1,24 +1,7 @@
1
- import { type ResolvedConfig } from "vite";
2
1
  interface PluginContextLike {
3
2
  addWatchFile(path: string): void;
4
3
  }
5
4
  /**
6
- * True when the given stylesheet should be run through Vite's `preprocessCSS`,
7
- * given Vitest's `test.css` semantics:
8
- *
9
- * - non-test contexts → always preprocess
10
- * - `test.css: true` → always preprocess
11
- * - `test.css: false` → never preprocess
12
- * - `test.css: { include }` → preprocess only when `filePath` matches an
13
- * include pattern and isn't excluded
14
- * - `test.css` unset → Vitest defaults to `include: []`, so nothing
15
- * matches and we don't preprocess
16
- *
17
- * Used to gate `preprocessCSS` calls in test mode so we don't surface SCSS
18
- * deprecation noise or pay preprocessing cost the user didn't ask for. (#2297)
19
- */
20
- export declare function shouldPreprocessTestCss(config: ResolvedConfig | undefined, filePath?: string): boolean;
21
- /**
22
5
  * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined
23
6
  * when the id doesn't match, so callers can fall through to the next check.
24
7
  *
@@ -28,20 +11,9 @@ export declare function shouldPreprocessTestCss(config: ResolvedConfig | undefin
28
11
  */
29
12
  export declare function rewriteHtmlRawImport(id: string, importer: string | undefined): string | undefined;
30
13
  /**
31
- * Rewrite a user `.scss?inline` / `.css?inline` / … import to a virtual
32
- * style id. Returns undefined when the id doesn't match.
33
- */
34
- export declare function rewriteInlineStyleImport(id: string, importer: string | undefined): string | undefined;
35
- /**
36
14
  * Load a virtual raw module: reads the backing file, registers it for HMR
37
15
  * watching, and returns its content as a default-exported string. Returns
38
16
  * undefined when the id is not a virtual raw id.
39
17
  */
40
18
  export declare function loadVirtualRawModule(ctx: PluginContextLike, id: string): Promise<string | undefined>;
41
- /**
42
- * Load a virtual style module: reads the backing stylesheet, runs it through
43
- * Vite's CSS preprocessor, and returns the result as a default-exported
44
- * string. Returns undefined when the id is not a virtual style id.
45
- */
46
- export declare function loadVirtualStyleModule(ctx: PluginContextLike, id: string, resolvedConfig: ResolvedConfig): Promise<string | undefined>;
47
19
  export {};
@@ -1,34 +1,24 @@
1
- import { fromVirtualRawId, fromVirtualStyleId, isVirtualRawId, isVirtualStyleId } from "./virtual-ids.js";
1
+ import { fromVirtualRawId, isVirtualRawId, toVirtualRawId } from "./virtual-ids.js";
2
2
  import { promises } from "node:fs";
3
- import "node:path";
4
- import { preprocessCSS } from "vite";
3
+ import { dirname, isAbsolute, resolve } from "node:path";
4
+ import { normalizePath } from "vite";
5
5
  //#region packages/vite-plugin-angular/src/lib/utils/virtual-resources.ts
6
+ function resolveImportPath(id, importer) {
7
+ const filePath = id.split("?")[0];
8
+ return isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
9
+ }
6
10
  /**
7
- * True when the given stylesheet should be run through Vite's `preprocessCSS`,
8
- * given Vitest's `test.css` semantics:
9
- *
10
- * - non-test contexts → always preprocess
11
- * - `test.css: true` → always preprocess
12
- * - `test.css: false` → never preprocess
13
- * - `test.css: { include }` → preprocess only when `filePath` matches an
14
- * include pattern and isn't excluded
15
- * - `test.css` unset → Vitest defaults to `include: []`, so nothing
16
- * matches and we don't preprocess
11
+ * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined
12
+ * when the id doesn't match, so callers can fall through to the next check.
17
13
  *
18
- * Used to gate `preprocessCSS` calls in test mode so we don't surface SCSS
19
- * deprecation noise or pay preprocessing cost the user didn't ask for. (#2297)
14
+ * Routed through a virtual id (rather than `?analog-raw`) so the path Vite
15
+ * sees has no file extension keeps vite:asset / vite:css from re-tagging
16
+ * the id before our load hook runs.
20
17
  */
21
- function shouldPreprocessTestCss(config, filePath) {
22
- if (!(process.env.NODE_ENV === "test" || !!process.env["VITEST"])) return true;
23
- const cssOpt = config?.test?.css;
24
- if (cssOpt === true) return true;
25
- if (cssOpt === false || cssOpt == null) return false;
26
- const toArray = (value) => value == null ? [] : Array.isArray(value) ? value : [value];
27
- const include = toArray(cssOpt.include);
28
- const exclude = toArray(cssOpt.exclude);
29
- if (!filePath || include.length === 0) return false;
30
- const matches = (patterns) => patterns.some((p) => typeof p === "string" ? filePath.includes(p) : p.test(filePath));
31
- return matches(include) && !matches(exclude);
18
+ function rewriteHtmlRawImport(id, importer) {
19
+ if (!id.includes(".html?raw")) return void 0;
20
+ const resolved = resolveImportPath(id, importer);
21
+ return resolved ? toVirtualRawId(resolved) : void 0;
32
22
  }
33
23
  /**
34
24
  * Load a virtual raw module: reads the backing file, registers it for HMR
@@ -42,21 +32,7 @@ async function loadVirtualRawModule(ctx, id) {
42
32
  const content = await promises.readFile(filePath, "utf-8");
43
33
  return `export default ${JSON.stringify(content)}`;
44
34
  }
45
- /**
46
- * Load a virtual style module: reads the backing stylesheet, runs it through
47
- * Vite's CSS preprocessor, and returns the result as a default-exported
48
- * string. Returns undefined when the id is not a virtual style id.
49
- */
50
- async function loadVirtualStyleModule(ctx, id, resolvedConfig) {
51
- if (!isVirtualStyleId(id)) return void 0;
52
- const filePath = fromVirtualStyleId(id);
53
- ctx.addWatchFile(filePath);
54
- const code = await promises.readFile(filePath, "utf-8");
55
- if (!shouldPreprocessTestCss(resolvedConfig, filePath)) return `export default ${JSON.stringify(code)}`;
56
- const result = await preprocessCSS(code, filePath, resolvedConfig);
57
- return `export default ${JSON.stringify(result.code)}`;
58
- }
59
35
  //#endregion
60
- export { loadVirtualRawModule, loadVirtualStyleModule, shouldPreprocessTestCss };
36
+ export { loadVirtualRawModule, rewriteHtmlRawImport };
61
37
 
62
38
  //# sourceMappingURL=virtual-resources.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-resources.js","names":[],"sources":["../../../../src/lib/utils/virtual-resources.ts"],"sourcesContent":["// Shared Vite plugin helpers for routing component resources (templates,\n// external styles) through virtual module ids. Both angular-vite-plugin and\n// fast-compile-plugin use these so the rewriting + loading behavior stays\n// in sync between them.\n\nimport { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, preprocessCSS, type ResolvedConfig } from 'vite';\n\nimport {\n fromVirtualRawId,\n fromVirtualStyleId,\n isVirtualRawId,\n isVirtualStyleId,\n toVirtualRawId,\n toVirtualStyleId,\n} from './virtual-ids.js';\n\nconst INLINE_STYLE_QUERY_RE = /\\.(css|scss|sass|less)\\?inline$/;\n\ninterface PluginContextLike {\n addWatchFile(path: string): void;\n}\n\ntype CssPattern = string | RegExp;\n\ntype VitestCssOption =\n | boolean\n | undefined\n | {\n // Vitest accepts both single patterns and arrays for include/exclude.\n include?: CssPattern | CssPattern[];\n exclude?: CssPattern | CssPattern[];\n };\n\n/**\n * True when the given stylesheet should be run through Vite's `preprocessCSS`,\n * given Vitest's `test.css` semantics:\n *\n * - non-test contexts → always preprocess\n * - `test.css: true` → always preprocess\n * - `test.css: false` → never preprocess\n * - `test.css: { include }` → preprocess only when `filePath` matches an\n * include pattern and isn't excluded\n * - `test.css` unset → Vitest defaults to `include: []`, so nothing\n * matches and we don't preprocess\n *\n * Used to gate `preprocessCSS` calls in test mode so we don't surface SCSS\n * deprecation noise or pay preprocessing cost the user didn't ask for. (#2297)\n */\nexport function shouldPreprocessTestCss(\n config: ResolvedConfig | undefined,\n filePath?: string,\n): boolean {\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n if (!isTest) return true;\n\n const cssOpt = (\n config as\n | (ResolvedConfig & { test?: { css?: VitestCssOption } })\n | undefined\n )?.test?.css;\n\n if (cssOpt === true) return true;\n if (cssOpt === false || cssOpt == null) return false;\n\n const toArray = <T>(value: T | T[] | undefined): T[] =>\n value == null ? [] : Array.isArray(value) ? value : [value];\n const include = toArray(cssOpt.include);\n const exclude = toArray(cssOpt.exclude);\n if (!filePath || include.length === 0) return false;\n\n const matches = (patterns: CssPattern[]) =>\n patterns.some((p) =>\n typeof p === 'string' ? filePath.includes(p) : p.test(filePath),\n );\n\n return matches(include) && !matches(exclude);\n}\n\nfunction resolveImportPath(\n id: string,\n importer: string | undefined,\n): string | undefined {\n const filePath = id.split('?')[0];\n return isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n}\n\n/**\n * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined\n * when the id doesn't match, so callers can fall through to the next check.\n *\n * Routed through a virtual id (rather than `?analog-raw`) so the path Vite\n * sees has no file extension — keeps vite:asset / vite:css from re-tagging\n * the id before our load hook runs.\n */\nexport function rewriteHtmlRawImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!id.includes('.html?raw')) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualRawId(resolved) : undefined;\n}\n\n/**\n * Rewrite a user `.scss?inline` / `.css?inline` / … import to a virtual\n * style id. Returns undefined when the id doesn't match.\n */\nexport function rewriteInlineStyleImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!INLINE_STYLE_QUERY_RE.test(id)) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualStyleId(resolved) : undefined;\n}\n\n/**\n * Load a virtual raw module: reads the backing file, registers it for HMR\n * watching, and returns its content as a default-exported string. Returns\n * undefined when the id is not a virtual raw id.\n */\nexport async function loadVirtualRawModule(\n ctx: PluginContextLike,\n id: string,\n): Promise<string | undefined> {\n if (!isVirtualRawId(id)) return undefined;\n const filePath = fromVirtualRawId(id);\n ctx.addWatchFile(filePath);\n const content = await fsPromises.readFile(filePath, 'utf-8');\n return `export default ${JSON.stringify(content)}`;\n}\n\n/**\n * Load a virtual style module: reads the backing stylesheet, runs it through\n * Vite's CSS preprocessor, and returns the result as a default-exported\n * string. Returns undefined when the id is not a virtual style id.\n */\nexport async function loadVirtualStyleModule(\n ctx: PluginContextLike,\n id: string,\n resolvedConfig: ResolvedConfig,\n): Promise<string | undefined> {\n if (!isVirtualStyleId(id)) return undefined;\n const filePath = fromVirtualStyleId(id);\n ctx.addWatchFile(filePath);\n const code = await fsPromises.readFile(filePath, 'utf-8');\n // In tests, mirror Vitest's `test.css` rules — defaults to no preprocessing\n // (matches Vite's CSS pipeline behavior under Vitest). (#2297)\n if (!shouldPreprocessTestCss(resolvedConfig, filePath)) {\n return `export default ${JSON.stringify(code)}`;\n }\n const result = await preprocessCSS(code, filePath, resolvedConfig);\n return `export default ${JSON.stringify(result.code)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,wBACd,QACA,UACS;AAET,KAAI,EAAA,QAAA,IAAA,aADuC,UAAU,CAAC,CAAC,QAAQ,IAAI,WACtD,QAAO;CAEpB,MAAM,SACJ,QAGC,MAAM;AAET,KAAI,WAAW,KAAM,QAAO;AAC5B,KAAI,WAAW,SAAS,UAAU,KAAM,QAAO;CAE/C,MAAM,WAAc,UAClB,SAAS,OAAO,EAAE,GAAG,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;CAC7D,MAAM,UAAU,QAAQ,OAAO,QAAQ;CACvC,MAAM,UAAU,QAAQ,OAAO,QAAQ;AACvC,KAAI,CAAC,YAAY,QAAQ,WAAW,EAAG,QAAO;CAE9C,MAAM,WAAW,aACf,SAAS,MAAM,MACb,OAAO,MAAM,WAAW,SAAS,SAAS,EAAE,GAAG,EAAE,KAAK,SAAS,CAChE;AAEH,QAAO,QAAQ,QAAQ,IAAI,CAAC,QAAQ,QAAQ;;;;;;;AAkD9C,eAAsB,qBACpB,KACA,IAC6B;AAC7B,KAAI,CAAC,eAAe,GAAG,CAAE,QAAO,KAAA;CAChC,MAAM,WAAW,iBAAiB,GAAG;AACrC,KAAI,aAAa,SAAS;CAC1B,MAAM,UAAU,MAAM,SAAW,SAAS,UAAU,QAAQ;AAC5D,QAAO,kBAAkB,KAAK,UAAU,QAAQ;;;;;;;AAQlD,eAAsB,uBACpB,KACA,IACA,gBAC6B;AAC7B,KAAI,CAAC,iBAAiB,GAAG,CAAE,QAAO,KAAA;CAClC,MAAM,WAAW,mBAAmB,GAAG;AACvC,KAAI,aAAa,SAAS;CAC1B,MAAM,OAAO,MAAM,SAAW,SAAS,UAAU,QAAQ;AAGzD,KAAI,CAAC,wBAAwB,gBAAgB,SAAS,CACpD,QAAO,kBAAkB,KAAK,UAAU,KAAK;CAE/C,MAAM,SAAS,MAAM,cAAc,MAAM,UAAU,eAAe;AAClE,QAAO,kBAAkB,KAAK,UAAU,OAAO,KAAK"}
1
+ {"version":3,"file":"virtual-resources.js","names":[],"sources":["../../../../src/lib/utils/virtual-resources.ts"],"sourcesContent":["// Shared Vite plugin helpers for routing component resources (templates)\n// through virtual module ids. Both angular-vite-plugin and fast-compile-plugin\n// use these so the rewriting + loading behavior stays in sync between them.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids.\n\nimport { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\n\nimport {\n fromVirtualRawId,\n isVirtualRawId,\n toVirtualRawId,\n} from './virtual-ids.js';\n\ninterface PluginContextLike {\n addWatchFile(path: string): void;\n}\n\nfunction resolveImportPath(\n id: string,\n importer: string | undefined,\n): string | undefined {\n const filePath = id.split('?')[0];\n return isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n}\n\n/**\n * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined\n * when the id doesn't match, so callers can fall through to the next check.\n *\n * Routed through a virtual id (rather than `?analog-raw`) so the path Vite\n * sees has no file extension — keeps vite:asset / vite:css from re-tagging\n * the id before our load hook runs.\n */\nexport function rewriteHtmlRawImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!id.includes('.html?raw')) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualRawId(resolved) : undefined;\n}\n\n/**\n * Load a virtual raw module: reads the backing file, registers it for HMR\n * watching, and returns its content as a default-exported string. Returns\n * undefined when the id is not a virtual raw id.\n */\nexport async function loadVirtualRawModule(\n ctx: PluginContextLike,\n id: string,\n): Promise<string | undefined> {\n if (!isVirtualRawId(id)) return undefined;\n const filePath = fromVirtualRawId(id);\n ctx.addWatchFile(filePath);\n const content = await fsPromises.readFile(filePath, 'utf-8');\n return `export default ${JSON.stringify(content)}`;\n}\n"],"mappings":";;;;;AAsBA,SAAS,kBACP,IACA,UACoB;CACpB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAC/B,QAAO,WAAW,SAAS,GACvB,cAAc,SAAS,GACvB,WACE,cAAc,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GACnD,KAAA;;;;;;;;;;AAWR,SAAgB,qBACd,IACA,UACoB;AACpB,KAAI,CAAC,GAAG,SAAS,YAAY,CAAE,QAAO,KAAA;CACtC,MAAM,WAAW,kBAAkB,IAAI,SAAS;AAChD,QAAO,WAAW,eAAe,SAAS,GAAG,KAAA;;;;;;;AAQ/C,eAAsB,qBACpB,KACA,IAC6B;AAC7B,KAAI,CAAC,eAAe,GAAG,CAAE,QAAO,KAAA;CAChC,MAAM,WAAW,iBAAiB,GAAG;AACrC,KAAI,aAAa,SAAS;CAC1B,MAAM,UAAU,MAAM,SAAW,SAAS,UAAU,QAAQ;AAC5D,QAAO,kBAAkB,KAAK,UAAU,QAAQ"}
@@ -1,46 +1,19 @@
1
- import { toVirtualRawId, toVirtualStyleId } from "./utils/virtual-ids.js";
2
- import { loadVirtualRawModule, loadVirtualStyleModule, shouldPreprocessTestCss } from "./utils/virtual-resources.js";
3
- import { promises } from "node:fs";
1
+ import { toVirtualRawId } from "./utils/virtual-ids.js";
4
2
  import { dirname, isAbsolute, resolve } from "node:path";
5
- import { normalizePath, preprocessCSS } from "vite";
3
+ import { normalizePath } from "vite";
6
4
  //#region packages/vite-plugin-angular/src/lib/virtual-modules-plugin.ts
7
5
  function virtualModulesPlugin(pluginOptions) {
8
- let resolvedConfig;
9
6
  return {
10
7
  name: "@analogjs/vite-plugin-angular:virtual-modules",
11
8
  enforce: "pre",
12
- configResolved(config) {
13
- resolvedConfig = config;
14
- },
15
9
  resolveId(id, importer) {
16
- if (id.startsWith("virtual:@analogjs/vite-plugin-angular:inline-style:") || id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
17
- if (pluginOptions.jit && id.startsWith("angular:jit:")) {
18
- const filePath = normalizePath(resolve(dirname(importer), id.split(";")[1]));
19
- return id.includes(":style") ? toVirtualStyleId(filePath) : toVirtualRawId(filePath);
20
- }
10
+ if (id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
11
+ if (pluginOptions.jit && id.startsWith("angular:jit:")) return toVirtualRawId(normalizePath(resolve(dirname(importer), id.split(";")[1])));
21
12
  if (id.includes(".html?raw")) {
22
13
  const filePath = id.split("?")[0];
23
14
  const resolved = isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
24
15
  if (resolved) return toVirtualRawId(resolved);
25
16
  }
26
- if (/\.(css|scss|sass|less)\?inline$/.test(id)) {
27
- const filePath = id.split("?")[0];
28
- const resolved = isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
29
- if (resolved) return toVirtualStyleId(resolved);
30
- }
31
- },
32
- async load(id) {
33
- const styleModule = await loadVirtualStyleModule(this, id, resolvedConfig);
34
- if (styleModule !== void 0) return styleModule;
35
- const rawModule = await loadVirtualRawModule(this, id);
36
- if (rawModule !== void 0) return rawModule;
37
- if (/\.(css|scss|sass|less)\?inline$/.test(id)) {
38
- const filePath = id.split("?")[0];
39
- const code = await promises.readFile(filePath, "utf-8");
40
- if (!shouldPreprocessTestCss(resolvedConfig, filePath)) return `export default ${JSON.stringify(code)}`;
41
- const result = await preprocessCSS(code, filePath, resolvedConfig);
42
- return `export default ${JSON.stringify(result.code)}`;
43
- }
44
17
  }
45
18
  };
46
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin, preprocessCSS, ResolvedConfig } from 'vite';\nimport {\n VIRTUAL_RAW_PREFIX,\n VIRTUAL_STYLE_PREFIX,\n toVirtualRawId,\n toVirtualStyleId,\n} from './utils/virtual-ids.js';\nimport {\n loadVirtualRawModule,\n loadVirtualStyleModule,\n shouldPreprocessTestCss,\n} from './utils/virtual-resources.js';\n\nexport interface VirtualModulesPluginOptions {\n jit: boolean;\n}\n\nexport function virtualModulesPlugin(\n pluginOptions: VirtualModulesPluginOptions,\n): Plugin {\n let resolvedConfig: ResolvedConfig;\n\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n configResolved(config) {\n resolvedConfig = config;\n },\n resolveId(id, importer) {\n if (\n id.startsWith(VIRTUAL_STYLE_PREFIX) ||\n id.startsWith(VIRTUAL_RAW_PREFIX)\n ) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n return id.includes(':style')\n ? toVirtualStyleId(filePath)\n : toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n if (id.includes('.html?raw')) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualRawId(resolved);\n }\n }\n\n // Intercept style ?inline imports to bypass Vite server.fs restrictions\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id)) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualStyleId(resolved);\n }\n }\n\n return undefined;\n },\n async load(id) {\n const styleModule = await loadVirtualStyleModule(\n this,\n id,\n resolvedConfig,\n );\n if (styleModule !== undefined) return styleModule;\n\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Vitest fallback: the module-runner calls ensureEntryFromUrl before\n // transformRequest, which skips pluginContainer.resolveId entirely,\n // so a user `import foo from './a.scss?inline'` reaches load as the\n // bare query form. Handle it here so tests still resolve.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id)) {\n const filePath = id.split('?')[0];\n const code = await fsPromises.readFile(filePath, 'utf-8');\n if (!shouldPreprocessTestCss(resolvedConfig, filePath)) {\n return `export default ${JSON.stringify(code)}`;\n }\n const result = await preprocessCSS(code, filePath, resolvedConfig);\n return `export default ${JSON.stringify(result.code)}`;\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;;;;AAmBA,SAAgB,qBACd,eACQ;CACR,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;EACT,eAAe,QAAQ;AACrB,oBAAiB;;EAEnB,UAAU,IAAI,UAAU;AACtB,OACE,GAAG,WAAA,sDAAgC,IACnC,GAAG,WAAA,6CAA8B,CAEjC,QAAO,KAAK;AAGd,OAAI,cAAc,OAAO,GAAG,WAAW,eAAe,EAAE;IACtD,MAAM,WAAW,cACf,QAAQ,QAAQ,SAAmB,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CACvD;AACD,WAAO,GAAG,SAAS,SAAS,GACxB,iBAAiB,SAAS,GAC1B,eAAe,SAAS;;AAI9B,OAAI,GAAG,SAAS,YAAY,EAAE;IAC5B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;IAC/B,MAAM,WAAW,WAAW,SAAS,GACjC,cAAc,SAAS,GACvB,WACE,cAAc,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GACnD,KAAA;AACN,QAAI,SACF,QAAO,eAAe,SAAS;;AAKnC,OAAI,kCAAkC,KAAK,GAAG,EAAE;IAC9C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;IAC/B,MAAM,WAAW,WAAW,SAAS,GACjC,cAAc,SAAS,GACvB,WACE,cAAc,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GACnD,KAAA;AACN,QAAI,SACF,QAAO,iBAAiB,SAAS;;;EAMvC,MAAM,KAAK,IAAI;GACb,MAAM,cAAc,MAAM,uBACxB,MACA,IACA,eACD;AACD,OAAI,gBAAgB,KAAA,EAAW,QAAO;GAEtC,MAAM,YAAY,MAAM,qBAAqB,MAAM,GAAG;AACtD,OAAI,cAAc,KAAA,EAAW,QAAO;AAMpC,OAAI,kCAAkC,KAAK,GAAG,EAAE;IAC9C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;IAC/B,MAAM,OAAO,MAAM,SAAW,SAAS,UAAU,QAAQ;AACzD,QAAI,CAAC,wBAAwB,gBAAgB,SAAS,CACpD,QAAO,kBAAkB,KAAK,UAAU,KAAK;IAE/C,MAAM,SAAS,MAAM,cAAc,MAAM,UAAU,eAAe;AAClE,WAAO,kBAAkB,KAAK,UAAU,OAAO,KAAK;;;EAKzD"}
1
+ {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin } from 'vite';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\n\nexport interface VirtualModulesPluginOptions {\n jit: boolean;\n}\n\nexport function virtualModulesPlugin(\n pluginOptions: VirtualModulesPluginOptions,\n): Plugin {\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n resolveId(id, importer) {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n if (id.includes('.html?raw')) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualRawId(resolved);\n }\n }\n\n return undefined;\n },\n };\n}\n"],"mappings":";;;;AAQA,SAAgB,qBACd,eACQ;AACR,QAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,IAAI,UAAU;AACtB,OAAI,GAAG,WAAA,6CAA8B,CACnC,QAAO,KAAK;AAGd,OAAI,cAAc,OAAO,GAAG,WAAW,eAAe,CAIpD,QAAO,eAHU,cACf,QAAQ,QAAQ,SAAmB,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CACvD,CAC8B;AAIjC,OAAI,GAAG,SAAS,YAAY,EAAE;IAC5B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;IAC/B,MAAM,WAAW,WAAW,SAAS,GACjC,cAAc,SAAS,GACvB,WACE,cAAc,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GACnD,KAAA;AACN,QAAI,SACF,QAAO,eAAe,SAAS;;;EAMtC"}