@analogjs/vite-plugin-angular 3.0.0-alpha.73 → 3.0.0-alpha.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/index.d.ts +2 -2
- package/src/index.js.map +1 -1
- package/src/lib/analog-plugin-interop.d.ts +12 -1
- package/src/lib/analog-plugin-interop.js +19 -1
- package/src/lib/analog-plugin-interop.js.map +1 -1
- package/src/lib/angular-jit-plugin.js +0 -2
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +1 -77
- package/src/lib/angular-vite-plugin.js +7 -22
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +0 -7
- package/src/lib/compilation-api/compilation-api-plugin.js +4 -9
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/host.js +0 -2
- package/src/lib/host.js.map +1 -1
- package/src/lib/style-preprocessor.d.ts +1 -1
- package/src/lib/style-preprocessor.js.map +1 -1
- package/src/lib/utils/debug.d.ts +1 -3
- package/src/lib/utils/debug.js +1 -5
- package/src/lib/utils/debug.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.d.ts +0 -1
- package/src/lib/utils/tsconfig-resolver.js +1 -2
- package/src/lib/utils/tsconfig-resolver.js.map +1 -1
- package/src/lib/style-pipeline.d.ts +0 -15
- package/src/lib/style-pipeline.js +0 -31
- package/src/lib/style-pipeline.js.map +0 -1
- package/src/lib/tailwind-plugin.d.ts +0 -34
- package/src/lib/tailwind-plugin.js +0 -116
- package/src/lib/tailwind-plugin.js.map +0 -1
- package/src/lib/utils/tailwind-reference.d.ts +0 -12
- package/src/lib/utils/tailwind-reference.js +0 -99
- package/src/lib/utils/tailwind-reference.js.map +0 -1
package/README.md
CHANGED
|
@@ -116,6 +116,6 @@ Create a `tsconfig.app.json` in the root of the project.
|
|
|
116
116
|
|
|
117
117
|
## Tailwind CSS v4
|
|
118
118
|
|
|
119
|
-
For Angular component styles that use Tailwind utilities like `@apply`,
|
|
119
|
+
For Angular component styles that use Tailwind utilities like `@apply`, add a `@reference` to your root stylesheet in those component stylesheets and follow the Tailwind guide for Analog:
|
|
120
120
|
|
|
121
121
|
- https://analogjs.org/docs/integrations/tailwind
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 } from "./lib/analog-plugin-interop.js";
|
|
5
|
-
export type { StylePreprocessor, StylesheetTransformContext, StylesheetTransformResult } from "./lib/style-preprocessor.js";
|
|
4
|
+
export type { AnalogIntegrationPlugin, AnalogPluginContext, AnalogPluginHooks, StylesheetRegistryConfigurator, StylesheetRegistryContext } from "./lib/analog-plugin-interop.js";
|
|
5
|
+
export type { StylePreprocessor, StylesheetDependency, StylesheetDiagnostic, StylesheetRegistryReader, StylesheetTransformContext, StylesheetTransformResult } from "./lib/style-preprocessor.js";
|
|
6
6
|
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} from './lib/analog-plugin-interop.js';\nexport type {\n StylePreprocessor,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './lib/style-preprocessor.js';\n\nexport default angular;\n"],"mappings":";;
|
|
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,5 +1,9 @@
|
|
|
1
1
|
import type { Plugin, ResolvedConfig } from "vite";
|
|
2
|
-
import { type StylePreprocessor } from "./style-preprocessor.js";
|
|
2
|
+
import { type StylePreprocessor, type StylesheetRegistryReader } from "./style-preprocessor.js";
|
|
3
|
+
export interface StylesheetRegistryContext {
|
|
4
|
+
workspaceRoot: string;
|
|
5
|
+
}
|
|
6
|
+
export type StylesheetRegistryConfigurator = (registry: StylesheetRegistryReader, context: StylesheetRegistryContext) => void;
|
|
3
7
|
/**
|
|
4
8
|
* Narrow framework context handed to a Vite plugin's `analog.setup()` hook.
|
|
5
9
|
* Only grows when a concrete integration needs another seam.
|
|
@@ -18,6 +22,12 @@ export interface AnalogPluginContext {
|
|
|
18
22
|
* inlining component styles.
|
|
19
23
|
*/
|
|
20
24
|
externalizeComponentStyles(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Receives the live stylesheet registry for externalized component styles
|
|
27
|
+
* each time a compilation creates one, so the plugin can map component
|
|
28
|
+
* stylesheet sources to their served ids, dependencies, and diagnostics.
|
|
29
|
+
*/
|
|
30
|
+
configureStylesheetRegistry(configure: StylesheetRegistryConfigurator): void;
|
|
21
31
|
}
|
|
22
32
|
export interface AnalogPluginHooks {
|
|
23
33
|
setup?(context: AnalogPluginContext): void | Promise<void>;
|
|
@@ -32,6 +42,7 @@ export type AnalogIntegrationPlugin = Plugin & {
|
|
|
32
42
|
};
|
|
33
43
|
export interface AnalogIntegrations {
|
|
34
44
|
stylePreprocessor?: StylePreprocessor;
|
|
45
|
+
configureStylesheetRegistry?: StylesheetRegistryConfigurator;
|
|
35
46
|
externalizeStyles: boolean;
|
|
36
47
|
}
|
|
37
48
|
/**
|
|
@@ -16,6 +16,7 @@ function discoverAnalogIntegrations(config) {
|
|
|
16
16
|
}
|
|
17
17
|
async function runAnalogSetupHooks(plugins) {
|
|
18
18
|
const preprocessors = [];
|
|
19
|
+
const registryConfigurators = [];
|
|
19
20
|
let externalizeStyles = false;
|
|
20
21
|
for (const plugin of plugins) {
|
|
21
22
|
if (typeof plugin.analog?.setup !== "function") continue;
|
|
@@ -26,6 +27,9 @@ async function runAnalogSetupHooks(plugins) {
|
|
|
26
27
|
},
|
|
27
28
|
externalizeComponentStyles() {
|
|
28
29
|
externalizeStyles = true;
|
|
30
|
+
},
|
|
31
|
+
configureStylesheetRegistry(configure) {
|
|
32
|
+
registryConfigurators.push(wrapRegistryConfigurator(plugin.name, configure));
|
|
29
33
|
}
|
|
30
34
|
};
|
|
31
35
|
try {
|
|
@@ -36,11 +40,15 @@ async function runAnalogSetupHooks(plugins) {
|
|
|
36
40
|
debugStylePipeline("analog.setup() completed", {
|
|
37
41
|
plugin: plugin.name,
|
|
38
42
|
stylePreprocessors: preprocessors.length - registeredBefore,
|
|
43
|
+
registryConfigurators: registryConfigurators.length,
|
|
39
44
|
externalizeStyles
|
|
40
45
|
});
|
|
41
46
|
}
|
|
42
47
|
return {
|
|
43
48
|
stylePreprocessor: composeStylePreprocessors(preprocessors),
|
|
49
|
+
configureStylesheetRegistry: registryConfigurators.length ? (registry, context) => {
|
|
50
|
+
for (const configure of registryConfigurators) configure(registry, context);
|
|
51
|
+
} : void 0,
|
|
44
52
|
externalizeStyles
|
|
45
53
|
};
|
|
46
54
|
}
|
|
@@ -54,6 +62,7 @@ async function resolveAnalogIntegrations(config, configured) {
|
|
|
54
62
|
const integrations = await discoverAnalogIntegrations(config);
|
|
55
63
|
return {
|
|
56
64
|
stylePreprocessor: composeStylePreprocessors([integrations.stylePreprocessor, configured]),
|
|
65
|
+
configureStylesheetRegistry: integrations.configureStylesheetRegistry,
|
|
57
66
|
externalizeStyles: integrations.externalizeStyles
|
|
58
67
|
};
|
|
59
68
|
}
|
|
@@ -66,10 +75,19 @@ function wrapStylePreprocessor(pluginName, preprocessor) {
|
|
|
66
75
|
}
|
|
67
76
|
};
|
|
68
77
|
}
|
|
78
|
+
function wrapRegistryConfigurator(pluginName, configure) {
|
|
79
|
+
return (registry, context) => {
|
|
80
|
+
try {
|
|
81
|
+
configure(registry, context);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
throw new Error(`[analog] Stylesheet registry configurator from plugin "${pluginName}" failed: ${describeError(error)}`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
69
87
|
function describeError(error) {
|
|
70
88
|
return error instanceof Error ? error.message : String(error);
|
|
71
89
|
}
|
|
72
90
|
//#endregion
|
|
73
|
-
export { resolveAnalogIntegrations };
|
|
91
|
+
export { discoverAnalogIntegrations, resolveAnalogIntegrations };
|
|
74
92
|
|
|
75
93
|
//# 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} from './style-preprocessor.js';\nimport { debugStylePipeline } from './utils/debug.js';\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\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 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 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 };\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 externalizeStyles,\n });\n }\n\n return {\n stylePreprocessor: composeStylePreprocessors(preprocessors),\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 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 describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;
|
|
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,6 +1,5 @@
|
|
|
1
1
|
import { getJitInlineStyles } from "./utils/jit-inline-styles.js";
|
|
2
2
|
import { debugStyles } from "./utils/debug.js";
|
|
3
|
-
import { isTailwindReferenceError } from "./utils/tailwind-reference.js";
|
|
4
3
|
import { resolveAnalogIntegrations } from "./analog-plugin-interop.js";
|
|
5
4
|
import { preprocessStylesheet } from "./stylesheet-registry.js";
|
|
6
5
|
import { preprocessCSS } from "vite";
|
|
@@ -34,7 +33,6 @@ function jitPlugin({ inlineStylesExtension }) {
|
|
|
34
33
|
try {
|
|
35
34
|
styles = (await preprocessCSS(preprocessed, `${filename}?direct`, config))?.code;
|
|
36
35
|
} catch (e) {
|
|
37
|
-
if (isTailwindReferenceError(e)) throw e;
|
|
38
36
|
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
39
37
|
debugStyles("jit css compilation error", {
|
|
40
38
|
styleIdHash,
|
|
@@ -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 {
|
|
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"}
|
|
@@ -5,9 +5,7 @@ import type { StylePreprocessor } from "./style-preprocessor.js";
|
|
|
5
5
|
import { type DebugOption } from "./utils/debug.js";
|
|
6
6
|
import { FileReplacement } from "./plugins/file-replacements.plugin.js";
|
|
7
7
|
import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
|
|
8
|
-
import { AngularStylePipelineOptions } from "./style-pipeline.js";
|
|
9
8
|
export { DiagnosticModes, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, toAngularCompilationFileReplacements, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, describeStylesheetContent, isTestWatchMode } from "./utils/compilation-shared.js";
|
|
10
|
-
export { buildStylePreprocessor } from "./tailwind-plugin.js";
|
|
11
9
|
export interface PluginOptions {
|
|
12
10
|
tsconfig?: string | (() => string);
|
|
13
11
|
workspaceRoot?: string;
|
|
@@ -58,7 +56,7 @@ export interface PluginOptions {
|
|
|
58
56
|
* Enable debug logging for specific scopes.
|
|
59
57
|
*
|
|
60
58
|
* - `true` → enables all `analog:angular:*` scopes
|
|
61
|
-
* - `string[]` → enables listed namespaces (e.g. `['analog:angular:
|
|
59
|
+
* - `string[]` → enables listed namespaces (e.g. `['analog:angular:hmr']`)
|
|
62
60
|
* - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`
|
|
63
61
|
* to restrict output to a specific Vite command (omit for both)
|
|
64
62
|
*
|
|
@@ -76,80 +74,6 @@ export interface PluginOptions {
|
|
|
76
74
|
* @returns Transformed CSS string, or the original code if no transformation is needed
|
|
77
75
|
*/
|
|
78
76
|
stylePreprocessor?: StylePreprocessor;
|
|
79
|
-
/**
|
|
80
|
-
* Experimental Angular stylesheet-resource hooks for community-maintained
|
|
81
|
-
* style-pipeline plugins.
|
|
82
|
-
*
|
|
83
|
-
* These hooks run inside the Angular resource pipeline, which is the seam a
|
|
84
|
-
* standalone Vite plugin cannot own on its own.
|
|
85
|
-
*/
|
|
86
|
-
stylePipeline?: AngularStylePipelineOptions;
|
|
87
|
-
/**
|
|
88
|
-
* First-class Tailwind CSS v4 integration for Angular component styles.
|
|
89
|
-
*
|
|
90
|
-
* Angular's compiler processes component CSS through Vite's `preprocessCSS()`,
|
|
91
|
-
* which runs `@tailwindcss/vite` — but each component stylesheet is processed
|
|
92
|
-
* in isolation without access to the root Tailwind configuration (prefix, @theme,
|
|
93
|
-
* @custom-variant, @plugin definitions). This causes errors like:
|
|
94
|
-
*
|
|
95
|
-
* "Cannot apply utility class `sa:grid` because the `sa` variant does not exist"
|
|
96
|
-
*
|
|
97
|
-
* The `tailwindCss` option solves this by auto-injecting a `@reference` directive
|
|
98
|
-
* into every component CSS file that uses Tailwind utilities, pointing it to the
|
|
99
|
-
* root Tailwind stylesheet so `@tailwindcss/vite` can resolve the full configuration.
|
|
100
|
-
*
|
|
101
|
-
* @example Basic usage — reference a root Tailwind CSS file:
|
|
102
|
-
* ```ts
|
|
103
|
-
* import { resolve } from 'node:path';
|
|
104
|
-
*
|
|
105
|
-
* angular({
|
|
106
|
-
* tailwindCss: {
|
|
107
|
-
* rootStylesheet: resolve(__dirname, 'src/styles/tailwind.css'),
|
|
108
|
-
* },
|
|
109
|
-
* })
|
|
110
|
-
* ```
|
|
111
|
-
*
|
|
112
|
-
* @example With prefix detection — only inject for files using specific prefixes:
|
|
113
|
-
* ```ts
|
|
114
|
-
* angular({
|
|
115
|
-
* tailwindCss: {
|
|
116
|
-
* rootStylesheet: resolve(__dirname, 'src/styles/tailwind.css'),
|
|
117
|
-
* // Only inject @reference into files that use these prefixed classes
|
|
118
|
-
* prefixes: ['sa:', 'tw:'],
|
|
119
|
-
* },
|
|
120
|
-
* })
|
|
121
|
-
* ```
|
|
122
|
-
*
|
|
123
|
-
* @example AnalogJS platform — passed through the `vite` option:
|
|
124
|
-
* ```ts
|
|
125
|
-
* analog({
|
|
126
|
-
* vite: {
|
|
127
|
-
* tailwindCss: {
|
|
128
|
-
* rootStylesheet: resolve(__dirname, '../../../libs/meritos/tailwind.config.css'),
|
|
129
|
-
* },
|
|
130
|
-
* },
|
|
131
|
-
* })
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
tailwindCss?: {
|
|
135
|
-
/**
|
|
136
|
-
* Absolute path to the root Tailwind CSS file that contains `@import "tailwindcss"`,
|
|
137
|
-
* `@theme`, `@custom-variant`, and `@plugin` definitions.
|
|
138
|
-
*
|
|
139
|
-
* A `@reference` directive pointing to this file will be auto-injected into
|
|
140
|
-
* component CSS files that use Tailwind utilities.
|
|
141
|
-
*/
|
|
142
|
-
rootStylesheet: string;
|
|
143
|
-
/**
|
|
144
|
-
* Optional list of class prefixes to detect (e.g. `['sa:', 'tw:']`).
|
|
145
|
-
* When provided, `@reference` is only injected into component CSS files that
|
|
146
|
-
* contain at least one of these prefixes. When omitted, `@reference` is injected
|
|
147
|
-
* into all component CSS files that contain `@apply` or `@` directives.
|
|
148
|
-
*
|
|
149
|
-
* @default undefined — inject into all component CSS files with `@apply`
|
|
150
|
-
*/
|
|
151
|
-
prefixes?: string[];
|
|
152
|
-
};
|
|
153
77
|
}
|
|
154
78
|
export declare function evictDeletedFileMetadata(file: string, { classNamesMap, fileTransformMap }: {
|
|
155
79
|
classNamesMap: Map<string, string>;
|
|
@@ -11,7 +11,6 @@ import { jitPlugin } from "./angular-jit-plugin.js";
|
|
|
11
11
|
import { StyleUrlsResolver, TemplateUrlsResolver } from "./component-resolvers.js";
|
|
12
12
|
import { augmentHostWithCaching, augmentHostWithResources, augmentProgramWithVersioning, mergeTransformers } from "./host.js";
|
|
13
13
|
import { TsconfigResolver } from "./utils/tsconfig-resolver.js";
|
|
14
|
-
import { configureStylePipelineRegistry } from "./style-pipeline.js";
|
|
15
14
|
import { describeStylesheetContent, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, isTestWatchMode } from "./utils/compilation-shared.js";
|
|
16
15
|
import { toVirtualRawId } from "./utils/virtual-ids.js";
|
|
17
16
|
import { loadVirtualRawModule, rewriteHtmlRawImport } from "./utils/virtual-resources.js";
|
|
@@ -21,7 +20,6 @@ import { ANGULAR_DECORATOR_CALL_RE } from "./compiler/constants.js";
|
|
|
21
20
|
import "./compiler/index.js";
|
|
22
21
|
import { markStylePathSafe } from "./utils/safe-module-paths.js";
|
|
23
22
|
import { fastCompilePlugin } from "./fast-compile-plugin.js";
|
|
24
|
-
import { buildStylePreprocessor, tailwindReferencePlugin, validateTailwindConfig } from "./tailwind-plugin.js";
|
|
25
23
|
import { encapsulationPlugin, getComponentStyleSheetMeta, isComponentStyleSheet } from "./encapsulation-plugin.js";
|
|
26
24
|
import { virtualModulesPlugin } from "./virtual-modules-plugin.js";
|
|
27
25
|
import { angularVitestPlugins } from "./angular-vitest-plugin.js";
|
|
@@ -48,8 +46,9 @@ function evictDeletedFileMetadata(file, { classNamesMap, fileTransformMap }) {
|
|
|
48
46
|
function angular(options) {
|
|
49
47
|
applyDebugOption(options?.debug, options?.workspaceRoot);
|
|
50
48
|
const liveReload = options?.liveReload ?? true;
|
|
51
|
-
const configuredStylePreprocessor =
|
|
49
|
+
const configuredStylePreprocessor = options?.stylePreprocessor;
|
|
52
50
|
let externalizeStylesRequested = false;
|
|
51
|
+
let configureStylesheetRegistry;
|
|
53
52
|
/**
|
|
54
53
|
* Normalize plugin options so defaults
|
|
55
54
|
* are used for values not provided.
|
|
@@ -73,8 +72,6 @@ function angular(options) {
|
|
|
73
72
|
useAngularCompilationAPI: options?.experimental?.useAngularCompilationAPI ?? false,
|
|
74
73
|
fastCompile: options?.fastCompile ?? false,
|
|
75
74
|
fastCompileMode: options?.fastCompileMode ?? "full",
|
|
76
|
-
hasTailwindCss: !!options?.tailwindCss,
|
|
77
|
-
tailwindCss: options?.tailwindCss,
|
|
78
75
|
stylePreprocessor: configuredStylePreprocessor
|
|
79
76
|
};
|
|
80
77
|
let resolvedConfig;
|
|
@@ -89,7 +86,6 @@ function angular(options) {
|
|
|
89
86
|
workspaceRoot: pluginOptions.workspaceRoot,
|
|
90
87
|
include: pluginOptions.include,
|
|
91
88
|
liveReload: pluginOptions.liveReload,
|
|
92
|
-
hasTailwindCss: pluginOptions.hasTailwindCss,
|
|
93
89
|
isTest
|
|
94
90
|
});
|
|
95
91
|
function invalidateFsCaches() {
|
|
@@ -118,19 +114,15 @@ function angular(options) {
|
|
|
118
114
|
*
|
|
119
115
|
* Required for TWO independent use-cases:
|
|
120
116
|
* 1. HMR — Vite needs external modules for hot replacement
|
|
121
|
-
* 2.
|
|
122
|
-
* CSS pipeline
|
|
117
|
+
* 2. A Vite plugin asked for it through `analog.setup()` so its styles
|
|
118
|
+
* pass through Vite's CSS pipeline (e.g. @tailwindcss/vite)
|
|
123
119
|
*
|
|
124
120
|
* In production builds (!watchMode), styles are NOT externalized — they
|
|
125
121
|
* are inlined after preprocessCSS runs eagerly in transformStylesheet.
|
|
126
122
|
*/
|
|
127
123
|
function shouldExternalizeStyles() {
|
|
128
124
|
if (!(isTest ? testWatchMode : watchMode)) return false;
|
|
129
|
-
return !!(shouldEnableLiveReload() ||
|
|
130
|
-
}
|
|
131
|
-
function validateNoDuplicateAnalogPlugins(config) {
|
|
132
|
-
const analogInstances = (config.plugins ?? []).filter((p) => p.name === "@analogjs/vite-plugin-angular");
|
|
133
|
-
if (analogInstances.length > 1 && !config.build?.ssr) throw new Error(`[@analogjs/vite-plugin-angular] analog() is registered ${analogInstances.length} times. Each instance creates separate style maps, causing component styles to be lost. Remove duplicate registrations.`);
|
|
125
|
+
return !!(shouldEnableLiveReload() || externalizeStylesRequested);
|
|
134
126
|
}
|
|
135
127
|
let stylesheetRegistry;
|
|
136
128
|
const sourceFileCache$1 = new sourceFileCache();
|
|
@@ -258,10 +250,6 @@ function angular(options) {
|
|
|
258
250
|
originalWarnOnce(msg, options);
|
|
259
251
|
};
|
|
260
252
|
}
|
|
261
|
-
if (pluginOptions.hasTailwindCss) {
|
|
262
|
-
validateTailwindConfig(pluginOptions.tailwindCss, config, watchMode);
|
|
263
|
-
validateNoDuplicateAnalogPlugins(config);
|
|
264
|
-
}
|
|
265
253
|
if (!jit) styleTransform = (code, filename) => preprocessCSS(code, filename, config);
|
|
266
254
|
if (isTest) testWatchMode = !(config.server.watch === null) || config.test?.watch === true || testWatchMode;
|
|
267
255
|
},
|
|
@@ -726,9 +714,6 @@ function angular(options) {
|
|
|
726
714
|
transformFilter: options?.transformFilter,
|
|
727
715
|
fileReplacements: pluginOptions.fileReplacements,
|
|
728
716
|
stylePreprocessor: pluginOptions.stylePreprocessor,
|
|
729
|
-
stylePipeline: options?.stylePipeline,
|
|
730
|
-
hasTailwindCss: pluginOptions.hasTailwindCss,
|
|
731
|
-
tailwindCss: pluginOptions.tailwindCss,
|
|
732
717
|
isTest,
|
|
733
718
|
isAstroIntegration,
|
|
734
719
|
include: pluginOptions.include,
|
|
@@ -750,7 +735,6 @@ function angular(options) {
|
|
|
750
735
|
cssExtensionStyleResolverPlugin(),
|
|
751
736
|
replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),
|
|
752
737
|
virtualModulesPlugin({ jit }),
|
|
753
|
-
pluginOptions.hasTailwindCss && tailwindReferencePlugin({ tailwindCss: pluginOptions.tailwindCss }),
|
|
754
738
|
pluginOptions.liveReload && liveReloadPlugin({
|
|
755
739
|
classNames,
|
|
756
740
|
fileEmitter
|
|
@@ -786,6 +770,7 @@ function angular(options) {
|
|
|
786
770
|
const integrations = await resolveAnalogIntegrations(config, configuredStylePreprocessor);
|
|
787
771
|
pluginOptions.stylePreprocessor = integrations.stylePreprocessor;
|
|
788
772
|
externalizeStylesRequested = integrations.externalizeStyles;
|
|
773
|
+
configureStylesheetRegistry = integrations.configureStylesheetRegistry;
|
|
789
774
|
await _doPerformCompilation(config, ids);
|
|
790
775
|
} finally {
|
|
791
776
|
resolve();
|
|
@@ -849,7 +834,7 @@ function angular(options) {
|
|
|
849
834
|
if (!jit) {
|
|
850
835
|
const externalizeStyles = !!tsCompilerOptions["externalRuntimeStyles"];
|
|
851
836
|
stylesheetRegistry = externalizeStyles ? new AnalogStylesheetRegistry() : void 0;
|
|
852
|
-
if (stylesheetRegistry)
|
|
837
|
+
if (stylesheetRegistry) configureStylesheetRegistry?.(stylesheetRegistry, { workspaceRoot: pluginOptions.workspaceRoot });
|
|
853
838
|
debugStyles("stylesheet registry initialized (NgtscProgram path)", { externalizeStyles });
|
|
854
839
|
augmentHostWithResources(host, styleTransform, {
|
|
855
840
|
inlineStylesExtension: pluginOptions.inlineStylesExtension,
|