@analogjs/vite-plugin-angular 3.0.0-alpha.98 → 3.0.0-beta.1

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.
Files changed (90) hide show
  1. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
  2. package/migrations/update-3-0-0/migrate-setup-vitest.js +3 -2
  3. package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -1
  4. package/package.json +1 -1
  5. package/src/lib/analog-plugin-interop.js +1 -1
  6. package/src/lib/analog-plugin-interop.js.map +1 -1
  7. package/src/lib/angular-build-optimizer-plugin.js +1 -1
  8. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  9. package/src/lib/angular-jit-plugin.js +3 -4
  10. package/src/lib/angular-jit-plugin.js.map +1 -1
  11. package/src/lib/angular-vite-plugin.js +11 -8
  12. package/src/lib/angular-vite-plugin.js.map +1 -1
  13. package/src/lib/angular-vitest-plugin.js +1 -1
  14. package/src/lib/angular-vitest-plugin.js.map +1 -1
  15. package/src/lib/compilation-api/compilation-api-plugin.js +6 -5
  16. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
  17. package/src/lib/compilation-api/index.js +2 -1
  18. package/src/lib/compiler/angular-version.js +1 -1
  19. package/src/lib/compiler/angular-version.js.map +1 -1
  20. package/src/lib/compiler/class-field-lowering.js.map +1 -1
  21. package/src/lib/compiler/compile.js +24 -22
  22. package/src/lib/compiler/compile.js.map +1 -1
  23. package/src/lib/compiler/constants.js +4 -4
  24. package/src/lib/compiler/constants.js.map +1 -1
  25. package/src/lib/compiler/debug.js.map +1 -1
  26. package/src/lib/compiler/defer.js +1 -1
  27. package/src/lib/compiler/defer.js.map +1 -1
  28. package/src/lib/compiler/dts-reader.js +1 -1
  29. package/src/lib/compiler/dts-reader.js.map +1 -1
  30. package/src/lib/compiler/hmr.js.map +1 -1
  31. package/src/lib/compiler/index.js +9 -8
  32. package/src/lib/compiler/jit-metadata.d.ts +2 -0
  33. package/src/lib/compiler/jit-metadata.js +9 -4
  34. package/src/lib/compiler/jit-metadata.js.map +1 -1
  35. package/src/lib/compiler/jit-transform.js +60 -34
  36. package/src/lib/compiler/jit-transform.js.map +1 -1
  37. package/src/lib/compiler/js-emitter.js +2 -4
  38. package/src/lib/compiler/js-emitter.js.map +1 -1
  39. package/src/lib/compiler/metadata.js +26 -18
  40. package/src/lib/compiler/metadata.js.map +1 -1
  41. package/src/lib/compiler/registry.js.map +1 -1
  42. package/src/lib/compiler/resource-inliner.js.map +1 -1
  43. package/src/lib/compiler/style-ast.js.map +1 -1
  44. package/src/lib/compiler/type-elision.js +2 -2
  45. package/src/lib/compiler/type-elision.js.map +1 -1
  46. package/src/lib/compiler/utils.js +7 -5
  47. package/src/lib/compiler/utils.js.map +1 -1
  48. package/src/lib/compiler-plugin.js +7 -0
  49. package/src/lib/compiler-plugin.js.map +1 -1
  50. package/src/lib/component-resolvers.js +1 -1
  51. package/src/lib/component-resolvers.js.map +1 -1
  52. package/src/lib/encapsulation-plugin.js +3 -2
  53. package/src/lib/encapsulation-plugin.js.map +1 -1
  54. package/src/lib/fast-compile-plugin.js +3 -2
  55. package/src/lib/fast-compile-plugin.js.map +1 -1
  56. package/src/lib/host.js.map +1 -1
  57. package/src/lib/hot-update-batch.js +1 -1
  58. package/src/lib/hot-update-batch.js.map +1 -1
  59. package/src/lib/live-reload-plugin.js.map +1 -1
  60. package/src/lib/nx-folder-plugin.js.map +1 -1
  61. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  62. package/src/lib/router-plugin.js.map +1 -1
  63. package/src/lib/style-preprocessor.js.map +1 -1
  64. package/src/lib/stylesheet-registry.js.map +1 -1
  65. package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -1
  66. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  67. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +2 -1
  68. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  69. package/src/lib/utils/compilation-shared.js.map +1 -1
  70. package/src/lib/utils/css-extension-resolver.js.map +1 -1
  71. package/src/lib/utils/css-preprocessor-workers.js.map +1 -1
  72. package/src/lib/utils/debug-harness.js.map +1 -1
  73. package/src/lib/utils/debug-log-file.js +2 -1
  74. package/src/lib/utils/debug-log-file.js.map +1 -1
  75. package/src/lib/utils/debug.js.map +1 -1
  76. package/src/lib/utils/devkit.js +1 -1
  77. package/src/lib/utils/devkit.js.map +1 -1
  78. package/src/lib/utils/jit-inline-styles.d.ts +3 -2
  79. package/src/lib/utils/jit-inline-styles.js +9 -5
  80. package/src/lib/utils/jit-inline-styles.js.map +1 -1
  81. package/src/lib/utils/plugin-config.js.map +1 -1
  82. package/src/lib/utils/rolldown.js.map +1 -1
  83. package/src/lib/utils/safe-module-paths.js.map +1 -1
  84. package/src/lib/utils/transform-cache.js.map +1 -1
  85. package/src/lib/utils/tsconfig-resolver.js +2 -1
  86. package/src/lib/utils/tsconfig-resolver.js.map +1 -1
  87. package/src/lib/utils/virtual-ids.js.map +1 -1
  88. package/src/lib/utils/virtual-resources.js.map +1 -1
  89. package/src/lib/virtual-modules-plugin.js +4 -1
  90. package/src/lib/virtual-modules-plugin.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"angular-vitest-plugin.js","names":[],"sources":["../../../src/lib/angular-vitest-plugin.ts"],"sourcesContent":["import type { Plugin, TransformResult, UserConfig } from 'vite';\n// Use the namespace import so these runtime helpers still resolve on Vite 6,\n// which does not expose them as named exports.\nimport * as vite from 'vite';\nimport { getJsTransformConfigKey, isRolldown } from './utils/rolldown.js';\n\nconst vitestAngularSetupEntries = [\n '@analogjs/vitest-angular/setup-testbed',\n '@analogjs/vitest-angular/setup-zone',\n '@analogjs/vitest-angular/setup-snapshots',\n '@analogjs/vitest-angular/setup-serializers',\n];\n\n/**\n * Sets up test config for Vitest and downlevels Angular FESM bundles and\n * `@angular/cdk` from modern async/await to ES2016 so that Zone.js can\n * intercept promises during `fakeAsync` tests.\n *\n * Under Vite 8+ (Rolldown) downleveling is not needed.\n * Under Vite ≤7, esbuild handles the downlevel.\n */\nexport function angularVitestPlugin(): Plugin {\n return {\n name: '@analogjs/vitest-angular-esm-plugin',\n apply: 'serve',\n enforce: 'post',\n config(userConfig) {\n // The `vmThreads` pool default only applies to the Node/JSDOM runner.\n // In Vitest browser mode a Node pool is a no-op for execution, but it\n // still poisons isolation: `isolate` has no effect under VM pools\n // (https://vitest.dev/config/isolate), and since Vitest 4.0.7 browser\n // isolation inherits that resolution — so forcing `vmThreads` disables\n // per-file isolation and leaks global state (e.g. fake timers) between\n // spec files. Leave the pool untouched when browser mode is enabled.\n const browserEnabled = (userConfig as any).test?.browser?.enabled;\n\n return {\n optimizeDeps: {\n include: [\n 'tslib',\n '@angular/core',\n '@angular/core/testing',\n '@angular/platform-browser/testing',\n ],\n },\n ssr: {\n noExternal: [\n ...vitestAngularSetupEntries,\n /fesm2022(.*?)testing/,\n /fesm2015/,\n ],\n },\n ...(browserEnabled\n ? {}\n : {\n test: {\n pool: (userConfig as any).test?.pool ?? 'vmThreads',\n },\n }),\n };\n },\n // Filter by module ID so only Angular FESM2022 bundles and CDK enter\n // the handler. The inner guards add a secondary code-content check\n // (`async` keyword) for fesm2022 to avoid needless transforms.\n transform: {\n filter: {\n id: /fesm2022|@angular\\/cdk/,\n },\n async handler(_code, id) {\n if (\n (/fesm2022/.test(id) && _code.includes('async ')) ||\n _code.includes('@angular/cdk')\n ) {\n if (isRolldown()) {\n return undefined;\n }\n\n const { code, map } = await vite.transformWithEsbuild(_code, id, {\n loader: 'js',\n format: 'esm',\n target: 'es2016',\n sourcemap: true,\n sourcefile: id,\n });\n\n return {\n code,\n map,\n };\n }\n\n return undefined;\n },\n },\n };\n}\n\n/**\n * Eagerly disables the built-in JS transformer (esbuild on Vite ≤7, OXC on\n * Vite 8+) so Vitest's internal plugin doesn't race with the Angular\n * compiler. Must run at `enforce: 'pre'` to take effect before Vitest\n * reads the resolved config.\n */\nexport function angularVitestEsbuildPlugin(): Plugin {\n return {\n name: '@analogjs/vitest-angular-esbuild-oxc-plugin',\n enforce: 'pre',\n config(userConfig: UserConfig) {\n const jsTransformConfigKey = getJsTransformConfigKey();\n\n return {\n [jsTransformConfigKey]:\n jsTransformConfigKey === 'oxc'\n ? (userConfig.oxc ?? false)\n : (userConfig.esbuild ?? false),\n };\n },\n };\n}\n\n/**\n * Post-processing pass that converts any `.ts` files Angular's compilation\n * skipped (e.g. files without Angular decorators when\n * `angularCompilationPlugin()` is used) into runnable JS via esbuild/OXC.\n *\n * Files Angular already compiled have a sourcemap available via\n * `getInMap` — we skip those here to avoid breaking the chain Vite is\n * already wiring up. Re-running OXC over already-compiled JS produces a\n * map relative to the TS-emitted JS, not the original .ts source, and\n * OXC's `inMap` parameter does not chain through the way esbuild's inline\n * `//# sourceMappingURL=` auto-detection does.\n */\nexport function angularVitestSourcemapPlugin(\n getInMap?: (id: string) => string | undefined,\n): Plugin {\n return {\n name: '@analogjs/vitest-angular-sourcemap-plugin',\n transform: {\n filter: {\n // Match `.ts` at the end of the path OR before a `?` query string.\n // Vite/Vitest appends query params for virtual modules (e.g.\n // `component.ts?inline`), so a plain `$` anchor would reject them\n // and leave sourcemaps misaligned — causing Angular TestBed teardown\n // crashes (`_doc` undefined in `removeAllRootElements`).\n // The negative lookahead `(?!x)` prevents matching `.tsx` or `.d.ts`.\n id: /\\.ts(?:\\?|$)/,\n },\n async handler(code: string, id: string) {\n const [bareId, query] = id.split('?');\n\n if (query && query.includes('inline')) {\n return;\n }\n\n if (getInMap?.(bareId)) {\n return;\n }\n\n // Keep this in step with `getJsTransformConfigKey()`, which picks the\n // `oxc`/`esbuild` config key off the same signal. Vite 8 ships\n // `transformWithOxc` even on the esbuild path, so feature detection\n // alone would transform with OXC under an `esbuild` config key.\n if (isRolldown() && vite.transformWithOxc) {\n const result = await vite.transformWithOxc(code, id, {\n lang: /\\.tsx(\\?|$)/.test(bareId) ? 'tsx' : 'ts',\n });\n return result as unknown as vite.TransformResult;\n } else {\n const result = await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n });\n return result;\n }\n },\n },\n };\n}\n\nexport function angularVitestPlugins(\n getInMap?: (id: string) => string | undefined,\n): Plugin[] {\n return [\n angularVitestPlugin(),\n angularVitestEsbuildPlugin(),\n angularVitestSourcemapPlugin(getInMap),\n ];\n}\n"],"mappings":";;;AAMA,IAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACD;;;;;;;;;AAUD,SAAgB,sBAA8B;AAC5C,QAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;EACT,OAAO,YAAY;GAQjB,MAAM,iBAAkB,WAAmB,MAAM,SAAS;AAE1D,UAAO;IACL,cAAc,EACZ,SAAS;KACP;KACA;KACA;KACA;KACD,EACF;IACD,KAAK,EACH,YAAY;KACV,GAAG;KACH;KACA;KACD,EACF;IACD,GAAI,iBACA,EAAE,GACF,EACE,MAAM,EACJ,MAAO,WAAmB,MAAM,QAAQ,aACzC,EACF;IACN;;EAKH,WAAW;GACT,QAAQ,EACN,IAAI,0BACL;GACD,MAAM,QAAQ,OAAO,IAAI;AACvB,QACG,WAAW,KAAK,GAAG,IAAI,MAAM,SAAS,SAAS,IAChD,MAAM,SAAS,eAAe,EAC9B;AACA,SAAI,YAAY,CACd;KAGF,MAAM,EAAE,MAAM,QAAQ,MAAM,KAAK,qBAAqB,OAAO,IAAI;MAC/D,QAAQ;MACR,QAAQ;MACR,QAAQ;MACR,WAAW;MACX,YAAY;MACb,CAAC;AAEF,YAAO;MACL;MACA;MACD;;;GAKN;EACF;;;;;;;;AASH,SAAgB,6BAAqC;AACnD,QAAO;EACL,MAAM;EACN,SAAS;EACT,OAAO,YAAwB;GAC7B,MAAM,uBAAuB,yBAAyB;AAEtD,UAAO,GACJ,uBACC,yBAAyB,QACpB,WAAW,OAAO,QAClB,WAAW,WAAW,OAC9B;;EAEJ;;;;;;;;;;;;;;AAeH,SAAgB,6BACd,UACQ;AACR,QAAO;EACL,MAAM;EACN,WAAW;GACT,QAAQ,EAON,IAAI,gBACL;GACD,MAAM,QAAQ,MAAc,IAAY;IACtC,MAAM,CAAC,QAAQ,SAAS,GAAG,MAAM,IAAI;AAErC,QAAI,SAAS,MAAM,SAAS,SAAS,CACnC;AAGF,QAAI,WAAW,OAAO,CACpB;AAOF,QAAI,YAAY,IAAI,KAAK,iBAIvB,QAHe,MAAM,KAAK,iBAAiB,MAAM,IAAI,EACnD,MAAM,cAAc,KAAK,OAAO,GAAG,QAAQ,MAC5C,CAAC;QAMF,QAHe,MAAM,KAAK,qBAAqB,MAAM,IAAI,EACvD,QAAQ,MACT,CAAC;;GAIP;EACF;;AAGH,SAAgB,qBACd,UACU;AACV,QAAO;EACL,qBAAqB;EACrB,4BAA4B;EAC5B,6BAA6B,SAAS;EACvC"}
