@analogjs/vite-plugin-angular 3.0.0-alpha.75 → 3.0.0-alpha.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/vite-plugin-angular",
3
- "version": "3.0.0-alpha.75",
3
+ "version": "3.0.0-alpha.76",
4
4
  "description": "Vite Plugin for Angular",
5
5
  "type": "module",
6
6
  "keywords": [
package/src/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { angular } from "./lib/angular-vite-plugin.js";
2
2
  export { angular } from "./lib/angular-vite-plugin.js";
3
3
  export type { PluginOptions } from "./lib/angular-vite-plugin.js";
4
- export type { AnalogIntegrationPlugin, AnalogPluginContext, AnalogPluginHooks, StylesheetRegistryConfigurator, StylesheetRegistryContext } from "./lib/analog-plugin-interop.js";
4
+ export type { AnalogIntegrationPlugin, AnalogPluginContext, AnalogPluginHooks, ComponentRegistryEntries, StylesheetRegistryConfigurator, StylesheetRegistryContext, TransformFilter } from "./lib/analog-plugin-interop.js";
5
+ export type { RegistryEntry as ComponentRegistryEntry, RegistryInput as ComponentRegistryInput } from "./lib/compiler/registry.js";
5
6
  export type { StylePreprocessor, StylesheetDependency, StylesheetDiagnostic, StylesheetRegistryReader, StylesheetTransformContext, StylesheetTransformResult } from "./lib/style-preprocessor.js";
6
7
  export default angular;
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { angular } from './lib/angular-vite-plugin.js';\nexport { angular } from './lib/angular-vite-plugin.js';\nexport type { PluginOptions } from './lib/angular-vite-plugin.js';\nexport type {\n AnalogIntegrationPlugin,\n AnalogPluginContext,\n AnalogPluginHooks,\n StylesheetRegistryConfigurator,\n StylesheetRegistryContext,\n} from './lib/analog-plugin-interop.js';\nexport type {\n StylePreprocessor,\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetRegistryReader,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './lib/style-preprocessor.js';\n\nexport default angular;\n"],"mappings":";;AAmBA,IAAA,cAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { angular } from './lib/angular-vite-plugin.js';\nexport { angular } from './lib/angular-vite-plugin.js';\nexport type { PluginOptions } from './lib/angular-vite-plugin.js';\nexport type {\n AnalogIntegrationPlugin,\n AnalogPluginContext,\n AnalogPluginHooks,\n ComponentRegistryEntries,\n StylesheetRegistryConfigurator,\n StylesheetRegistryContext,\n TransformFilter,\n} from './lib/analog-plugin-interop.js';\nexport type {\n RegistryEntry as ComponentRegistryEntry,\n RegistryInput as ComponentRegistryInput,\n} from './lib/compiler/registry.js';\nexport type {\n StylePreprocessor,\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetRegistryReader,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './lib/style-preprocessor.js';\n\nexport default angular;\n"],"mappings":";;AAyBA,IAAA,cAAe"}
@@ -1,5 +1,8 @@
1
1
  import type { Plugin, ResolvedConfig } from "vite";
2
2
  import { type StylePreprocessor, type StylesheetRegistryReader } from "./style-preprocessor.js";
3
+ import type { RegistryEntry } from "./compiler/registry.js";
4
+ export type TransformFilter = (code: string, id: string) => boolean;
5
+ export type ComponentRegistryEntries = ReadonlyMap<string, RegistryEntry>;
3
6
  export interface StylesheetRegistryContext {
4
7
  workspaceRoot: string;
5
8
  }
@@ -28,6 +31,19 @@ export interface AnalogPluginContext {
28
31
  * stylesheet sources to their served ids, dependencies, and diagnostics.
29
32
  */
30
33
  configureStylesheetRegistry(configure: StylesheetRegistryConfigurator): void;
34
+ /**
35
+ * Restricts which modules Angular compiles. A module is transformed only
36
+ * when every registered filter returns `true` for it.
37
+ */
38
+ registerTransformFilter(filter: TransformFilter): void;
39
+ /**
40
+ * Contributes directive, component, pipe, and NgModule metadata keyed by
41
+ * class name for classes the fast compiler cannot reach through its own
42
+ * tsconfig-driven scan (for example components compiled from another
43
+ * source format). The map is read on every compile, so a plugin may keep
44
+ * filling it after setup.
45
+ */
46
+ registerComponentRegistry(entries: ComponentRegistryEntries): void;
31
47
  }
32
48
  export interface AnalogPluginHooks {
33
49
  setup?(context: AnalogPluginContext): void | Promise<void>;
@@ -43,6 +59,8 @@ export type AnalogIntegrationPlugin = Plugin & {
43
59
  export interface AnalogIntegrations {
44
60
  stylePreprocessor?: StylePreprocessor;
45
61
  configureStylesheetRegistry?: StylesheetRegistryConfigurator;
62
+ transformFilter?: TransformFilter;
63
+ componentRegistries: ComponentRegistryEntries[];
46
64
  externalizeStyles: boolean;
47
65
  }
48
66
  /**
@@ -51,10 +69,3 @@ export interface AnalogIntegrations {
51
69
  */
52
70
  export declare function discoverAnalogIntegrations(config: ResolvedConfig): Promise<AnalogIntegrations>;
53
71
  export declare function runAnalogSetupHooks(plugins: readonly Plugin[]): Promise<AnalogIntegrations>;
54
- /**
55
- * Resolves what a compilation path needs from the discovered integrations:
56
- * the stylesheet preprocessor chain (plugin-registered preprocessors first,
57
- * then the chain configured through `angular()` options) and whether any
58
- * plugin asked for externalized component styles.
59
- */
60
- export declare function resolveAnalogIntegrations(config: ResolvedConfig, configured?: StylePreprocessor): Promise<AnalogIntegrations>;
@@ -17,6 +17,8 @@ function discoverAnalogIntegrations(config) {
17
17
  async function runAnalogSetupHooks(plugins) {
18
18
  const preprocessors = [];
19
19
  const registryConfigurators = [];
20
+ const transformFilters = [];
21
+ const componentRegistries = [];
20
22
  let externalizeStyles = false;
21
23
  for (const plugin of plugins) {
22
24
  if (typeof plugin.analog?.setup !== "function") continue;
@@ -30,6 +32,12 @@ async function runAnalogSetupHooks(plugins) {
30
32
  },
31
33
  configureStylesheetRegistry(configure) {
32
34
  registryConfigurators.push(wrapRegistryConfigurator(plugin.name, configure));
35
+ },
36
+ registerTransformFilter(filter) {
37
+ transformFilters.push(filter);
38
+ },
39
+ registerComponentRegistry(entries) {
40
+ componentRegistries.push(entries);
33
41
  }
34
42
  };
35
43
  try {
@@ -41,6 +49,8 @@ async function runAnalogSetupHooks(plugins) {
41
49
  plugin: plugin.name,
42
50
  stylePreprocessors: preprocessors.length - registeredBefore,
43
51
  registryConfigurators: registryConfigurators.length,
52
+ transformFilters: transformFilters.length,
53
+ componentRegistries: componentRegistries.length,
44
54
  externalizeStyles
45
55
  });
46
56
  }
@@ -49,23 +59,11 @@ async function runAnalogSetupHooks(plugins) {
49
59
  configureStylesheetRegistry: registryConfigurators.length ? (registry, context) => {
50
60
  for (const configure of registryConfigurators) configure(registry, context);
51
61
  } : void 0,
62
+ transformFilter: transformFilters.length ? (code, id) => transformFilters.every((filter) => filter(code, id)) : void 0,
63
+ componentRegistries,
52
64
  externalizeStyles
53
65
  };
54
66
  }
55
- /**
56
- * Resolves what a compilation path needs from the discovered integrations:
57
- * the stylesheet preprocessor chain (plugin-registered preprocessors first,
58
- * then the chain configured through `angular()` options) and whether any
59
- * plugin asked for externalized component styles.
60
- */
61
- async function resolveAnalogIntegrations(config, configured) {
62
- const integrations = await discoverAnalogIntegrations(config);
63
- return {
64
- stylePreprocessor: composeStylePreprocessors([integrations.stylePreprocessor, configured]),
65
- configureStylesheetRegistry: integrations.configureStylesheetRegistry,
66
- externalizeStyles: integrations.externalizeStyles
67
- };
68
- }
69
67
  function wrapStylePreprocessor(pluginName, preprocessor) {
70
68
  return (code, filename, context) => {
71
69
  try {
@@ -88,6 +86,6 @@ function describeError(error) {
88
86
  return error instanceof Error ? error.message : String(error);
89
87
  }
90
88
  //#endregion
91
- export { discoverAnalogIntegrations, resolveAnalogIntegrations };
89
+ export { discoverAnalogIntegrations };
92
90
 
93
91
  //# sourceMappingURL=analog-plugin-interop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"analog-plugin-interop.js","names":[],"sources":["../../../src/lib/analog-plugin-interop.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from 'vite';\nimport {\n composeStylePreprocessors,\n type StylePreprocessor,\n type StylesheetRegistryReader,\n} from './style-preprocessor.js';\nimport { debugStylePipeline } from './utils/debug.js';\n\nexport interface StylesheetRegistryContext {\n workspaceRoot: string;\n}\n\nexport type StylesheetRegistryConfigurator = (\n registry: StylesheetRegistryReader,\n context: StylesheetRegistryContext,\n) => void;\n\n/**\n * Narrow framework context handed to a Vite plugin's `analog.setup()` hook.\n * Only grows when a concrete integration needs another seam.\n */\nexport interface AnalogPluginContext {\n /**\n * Registers a pre-transform that runs on every Angular component stylesheet\n * before it enters Vite's `preprocessCSS` pipeline.\n */\n registerStylePreprocessor(preprocessor: StylePreprocessor): void;\n /**\n * Requests that component styles are externalized in dev and watch mode so\n * they run through Vite's CSS plugin pipeline (for example\n * `@tailwindcss/vite`) instead of being inlined through `preprocessCSS`,\n * which only runs PostCSS and CSS preprocessors. Production builds keep\n * inlining component styles.\n */\n externalizeComponentStyles(): void;\n /**\n * Receives the live stylesheet registry for externalized component styles\n * each time a compilation creates one, so the plugin can map component\n * stylesheet sources to their served ids, dependencies, and diagnostics.\n */\n configureStylesheetRegistry(configure: StylesheetRegistryConfigurator): void;\n}\n\nexport interface AnalogPluginHooks {\n setup?(context: AnalogPluginContext): void | Promise<void>;\n}\n\n/**\n * A normal Vite plugin that optionally exposes an `analog` setup hook.\n * Discovery is structural (`plugin.analog?.setup`), so this type is a DX aid\n * rather than a requirement.\n */\nexport type AnalogIntegrationPlugin = Plugin & { analog?: AnalogPluginHooks };\n\nexport interface AnalogIntegrations {\n stylePreprocessor?: StylePreprocessor;\n configureStylesheetRegistry?: StylesheetRegistryConfigurator;\n externalizeStyles: boolean;\n}\n\nconst integrationsByConfig = new WeakMap<\n ResolvedConfig,\n Promise<AnalogIntegrations>\n>();\n\n/**\n * Runs every `analog.setup()` hook found in the resolved Vite plugin list,\n * once per resolved config, and composes the registrations in plugin order.\n */\nexport function discoverAnalogIntegrations(\n config: ResolvedConfig,\n): Promise<AnalogIntegrations> {\n let pending = integrationsByConfig.get(config);\n if (!pending) {\n pending = runAnalogSetupHooks(config.plugins ?? []);\n integrationsByConfig.set(config, pending);\n }\n return pending;\n}\n\nexport async function runAnalogSetupHooks(\n plugins: readonly Plugin[],\n): Promise<AnalogIntegrations> {\n const preprocessors: StylePreprocessor[] = [];\n const registryConfigurators: StylesheetRegistryConfigurator[] = [];\n let externalizeStyles = false;\n\n for (const plugin of plugins as readonly AnalogIntegrationPlugin[]) {\n if (typeof plugin.analog?.setup !== 'function') {\n continue;\n }\n\n const registeredBefore = preprocessors.length;\n const context: AnalogPluginContext = {\n registerStylePreprocessor(preprocessor) {\n preprocessors.push(wrapStylePreprocessor(plugin.name, preprocessor));\n },\n externalizeComponentStyles() {\n externalizeStyles = true;\n },\n configureStylesheetRegistry(configure) {\n registryConfigurators.push(\n wrapRegistryConfigurator(plugin.name, configure),\n );\n },\n };\n\n try {\n await plugin.analog.setup(context);\n } catch (error) {\n throw new Error(\n `[analog] analog.setup() from plugin \"${plugin.name}\" failed: ${describeError(error)}`,\n );\n }\n\n debugStylePipeline('analog.setup() completed', {\n plugin: plugin.name,\n stylePreprocessors: preprocessors.length - registeredBefore,\n registryConfigurators: registryConfigurators.length,\n externalizeStyles,\n });\n }\n\n return {\n stylePreprocessor: composeStylePreprocessors(preprocessors),\n configureStylesheetRegistry: registryConfigurators.length\n ? (registry, context) => {\n for (const configure of registryConfigurators) {\n configure(registry, context);\n }\n }\n : undefined,\n externalizeStyles,\n };\n}\n\n/**\n * Resolves what a compilation path needs from the discovered integrations:\n * the stylesheet preprocessor chain (plugin-registered preprocessors first,\n * then the chain configured through `angular()` options) and whether any\n * plugin asked for externalized component styles.\n */\nexport async function resolveAnalogIntegrations(\n config: ResolvedConfig,\n configured?: StylePreprocessor,\n): Promise<AnalogIntegrations> {\n const integrations = await discoverAnalogIntegrations(config);\n return {\n stylePreprocessor: composeStylePreprocessors([\n integrations.stylePreprocessor,\n configured,\n ]),\n configureStylesheetRegistry: integrations.configureStylesheetRegistry,\n externalizeStyles: integrations.externalizeStyles,\n };\n}\n\nfunction wrapStylePreprocessor(\n pluginName: string,\n preprocessor: StylePreprocessor,\n): StylePreprocessor {\n return (code, filename, context) => {\n try {\n return preprocessor(code, filename, context);\n } catch (error) {\n throw new Error(\n `[analog] Style preprocessor from plugin \"${pluginName}\" failed for \"${filename}\": ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction wrapRegistryConfigurator(\n pluginName: string,\n configure: StylesheetRegistryConfigurator,\n): StylesheetRegistryConfigurator {\n return (registry, context) => {\n try {\n configure(registry, context);\n } catch (error) {\n throw new Error(\n `[analog] Stylesheet registry configurator from plugin \"${pluginName}\" failed: ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;AA4DA,IAAM,uCAAuB,IAAI,SAG9B;;;;;AAMH,SAAgB,2BACd,QAC6B;CAC7B,IAAI,UAAU,qBAAqB,IAAI,OAAO;AAC9C,KAAI,CAAC,SAAS;AACZ,YAAU,oBAAoB,OAAO,WAAW,EAAE,CAAC;AACnD,uBAAqB,IAAI,QAAQ,QAAQ;;AAE3C,QAAO;;AAGT,eAAsB,oBACpB,SAC6B;CAC7B,MAAM,gBAAqC,EAAE;CAC7C,MAAM,wBAA0D,EAAE;CAClE,IAAI,oBAAoB;AAExB,MAAK,MAAM,UAAU,SAA+C;AAClE,MAAI,OAAO,OAAO,QAAQ,UAAU,WAClC;EAGF,MAAM,mBAAmB,cAAc;EACvC,MAAM,UAA+B;GACnC,0BAA0B,cAAc;AACtC,kBAAc,KAAK,sBAAsB,OAAO,MAAM,aAAa,CAAC;;GAEtE,6BAA6B;AAC3B,wBAAoB;;GAEtB,4BAA4B,WAAW;AACrC,0BAAsB,KACpB,yBAAyB,OAAO,MAAM,UAAU,CACjD;;GAEJ;AAED,MAAI;AACF,SAAM,OAAO,OAAO,MAAM,QAAQ;WAC3B,OAAO;AACd,SAAM,IAAI,MACR,wCAAwC,OAAO,KAAK,YAAY,cAAc,MAAM,GACrF;;AAGH,qBAAmB,4BAA4B;GAC7C,QAAQ,OAAO;GACf,oBAAoB,cAAc,SAAS;GAC3C,uBAAuB,sBAAsB;GAC7C;GACD,CAAC;;AAGJ,QAAO;EACL,mBAAmB,0BAA0B,cAAc;EAC3D,6BAA6B,sBAAsB,UAC9C,UAAU,YAAY;AACrB,QAAK,MAAM,aAAa,sBACtB,WAAU,UAAU,QAAQ;MAGhC,KAAA;EACJ;EACD;;;;;;;;AASH,eAAsB,0BACpB,QACA,YAC6B;CAC7B,MAAM,eAAe,MAAM,2BAA2B,OAAO;AAC7D,QAAO;EACL,mBAAmB,0BAA0B,CAC3C,aAAa,mBACb,WACD,CAAC;EACF,6BAA6B,aAAa;EAC1C,mBAAmB,aAAa;EACjC;;AAGH,SAAS,sBACP,YACA,cACmB;AACnB,SAAQ,MAAM,UAAU,YAAY;AAClC,MAAI;AACF,UAAO,aAAa,MAAM,UAAU,QAAQ;WACrC,OAAO;AACd,SAAM,IAAI,MACR,4CAA4C,WAAW,gBAAgB,SAAS,KAAK,cAAc,MAAM,GAC1G;;;;AAKP,SAAS,yBACP,YACA,WACgC;AAChC,SAAQ,UAAU,YAAY;AAC5B,MAAI;AACF,aAAU,UAAU,QAAQ;WACrB,OAAO;AACd,SAAM,IAAI,MACR,0DAA0D,WAAW,YAAY,cAAc,MAAM,GACtG;;;;AAKP,SAAS,cAAc,OAAwB;AAC7C,QAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM"}
1
+ {"version":3,"file":"analog-plugin-interop.js","names":[],"sources":["../../../src/lib/analog-plugin-interop.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from 'vite';\nimport {\n composeStylePreprocessors,\n type StylePreprocessor,\n type StylesheetRegistryReader,\n} from './style-preprocessor.js';\nimport type { RegistryEntry } from './compiler/registry.js';\nimport { debugStylePipeline } from './utils/debug.js';\n\nexport type TransformFilter = (code: string, id: string) => boolean;\n\nexport type ComponentRegistryEntries = ReadonlyMap<string, RegistryEntry>;\n\nexport interface StylesheetRegistryContext {\n workspaceRoot: string;\n}\n\nexport type StylesheetRegistryConfigurator = (\n registry: StylesheetRegistryReader,\n context: StylesheetRegistryContext,\n) => void;\n\n/**\n * Narrow framework context handed to a Vite plugin's `analog.setup()` hook.\n * Only grows when a concrete integration needs another seam.\n */\nexport interface AnalogPluginContext {\n /**\n * Registers a pre-transform that runs on every Angular component stylesheet\n * before it enters Vite's `preprocessCSS` pipeline.\n */\n registerStylePreprocessor(preprocessor: StylePreprocessor): void;\n /**\n * Requests that component styles are externalized in dev and watch mode so\n * they run through Vite's CSS plugin pipeline (for example\n * `@tailwindcss/vite`) instead of being inlined through `preprocessCSS`,\n * which only runs PostCSS and CSS preprocessors. Production builds keep\n * inlining component styles.\n */\n externalizeComponentStyles(): void;\n /**\n * Receives the live stylesheet registry for externalized component styles\n * each time a compilation creates one, so the plugin can map component\n * stylesheet sources to their served ids, dependencies, and diagnostics.\n */\n configureStylesheetRegistry(configure: StylesheetRegistryConfigurator): void;\n /**\n * Restricts which modules Angular compiles. A module is transformed only\n * when every registered filter returns `true` for it.\n */\n registerTransformFilter(filter: TransformFilter): void;\n /**\n * Contributes directive, component, pipe, and NgModule metadata keyed by\n * class name for classes the fast compiler cannot reach through its own\n * tsconfig-driven scan (for example components compiled from another\n * source format). The map is read on every compile, so a plugin may keep\n * filling it after setup.\n */\n registerComponentRegistry(entries: ComponentRegistryEntries): void;\n}\n\nexport interface AnalogPluginHooks {\n setup?(context: AnalogPluginContext): void | Promise<void>;\n}\n\n/**\n * A normal Vite plugin that optionally exposes an `analog` setup hook.\n * Discovery is structural (`plugin.analog?.setup`), so this type is a DX aid\n * rather than a requirement.\n */\nexport type AnalogIntegrationPlugin = Plugin & { analog?: AnalogPluginHooks };\n\nexport interface AnalogIntegrations {\n stylePreprocessor?: StylePreprocessor;\n configureStylesheetRegistry?: StylesheetRegistryConfigurator;\n transformFilter?: TransformFilter;\n componentRegistries: ComponentRegistryEntries[];\n externalizeStyles: boolean;\n}\n\nconst integrationsByConfig = new WeakMap<\n ResolvedConfig,\n Promise<AnalogIntegrations>\n>();\n\n/**\n * Runs every `analog.setup()` hook found in the resolved Vite plugin list,\n * once per resolved config, and composes the registrations in plugin order.\n */\nexport function discoverAnalogIntegrations(\n config: ResolvedConfig,\n): Promise<AnalogIntegrations> {\n let pending = integrationsByConfig.get(config);\n if (!pending) {\n pending = runAnalogSetupHooks(config.plugins ?? []);\n integrationsByConfig.set(config, pending);\n }\n return pending;\n}\n\nexport async function runAnalogSetupHooks(\n plugins: readonly Plugin[],\n): Promise<AnalogIntegrations> {\n const preprocessors: StylePreprocessor[] = [];\n const registryConfigurators: StylesheetRegistryConfigurator[] = [];\n const transformFilters: TransformFilter[] = [];\n const componentRegistries: ComponentRegistryEntries[] = [];\n let externalizeStyles = false;\n\n for (const plugin of plugins as readonly AnalogIntegrationPlugin[]) {\n if (typeof plugin.analog?.setup !== 'function') {\n continue;\n }\n\n const registeredBefore = preprocessors.length;\n const context: AnalogPluginContext = {\n registerStylePreprocessor(preprocessor) {\n preprocessors.push(wrapStylePreprocessor(plugin.name, preprocessor));\n },\n externalizeComponentStyles() {\n externalizeStyles = true;\n },\n configureStylesheetRegistry(configure) {\n registryConfigurators.push(\n wrapRegistryConfigurator(plugin.name, configure),\n );\n },\n registerTransformFilter(filter) {\n transformFilters.push(filter);\n },\n registerComponentRegistry(entries) {\n componentRegistries.push(entries);\n },\n };\n\n try {\n await plugin.analog.setup(context);\n } catch (error) {\n throw new Error(\n `[analog] analog.setup() from plugin \"${plugin.name}\" failed: ${describeError(error)}`,\n );\n }\n\n debugStylePipeline('analog.setup() completed', {\n plugin: plugin.name,\n stylePreprocessors: preprocessors.length - registeredBefore,\n registryConfigurators: registryConfigurators.length,\n transformFilters: transformFilters.length,\n componentRegistries: componentRegistries.length,\n externalizeStyles,\n });\n }\n\n return {\n stylePreprocessor: composeStylePreprocessors(preprocessors),\n configureStylesheetRegistry: registryConfigurators.length\n ? (registry, context) => {\n for (const configure of registryConfigurators) {\n configure(registry, context);\n }\n }\n : undefined,\n transformFilter: transformFilters.length\n ? (code, id) => transformFilters.every((filter) => filter(code, id))\n : undefined,\n componentRegistries,\n externalizeStyles,\n };\n}\n\nfunction wrapStylePreprocessor(\n pluginName: string,\n preprocessor: StylePreprocessor,\n): StylePreprocessor {\n return (code, filename, context) => {\n try {\n return preprocessor(code, filename, context);\n } catch (error) {\n throw new Error(\n `[analog] Style preprocessor from plugin \"${pluginName}\" failed for \"${filename}\": ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction wrapRegistryConfigurator(\n pluginName: string,\n configure: StylesheetRegistryConfigurator,\n): StylesheetRegistryConfigurator {\n return (registry, context) => {\n try {\n configure(registry, context);\n } catch (error) {\n throw new Error(\n `[analog] Stylesheet registry configurator from plugin \"${pluginName}\" failed: ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;AAgFA,IAAM,uCAAuB,IAAI,SAG9B;;;;;AAMH,SAAgB,2BACd,QAC6B;CAC7B,IAAI,UAAU,qBAAqB,IAAI,OAAO;AAC9C,KAAI,CAAC,SAAS;AACZ,YAAU,oBAAoB,OAAO,WAAW,EAAE,CAAC;AACnD,uBAAqB,IAAI,QAAQ,QAAQ;;AAE3C,QAAO;;AAGT,eAAsB,oBACpB,SAC6B;CAC7B,MAAM,gBAAqC,EAAE;CAC7C,MAAM,wBAA0D,EAAE;CAClE,MAAM,mBAAsC,EAAE;CAC9C,MAAM,sBAAkD,EAAE;CAC1D,IAAI,oBAAoB;AAExB,MAAK,MAAM,UAAU,SAA+C;AAClE,MAAI,OAAO,OAAO,QAAQ,UAAU,WAClC;EAGF,MAAM,mBAAmB,cAAc;EACvC,MAAM,UAA+B;GACnC,0BAA0B,cAAc;AACtC,kBAAc,KAAK,sBAAsB,OAAO,MAAM,aAAa,CAAC;;GAEtE,6BAA6B;AAC3B,wBAAoB;;GAEtB,4BAA4B,WAAW;AACrC,0BAAsB,KACpB,yBAAyB,OAAO,MAAM,UAAU,CACjD;;GAEH,wBAAwB,QAAQ;AAC9B,qBAAiB,KAAK,OAAO;;GAE/B,0BAA0B,SAAS;AACjC,wBAAoB,KAAK,QAAQ;;GAEpC;AAED,MAAI;AACF,SAAM,OAAO,OAAO,MAAM,QAAQ;WAC3B,OAAO;AACd,SAAM,IAAI,MACR,wCAAwC,OAAO,KAAK,YAAY,cAAc,MAAM,GACrF;;AAGH,qBAAmB,4BAA4B;GAC7C,QAAQ,OAAO;GACf,oBAAoB,cAAc,SAAS;GAC3C,uBAAuB,sBAAsB;GAC7C,kBAAkB,iBAAiB;GACnC,qBAAqB,oBAAoB;GACzC;GACD,CAAC;;AAGJ,QAAO;EACL,mBAAmB,0BAA0B,cAAc;EAC3D,6BAA6B,sBAAsB,UAC9C,UAAU,YAAY;AACrB,QAAK,MAAM,aAAa,sBACtB,WAAU,UAAU,QAAQ;MAGhC,KAAA;EACJ,iBAAiB,iBAAiB,UAC7B,MAAM,OAAO,iBAAiB,OAAO,WAAW,OAAO,MAAM,GAAG,CAAC,GAClE,KAAA;EACJ;EACA;EACD;;AAGH,SAAS,sBACP,YACA,cACmB;AACnB,SAAQ,MAAM,UAAU,YAAY;AAClC,MAAI;AACF,UAAO,aAAa,MAAM,UAAU,QAAQ;WACrC,OAAO;AACd,SAAM,IAAI,MACR,4CAA4C,WAAW,gBAAgB,SAAS,KAAK,cAAc,MAAM,GAC1G;;;;AAKP,SAAS,yBACP,YACA,WACgC;AAChC,SAAQ,UAAU,YAAY;AAC5B,MAAI;AACF,aAAU,UAAU,QAAQ;WACrB,OAAO;AACd,SAAM,IAAI,MACR,0DAA0D,WAAW,YAAY,cAAc,MAAM,GACtG;;;;AAKP,SAAS,cAAc,OAAwB;AAC7C,QAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM"}
@@ -1,6 +1,6 @@
1
1
  import { getJitInlineStyles } from "./utils/jit-inline-styles.js";
2
2
  import { debugStyles } from "./utils/debug.js";
3
- import { resolveAnalogIntegrations } from "./analog-plugin-interop.js";
3
+ import { discoverAnalogIntegrations } from "./analog-plugin-interop.js";
4
4
  import { preprocessStylesheet } from "./stylesheet-registry.js";
5
5
  import { preprocessCSS } from "vite";
6
6
  //#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
@@ -13,7 +13,7 @@ function jitPlugin({ inlineStylesExtension }) {
13
13
  config = _config;
14
14
  },
15
15
  async buildStart() {
16
- stylePreprocessor = (await resolveAnalogIntegrations(config)).stylePreprocessor;
16
+ stylePreprocessor = (await discoverAnalogIntegrations(config)).stylePreprocessor;
17
17
  },
18
18
  resolveId(id) {
19
19
  if (id.startsWith("virtual:angular")) return `\0${id}`;
@@ -1 +1 @@
1
- {"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport {\n JIT_INLINE_STYLE_PREFIX,\n getJitInlineStyles,\n} from './utils/jit-inline-styles.js';\nimport { debugStyles } from './utils/debug.js';\nimport { resolveAnalogIntegrations } from './analog-plugin-interop.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n let stylePreprocessor: StylePreprocessor | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n async buildStart() {\n stylePreprocessor = (await resolveAnalogIntegrations(config))\n .stylePreprocessor;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes(JIT_INLINE_STYLE_PREFIX)) {\n const styleIdHash = id.split('style:inline;')[1];\n const encodedStyles = getJitInlineStyles(styleIdHash);\n\n if (encodedStyles === undefined) {\n return;\n }\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(encodedStyles),\n 'base64',\n ).toString();\n const filename = `${styleIdHash}.${inlineStylesExtension}`;\n const preprocessed = preprocessStylesheet(\n decodedStyles,\n filename,\n stylePreprocessor,\n { filename, inline: true },\n );\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n preprocessed,\n `${filename}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n debugStyles('jit css compilation error', {\n styleIdHash,\n error: errorMessage,\n });\n console.warn(\n '[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s',\n styleIdHash,\n errorMessage,\n );\n }\n\n return `export default \\`${styles}\\``;\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;;;;AAUA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;CACJ,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,eAAe,SAAS;AACtB,YAAS;;EAEX,MAAM,aAAa;AACjB,wBAAqB,MAAM,0BAA0B,OAAO,EACzD;;EAEL,UAAU,IAAY;AACpB,OAAI,GAAG,WAAW,kBAAkB,CAClC,QAAO,KAAK;;EAKhB,MAAM,KAAK,IAAY;AACrB,OAAI,GAAG,SAAA,oCAAiC,EAAE;IACxC,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC;IAC9C,MAAM,gBAAgB,mBAAmB,YAAY;AAErD,QAAI,kBAAkB,KAAA,EACpB;IAGF,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,cAAc,EACjC,SACD,CAAC,UAAU;IACZ,MAAM,WAAW,GAAG,YAAY,GAAG;IACnC,MAAM,eAAe,qBACnB,eACA,UACA,mBACA;KAAE;KAAU,QAAQ;KAAM,CAC3B;IAED,IAAI,SAA6B;AAEjC,QAAI;AAMF,eALiB,MAAM,cACrB,cACA,GAAG,SAAS,UACZ,OACD,GACkB;aACZ,GAAG;KACV,MAAM,eAAe,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;AAC/D,iBAAY,6BAA6B;MACvC;MACA,OAAO;MACR,CAAC;AACF,aAAQ,KACN,6HACA,aACA,aACD;;AAGH,WAAO,oBAAoB,OAAO;;;EAKvC"}
1
+ {"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport {\n JIT_INLINE_STYLE_PREFIX,\n getJitInlineStyles,\n} from './utils/jit-inline-styles.js';\nimport { debugStyles } from './utils/debug.js';\nimport { discoverAnalogIntegrations } from './analog-plugin-interop.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n let stylePreprocessor: StylePreprocessor | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n async buildStart() {\n stylePreprocessor = (await discoverAnalogIntegrations(config))\n .stylePreprocessor;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes(JIT_INLINE_STYLE_PREFIX)) {\n const styleIdHash = id.split('style:inline;')[1];\n const encodedStyles = getJitInlineStyles(styleIdHash);\n\n if (encodedStyles === undefined) {\n return;\n }\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(encodedStyles),\n 'base64',\n ).toString();\n const filename = `${styleIdHash}.${inlineStylesExtension}`;\n const preprocessed = preprocessStylesheet(\n decodedStyles,\n filename,\n stylePreprocessor,\n { filename, inline: true },\n );\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n preprocessed,\n `${filename}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n debugStyles('jit css compilation error', {\n styleIdHash,\n error: errorMessage,\n });\n console.warn(\n '[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s',\n styleIdHash,\n errorMessage,\n );\n }\n\n return `export default \\`${styles}\\``;\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;;;;AAUA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;CACJ,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,eAAe,SAAS;AACtB,YAAS;;EAEX,MAAM,aAAa;AACjB,wBAAqB,MAAM,2BAA2B,OAAO,EAC1D;;EAEL,UAAU,IAAY;AACpB,OAAI,GAAG,WAAW,kBAAkB,CAClC,QAAO,KAAK;;EAKhB,MAAM,KAAK,IAAY;AACrB,OAAI,GAAG,SAAA,oCAAiC,EAAE;IACxC,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC;IAC9C,MAAM,gBAAgB,mBAAmB,YAAY;AAErD,QAAI,kBAAkB,KAAA,EACpB;IAGF,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,cAAc,EACjC,SACD,CAAC,UAAU;IACZ,MAAM,WAAW,GAAG,YAAY,GAAG;IACnC,MAAM,eAAe,qBACnB,eACA,UACA,mBACA;KAAE;KAAU,QAAQ;KAAM,CAC3B;IAED,IAAI,SAA6B;AAEjC,QAAI;AAMF,eALiB,MAAM,cACrB,cACA,GAAG,SAAS,UACZ,OACD,GACkB;aACZ,GAAG;KACV,MAAM,eAAe,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;AAC/D,iBAAY,6BAA6B;MACvC;MACA,OAAO;MACR,CAAC;AACF,aAAQ,KACN,6HACA,aACA,aACD;;AAGH,WAAO,oBAAoB,OAAO;;;EAKvC"}
@@ -1,7 +1,6 @@
1
1
  import { NgtscProgram } from "@angular/compiler-cli";
2
2
  import * as ts from "typescript";
3
3
  import { ModuleNode, Plugin, ViteDevServer } from "vite";
4
- import type { StylePreprocessor } from "./style-preprocessor.js";
5
4
  import { type DebugOption } from "./utils/debug.js";
6
5
  import { FileReplacement } from "./plugins/file-replacements.plugin.js";
7
6
  import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
@@ -18,7 +17,6 @@ export interface PluginOptions {
18
17
  tsTransformers?: ts.CustomTransformers;
19
18
  };
20
19
  supportedBrowsers?: string[];
21
- transformFilter?: (code: string, id: string) => boolean;
22
20
  /**
23
21
  * Additional files to include in compilation
24
22
  */
@@ -64,16 +62,6 @@ export interface PluginOptions {
64
62
  * (browser), using the `obug` convention.
65
63
  */
66
64
  debug?: DebugOption;
67
- /**
68
- * Optional preprocessor that transforms component CSS before it enters Vite's
69
- * preprocessCSS pipeline. Runs on every component stylesheet (both external
70
- * `.component.css` files and inline `styles: [...]` blocks).
71
- *
72
- * @param code - Raw CSS content of the component stylesheet
73
- * @param filename - Resolved file path of the stylesheet (or containing .ts file for inline styles)
74
- * @returns Transformed CSS string, or the original code if no transformation is needed
75
- */
76
- stylePreprocessor?: StylePreprocessor;
77
65
  }
78
66
  export declare function evictDeletedFileMetadata(file: string, { classNamesMap, fileTransformMap }: {
79
67
  classNamesMap: Map<string, string>;
@@ -5,7 +5,7 @@ import { getJsTransformConfigKey, isRolldown } from "./utils/rolldown.js";
5
5
  import { buildOptimizerPlugin } from "./angular-build-optimizer-plugin.js";
6
6
  import { toJitInlineStyleId } from "./utils/jit-inline-styles.js";
7
7
  import { activateDeferredDebug, applyDebugOption, debugCompiler, debugCompilerV, debugEmit, debugEmitV, debugHmr, debugHmrV, debugStyles, debugStylesV } from "./utils/debug.js";
8
- import { resolveAnalogIntegrations } from "./analog-plugin-interop.js";
8
+ import { discoverAnalogIntegrations } from "./analog-plugin-interop.js";
9
9
  import { AnalogStylesheetRegistry, preprocessStylesheet, rewriteRelativeCssImports } from "./stylesheet-registry.js";
10
10
  import { jitPlugin } from "./angular-jit-plugin.js";
11
11
  import { StyleUrlsResolver, TemplateUrlsResolver } from "./component-resolvers.js";
@@ -46,9 +46,9 @@ function evictDeletedFileMetadata(file, { classNamesMap, fileTransformMap }) {
46
46
  function angular(options) {
47
47
  applyDebugOption(options?.debug, options?.workspaceRoot);
48
48
  const liveReload = options?.liveReload ?? true;
49
- const configuredStylePreprocessor = options?.stylePreprocessor;
50
49
  let externalizeStylesRequested = false;
51
50
  let configureStylesheetRegistry;
51
+ let transformFilter;
52
52
  /**
53
53
  * Normalize plugin options so defaults
54
54
  * are used for values not provided.
@@ -72,7 +72,7 @@ function angular(options) {
72
72
  useAngularCompilationAPI: options?.experimental?.useAngularCompilationAPI ?? false,
73
73
  fastCompile: options?.fastCompile ?? false,
74
74
  fastCompileMode: options?.fastCompileMode ?? "full",
75
- stylePreprocessor: configuredStylePreprocessor
75
+ stylePreprocessor: void 0
76
76
  };
77
77
  let resolvedConfig;
78
78
  let tsConfigResolutionContext = null;
@@ -594,10 +594,7 @@ function angular(options) {
594
594
  ]
595
595
  } },
596
596
  async handler(code, id) {
597
- /**
598
- * Check for options.transformFilter
599
- */
600
- if (options?.transformFilter && !(options?.transformFilter(code, id) ?? true)) return;
597
+ if (transformFilter && !transformFilter(code, id)) return;
601
598
  if (pluginOptions.useAngularCompilationAPI) {
602
599
  if (!ANGULAR_DECORATOR_CALL_RE.test(code)) return;
603
600
  }
@@ -711,9 +708,7 @@ function angular(options) {
711
708
  liveReload: pluginOptions.liveReload,
712
709
  disableTypeChecking: pluginOptions.disableTypeChecking,
713
710
  supportedBrowsers: pluginOptions.supportedBrowsers,
714
- transformFilter: options?.transformFilter,
715
711
  fileReplacements: pluginOptions.fileReplacements,
716
- stylePreprocessor: pluginOptions.stylePreprocessor,
717
712
  isTest,
718
713
  isAstroIntegration,
719
714
  include: pluginOptions.include,
@@ -726,7 +721,6 @@ function angular(options) {
726
721
  jit,
727
722
  liveReload: pluginOptions.liveReload,
728
723
  supportedBrowsers: pluginOptions.supportedBrowsers,
729
- transformFilter: options?.transformFilter,
730
724
  isTest,
731
725
  isAstroIntegration,
732
726
  fastCompileMode: pluginOptions.fastCompileMode
@@ -767,10 +761,11 @@ function angular(options) {
767
761
  });
768
762
  try {
769
763
  await previousLock;
770
- const integrations = await resolveAnalogIntegrations(config, configuredStylePreprocessor);
764
+ const integrations = await discoverAnalogIntegrations(config);
771
765
  pluginOptions.stylePreprocessor = integrations.stylePreprocessor;
772
766
  externalizeStylesRequested = integrations.externalizeStyles;
773
767
  configureStylesheetRegistry = integrations.configureStylesheetRegistry;
768
+ transformFilter = integrations.transformFilter;
774
769
  await _doPerformCompilation(config, ids);
775
770
  } finally {
776
771
  resolve();