@analogjs/vite-plugin-angular 3.0.0-alpha.2 → 3.0.0-alpha.21
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/migrations/migrate-setup-vitest/migrate-setup-vitest.d.ts +2 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +49 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -0
- package/migrations/migration.json +7 -1
- package/package.json +9 -12
- package/src/index.d.ts +3 -2
- package/src/index.js +6 -2
- package/src/index.js.map +1 -1
- package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
- package/src/lib/angular-build-optimizer-plugin.js +48 -62
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +3 -3
- package/src/lib/angular-jit-plugin.js +31 -37
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
- package/src/lib/angular-pending-tasks.plugin.js +17 -18
- package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +145 -45
- package/src/lib/angular-vite-plugin.js +822 -963
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +20 -16
- package/src/lib/angular-vitest-plugin.js +93 -114
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compiler-plugin.d.ts +11 -11
- package/src/lib/compiler-plugin.js +43 -44
- package/src/lib/compiler-plugin.js.map +1 -1
- package/src/lib/component-resolvers.d.ts +8 -6
- package/src/lib/component-resolvers.js +93 -64
- package/src/lib/component-resolvers.js.map +1 -1
- package/src/lib/host.d.ts +10 -8
- package/src/lib/host.js +70 -101
- package/src/lib/host.js.map +1 -1
- package/src/lib/live-reload-plugin.d.ts +5 -5
- package/src/lib/live-reload-plugin.js +51 -62
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/models.d.ts +9 -9
- package/src/lib/nx-folder-plugin.d.ts +5 -5
- package/src/lib/nx-folder-plugin.js +18 -16
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
- package/src/lib/plugins/file-replacements.plugin.js +35 -62
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +1 -1
- package/src/lib/router-plugin.js +23 -23
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-preprocessor.d.ts +1 -0
- package/src/lib/tools/package.json +2 -7
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +31 -35
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +51 -59
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/tools/src/index.js +0 -1
- package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
- package/src/lib/utils/devkit.d.ts +4 -4
- package/src/lib/utils/devkit.js +34 -38
- package/src/lib/utils/devkit.js.map +1 -1
- package/src/lib/utils/hmr-candidates.d.ts +28 -28
- package/src/lib/utils/rolldown.d.ts +2 -0
- package/src/lib/utils/rolldown.js +12 -0
- package/src/lib/utils/rolldown.js.map +1 -0
- package/src/lib/utils/source-file-cache.d.ts +8 -15
- package/src/lib/utils/source-file-cache.js +35 -37
- package/src/lib/utils/source-file-cache.js.map +1 -1
- package/src/test-setup.d.ts +2 -0
- package/setup-vitest.d.ts +0 -4
- package/setup-vitest.js +0 -217
- package/setup-vitest.js.map +0 -1
- package/src/lib/models.js +0 -1
- package/src/lib/models.js.map +0 -1
- package/src/lib/tools/README.md +0 -3
- package/src/lib/tools/src/index.d.ts +0 -0
- package/src/lib/tools/src/index.js.map +0 -1
- package/src/lib/utils/compiler-plugin-options.js +0 -1
- package/src/lib/utils/compiler-plugin-options.js.map +0 -1
- package/src/lib/utils/hmr-candidates.js +0 -272
- package/src/lib/utils/hmr-candidates.js.map +0 -1
- package/vite.config.d.ts +0 -2
- package/vite.config.js +0 -22
- package/vite.config.js.map +0 -1
|
@@ -1,53 +1,153 @@
|
|
|
1
|
-
import { NgtscProgram } from
|
|
2
|
-
import * as ts from
|
|
3
|
-
import { Plugin } from
|
|
4
|
-
import {
|
|
1
|
+
import { NgtscProgram } from "@angular/compiler-cli";
|
|
2
|
+
import * as ts from "typescript";
|
|
3
|
+
import { Plugin } from "vite";
|
|
4
|
+
import type { StylePreprocessor } from "./style-preprocessor.js";
|
|
5
|
+
import { FileReplacement } from "./plugins/file-replacements.plugin.js";
|
|
5
6
|
export declare enum DiagnosticModes {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
None = 0,
|
|
8
|
+
Option = 1,
|
|
9
|
+
Syntactic = 2,
|
|
10
|
+
Semantic = 4,
|
|
11
|
+
All = 7
|
|
11
12
|
}
|
|
12
13
|
export interface PluginOptions {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
tsconfig?: string | (() => string);
|
|
15
|
+
workspaceRoot?: string;
|
|
16
|
+
inlineStylesExtension?: string;
|
|
17
|
+
jit?: boolean;
|
|
18
|
+
advanced?: {
|
|
19
|
+
/**
|
|
20
|
+
* Custom TypeScript transformers that are run before Angular compilation
|
|
21
|
+
*/
|
|
22
|
+
tsTransformers?: ts.CustomTransformers;
|
|
23
|
+
};
|
|
24
|
+
supportedBrowsers?: string[];
|
|
25
|
+
transformFilter?: (code: string, id: string) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Additional files to include in compilation
|
|
28
|
+
*/
|
|
29
|
+
include?: string[];
|
|
30
|
+
additionalContentDirs?: string[];
|
|
31
|
+
liveReload?: boolean;
|
|
32
|
+
disableTypeChecking?: boolean;
|
|
33
|
+
fileReplacements?: FileReplacement[];
|
|
34
|
+
experimental?: {
|
|
35
|
+
useAngularCompilationAPI?: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Optional preprocessor that transforms component CSS before it enters Vite's
|
|
39
|
+
* preprocessCSS pipeline. Runs on every component stylesheet (both external
|
|
40
|
+
* `.component.css` files and inline `styles: [...]` blocks).
|
|
41
|
+
*
|
|
42
|
+
* @param code - Raw CSS content of the component stylesheet
|
|
43
|
+
* @param filename - Resolved file path of the stylesheet (or containing .ts file for inline styles)
|
|
44
|
+
* @returns Transformed CSS string, or the original code if no transformation is needed
|
|
45
|
+
*/
|
|
46
|
+
stylePreprocessor?: StylePreprocessor;
|
|
47
|
+
/**
|
|
48
|
+
* First-class Tailwind CSS v4 integration for Angular component styles.
|
|
49
|
+
*
|
|
50
|
+
* Angular's compiler processes component CSS through Vite's `preprocessCSS()`,
|
|
51
|
+
* which runs `@tailwindcss/vite` — but each component stylesheet is processed
|
|
52
|
+
* in isolation without access to the root Tailwind configuration (prefix, @theme,
|
|
53
|
+
* @custom-variant, @plugin definitions). This causes errors like:
|
|
54
|
+
*
|
|
55
|
+
* "Cannot apply utility class `sa:grid` because the `sa` variant does not exist"
|
|
56
|
+
*
|
|
57
|
+
* The `tailwindCss` option solves this by auto-injecting a `@reference` directive
|
|
58
|
+
* into every component CSS file that uses Tailwind utilities, pointing it to the
|
|
59
|
+
* root Tailwind stylesheet so `@tailwindcss/vite` can resolve the full configuration.
|
|
60
|
+
*
|
|
61
|
+
* @example Basic usage — reference a root Tailwind CSS file:
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { resolve } from 'node:path';
|
|
64
|
+
*
|
|
65
|
+
* angular({
|
|
66
|
+
* tailwindCss: {
|
|
67
|
+
* rootStylesheet: resolve(__dirname, 'src/styles/tailwind.css'),
|
|
68
|
+
* },
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example With prefix detection — only inject for files using specific prefixes:
|
|
73
|
+
* ```ts
|
|
74
|
+
* angular({
|
|
75
|
+
* tailwindCss: {
|
|
76
|
+
* rootStylesheet: resolve(__dirname, 'src/styles/tailwind.css'),
|
|
77
|
+
* // Only inject @reference into files that use these prefixed classes
|
|
78
|
+
* prefixes: ['sa:', 'tw:'],
|
|
79
|
+
* },
|
|
80
|
+
* })
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @example AnalogJS platform — passed through the `vite` option:
|
|
84
|
+
* ```ts
|
|
85
|
+
* analog({
|
|
86
|
+
* vite: {
|
|
87
|
+
* tailwindCss: {
|
|
88
|
+
* rootStylesheet: resolve(__dirname, '../../../libs/meritos/tailwind.config.css'),
|
|
89
|
+
* },
|
|
90
|
+
* },
|
|
91
|
+
* })
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
tailwindCss?: {
|
|
95
|
+
/**
|
|
96
|
+
* Absolute path to the root Tailwind CSS file that contains `@import "tailwindcss"`,
|
|
97
|
+
* `@theme`, `@custom-variant`, and `@plugin` definitions.
|
|
98
|
+
*
|
|
99
|
+
* A `@reference` directive pointing to this file will be auto-injected into
|
|
100
|
+
* component CSS files that use Tailwind utilities.
|
|
101
|
+
*/
|
|
102
|
+
rootStylesheet: string;
|
|
103
|
+
/**
|
|
104
|
+
* Optional list of class prefixes to detect (e.g. `['sa:', 'tw:']`).
|
|
105
|
+
* When provided, `@reference` is only injected into component CSS files that
|
|
106
|
+
* contain at least one of these prefixes. When omitted, `@reference` is injected
|
|
107
|
+
* into all component CSS files that contain `@apply` or `@` directives.
|
|
108
|
+
*
|
|
109
|
+
* @default undefined — inject into all component CSS files with `@apply`
|
|
110
|
+
*/
|
|
111
|
+
prefixes?: string[];
|
|
112
|
+
};
|
|
36
113
|
}
|
|
37
114
|
export declare function angular(options?: PluginOptions): Plugin[];
|
|
38
|
-
export declare function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
115
|
+
export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Convert Analog/Angular CLI-style file replacements into the flat record
|
|
118
|
+
* expected by `AngularHostOptions.fileReplacements`.
|
|
119
|
+
*
|
|
120
|
+
* Only browser replacements (`{ replace, with }`) are converted. SSR-only
|
|
121
|
+
* replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to
|
|
122
|
+
* handle — they should not be baked into the Angular compilation host because
|
|
123
|
+
* that would apply them to both browser and server builds.
|
|
124
|
+
*
|
|
125
|
+
* Relative paths are resolved against `workspaceRoot` so that the host
|
|
126
|
+
* receives the same absolute paths it would get from the Angular CLI.
|
|
127
|
+
*/
|
|
128
|
+
export declare function toAngularCompilationFileReplacements(replacements: FileReplacement[], workspaceRoot: string): Record<string, string> | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)
|
|
131
|
+
* back to absolute file paths with their associated HMR code and component
|
|
132
|
+
* class name.
|
|
133
|
+
*
|
|
134
|
+
* Angular's private Compilation API emits template update keys in the form
|
|
135
|
+
* `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve
|
|
136
|
+
* them so the caller can look up updates by the same normalized absolute path
|
|
137
|
+
* used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).
|
|
138
|
+
*/
|
|
139
|
+
export declare function mapTemplateUpdatesToFiles(templateUpdates: ReadonlyMap<string, string> | undefined): Map<string, {
|
|
140
|
+
className: string;
|
|
141
|
+
code: string;
|
|
142
|
+
}>;
|
|
143
|
+
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], liveReload?: boolean, disableTypeChecking?: boolean): (file: string) => {
|
|
144
|
+
errors?: string[];
|
|
145
|
+
warnings?: (string | ts.DiagnosticMessageChain)[];
|
|
146
|
+
hmrUpdateCode?: string | null;
|
|
147
|
+
hmrEligible?: boolean;
|
|
48
148
|
};
|
|
49
149
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
150
|
+
* Checks for vitest run from the command line
|
|
151
|
+
* @returns boolean
|
|
152
|
+
*/
|
|
53
153
|
export declare function isTestWatchMode(args?: string[]): boolean;
|