1
+ {"version":3,"file":"angular-vitest-plugin.js","names":[],"sources":["../../../src/lib/angular-vitest-plugin.ts"],"sourcesContent":["import type { Plugin, TransformResult, UserConfig } from 'vite';\n// Use the namespace import so these runtime helpers still resolve on Vite 6,\n// which does not expose them as named exports.\nimport * as vite from 'vite';\nimport { getJsTransformConfigKey, isRolldown } from './utils/rolldown.js';\n\nconst vitestAngularSetupEntries = [\n '@analogjs/vitest-angular/setup-testbed',\n '@analogjs/vitest-angular/setup-zone',\n '@analogjs/vitest-angular/setup-snapshots',\n '@analogjs/vitest-angular/setup-serializers',\n];\n\n/**\n * Sets up test config for Vitest and downlevels Angular FESM bundles and\n * `@angular/cdk` from modern async/await to ES2016 so that Zone.js can\n * intercept promises during `fakeAsync` tests.\n *\n * Under Vite 8+ (Rolldown) downleveling is not needed.\n * Under Vite ≤7, esbuild handles the downlevel.\n */\nexport function angularVitestPlugin(): Plugin {\n return {\n name: '@analogjs/vitest-angular-esm-plugin',\n apply: 'serve',\n enforce: 'post',\n config(userConfig) {\n // The `vmThreads` pool default only applies to the Node/JSDOM runner.\n // In Vitest browser mode a Node pool is a no-op for execution, but it\n // still poisons isolation: `isolate` has no effect under VM pools\n // (https://vitest.dev/config/isolate), and since Vitest 4.0.7 browser\n // isolation inherits that resolution — so forcing `vmThreads` disables\n // per-file isolation and leaks global state (e.g. fake timers) between\n // spec files. Leave the pool untouched when browser mode is enabled.\n const browserEnabled = (userConfig as any).test?.browser?.enabled;\n\n return {\n optimizeDeps: {\n include: [\n 'tslib',\n '@angular/core',\n '@angular/core/testing',\n '@angular/platform-browser/testing',\n ],\n },\n ssr: {\n noExternal: [\n ...vitestAngularSetupEntries,\n /fesm2022(.*?)testing/,\n /fesm2015/,\n ],\n },\n ...(browserEnabled\n ? {}\n : {\n test: {\n pool: (userConfig as any).test?.pool ?? 'vmThreads',\n },\n }),\n };\n },\n // Filter by module ID so only Angular FESM2022 bundles and CDK enter\n // the handler. The inner guards add a secondary code-content check\n // (`async` keyword) for fesm2022 to avoid needless transforms.\n transform: {\n filter: {\n id: /fesm2022|@angular\\/cdk/,\n },\n async handler(_code, id) {\n if (\n (/fesm2022/.test(id) && _code.includes('async ')) ||\n _code.includes('@angular/cdk')\n ) {\n if (isRolldown()) {\n return undefined;\n }\n\n const { code, map } = await vite.transformWithEsbuild(_code, id, {\n loader: 'js',\n format: 'esm',\n target: 'es2016',\n sourcemap: true,\n sourcefile: id,\n });\n\n return {\n code,\n map,\n };\n }\n\n return undefined;\n },\n },\n };\n}\n\n/**\n * Eagerly disables the built-in JS transformer (esbuild on Vite ≤7, OXC on\n * Vite 8+) so Vitest's internal plugin doesn't race with the Angular\n * compiler. Must run at `enforce: 'pre'` to take effect before Vitest\n * reads the resolved config.\n */\nexport function angularVitestEsbuildPlugin(): Plugin {\n return {\n name: '@analogjs/vitest-angular-esbuild-oxc-plugin',\n enforce: 'pre',\n config(userConfig: UserConfig) {\n const jsTransformConfigKey = getJsTransformConfigKey();\n\n return {\n [jsTransformConfigKey]:\n jsTransformConfigKey === 'oxc'\n ? (userConfig.oxc ?? false)\n : (userConfig.esbuild ?? false),\n };\n },\n };\n}\n\n/**\n * Post-processing pass that converts any `.ts` files Angular's compilation\n * skipped (e.g. files without Angular decorators when\n * `angularCompilationPlugin()` is used) into runnable JS via esbuild/OXC.\n *\n * Files Angular already compiled have a sourcemap available via\n * `getInMap` — we skip those here to avoid breaking the chain Vite is\n * already wiring up. Re-running OXC over already-compiled JS produces a\n * map relative to the TS-emitted JS, not the original .ts source, and\n * OXC's `inMap` parameter does not chain through the way esbuild's inline\n * `//# sourceMappingURL=` auto-detection does.\n */\nexport function angularVitestSourcemapPlugin(\n getInMap?: (id: string) => string | undefined,\n): Plugin {\n return {\n name: '@analogjs/vitest-angular-sourcemap-plugin',\n transform: {\n filter: {\n // Match `.ts` at the end of the path OR before a `?` query string.\n // Vite/Vitest appends query params for virtual modules (e.g.\n // `component.ts?inline`), so a plain `$` anchor would reject them\n // and leave sourcemaps misaligned — causing Angular TestBed teardown\n // crashes (`_doc` undefined in `removeAllRootElements`).\n // The negative lookahead `(?!x)` prevents matching `.tsx` or `.d.ts`.\n id: /\\.ts(?:\\?|$)/,\n },\n async handler(code: string, id: string) {\n const [bareId, query] = id.split('?');\n\n if (query && query.includes('inline')) {\n return;\n }\n\n if (getInMap?.(bareId)) {\n return;\n }\n\n // Keep this in step with `getJsTransformConfigKey()`, which picks the\n // `oxc`/`esbuild` config key off the same signal. Vite 8 ships\n // `transformWithOxc` even on the esbuild path, so feature detection\n // alone would transform with OXC under an `esbuild` config key.\n if (isRolldown() && vite.transformWithOxc) {\n const result = await vite.transformWithOxc(code, id, {\n lang: /\\.tsx(\\?|$)/.test(bareId) ? 'tsx' : 'ts',\n });\n return result as unknown as vite.TransformResult;\n } else {\n const result = await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n });\n return result;\n }\n },\n },\n };\n}\n\nexport function angularVitestPlugins(\n getInMap?: (id: string) => string | undefined,\n): Plugin[] {\n return [\n angularVitestPlugin(),\n angularVitestEsbuildPlugin(),\n angularVitestSourcemapPlugin(getInMap),\n ];\n}\n"],"mappings":";;;AAMA,IAAM,4BAA4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AO,MAHc,KAAK,iBAAiB,MAAM,IAAI,EACnD,MAAM,cAAc,KAAK,MAAM,IAAI,QAAQ,KAC7C,CAAC;SAMD,OAAO,MAHc,KAAK,qBAAqB,MAAM,IAAI,EACvD,QAAQ,KACV,CAAC;GAGL;EACF;CACF;AACF;AAEA,SAAgB,qBACd,UACU;CACV,OAAO;EACL,oBAAoB;EACpB,2BAA2B;EAC3B,6BAA6B,QAAQ;CACvC;AACF"}
@@ -95,14 +95,16 @@ function angularCompilationPlugin(options = {}) {
95
95
  const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(resolvedTsConfigPath, config);
96
96
  const mergedRootNames = union(cached.rootNames, expandedGraphRoots, includedFiles).map((file) => normalizePath(file));
97
97
  if (mergedRootNames.length === cached.rootNames.length) return resolvedTsConfigPath;
98
- const wrapperDir = join(isAbsolute(config.cacheDir) ? config.cacheDir : resolve(config.root, config.cacheDir), "analog-angular", "compilation-api");
98
+ const resolvedCacheDir = isAbsolute(config.cacheDir) ? config.cacheDir : resolve(config.root, config.cacheDir);
99
+ const wrapperDir = join(resolvedCacheDir, "analog-angular", "compilation-api");
99
100
  const rawTsconfig = ts.readConfigFile(resolvedTsConfigPath, ts.sys.readFile).config ?? {};
100
101
  const wrapperPayload = {
101
102
  extends: normalizePath(resolvedTsConfigPath),
102
103
  files: [...mergedRootNames].sort(),
103
104
  ...rawTsconfig.references ? { references: rawTsconfig.references } : {}
104
105
  };
105
- const wrapperPath = join(wrapperDir, `tsconfig.includes.${createHash("sha1").update(JSON.stringify(wrapperPayload)).digest("hex").slice(0, 12)}.json`);
106
+ const wrapperHash = createHash("sha1").update(JSON.stringify(wrapperPayload)).digest("hex").slice(0, 12);
107
+ const wrapperPath = join(wrapperDir, `tsconfig.includes.${wrapperHash}.json`);
106
108
  mkdirSync(wrapperDir, { recursive: true });
107
109
  if (!existsSync(wrapperPath)) writeFileSync(wrapperPath, `${JSON.stringify(wrapperPayload, null, 2)}\n`, "utf-8");
108
110
  debugCompilationApi("generated include wrapper tsconfig", {
@@ -116,12 +118,11 @@ function angularCompilationPlugin(options = {}) {
116
118
  const normalizeEmitterLookupId = (file) => {
117
119
  const normalizedFile = normalizePath(file);
118
120
  if (!normalizedFile.startsWith("/@fs/")) return normalizedFile;
119
- return normalizePath(normalizedFile.slice(4).replace(/^\/([A-Za-z]:\/)/, "$1"));
121
+ const fsPath = normalizedFile.slice(4).replace(/^\/([A-Za-z]:\/)/, "$1");
122
+ return normalizePath(fsPath);
120
123
  };
121
- let outputFile;
122
124
  const fileEmitter = (file) => {
123
125
  const normalizedFile = normalizeEmitterLookupId(file);
124
- outputFile?.(normalizedFile);
125
126
  return outputFiles.get(normalizedFile);
126
127
  };
127
128
  async function performAngularCompilation(config, ids) {
@@ -1 +1 @@
1
- {"version":3,"file":"compilation-api-plugin.js","names":[],"sources":["../../../../src/lib/compilation-api/compilation-api-plugin.ts"],"sourcesContent":["import { type createAngularCompilation as createAngularCompilationType } from '@angular/build/private';\nimport { union } from 'es-toolkit';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n normalizePath,\n Plugin,\n preprocessCSS,\n ResolvedConfig,\n ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularCompilation,\n SourceFileCache,\n angularFullVersion,\n} from '../utils/devkit.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from '../utils/debug.js';\nimport {\n getTsConfigPath,\n createTsConfigGetter,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { isRolldown } from '../utils/rolldown.js';\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport {\n discoverAnalogIntegrations,\n type TransformFilter,\n} from '../analog-plugin-interop.js';\nimport { type FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport type { EmitFileResult } from '../models.js';\nimport type { SourceFileCache as SourceFileCacheType } from '../utils/source-file-cache.js';\nimport {\n injectViteIgnoreForHmrMetadata,\n isIgnoredHmrFile,\n toAngularCompilationFileReplacements,\n mapTemplateUpdatesToFiles,\n refreshStylesheetRegistryForFile,\n DiagnosticModes,\n isTestWatchMode,\n getBrowserModeCliOverride,\n} from '../utils/compilation-shared.js';\nimport { createHotUpdateBatcher } from '../hot-update-batch.js';\nimport { angularVitestPlugins } from '../angular-vitest-plugin.js';\nimport { buildOptimizerPlugin } from '../angular-build-optimizer-plugin.js';\nimport { jitPlugin } from '../angular-jit-plugin.js';\nimport { liveReloadPlugin } from '../live-reload-plugin.js';\nimport { virtualModulesPlugin } from '../virtual-modules-plugin.js';\nimport { encapsulationPlugin } from '../encapsulation-plugin.js';\nimport { nxFolderPlugin } from '../nx-folder-plugin.js';\nimport { routerPlugin } from '../router-plugin.js';\nimport { replaceFiles } from '../plugins/file-replacements.plugin.js';\nimport { cssExtensionStyleResolverPlugin } from '../utils/css-extension-resolver.js';\nimport { loadVirtualRawModule } from '../utils/virtual-resources.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\n/**\n * @experimental The Angular Compilation API plugin may change in future releases.\n */\nexport interface AngularCompilationPluginOptions {\n tsconfig?: string | (() => string);\n workspaceRoot?: string;\n inlineStylesExtension?: string;\n jit?: boolean;\n liveReload?: boolean;\n disableTypeChecking?: boolean;\n supportedBrowsers?: string[];\n fileReplacements?: FileReplacement[];\n include?: string[];\n debug?: DebugOption;\n}\n\n/**\n * Compiles Angular applications using Angular's private Compilation API.\n *\n * @experimental This plugin may change in future releases.\n */\nexport function angularCompilationPlugin(\n options: AngularCompilationPluginOptions = {},\n): Plugin[] {\n if (\n angularFullVersion < 200100 ||\n typeof createAngularCompilation !== 'function'\n ) {\n throw new Error(\n '[@analogjs/vite-plugin-angular]: angularCompilationPlugin requires Angular v20.1 or later and a matching @angular/build package with the Compilation API.',\n );\n }\n\n applyDebugOption(options.debug, options.workspaceRoot);\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const isStackBlitz = !!process.versions['webcontainer'];\n const pluginOptions = {\n tsconfigGetter: createTsConfigGetter(options.tsconfig),\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n inlineStylesExtension: options.inlineStylesExtension ?? 'css',\n jit: options.jit ?? isTest,\n liveReload: options.liveReload ?? true,\n disableTypeChecking: options.disableTypeChecking ?? true,\n supportedBrowsers: options.supportedBrowsers ?? ['safari 15'],\n fileReplacements: options.fileReplacements ?? [],\n include: options.include ?? [],\n isAstroIntegration: process.env['ANALOG_ASTRO'] === 'true',\n };\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n let stylePreprocessor: StylePreprocessor | undefined;\n let transformFilter: TransformFilter | undefined;\n let externalizeStylesRequested = false;\n\n // Persistent compilation instance — kept alive across rebuilds so Angular\n // can diff prior state and emit `templateUpdates` for HMR.\n let angularCompilation:\n | Awaited<ReturnType<typeof createAngularCompilationType>>\n | undefined;\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const outputFiles = new Map<string, EmitFileResult>();\n const classNames = new Map<string, string>();\n let stylesheetRegistry: AnalogStylesheetRegistry | undefined;\n let compilationLock = Promise.resolve();\n let pendingCompilation: Promise<void> | null = null;\n let initialCompilation = false;\n let viteServer: ViteDevServer | undefined;\n const hotUpdates = createHotUpdateBatcher((ids) =>\n performCompilation(resolvedConfig, ids),\n );\n\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n isTest,\n });\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n let deferInitialCompilation = isVitestVscode;\n let testWatchMode = isTestWatchMode();\n\n function hasViteHmrTransport(): boolean {\n return resolvedConfig ? resolvedConfig.server.hmr !== false : true;\n }\n\n function shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n return !!(\n effectiveWatchMode &&\n pluginOptions.liveReload &&\n hasViteHmrTransport()\n );\n }\n\n function shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n if (!effectiveWatchMode) return false;\n return !!(shouldEnableLiveReload() || externalizeStylesRequested);\n }\n\n function resolveTsConfigPath() {\n const tsconfigValue = pluginOptions.tsconfigGetter();\n return getTsConfigPath(\n tsConfigResolutionContext!.root,\n tsconfigValue,\n tsConfigResolutionContext!.isProd,\n isTest,\n tsConfigResolutionContext!.isLib,\n );\n }\n\n function resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const includedFiles = tsconfigResolver.ensureIncludeCache();\n const cached = tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(\n resolvedTsConfigPath,\n config,\n );\n const mergedRootNames = union(\n cached.rootNames,\n expandedGraphRoots,\n includedFiles,\n ).map((file) => normalizePath(file));\n\n if (mergedRootNames.length === cached.rootNames.length) {\n return resolvedTsConfigPath;\n }\n\n const resolvedCacheDir = isAbsolute(config.cacheDir)\n ? config.cacheDir\n : resolve(config.root, config.cacheDir);\n const wrapperDir = join(\n resolvedCacheDir,\n 'analog-angular',\n 'compilation-api',\n );\n const rawTsconfig = (ts.readConfigFile(\n resolvedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as { references?: unknown[] };\n const wrapperPayload = {\n extends: normalizePath(resolvedTsConfigPath),\n files: [...mergedRootNames].sort(),\n ...(rawTsconfig.references ? { references: rawTsconfig.references } : {}),\n };\n const wrapperHash = createHash('sha1')\n .update(JSON.stringify(wrapperPayload))\n .digest('hex')\n .slice(0, 12);\n const wrapperPath = join(\n wrapperDir,\n `tsconfig.includes.${wrapperHash}.json`,\n );\n\n mkdirSync(wrapperDir, { recursive: true });\n if (!existsSync(wrapperPath)) {\n writeFileSync(\n wrapperPath,\n `${JSON.stringify(wrapperPayload, null, 2)}\\n`,\n 'utf-8',\n );\n }\n\n debugCompilationApi('generated include wrapper tsconfig', {\n originalTsconfig: resolvedTsConfigPath,\n wrapperTsconfig: wrapperPath,\n includeCount: includedFiles.length,\n rootNameCount: mergedRootNames.length,\n });\n\n return wrapperPath;\n }\n\n const normalizeEmitterLookupId = (file: string) => {\n const normalizedFile = normalizePath(file);\n if (!normalizedFile.startsWith('/@fs/')) return normalizedFile;\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n return normalizePath(fsPath);\n };\n\n let outputFile: ((file: string) => void) | undefined;\n const fileEmitter = (file: string) => {\n const normalizedFile = normalizeEmitterLookupId(file);\n outputFile?.(normalizedFile);\n return outputFiles.get(normalizedFile);\n };\n\n async function performAngularCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ) {\n const compilation = (angularCompilation ??= await (\n createAngularCompilation as typeof createAngularCompilationType\n )(!!pluginOptions.jit, false));\n const modifiedFiles = ids?.length\n ? new Set(ids.map((file) => normalizePath(file)))\n : undefined;\n if (modifiedFiles?.size) {\n sourceFileCache.invalidate(modifiedFiles);\n }\n if (modifiedFiles?.size && compilation.update) {\n debugCompilationApi('incremental update', {\n files: [...modifiedFiles],\n });\n await compilation.update(modifiedFiles);\n }\n\n const resolvedTsConfigPath = resolveTsConfigPath();\n const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath,\n config,\n );\n debugEmit('compilation initialize', {\n resolvedTsConfigPath,\n compilationApiTsConfigPath,\n modifiedFileCount: modifiedFiles?.size ?? 0,\n });\n const transformCompilerOptions = (\n tsCompilerOptions: Record<string, unknown>,\n ) => {\n if (shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (compilation API)', {\n liveReload: pluginOptions.liveReload,\n viteHmr: hasViteHmrTransport(),\n externalizeStylesRequested,\n watchMode,\n shouldExternalize: shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && resolvedConfig.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n return tsCompilerOptions;\n };\n const compilationResult = await compilation.initialize(\n compilationApiTsConfigPath,\n {\n fileReplacements: toAngularCompilationFileReplacements(\n pluginOptions.fileReplacements,\n pluginOptions.workspaceRoot,\n ),\n modifiedFiles,\n async transformStylesheet(\n data: string,\n containingFile: string,\n resourceFile: string | null,\n order: number,\n className: string | null,\n ) {\n const filename =\n resourceFile ??\n containingFile.replace(\n '.ts',\n `.${pluginOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n stylePreprocessor,\n {\n filename,\n containingFile,\n resourceFile,\n className,\n order,\n inline: !resourceFile,\n },\n );\n\n if (shouldEnableLiveReload() && className && containingFile) {\n classNames.set(normalizePath(containingFile), className as string);\n }\n\n if (shouldExternalizeStyles()) {\n const stylesheetId = registerStylesheetContent(\n stylesheetRegistry!,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile,\n className: className as string | undefined,\n order,\n inlineStylesExtension: pluginOptions.inlineStylesExtension,\n resourceFile: resourceFile ?? undefined,\n },\n );\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: resourceFile ?? '(inline)',\n });\n\n return stylesheetId;\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n debugStyles('preprocessCSS error', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n return stylesheetResult?.code || '';\n },\n processWebWorker(workerFile: string) {\n return workerFile;\n },\n },\n angularFullVersion >= 220200\n ? {\n enableHmr: shouldEnableLiveReload(),\n externalRuntimeStyles: shouldExternalizeStyles(),\n includeTestMetadata: isTest || shouldEnableLiveReload(),\n instrumentForCoverage: !isTest,\n }\n : (transformCompilerOptions as unknown as Parameters<\n typeof compilation.initialize\n >[2]),\n );\n\n // Preprocess external stylesheets for Tailwind CSS @reference\n debugStyles('external stylesheets from compilation API', {\n count: compilationResult.externalStylesheets?.size ?? 0,\n hasPreprocessor: !!stylePreprocessor,\n hasInlineMap: !!stylesheetRegistry,\n });\n const preprocessStats = { total: 0, injected: 0, skipped: 0, errors: 0 };\n for (const [key, value] of compilationResult.externalStylesheets ?? []) {\n preprocessStats.total++;\n const angularHash = `${value}.css`;\n stylesheetRegistry?.registerExternalRequest(angularHash, key);\n\n if (stylesheetRegistry && stylePreprocessor && existsSync(key)) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(preprocessed.code, key);\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId: angularHash,\n sourcePath: key,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [key, normalizePath(key), basename(key), key.replace(/^\\//, '')],\n );\n\n if (servedCss && servedCss !== rawCss) {\n preprocessStats.injected++;\n } else {\n preprocessStats.skipped++;\n }\n } catch (e) {\n preprocessStats.errors++;\n console.warn(\n `[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`,\n );\n }\n } else {\n preprocessStats.skipped++;\n }\n }\n debugStyles('external stylesheet preprocessing complete', preprocessStats);\n\n const diagnostics = await compilation.diagnoseFiles(\n pluginOptions.disableTypeChecking\n ? DiagnosticModes.All & ~DiagnosticModes.Semantic\n : DiagnosticModes.All,\n );\n\n const errors = diagnostics.errors?.length ? diagnostics.errors : [];\n const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];\n\n const templateUpdates = mapTemplateUpdatesToFiles(\n compilationResult.templateUpdates,\n );\n if (templateUpdates.size > 0) {\n debugHmr('compilation API template updates', {\n count: templateUpdates.size,\n files: [...templateUpdates.keys()],\n });\n }\n\n const affectedFiles = await compilation.emitAffectedFiles();\n debugEmit('emitAffectedFiles summary', {\n count: affectedFiles.length,\n templateUpdateCount: templateUpdates.size,\n knownOutputCountBefore: outputFiles.size,\n });\n\n for (const file of affectedFiles) {\n const normalizedFilename = normalizePath(file.filename);\n const templateUpdate = templateUpdates.get(normalizedFilename);\n\n if (templateUpdate) {\n classNames.set(normalizedFilename, templateUpdate.className);\n }\n\n outputFiles.set(normalizedFilename, {\n content: file.contents,\n dependencies: [],\n errors: errors.map((error: { text?: string }) => error.text || ''),\n warnings: warnings.map(\n (warning: { text?: string }) => warning.text || '',\n ),\n hmrUpdateCode: templateUpdate?.code,\n hmrEligible: !!templateUpdate?.code,\n });\n }\n\n // Free the compilation before chunks render; `transform` still reads `outputFiles`.\n if (!watchMode && !isTest) {\n await compilation.close?.();\n angularCompilation = undefined;\n }\n }\n\n async function performCompilation(config: ResolvedConfig, ids?: string[]) {\n let resolve: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n resolve = r;\n });\n try {\n await previousLock;\n const integrations = await discoverAnalogIntegrations(config);\n stylePreprocessor = integrations.stylePreprocessor;\n transformFilter = integrations.transformFilter;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n externalizeStylesRequested = integrations.externalizeStyles;\n await performAngularCompilation(config, ids);\n } finally {\n resolve!();\n }\n }\n\n function isComponentStyleSheet(id: string): boolean {\n return id.includes('ngcomp=');\n }\n\n function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n }\n\n function sendHMRComponentUpdate(server: ViteDevServer, id: string) {\n debugHmrV('ws send: angular component update', {\n id,\n timestamp: Date.now(),\n });\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(id),\n timestamp: Date.now(),\n });\n classNames.delete(id);\n }\n\n const compilerPlugin: Plugin = {\n name: '@analogjs/vite-plugin-angular-compilation-api',\n api: { getTsConfigPath: resolveTsConfigPath },\n enforce: 'pre' as const,\n async config(config, { command }) {\n activateDeferredDebug(command);\n watchMode = command === 'serve';\n const isProd =\n config.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n\n // Angular Compilation API handles TypeScript transforms — disable\n // esbuild/oxc so they don't compete.\n debugCompilationApi('esbuild/oxc disabled, Angular handles transforms');\n\n // The compilation API owns user-source transforms, but deps\n // optimization still bundles partial-compiled Angular libs from\n // node_modules (`ɵɵngDeclareInjectable/Factory`). Without the\n // linker plugin, those declarations reach the browser unprocessed\n // and Angular tries to JIT-compile them at runtime. Mirror the\n // deps-optimizer wiring from `angular-vite-plugin.ts` so the\n // linker runs on `.[cm]?js` deps under both rolldown and esbuild.\n const useRolldown = isRolldown();\n const preliminaryTsConfigPath = resolveTsConfigPath();\n const compilerPluginOptions = {\n tsconfig: preliminaryTsConfigPath,\n sourcemap: !isProd,\n advancedOptimizations: isProd,\n jit: pluginOptions.jit,\n incremental: watchMode,\n };\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`, registered once at the\n // `angularCompilationPlugin()` factory level. Adding `style` globally caused\n // Tailwind v4's JS plugin resolver to pick the `style` exports of\n // packages such as `tailwindcss-primeui`, which then crashed Node's\n // ESM loader when it tried to import the resulting `.css` file.\n return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(useRolldown\n ? {\n rolldownOptions: {\n plugins: [\n createRolldownCompilerPlugin(\n compilerPluginOptions,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }\n : {\n esbuildOptions: {\n plugins: [\n createCompilerPlugin(\n compilerPluginOptions,\n isTest,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }),\n },\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n const integrations = await discoverAnalogIntegrations(config);\n integrations.configureStylesheetRegistry?.(stylesheetRegistry, {\n workspaceRoot: pluginOptions.workspaceRoot,\n });\n debugStyles('stylesheet registry initialized (Angular Compilation API)');\n\n if (isTest) {\n const browser = (config as any).test?.browser;\n deferInitialCompilation =\n isVitestVscode ||\n (!!browser &&\n (getBrowserModeCliOverride() ?? browser.enabled) === true);\n\n testWatchMode =\n !(config.server.watch === null) ||\n (config as any).test?.watch === true ||\n testWatchMode;\n }\n },\n configureServer(server) {\n viteServer = server;\n hotUpdates.configureServer(server);\n\n const invalidateCompilation = async () => {\n tsconfigResolver.invalidateAll();\n await performCompilation(resolvedConfig);\n };\n server.watcher.on('add', invalidateCompilation);\n server.watcher.on('unlink', invalidateCompilation);\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n tsconfigResolver.invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n if (!deferInitialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n await pendingCompilation;\n pendingCompilation = null;\n initialCompilation = true;\n }\n },\n async handleHotUpdate(ctx) {\n if (isIgnoredHmrFile(ctx.file)) {\n debugHmr('ignored file change', { file: ctx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n debugHmr('TS file changed', { file: ctx.file, fileId });\n\n await hotUpdates.schedule(ctx.file, [fileId]);\n\n let result;\n\n if (shouldEnableLiveReload()) {\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!classNames.get(fileId),\n });\n }\n\n if (\n shouldEnableLiveReload() &&\n result?.hmrEligible &&\n classNames.get(fileId)\n ) {\n const relativeFileId = `${normalizePath(\n relative(process.cwd(), fileId),\n )}@${classNames.get(fileId)}`;\n\n debugHmr('sending component update', { relativeFileId });\n sendHMRComponentUpdate(ctx.server, relativeFileId);\n\n return ctx.modules.map((mod) => {\n if (mod.id === ctx.file) {\n mod.isSelfAccepting = true;\n }\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm)$/.test(ctx.file)) {\n debugHmr('template file changed', { file: ctx.file });\n // Recompile to pick up template changes\n pendingCompilation = performCompilation(resolvedConfig);\n }\n\n if (/\\.(css|less|sass|scss)$/.test(ctx.file)) {\n debugHmr('stylesheet file changed', { file: ctx.file });\n refreshStylesheetRegistryForFile(\n ctx.file,\n stylesheetRegistry,\n stylePreprocessor,\n );\n }\n\n return ctx.modules;\n },\n resolveId(id) {\n // Map angular component stylesheets\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath =\n stylesheetRegistry?.getServedSourcePath(filename);\n\n if (servedSourcePath) {\n debugStylesV('resolveId: mapped served stylesheet to source', {\n filename,\n resolvedPath: servedSourcePath,\n });\n return servedSourcePath + search;\n }\n\n if (stylesheetRegistry?.hasServed(filename)) {\n return id;\n }\n\n const componentStyles =\n stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n return componentStyles + new URL(id, 'http://localhost').search;\n }\n }\n\n return undefined;\n },\n async load(id) {\n // Virtual raw ids back JIT-emitted templateUrl/styleUrl imports.\n // virtual-modules-plugin resolves them; this plugin is the active\n // compilation plugin in compilation-API mode, so load must read the\n // backing file (jit=true is the test-mode default).\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Serve component stylesheets from registry\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (componentStyles) {\n stylesheetRegistry?.registerActiveRequest(id);\n return componentStyles;\n }\n }\n\n return;\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n if (/[?&]raw\\b/.test(id)) return;\n if (transformFilter && !transformFilter(code, id)) {\n return;\n }\n\n // Angular emits every file in the program, not only files with\n // Angular decorators, and `@analogjs/platform` excludes `.ts` from\n // Vite's own transform. So serve Angular's output for any emitted\n // file; only the \"not emitted\" warning below is decorator-specific.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n\n if (isTest) {\n if (deferInitialCompilation && !initialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n if (testWatchMode && invalidated) {\n pendingCompilation = performCompilation(resolvedConfig, [id]);\n }\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n await hotUpdates.wait();\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilationApi('transform skip (file not emitted)', { id });\n if (isAngular) {\n this.warn(\n `[@analogjs/vite-plugin-angular]: \"${id}\" contains Angular decorators but is not in the TypeScript program. ` +\n `Ensure it is included in your tsconfig.`,\n );\n }\n return;\n }\n\n if (typescriptResult.warnings && typescriptResult.warnings.length > 0) {\n this.warn(`${typescriptResult.warnings.join('\\n')}`);\n }\n\n if (typescriptResult.errors && typescriptResult.errors.length > 0) {\n this.error(`${typescriptResult.errors.join('\\n')}`);\n }\n\n let data = typescriptResult.content ?? '';\n\n // Re-inject @vite-ignore for Angular HMR dynamic imports\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n if (hasMetaUrl) {\n data = injectViteIgnoreForHmrMetadata(data);\n }\n }\n\n return {\n code: data,\n map: null,\n };\n },\n },\n async closeBundle() {\n hotUpdates.close();\n await compilationLock;\n await angularCompilation?.close?.();\n angularCompilation = undefined;\n outputFiles.clear();\n classNames.clear();\n sourceFileCache.clear();\n tsconfigResolver.invalidateAll();\n stylesheetRegistry = undefined;\n pendingCompilation = null;\n initialCompilation = false;\n },\n };\n\n return [\n cssExtensionStyleResolverPlugin(),\n replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),\n virtualModulesPlugin({ jit: pluginOptions.jit }),\n compilerPlugin,\n pluginOptions.liveReload && liveReloadPlugin({ classNames, fileEmitter }),\n ...(isTest && !isStackBlitz\n ? angularVitestPlugins((id) => outputFiles.get(normalizePath(id))?.map)\n : []),\n pluginOptions.jit &&\n jitPlugin({ inlineStylesExtension: pluginOptions.inlineStylesExtension }),\n buildOptimizerPlugin({\n jit: pluginOptions.jit,\n }),\n routerPlugin(),\n nxFolderPlugin(),\n encapsulationPlugin(),\n ].filter(Boolean) as Plugin[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,IAAM,KADU,cAAc,OAAO,KAAK,IAAI,CAC3B,aAAa;;;;;;AAuBhC,SAAgB,yBACd,UAA2C,EAAE,EACnC;AACV,KACE,qBAAqB,UACrB,OAAO,6BAA6B,WAEpC,OAAM,IAAI,MACR,4JACD;AAGH,kBAAiB,QAAQ,OAAO,QAAQ,cAAc;CACtD,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,eAAe,CAAC,CAAC,QAAQ,SAAS;CACxC,MAAM,gBAAgB;EACpB,gBAAgB,qBAAqB,QAAQ,SAAS;EACtD,eACE,QAAQ,iBACR,QAAQ,IAAI,wBACZ,QAAQ,KAAK;EACf,uBAAuB,QAAQ,yBAAyB;EACxD,KAAK,QAAQ,OAAO;EACpB,YAAY,QAAQ,cAAc;EAClC,qBAAqB,QAAQ,uBAAuB;EACpD,mBAAmB,QAAQ,qBAAqB,CAAC,YAAY;EAC7D,kBAAkB,QAAQ,oBAAoB,EAAE;EAChD,SAAS,QAAQ,WAAW,EAAE;EAC9B,oBAAoB,QAAQ,IAAI,oBAAoB;EACrD;CACD,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAChB,IAAI;CACJ,IAAI;CACJ,IAAI,6BAA6B;CAIjC,IAAI;CAGJ,MAAM,kBAAuC,IAAI,iBAAiB;CAClE,MAAM,8BAAc,IAAI,KAA6B;CACrD,MAAM,6BAAa,IAAI,KAAqB;CAC5C,IAAI;CACJ,IAAI,kBAA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,OAAO,QAAQ"}
1
+ {"version":3,"file":"compilation-api-plugin.js","names":[],"sources":["../../../../src/lib/compilation-api/compilation-api-plugin.ts"],"sourcesContent":["import { type createAngularCompilation as createAngularCompilationType } from '@angular/build/private';\nimport { union } from 'es-toolkit';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n normalizePath,\n Plugin,\n preprocessCSS,\n ResolvedConfig,\n ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularCompilation,\n SourceFileCache,\n angularFullVersion,\n} from '../utils/devkit.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from '../utils/debug.js';\nimport {\n getTsConfigPath,\n createTsConfigGetter,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { isRolldown } from '../utils/rolldown.js';\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport {\n discoverAnalogIntegrations,\n type TransformFilter,\n} from '../analog-plugin-interop.js';\nimport { type FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport type { EmitFileResult } from '../models.js';\nimport type { SourceFileCache as SourceFileCacheType } from '../utils/source-file-cache.js';\nimport {\n injectViteIgnoreForHmrMetadata,\n isIgnoredHmrFile,\n toAngularCompilationFileReplacements,\n mapTemplateUpdatesToFiles,\n refreshStylesheetRegistryForFile,\n DiagnosticModes,\n isTestWatchMode,\n getBrowserModeCliOverride,\n} from '../utils/compilation-shared.js';\nimport { createHotUpdateBatcher } from '../hot-update-batch.js';\nimport { angularVitestPlugins } from '../angular-vitest-plugin.js';\nimport { buildOptimizerPlugin } from '../angular-build-optimizer-plugin.js';\nimport { jitPlugin } from '../angular-jit-plugin.js';\nimport { liveReloadPlugin } from '../live-reload-plugin.js';\nimport { virtualModulesPlugin } from '../virtual-modules-plugin.js';\nimport { encapsulationPlugin } from '../encapsulation-plugin.js';\nimport { nxFolderPlugin } from '../nx-folder-plugin.js';\nimport { routerPlugin } from '../router-plugin.js';\nimport { replaceFiles } from '../plugins/file-replacements.plugin.js';\nimport { cssExtensionStyleResolverPlugin } from '../utils/css-extension-resolver.js';\nimport { loadVirtualRawModule } from '../utils/virtual-resources.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\n/**\n * @experimental The Angular Compilation API plugin may change in future releases.\n */\nexport interface AngularCompilationPluginOptions {\n tsconfig?: string | (() => string);\n workspaceRoot?: string;\n inlineStylesExtension?: string;\n jit?: boolean;\n liveReload?: boolean;\n disableTypeChecking?: boolean;\n supportedBrowsers?: string[];\n fileReplacements?: FileReplacement[];\n include?: string[];\n debug?: DebugOption;\n}\n\n/**\n * Compiles Angular applications using Angular's private Compilation API.\n *\n * @experimental This plugin may change in future releases.\n */\nexport function angularCompilationPlugin(\n options: AngularCompilationPluginOptions = {},\n): Plugin[] {\n if (\n angularFullVersion < 200100 ||\n typeof createAngularCompilation !== 'function'\n ) {\n throw new Error(\n '[@analogjs/vite-plugin-angular]: angularCompilationPlugin requires Angular v20.1 or later and a matching @angular/build package with the Compilation API.',\n );\n }\n\n applyDebugOption(options.debug, options.workspaceRoot);\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const isStackBlitz = !!process.versions['webcontainer'];\n const pluginOptions = {\n tsconfigGetter: createTsConfigGetter(options.tsconfig),\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n inlineStylesExtension: options.inlineStylesExtension ?? 'css',\n jit: options.jit ?? isTest,\n liveReload: options.liveReload ?? true,\n disableTypeChecking: options.disableTypeChecking ?? true,\n supportedBrowsers: options.supportedBrowsers ?? ['safari 15'],\n fileReplacements: options.fileReplacements ?? [],\n include: options.include ?? [],\n isAstroIntegration: process.env['ANALOG_ASTRO'] === 'true',\n };\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n let stylePreprocessor: StylePreprocessor | undefined;\n let transformFilter: TransformFilter | undefined;\n let externalizeStylesRequested = false;\n\n // Persistent compilation instance — kept alive across rebuilds so Angular\n // can diff prior state and emit `templateUpdates` for HMR.\n let angularCompilation:\n | Awaited<ReturnType<typeof createAngularCompilationType>>\n | undefined;\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const outputFiles = new Map<string, EmitFileResult>();\n const classNames = new Map<string, string>();\n let stylesheetRegistry: AnalogStylesheetRegistry | undefined;\n let compilationLock = Promise.resolve();\n let pendingCompilation: Promise<void> | null = null;\n let initialCompilation = false;\n let viteServer: ViteDevServer | undefined;\n const hotUpdates = createHotUpdateBatcher((ids) =>\n performCompilation(resolvedConfig, ids),\n );\n\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n isTest,\n });\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n let deferInitialCompilation = isVitestVscode;\n let testWatchMode = isTestWatchMode();\n\n function hasViteHmrTransport(): boolean {\n return resolvedConfig ? resolvedConfig.server.hmr !== false : true;\n }\n\n function shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n return !!(\n effectiveWatchMode &&\n pluginOptions.liveReload &&\n hasViteHmrTransport()\n );\n }\n\n function shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n if (!effectiveWatchMode) return false;\n return !!(shouldEnableLiveReload() || externalizeStylesRequested);\n }\n\n function resolveTsConfigPath() {\n const tsconfigValue = pluginOptions.tsconfigGetter();\n return getTsConfigPath(\n tsConfigResolutionContext!.root,\n tsconfigValue,\n tsConfigResolutionContext!.isProd,\n isTest,\n tsConfigResolutionContext!.isLib,\n );\n }\n\n function resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const includedFiles = tsconfigResolver.ensureIncludeCache();\n const cached = tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(\n resolvedTsConfigPath,\n config,\n );\n const mergedRootNames = union(\n cached.rootNames,\n expandedGraphRoots,\n includedFiles,\n ).map((file) => normalizePath(file));\n\n if (mergedRootNames.length === cached.rootNames.length) {\n return resolvedTsConfigPath;\n }\n\n const resolvedCacheDir = isAbsolute(config.cacheDir)\n ? config.cacheDir\n : resolve(config.root, config.cacheDir);\n const wrapperDir = join(\n resolvedCacheDir,\n 'analog-angular',\n 'compilation-api',\n );\n const rawTsconfig = (ts.readConfigFile(\n resolvedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as { references?: unknown[] };\n const wrapperPayload = {\n extends: normalizePath(resolvedTsConfigPath),\n files: [...mergedRootNames].sort(),\n ...(rawTsconfig.references ? { references: rawTsconfig.references } : {}),\n };\n const wrapperHash = createHash('sha1')\n .update(JSON.stringify(wrapperPayload))\n .digest('hex')\n .slice(0, 12);\n const wrapperPath = join(\n wrapperDir,\n `tsconfig.includes.${wrapperHash}.json`,\n );\n\n mkdirSync(wrapperDir, { recursive: true });\n if (!existsSync(wrapperPath)) {\n writeFileSync(\n wrapperPath,\n `${JSON.stringify(wrapperPayload, null, 2)}\\n`,\n 'utf-8',\n );\n }\n\n debugCompilationApi('generated include wrapper tsconfig', {\n originalTsconfig: resolvedTsConfigPath,\n wrapperTsconfig: wrapperPath,\n includeCount: includedFiles.length,\n rootNameCount: mergedRootNames.length,\n });\n\n return wrapperPath;\n }\n\n const normalizeEmitterLookupId = (file: string) => {\n const normalizedFile = normalizePath(file);\n if (!normalizedFile.startsWith('/@fs/')) return normalizedFile;\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n return normalizePath(fsPath);\n };\n\n let outputFile: ((file: string) => void) | undefined;\n const fileEmitter = (file: string) => {\n const normalizedFile = normalizeEmitterLookupId(file);\n outputFile?.(normalizedFile);\n return outputFiles.get(normalizedFile);\n };\n\n async function performAngularCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ) {\n const compilation = (angularCompilation ??= await (\n createAngularCompilation as typeof createAngularCompilationType\n )(!!pluginOptions.jit, false));\n const modifiedFiles = ids?.length\n ? new Set(ids.map((file) => normalizePath(file)))\n : undefined;\n if (modifiedFiles?.size) {\n sourceFileCache.invalidate(modifiedFiles);\n }\n if (modifiedFiles?.size && compilation.update) {\n debugCompilationApi('incremental update', {\n files: [...modifiedFiles],\n });\n await compilation.update(modifiedFiles);\n }\n\n const resolvedTsConfigPath = resolveTsConfigPath();\n const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath,\n config,\n );\n debugEmit('compilation initialize', {\n resolvedTsConfigPath,\n compilationApiTsConfigPath,\n modifiedFileCount: modifiedFiles?.size ?? 0,\n });\n const transformCompilerOptions = (\n tsCompilerOptions: Record<string, unknown>,\n ) => {\n if (shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (compilation API)', {\n liveReload: pluginOptions.liveReload,\n viteHmr: hasViteHmrTransport(),\n externalizeStylesRequested,\n watchMode,\n shouldExternalize: shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && resolvedConfig.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n return tsCompilerOptions;\n };\n const compilationResult = await compilation.initialize(\n compilationApiTsConfigPath,\n {\n fileReplacements: toAngularCompilationFileReplacements(\n pluginOptions.fileReplacements,\n pluginOptions.workspaceRoot,\n ),\n modifiedFiles,\n async transformStylesheet(\n data: string,\n containingFile: string,\n resourceFile: string | null,\n order: number,\n className: string | null,\n ) {\n const filename =\n resourceFile ??\n containingFile.replace(\n '.ts',\n `.${pluginOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n stylePreprocessor,\n {\n filename,\n containingFile,\n resourceFile,\n className,\n order,\n inline: !resourceFile,\n },\n );\n\n if (shouldEnableLiveReload() && className && containingFile) {\n classNames.set(normalizePath(containingFile), className as string);\n }\n\n if (shouldExternalizeStyles()) {\n const stylesheetId = registerStylesheetContent(\n stylesheetRegistry!,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile,\n className: className as string | undefined,\n order,\n inlineStylesExtension: pluginOptions.inlineStylesExtension,\n resourceFile: resourceFile ?? undefined,\n },\n );\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: resourceFile ?? '(inline)',\n });\n\n return stylesheetId;\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n debugStyles('preprocessCSS error', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n return stylesheetResult?.code || '';\n },\n processWebWorker(workerFile: string) {\n return workerFile;\n },\n },\n angularFullVersion >= 220200\n ? {\n enableHmr: shouldEnableLiveReload(),\n externalRuntimeStyles: shouldExternalizeStyles(),\n includeTestMetadata: isTest || shouldEnableLiveReload(),\n instrumentForCoverage: !isTest,\n }\n : (transformCompilerOptions as unknown as Parameters<\n typeof compilation.initialize\n >[2]),\n );\n\n // Preprocess external stylesheets for Tailwind CSS @reference\n debugStyles('external stylesheets from compilation API', {\n count: compilationResult.externalStylesheets?.size ?? 0,\n hasPreprocessor: !!stylePreprocessor,\n hasInlineMap: !!stylesheetRegistry,\n });\n const preprocessStats = { total: 0, injected: 0, skipped: 0, errors: 0 };\n for (const [key, value] of compilationResult.externalStylesheets ?? []) {\n preprocessStats.total++;\n const angularHash = `${value}.css`;\n stylesheetRegistry?.registerExternalRequest(angularHash, key);\n\n if (stylesheetRegistry && stylePreprocessor && existsSync(key)) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(preprocessed.code, key);\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId: angularHash,\n sourcePath: key,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [key, normalizePath(key), basename(key), key.replace(/^\\//, '')],\n );\n\n if (servedCss && servedCss !== rawCss) {\n preprocessStats.injected++;\n } else {\n preprocessStats.skipped++;\n }\n } catch (e) {\n preprocessStats.errors++;\n console.warn(\n `[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`,\n );\n }\n } else {\n preprocessStats.skipped++;\n }\n }\n debugStyles('external stylesheet preprocessing complete', preprocessStats);\n\n const diagnostics = await compilation.diagnoseFiles(\n pluginOptions.disableTypeChecking\n ? DiagnosticModes.All & ~DiagnosticModes.Semantic\n : DiagnosticModes.All,\n );\n\n const errors = diagnostics.errors?.length ? diagnostics.errors : [];\n const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];\n\n const templateUpdates = mapTemplateUpdatesToFiles(\n compilationResult.templateUpdates,\n );\n if (templateUpdates.size > 0) {\n debugHmr('compilation API template updates', {\n count: templateUpdates.size,\n files: [...templateUpdates.keys()],\n });\n }\n\n const affectedFiles = await compilation.emitAffectedFiles();\n debugEmit('emitAffectedFiles summary', {\n count: affectedFiles.length,\n templateUpdateCount: templateUpdates.size,\n knownOutputCountBefore: outputFiles.size,\n });\n\n for (const file of affectedFiles) {\n const normalizedFilename = normalizePath(file.filename);\n const templateUpdate = templateUpdates.get(normalizedFilename);\n\n if (templateUpdate) {\n classNames.set(normalizedFilename, templateUpdate.className);\n }\n\n outputFiles.set(normalizedFilename, {\n content: file.contents,\n dependencies: [],\n errors: errors.map((error: { text?: string }) => error.text || ''),\n warnings: warnings.map(\n (warning: { text?: string }) => warning.text || '',\n ),\n hmrUpdateCode: templateUpdate?.code,\n hmrEligible: !!templateUpdate?.code,\n });\n }\n\n // Free the compilation before chunks render; `transform` still reads `outputFiles`.\n if (!watchMode && !isTest) {\n await compilation.close?.();\n angularCompilation = undefined;\n }\n }\n\n async function performCompilation(config: ResolvedConfig, ids?: string[]) {\n let resolve: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n resolve = r;\n });\n try {\n await previousLock;\n const integrations = await discoverAnalogIntegrations(config);\n stylePreprocessor = integrations.stylePreprocessor;\n transformFilter = integrations.transformFilter;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n externalizeStylesRequested = integrations.externalizeStyles;\n await performAngularCompilation(config, ids);\n } finally {\n resolve!();\n }\n }\n\n function isComponentStyleSheet(id: string): boolean {\n return id.includes('ngcomp=');\n }\n\n function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n }\n\n function sendHMRComponentUpdate(server: ViteDevServer, id: string) {\n debugHmrV('ws send: angular component update', {\n id,\n timestamp: Date.now(),\n });\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(id),\n timestamp: Date.now(),\n });\n classNames.delete(id);\n }\n\n const compilerPlugin: Plugin = {\n name: '@analogjs/vite-plugin-angular-compilation-api',\n api: { getTsConfigPath: resolveTsConfigPath },\n enforce: 'pre' as const,\n async config(config, { command }) {\n activateDeferredDebug(command);\n watchMode = command === 'serve';\n const isProd =\n config.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n\n // Angular Compilation API handles TypeScript transforms — disable\n // esbuild/oxc so they don't compete.\n debugCompilationApi('esbuild/oxc disabled, Angular handles transforms');\n\n // The compilation API owns user-source transforms, but deps\n // optimization still bundles partial-compiled Angular libs from\n // node_modules (`ɵɵngDeclareInjectable/Factory`). Without the\n // linker plugin, those declarations reach the browser unprocessed\n // and Angular tries to JIT-compile them at runtime. Mirror the\n // deps-optimizer wiring from `angular-vite-plugin.ts` so the\n // linker runs on `.[cm]?js` deps under both rolldown and esbuild.\n const useRolldown = isRolldown();\n const preliminaryTsConfigPath = resolveTsConfigPath();\n const compilerPluginOptions = {\n tsconfig: preliminaryTsConfigPath,\n sourcemap: !isProd,\n advancedOptimizations: isProd,\n jit: pluginOptions.jit,\n incremental: watchMode,\n };\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`, registered once at the\n // `angularCompilationPlugin()` factory level. Adding `style` globally caused\n // Tailwind v4's JS plugin resolver to pick the `style` exports of\n // packages such as `tailwindcss-primeui`, which then crashed Node's\n // ESM loader when it tried to import the resulting `.css` file.\n return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(useRolldown\n ? {\n rolldownOptions: {\n plugins: [\n createRolldownCompilerPlugin(\n compilerPluginOptions,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }\n : {\n esbuildOptions: {\n plugins: [\n createCompilerPlugin(\n compilerPluginOptions,\n isTest,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }),\n },\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n const integrations = await discoverAnalogIntegrations(config);\n integrations.configureStylesheetRegistry?.(stylesheetRegistry, {\n workspaceRoot: pluginOptions.workspaceRoot,\n });\n debugStyles('stylesheet registry initialized (Angular Compilation API)');\n\n if (isTest) {\n const browser = (config as any).test?.browser;\n deferInitialCompilation =\n isVitestVscode ||\n (!!browser &&\n (getBrowserModeCliOverride() ?? browser.enabled) === true);\n\n testWatchMode =\n !(config.server.watch === null) ||\n (config as any).test?.watch === true ||\n testWatchMode;\n }\n },\n configureServer(server) {\n viteServer = server;\n hotUpdates.configureServer(server);\n\n const invalidateCompilation = async () => {\n tsconfigResolver.invalidateAll();\n await performCompilation(resolvedConfig);\n };\n server.watcher.on('add', invalidateCompilation);\n server.watcher.on('unlink', invalidateCompilation);\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n tsconfigResolver.invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n if (!deferInitialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n await pendingCompilation;\n pendingCompilation = null;\n initialCompilation = true;\n }\n },\n async handleHotUpdate(ctx) {\n if (isIgnoredHmrFile(ctx.file)) {\n debugHmr('ignored file change', { file: ctx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n debugHmr('TS file changed', { file: ctx.file, fileId });\n\n await hotUpdates.schedule(ctx.file, [fileId]);\n\n let result;\n\n if (shouldEnableLiveReload()) {\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!classNames.get(fileId),\n });\n }\n\n if (\n shouldEnableLiveReload() &&\n result?.hmrEligible &&\n classNames.get(fileId)\n ) {\n const relativeFileId = `${normalizePath(\n relative(process.cwd(), fileId),\n )}@${classNames.get(fileId)}`;\n\n debugHmr('sending component update', { relativeFileId });\n sendHMRComponentUpdate(ctx.server, relativeFileId);\n\n return ctx.modules.map((mod) => {\n if (mod.id === ctx.file) {\n mod.isSelfAccepting = true;\n }\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm)$/.test(ctx.file)) {\n debugHmr('template file changed', { file: ctx.file });\n // Recompile to pick up template changes\n pendingCompilation = performCompilation(resolvedConfig);\n }\n\n if (/\\.(css|less|sass|scss)$/.test(ctx.file)) {\n debugHmr('stylesheet file changed', { file: ctx.file });\n refreshStylesheetRegistryForFile(\n ctx.file,\n stylesheetRegistry,\n stylePreprocessor,\n );\n }\n\n return ctx.modules;\n },\n resolveId(id) {\n // Map angular component stylesheets\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath =\n stylesheetRegistry?.getServedSourcePath(filename);\n\n if (servedSourcePath) {\n debugStylesV('resolveId: mapped served stylesheet to source', {\n filename,\n resolvedPath: servedSourcePath,\n });\n return servedSourcePath + search;\n }\n\n if (stylesheetRegistry?.hasServed(filename)) {\n return id;\n }\n\n const componentStyles =\n stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n return componentStyles + new URL(id, 'http://localhost').search;\n }\n }\n\n return undefined;\n },\n async load(id) {\n // Virtual raw ids back JIT-emitted templateUrl/styleUrl imports.\n // virtual-modules-plugin resolves them; this plugin is the active\n // compilation plugin in compilation-API mode, so load must read the\n // backing file (jit=true is the test-mode default).\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Serve component stylesheets from registry\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (componentStyles) {\n stylesheetRegistry?.registerActiveRequest(id);\n return componentStyles;\n }\n }\n\n return;\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n if (/[?&]raw\\b/.test(id)) return;\n if (transformFilter && !transformFilter(code, id)) {\n return;\n }\n\n // Angular emits every file in the program, not only files with\n // Angular decorators, and `@analogjs/platform` excludes `.ts` from\n // Vite's own transform. So serve Angular's output for any emitted\n // file; only the \"not emitted\" warning below is decorator-specific.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n\n if (isTest) {\n if (deferInitialCompilation && !initialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n if (testWatchMode && invalidated) {\n pendingCompilation = performCompilation(resolvedConfig, [id]);\n }\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n await hotUpdates.wait();\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilationApi('transform skip (file not emitted)', { id });\n if (isAngular) {\n this.warn(\n `[@analogjs/vite-plugin-angular]: \"${id}\" contains Angular decorators but is not in the TypeScript program. ` +\n `Ensure it is included in your tsconfig.`,\n );\n }\n return;\n }\n\n if (typescriptResult.warnings && typescriptResult.warnings.length > 0) {\n this.warn(`${typescriptResult.warnings.join('\\n')}`);\n }\n\n if (typescriptResult.errors && typescriptResult.errors.length > 0) {\n this.error(`${typescriptResult.errors.join('\\n')}`);\n }\n\n let data = typescriptResult.content ?? '';\n\n // Re-inject @vite-ignore for Angular HMR dynamic imports\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n if (hasMetaUrl) {\n data = injectViteIgnoreForHmrMetadata(data);\n }\n }\n\n return {\n code: data,\n map: null,\n };\n },\n },\n async closeBundle() {\n hotUpdates.close();\n await compilationLock;\n await angularCompilation?.close?.();\n angularCompilation = undefined;\n outputFiles.clear();\n classNames.clear();\n sourceFileCache.clear();\n tsconfigResolver.invalidateAll();\n stylesheetRegistry = undefined;\n pendingCompilation = null;\n initialCompilation = false;\n },\n };\n\n return [\n cssExtensionStyleResolverPlugin(),\n replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),\n virtualModulesPlugin({ jit: pluginOptions.jit }),\n compilerPlugin,\n pluginOptions.liveReload && liveReloadPlugin({ classNames, fileEmitter }),\n ...(isTest && !isStackBlitz\n ? angularVitestPlugins((id) => outputFiles.get(normalizePath(id))?.map)\n : []),\n pluginOptions.jit &&\n jitPlugin({ inlineStylesExtension: pluginOptions.inlineStylesExtension }),\n buildOptimizerPlugin({\n jit: pluginOptions.jit,\n }),\n routerPlugin(),\n nxFolderPlugin(),\n encapsulationPlugin(),\n ].filter(Boolean) as Plugin[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,IAAM,KADU,cAAc,YAAY,GAC/B,CAAA,CAAQ,YAAY;;;;;;AAuB/B,SAAgB,yBACd,UAA2C,CAAC,GAClC;CACV,IACE,qBAAqB,UACrB,OAAO,6BAA6B,YAEpC,MAAM,IAAI,MACR,2JACF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G,CAAC;KAC/D,IAAI,WACF,KAAK,KACH,qCAAqC,GAAG,4GAE1C;KAEF;IACF;IAEA,IAAI,iBAAiB,YAAY,iBAAiB,SAAS,SAAS,GAClE,KAAK,KAAK,GAAG,iBAAiB,SAAS,KAAK,IAAI,GAAG;IAGrD,IAAI,iBAAiB,UAAU,iBAAiB,OAAO,SAAS,GAC9D,KAAK,MAAM,GAAG,iBAAiB,OAAO,KAAK,IAAI,GAAG;IAGpD,IAAI,OAAO,iBAAiB,WAAW;IAGvC,IAAI,KAAK,SAAS,SAAS,GACN;SAAA,KAAK,SAAS,uBAC7B,GACF,OAAO,+BAA+B,IAAI;IAAA;IAI9C,OAAO;KACL,MAAM;KACN,KAAK;IACP;GACF;EACF;EACA,MAAM,cAAc;GAClB,WAAW,MAAM;GACjB,MAAM;GACN,MAAM,oBAAoB,QAAQ;GAClC,qBAAqB,KAAA;GACrB,YAAY,MAAM;GAClB,WAAW,MAAM;GACjB,gBAAgB,MAAM;GACtB,iBAAiB,cAAc;GAC/B,qBAAqB,KAAA;GACrB,qBAAqB;GACrB,qBAAqB;EACvB;CACF;CAEA,OAAO;EACL,gCAAgC;EAChC,aAAa,cAAc,kBAAkB,cAAc,aAAa;EACxE,qBAAqB,EAAE,KAAK,cAAc,IAAI,CAAC;EAC/C;EACA,cAAc,cAAc,iBAAiB;GAAE;GAAY;EAAY,CAAC;EACxE,GAAI,UAAU,CAAC,eACX,sBAAsB,OAAO,YAAY,IAAI,cAAc,EAAE,CAAC,CAAC,EAAE,GAAG,IACpE,CAAC;EACL,cAAc,OACZ,UAAU,EAAE,uBAAuB,cAAc,sBAAsB,CAAC;EAC1E,qBAAqB,EACnB,KAAK,cAAc,IACrB,CAAC;EACD,aAAa;EACb,eAAe;EACf,oBAAoB;CACtB,CAAC,CAAC,OAAO,OAAO;AAClB"}
@@ -1 +1,2 @@
1
- import "./compilation-api-plugin.js";
1
+ import { angularCompilationPlugin } from "./compilation-api-plugin.js";
2
+ export { angularCompilationPlugin };
@@ -27,6 +27,6 @@ function angularVersionAtLeast(major) {
27
27
  return ANGULAR_MAJOR >= major;
28
28
  }
29
29
  //#endregion
30
- export { angularVersionAtLeast };
30
+ export { ANGULAR_MAJOR, angularVersionAtLeast };
31
31
 
32
32
  //# sourceMappingURL=angular-version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"angular-version.js","names":[],"sources":["../../../../src/lib/compiler/angular-version.ts"],"sourcesContent":["import * as o from '@angular/compiler';\n\n// Boundary blocks were introduced during the Angular 22.2 prereleases.\nexport const SUPPORTS_BOUNDARY_BLOCKS = 'TmplAstBoundaryBlock' in o;\n\nexport const SUPPORTS_INCREMENT_DECREMENT =\n typeof (o.UnaryOperator as Record<string, unknown>)['Increment'] === 'number';\n\n// Detect the installed @angular/compiler major version once at module load\n// time and expose helpers for version-aware code paths.\n//\n// Why this matters: Angular's compiler API surface (enum members,\n// metadata shapes, output formats) shifts between major versions in ways\n// that can't always be papered over with duck typing. The compatibility\n// matrix in .github/workflows/compiler-compat.yml runs the test\n// suite against multiple installed versions to catch this drift, and the\n// version-aware code paths in compile.ts / js-emitter.ts / metadata.ts\n// gate behavior on `ANGULAR_MAJOR` to keep the compiler working across\n// the supported `peerDependencies` range (currently >=20.0.0).\n//\n// Default fallback: when the version string is missing or unparseable\n// (vendored builds, monkey-patched test environments), assume the latest\n// known major. This biases toward the most-tested code path.\nconst DEFAULT_ASSUMED_MAJOR = 22;\n\n/**\n * The major version of the installed `@angular/compiler` package, parsed\n * from `o.VERSION.major`. Falls back to `DEFAULT_ASSUMED_MAJOR` when the\n * version is unavailable.\n */\nexport const ANGULAR_MAJOR: number = (() => {\n const major = Number.parseInt(o.VERSION?.major ?? '', 10);\n return Number.isFinite(major) && major > 0 ? major : DEFAULT_ASSUMED_MAJOR;\n})();\n\n/**\n * Returns `true` when the installed Angular major is at least `major`.\n * Use this to gate code paths that depend on APIs introduced in a\n * specific Angular release.\n *\n * @example\n * if (angularVersionAtLeast(21)) {\n * // Use Angular 21+ API\n * } else {\n * // Fall back to v20 behavior\n * }\n */\nexport function angularVersionAtLeast(major: number): boolean {\n return ANGULAR_MAJOR >= major;\n}\n"],"mappings":";AAGwC,0BAA0B;AAGxD,EAAE,cAA0C;AAiBtD,IAAM,wBAAwB;;;;;;AAO9B,IAAa,uBAA+B;CAC1C,MAAM,QAAQ,OAAO,SAAS,EAAE,SAAS,SAAS,IAAI,GAAG;AACzD,QAAO,OAAO,SAAS,MAAM,IAAI,QAAQ,IAAI,QAAQ;IACnD;;;;;;;;;;;;;AAcJ,SAAgB,sBAAsB,OAAwB;AAC5D,QAAO,iBAAiB"}
1
+ {"version":3,"file":"angular-version.js","names":[],"sources":["../../../../src/lib/compiler/angular-version.ts"],"sourcesContent":["import * as o from '@angular/compiler';\n\n// Boundary blocks were introduced during the Angular 22.2 prereleases.\nexport const SUPPORTS_BOUNDARY_BLOCKS = 'TmplAstBoundaryBlock' in o;\n\nexport const SUPPORTS_INCREMENT_DECREMENT =\n typeof (o.UnaryOperator as Record<string, unknown>)['Increment'] === 'number';\n\n// Detect the installed @angular/compiler major version once at module load\n// time and expose helpers for version-aware code paths.\n//\n// Why this matters: Angular's compiler API surface (enum members,\n// metadata shapes, output formats) shifts between major versions in ways\n// that can't always be papered over with duck typing. The compatibility\n// matrix in .github/workflows/compiler-compat.yml runs the test\n// suite against multiple installed versions to catch this drift, and the\n// version-aware code paths in compile.ts / js-emitter.ts / metadata.ts\n// gate behavior on `ANGULAR_MAJOR` to keep the compiler working across\n// the supported `peerDependencies` range (currently >=20.0.0).\n//\n// Default fallback: when the version string is missing or unparseable\n// (vendored builds, monkey-patched test environments), assume the latest\n// known major. This biases toward the most-tested code path.\nconst DEFAULT_ASSUMED_MAJOR = 22;\n\n/**\n * The major version of the installed `@angular/compiler` package, parsed\n * from `o.VERSION.major`. Falls back to `DEFAULT_ASSUMED_MAJOR` when the\n * version is unavailable.\n */\nexport const ANGULAR_MAJOR: number = (() => {\n const major = Number.parseInt(o.VERSION?.major ?? '', 10);\n return Number.isFinite(major) && major > 0 ? major : DEFAULT_ASSUMED_MAJOR;\n})();\n\n/**\n * Returns `true` when the installed Angular major is at least `major`.\n * Use this to gate code paths that depend on APIs introduced in a\n * specific Angular release.\n *\n * @example\n * if (angularVersionAtLeast(21)) {\n * // Use Angular 21+ API\n * } else {\n * // Fall back to v20 behavior\n * }\n */\nexport function angularVersionAtLeast(major: number): boolean {\n return ANGULAR_MAJOR >= major;\n}\n"],"mappings":";AAGwC,0BAA0B;AAGxD,EAAE,cAA0C;AAiBtD,IAAM,wBAAwB;;;;;;AAO9B,IAAa,uBAA+B;CAC1C,MAAM,QAAQ,OAAO,SAAS,EAAE,SAAS,SAAS,IAAI,EAAE;CACxD,OAAO,OAAO,SAAS,KAAK,KAAK,QAAQ,IAAI,QAAQ;AACvD,EAAA,CAAG;;;;;;;;;;;;;AAcH,SAAgB,sBAAsB,OAAwB;CAC5D,OAAO,iBAAiB;AAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"class-field-lowering.js","names":[],"sources":["../../../../src/lib/compiler/class-field-lowering.ts"],"sourcesContent":["import MagicString from 'magic-string';\n\n/**\n * Lower instance class field initializers into constructor assignments.\n *\n * When `useDefineForClassFields` is `false` (the standard Angular tsconfig),\n * field initializers must run as assignments inside the constructor body\n * rather than as native ES class field initializers. This ensures:\n *\n * 1. `inject()` calls in fields have an active injection context\n * 2. Fields referencing other injected fields work (sequential assignment)\n * 3. Constructor parameter properties are available to field initializers\n * 4. Inheritance works (parent constructor runs before child field assignments)\n *\n * Rules:\n * - Regular fields with initializers: remove declaration, add `this.field = value;`\n * - Private fields (`#field`) with initializers: keep `#field;` declaration, add `this.#field = value;`\n * - Static fields: not lowered\n * - Fields without initializers: not lowered\n * - `declare` fields: not lowered\n * - Assignments are inserted after `super()` (if present), before existing constructor body\n * - If no constructor exists, one is created (with `super(...args)` for subclasses)\n */\nexport function lowerClassFields(\n ms: MagicString,\n sourceCode: string,\n oxcProgram: any,\n): void {\n for (const stmt of oxcProgram.body) {\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? (stmt as any).declaration\n : stmt;\n\n if (\n !decl ||\n (decl.type !== 'ClassDeclaration' && decl.type !== 'ClassExpression') ||\n !decl.body\n ) {\n continue;\n }\n\n lowerClassFieldsForClass(ms, sourceCode, decl);\n }\n}\n\ninterface FieldToLower {\n /** The full property definition node */\n node: any;\n /** The member access expression to append after `this`, e.g. `.name`, `.#priv`, `[expr]`, `['some-key']`, `[123]` */\n accessor: string;\n /** The initializer source text */\n initializer: string;\n /** Whether this is a private field (#field) */\n isPrivate: boolean;\n}\n\nfunction lowerClassFieldsForClass(\n ms: MagicString,\n sourceCode: string,\n classNode: any,\n): void {\n const body = classNode.body;\n const members: any[] = body.body;\n const fieldsToLower: FieldToLower[] = [];\n\n for (const member of members) {\n if (!shouldLowerField(member)) continue;\n\n const accessor = getFieldAccessor(member, sourceCode);\n const initializer = sourceCode.slice(member.value.start, member.value.end);\n\n fieldsToLower.push({\n node: member,\n accessor,\n initializer,\n isPrivate:\n member.type === 'PropertyDefinition' &&\n member.key?.type === 'PrivateIdentifier',\n });\n }\n\n if (fieldsToLower.length === 0) return;\n\n // Build assignment statements\n const assignments = fieldsToLower.map(\n (f) => ` this${f.accessor} = ${f.initializer};`,\n );\n\n // Find existing constructor\n const ctor = members.find(\n (m: any) => m.type === 'MethodDefinition' && m.kind === 'constructor',\n );\n\n // Check if class has a superclass\n const hasSuperClass = !!classNode.superClass;\n\n if (ctor) {\n insertIntoExistingConstructor(ms, sourceCode, ctor, assignments);\n } else {\n createConstructorWithAssignments(\n ms,\n sourceCode,\n body,\n members,\n assignments,\n hasSuperClass,\n );\n }\n\n // Remove or strip field declarations\n for (const field of fieldsToLower) {\n if (field.isPrivate) {\n // Keep declaration without initializer: `#field;`\n // Start scanning after the type annotation (if present) to avoid\n // matching `=` inside `=>` of arrow function type annotations.\n const scanFrom = field.node.typeAnnotation\n ? field.node.typeAnnotation.end\n : field.node.key.end;\n const eqStart = findEqualsSign(\n sourceCode,\n scanFrom,\n field.node.value.start,\n );\n ms.remove(eqStart, field.node.value.end);\n } else {\n // Remove the field declaration. Include the trailing newline to avoid\n // leaving blank lines, BUT only if the character after the newline isn't\n // the closing `}` of the class. Otherwise the removal range ends at the\n // same position where Ivy static definitions are appendLeft-inserted,\n // and MagicString consumes those insertions as part of the removed range.\n let end = field.node.end;\n const nextChar = sourceCode[end];\n const charAfterNewline =\n nextChar === '\\n'\n ? sourceCode[end + 1]\n : nextChar === '\\r' && sourceCode[end + 1] === '\\n'\n ? sourceCode[end + 2]\n : null;\n // Only consume newline(s) when the next non-whitespace char is not `}`\n const safeToConsumeNewline =\n charAfterNewline !== null && charAfterNewline !== '}';\n if (safeToConsumeNewline) {\n if (nextChar === '\\n') end++;\n else if (nextChar === '\\r' && sourceCode[end + 1] === '\\n') end += 2;\n }\n ms.remove(field.node.start, end);\n }\n }\n}\n\nfunction shouldLowerField(member: any): boolean {\n // Must be a PropertyDefinition with an initializer (value)\n if (member.type !== 'PropertyDefinition') return false;\n if (!member.value) return false;\n // Don't lower static fields\n if (member.static) return false;\n // Don't lower declare fields\n if (member.declare) return false;\n\n return true;\n}\n\n/**\n * Build the member-access expression to append after `this` for a class field\n * being lowered. Returns the accessor with its leading punctuation:\n *\n * - `.name` — non-computed identifier key\n * - `.#priv` — private identifier key\n * - `[expr]` — computed key (square brackets in source)\n * - `['some-key']` — string literal key\n * - `[123]` — numeric literal key\n *\n * Without this, fields with non-identifier keys produced invalid syntax like\n * `this.'some-key' = …` which OXC parses as \"Cannot assign to this expression\".\n */\nfunction getFieldAccessor(member: any, sourceCode: string): string {\n const key = member.key;\n if (key.type === 'PrivateIdentifier') {\n return '.#' + key.name;\n }\n // Computed key: `[expr] = value` → `this[expr] = value`\n // OXC marks the parent PropertyDefinition with `computed: true`.\n if (member.computed) {\n return '[' + sourceCode.slice(key.start, key.end) + ']';\n }\n if (key.type === 'Identifier') {\n return '.' + key.name;\n }\n // String literal key: `'some-key' = value` → `this['some-key'] = value`\n if (\n key.type === 'StringLiteral' ||\n (key.type === 'Literal' && typeof key.value === 'string')\n ) {\n return '[' + JSON.stringify(key.value) + ']';\n }\n // Numeric literal key: `123 = value` → `this[123] = value`\n if (\n key.type === 'NumericLiteral' ||\n (key.type === 'Literal' && typeof key.value === 'number')\n ) {\n return '[' + key.value + ']';\n }\n // Fallback: bracket-access with the original source text\n return '[' + sourceCode.slice(key.start, key.end) + ']';\n}\n\nfunction findEqualsSign(sourceCode: string, from: number, to: number): number {\n for (let i = from; i < to; i++) {\n if (sourceCode[i] === '=') return i;\n }\n return from;\n}\n\nfunction insertIntoExistingConstructor(\n ms: MagicString,\n sourceCode: string,\n ctor: any,\n assignments: string[],\n): void {\n const ctorBody = ctor.value.body;\n if (!ctorBody) return;\n\n const bodyStatements: any[] = ctorBody.body;\n const assignmentBlock = '\\n' + assignments.join('\\n');\n\n // Find the position after super() call (if any)\n let insertPos: number | null = null;\n for (const stmt of bodyStatements) {\n if (isSuperCall(stmt)) {\n // Insert after super() statement including its semicolon\n insertPos = stmt.end;\n break;\n }\n }\n\n if (insertPos !== null) {\n ms.appendRight(insertPos, assignmentBlock);\n } else if (bodyStatements.length > 0) {\n // Insert before the first statement\n ms.appendRight(bodyStatements[0].start, assignments.join('\\n') + '\\n ');\n } else {\n // Empty constructor body — insert after opening {\n ms.appendRight(ctorBody.start + 1, assignmentBlock + '\\n ');\n }\n}\n\nfunction createConstructorWithAssignments(\n ms: MagicString,\n sourceCode: string,\n classBody: any,\n members: any[],\n assignments: string[],\n hasSuperClass: boolean,\n): void {\n const superCall = hasSuperClass ? ' super(...args);\\n' : '';\n const args = hasSuperClass ? '...args' : '';\n const ctorCode = [\n ` constructor(${args}) {`,\n superCall ? superCall.trimEnd() : null,\n ...assignments,\n ' }',\n ]\n .filter((l) => l !== null)\n .join('\\n');\n\n // Insert constructor at the beginning of the class body (after opening {)\n ms.appendRight(classBody.start + 1, '\\n' + ctorCode + '\\n');\n}\n\nfunction isSuperCall(stmt: any): boolean {\n if (stmt.type !== 'ExpressionStatement') return false;\n const expr = stmt.expression;\n if (expr.type !== 'CallExpression') return false;\n return expr.callee?.type === 'Super';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,iBACd,IACA,YACA,YACM;AACN,MAAK,MAAM,QAAQ,WAAW,MAAM;EAClC,MAAM,OACJ,KAAK,SAAS,4BACd,KAAK,SAAS,6BACT,KAAa,cACd;AAEN,MACE,CAAC,QACA,KAAK,SAAS,sBAAsB,KAAK,SAAS,qBACnD,CAAC,KAAK,KAEN;AAGF,2BAAyB,IAAI,YAAY,KAAK;;;AAelD,SAAS,yBACP,IACA,YACA,WACM;CACN,MAAM,OAAO,UAAU;CACvB,MAAM,UAAiB,KAAK;CAC5B,MAAM,gBAAgC,EAAE;AAExC,MAAK,MAAM,UAAU,SAAS;AAC5B,MAAI,CAAC,iBAAiB,OAAO,CAAE;EAE/B,MAAM,WAAW,iBAAiB,QAAQ,WAAW;EACrD,MAAM,cAAc,WAAW,MAAM,OAAO,MAAM,OAAO,OAAO,MAAM,IAAI;AAE1E,gBAAc,KAAK;GACjB,MAAM;GACN;GACA;GACA,WACE,OAAO,SAAS,wBAChB,OAAO,KAAK,SAAS;GACxB,CAAC;;AAGJ,KAAI,cAAc,WAAW,EAAG;CAGhC,MAAM,cAAc,cAAc,KAC/B,MAAM,WAAW,EAAE,SAAS,KAAK,EAAE,YAAY,GACjD;CAGD,MAAM,OAAO,QAAQ,MAClB,MAAW,EAAE,SAAS,sBAAsB,EAAE,SAAS,cACzD;CAGD,MAAM,gBAAgB,CAAC,CAAC,UAAU;AAElC,KAAI,KACF,+BAA8B,IAAI,YAAY,MAAM,YAAY;KAEhE,kCACE,IACA,YACA,MACA,SACA,aACA,cACD;AAIH,MAAK,MAAM,SAAS,cAClB,KAAI,MAAM,WAAW;EAOnB,MAAM,UAAU,eACd,YAJe,MAAM,KAAK,iB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,IACzB,KAAI,WAAW,OAAO,IAAK,QAAO;AAEpC,QAAO;;AAGT,SAAS,8BACP,IACA,YACA,MACA,aACM;CACN,MAAM,WAAW,KAAK,MAAM;AAC5B,KAAI,CAAC,SAAU;CAEf,MAAM,iBAAwB,SAAS;CACvC,MAAM,kBAAkB,OAAO,YAAY,KAAK,KAAK;CAGrD,IAAI,YAA2B;AAC/B,MAAK,MAAM,QAAQ,eACjB,KAAI,YAAY,KAAK,EAAE;AAErB,cAAY,KAAK;AACjB;;AAIJ,KAAI,cAAc,KAChB,IAAG,YAAY,WAAW,gBAAgB;UACjC,eAAe,SAAS,EAEjC,IAAG,YAAY,eAAe,GAAG,OAAO,YAAY,KAAK,KAAK,GAAG,SAAS;KAG1E,IAAG,YAAY,SAAS,QAAQ,GAAG,kBAAkB,OAAO;;AAIhE,SAAS,iCACP,IACA,YACA,WACA,SACA,aACA,eACM;CACN,MAAM,YAAY,gBAAgB,0BAA0B;CAE5D,MAAM,WAAW;EACf,iBAFW,gBAAgB,YAAY,GAEjB;EACtB,YAAY,UAAU,SAAS,GAAG;EAClC,GAAG;EACH;EACD,CACE,QAAQ,MAAM,MAAM,KAAK,CACzB,KAAK,KAAK;AAGb,IAAG,YAAY,UAAU,QAAQ,GAAG,OAAO,WAAW,KAAK;;AAG7D,SAAS,YAAY,MAAoB;AACvC,KAAI,KAAK,SAAS,sBAAuB,QAAO;CAChD,MAAM,OAAO,KAAK;AAClB,KAAI,KAAK,SAAS,iBAAkB,QAAO;AAC3C,QAAO,KAAK,QAAQ,SAAS"}
1
+ {"version":3,"file":"class-field-lowering.js","names":[],"sources":["../../../../src/lib/compiler/class-field-lowering.ts"],"sourcesContent":["import MagicString from 'magic-string';\n\n/**\n * Lower instance class field initializers into constructor assignments.\n *\n * When `useDefineForClassFields` is `false` (the standard Angular tsconfig),\n * field initializers must run as assignments inside the constructor body\n * rather than as native ES class field initializers. This ensures:\n *\n * 1. `inject()` calls in fields have an active injection context\n * 2. Fields referencing other injected fields work (sequential assignment)\n * 3. Constructor parameter properties are available to field initializers\n * 4. Inheritance works (parent constructor runs before child field assignments)\n *\n * Rules:\n * - Regular fields with initializers: remove declaration, add `this.field = value;`\n * - Private fields (`#field`) with initializers: keep `#field;` declaration, add `this.#field = value;`\n * - Static fields: not lowered\n * - Fields without initializers: not lowered\n * - `declare` fields: not lowered\n * - Assignments are inserted after `super()` (if present), before existing constructor body\n * - If no constructor exists, one is created (with `super(...args)` for subclasses)\n */\nexport function lowerClassFields(\n ms: MagicString,\n sourceCode: string,\n oxcProgram: any,\n): void {\n for (const stmt of oxcProgram.body) {\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? (stmt as any).declaration\n : stmt;\n\n if (\n !decl ||\n (decl.type !== 'ClassDeclaration' && decl.type !== 'ClassExpression') ||\n !decl.body\n ) {\n continue;\n }\n\n lowerClassFieldsForClass(ms, sourceCode, decl);\n }\n}\n\ninterface FieldToLower {\n /** The full property definition node */\n node: any;\n /** The member access expression to append after `this`, e.g. `.name`, `.#priv`, `[expr]`, `['some-key']`, `[123]` */\n accessor: string;\n /** The initializer source text */\n initializer: string;\n /** Whether this is a private field (#field) */\n isPrivate: boolean;\n}\n\nfunction lowerClassFieldsForClass(\n ms: MagicString,\n sourceCode: string,\n classNode: any,\n): void {\n const body = classNode.body;\n const members: any[] = body.body;\n const fieldsToLower: FieldToLower[] = [];\n\n for (const member of members) {\n if (!shouldLowerField(member)) continue;\n\n const accessor = getFieldAccessor(member, sourceCode);\n const initializer = sourceCode.slice(member.value.start, member.value.end);\n\n fieldsToLower.push({\n node: member,\n accessor,\n initializer,\n isPrivate:\n member.type === 'PropertyDefinition' &&\n member.key?.type === 'PrivateIdentifier',\n });\n }\n\n if (fieldsToLower.length === 0) return;\n\n // Build assignment statements\n const assignments = fieldsToLower.map(\n (f) => ` this${f.accessor} = ${f.initializer};`,\n );\n\n // Find existing constructor\n const ctor = members.find(\n (m: any) => m.type === 'MethodDefinition' && m.kind === 'constructor',\n );\n\n // Check if class has a superclass\n const hasSuperClass = !!classNode.superClass;\n\n if (ctor) {\n insertIntoExistingConstructor(ms, sourceCode, ctor, assignments);\n } else {\n createConstructorWithAssignments(\n ms,\n sourceCode,\n body,\n members,\n assignments,\n hasSuperClass,\n );\n }\n\n // Remove or strip field declarations\n for (const field of fieldsToLower) {\n if (field.isPrivate) {\n // Keep declaration without initializer: `#field;`\n // Start scanning after the type annotation (if present) to avoid\n // matching `=` inside `=>` of arrow function type annotations.\n const scanFrom = field.node.typeAnnotation\n ? field.node.typeAnnotation.end\n : field.node.key.end;\n const eqStart = findEqualsSign(\n sourceCode,\n scanFrom,\n field.node.value.start,\n );\n ms.remove(eqStart, field.node.value.end);\n } else {\n // Remove the field declaration. Include the trailing newline to avoid\n // leaving blank lines, BUT only if the character after the newline isn't\n // the closing `}` of the class. Otherwise the removal range ends at the\n // same position where Ivy static definitions are appendLeft-inserted,\n // and MagicString consumes those insertions as part of the removed range.\n let end = field.node.end;\n const nextChar = sourceCode[end];\n const charAfterNewline =\n nextChar === '\\n'\n ? sourceCode[end + 1]\n : nextChar === '\\r' && sourceCode[end + 1] === '\\n'\n ? sourceCode[end + 2]\n : null;\n // Only consume newline(s) when the next non-whitespace char is not `}`\n const safeToConsumeNewline =\n charAfterNewline !== null && charAfterNewline !== '}';\n if (safeToConsumeNewline) {\n if (nextChar === '\\n') end++;\n else if (nextChar === '\\r' && sourceCode[end + 1] === '\\n') end += 2;\n }\n ms.remove(field.node.start, end);\n }\n }\n}\n\nfunction shouldLowerField(member: any): boolean {\n // Must be a PropertyDefinition with an initializer (value)\n if (member.type !== 'PropertyDefinition') return false;\n if (!member.value) return false;\n // Don't lower static fields\n if (member.static) return false;\n // Don't lower declare fields\n if (member.declare) return false;\n\n return true;\n}\n\n/**\n * Build the member-access expression to append after `this` for a class field\n * being lowered. Returns the accessor with its leading punctuation:\n *\n * - `.name` — non-computed identifier key\n * - `.#priv` — private identifier key\n * - `[expr]` — computed key (square brackets in source)\n * - `['some-key']` — string literal key\n * - `[123]` — numeric literal key\n *\n * Without this, fields with non-identifier keys produced invalid syntax like\n * `this.'some-key' = …` which OXC parses as \"Cannot assign to this expression\".\n */\nfunction getFieldAccessor(member: any, sourceCode: string): string {\n const key = member.key;\n if (key.type === 'PrivateIdentifier') {\n return '.#' + key.name;\n }\n // Computed key: `[expr] = value` → `this[expr] = value`\n // OXC marks the parent PropertyDefinition with `computed: true`.\n if (member.computed) {\n return '[' + sourceCode.slice(key.start, key.end) + ']';\n }\n if (key.type === 'Identifier') {\n return '.' + key.name;\n }\n // String literal key: `'some-key' = value` → `this['some-key'] = value`\n if (\n key.type === 'StringLiteral' ||\n (key.type === 'Literal' && typeof key.value === 'string')\n ) {\n return '[' + JSON.stringify(key.value) + ']';\n }\n // Numeric literal key: `123 = value` → `this[123] = value`\n if (\n key.type === 'NumericLiteral' ||\n (key.type === 'Literal' && typeof key.value === 'number')\n ) {\n return '[' + key.value + ']';\n }\n // Fallback: bracket-access with the original source text\n return '[' + sourceCode.slice(key.start, key.end) + ']';\n}\n\nfunction findEqualsSign(sourceCode: string, from: number, to: number): number {\n for (let i = from; i < to; i++) {\n if (sourceCode[i] === '=') return i;\n }\n return from;\n}\n\nfunction insertIntoExistingConstructor(\n ms: MagicString,\n sourceCode: string,\n ctor: any,\n assignments: string[],\n): void {\n const ctorBody = ctor.value.body;\n if (!ctorBody) return;\n\n const bodyStatements: any[] = ctorBody.body;\n const assignmentBlock = '\\n' + assignments.join('\\n');\n\n // Find the position after super() call (if any)\n let insertPos: number | null = null;\n for (const stmt of bodyStatements) {\n if (isSuperCall(stmt)) {\n // Insert after super() statement including its semicolon\n insertPos = stmt.end;\n break;\n }\n }\n\n if (insertPos !== null) {\n ms.appendRight(insertPos, assignmentBlock);\n } else if (bodyStatements.length > 0) {\n // Insert before the first statement\n ms.appendRight(bodyStatements[0].start, assignments.join('\\n') + '\\n ');\n } else {\n // Empty constructor body — insert after opening {\n ms.appendRight(ctorBody.start + 1, assignmentBlock + '\\n ');\n }\n}\n\nfunction createConstructorWithAssignments(\n ms: MagicString,\n sourceCode: string,\n classBody: any,\n members: any[],\n assignments: string[],\n hasSuperClass: boolean,\n): void {\n const superCall = hasSuperClass ? ' super(...args);\\n' : '';\n const args = hasSuperClass ? '...args' : '';\n const ctorCode = [\n ` constructor(${args}) {`,\n superCall ? superCall.trimEnd() : null,\n ...assignments,\n ' }',\n ]\n .filter((l) => l !== null)\n .join('\\n');\n\n // Insert constructor at the beginning of the class body (after opening {)\n ms.appendRight(classBody.start + 1, '\\n' + ctorCode + '\\n');\n}\n\nfunction isSuperCall(stmt: any): boolean {\n if (stmt.type !== 'ExpressionStatement') return false;\n const expr = stmt.expression;\n if (expr.type !== 'CallExpression') return false;\n return expr.callee?.type === 'Super';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,iBACd,IACA,YACA,YACM;CACN,KAAK,MAAM,QAAQ,WAAW,MAAM;EAClC,MAAM,OACJ,KAAK,SAAS,4BACd,KAAK,SAAS,6BACT,KAAa,cACd;EAEN,IACE,CAAC,QACA,KAAK,SAAS,sBAAsB,KAAK,SAAS,qBACnD,CAAC,KAAK,MAEN;EAGF,yBAAyB,IAAI,YAAY,IAAI;CAC/C;AACF;AAaA,SAAS,yBACP,IACA,YACA,WACM;CACN,MAAM,OAAO,UAAU;CACvB,MAAM,UAAiB,KAAK;CAC5B,MAAM,gBAAgC,CAAC;CAEvC,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,CAAC,iBAAiB,MAAM,GAAG;EAE/B,MAAM,WAAW,iBAAiB,QAAQ,UAAU;EACpD,MAAM,cAAc,WAAW,MAAM,OAAO,MAAM,OAAO,OAAO,MAAM,GAAG;EAEzE,cAAc,KAAK;GACjB,MAAM;GACN;GACA;GACA,WACE,OAAO,SAAS,wBAChB,OAAO,KAAK,SAAS;EACzB,CAAC;CACH;CAEA,IAAI,cAAc,WAAW,GAAG;CAGhC,MA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OAAO,WAAW,IAAI;AAC5D;AAEA,SAAS,YAAY,MAAoB;CACvC,IAAI,KAAK,SAAS,uBAAuB,OAAO;CAChD,MAAM,OAAO,KAAK;CAClB,IAAI,KAAK,SAAS,kBAAkB,OAAO;CAC3C,OAAO,KAAK,QAAQ,SAAS;AAC/B"}
@@ -86,7 +86,8 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
86
86
  const stringConsts = collectStringConstants(oxcProgram);
87
87
  const constantPool = new ConstantPool();
88
88
  const resourceDependencies = [];
89
- const parseLoc = new ParseLocation(new ParseSourceFile(sourceCode, fileName), 0, 0, 0);
89
+ const parseFile = new ParseSourceFile(sourceCode, fileName);
90
+ const parseLoc = new ParseLocation(parseFile, 0, 0, 0);
90
91
  const typeSourceSpan = new ParseSourceSpan(parseLoc, parseLoc);
91
92
  const typeOnlyImports = detectTypeOnlyImportNames(sourceCode, oxcProgram);
92
93
  const importSpecifierByName = /* @__PURE__ */ new Map();
@@ -645,25 +646,27 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
645
646
  const decArgsNode = call.arguments[0];
646
647
  const resources = resolvedResources.get(dec);
647
648
  let metadataArgsExpr = null;
648
- if (decArgsNode) if (resources && ts.isObjectLiteralExpression(decArgsNode)) {
649
- const rewrittenProps = [];
650
- let needsTransform = false;
651
- for (const prop of decArgsNode.properties) {
652
- if (!ts.isPropertyAssignment(prop)) {
653
- rewrittenProps.push(prop.getText(origSourceFile));
654
- continue;
649
+ if (decArgsNode) {
650
+ if (resources && ts.isObjectLiteralExpression(decArgsNode)) {
651
+ const rewrittenProps = [];
652
+ let needsTransform = false;
653
+ for (const prop of decArgsNode.properties) {
654
+ if (!ts.isPropertyAssignment(prop)) {
655
+ rewrittenProps.push(prop.getText(origSourceFile));
656
+ continue;
657
+ }
658
+ const propName = prop.name?.getText(origSourceFile);
659
+ if (propName === "templateUrl" && resources.template) {
660
+ rewrittenProps.push(`template: ${JSON.stringify(resources.template)}`);
661
+ needsTransform = true;
662
+ } else if ((propName === "styleUrl" || propName === "styleUrls") && resources.styles?.length) {
663
+ rewrittenProps.push(`styles: [${resources.styles.map((s) => JSON.stringify(s)).join(", ")}]`);
664
+ needsTransform = true;
665
+ } else rewrittenProps.push(prop.getText(origSourceFile));
655
666
  }
656
- const propName = prop.name?.getText(origSourceFile);
657
- if (propName === "templateUrl" && resources.template) {
658
- rewrittenProps.push(`template: ${JSON.stringify(resources.template)}`);
659
- needsTransform = true;
660
- } else if ((propName === "styleUrl" || propName === "styleUrls") && resources.styles?.length) {
661
- rewrittenProps.push(`styles: [${resources.styles.map((s) => JSON.stringify(s)).join(", ")}]`);
662
- needsTransform = true;
663
- } else rewrittenProps.push(prop.getText(origSourceFile));
664
- }
665
- metadataArgsExpr = needsTransform ? `{${rewrittenProps.join(", ")}}` : decArgsNode.getText(origSourceFile);
666
- } else metadataArgsExpr = decArgsNode.getText(origSourceFile);
667
+ metadataArgsExpr = needsTransform ? `{${rewrittenProps.join(", ")}}` : decArgsNode.getText(origSourceFile);
668
+ } else metadataArgsExpr = decArgsNode.getText(origSourceFile);
669
+ }
667
670
  try {
668
671
  const classMetaInput = {
669
672
  type: new o.WrappedNodeExpr(ts.factory.createIdentifier(className)),
@@ -738,9 +741,8 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
738
741
  }
739
742
  if (referencesNonHoistable) for (const name of getDefinedNames(stmt)) nonHoistableNames.add(name);
740
743
  else {
741
- const text = stmt.getText(origSourceFile);
742
- ms.remove(stmtStart, stmt.getEnd());
743
- ms.appendLeft(firstClassPos, text + "\n");
744
+ ms.appendLeft(stmt.getEnd(), "\n");
745
+ ms.move(stmtStart, stmt.getEnd(), firstClassPos);
744
746
  }
745
747
  }
746
748
  }