@analogjs/vite-plugin-angular 3.0.0-alpha.9 → 3.0.0-alpha.90
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 +121 -0
- 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/migrations/migrations.json +9 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +2 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.js +36 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -0
- package/package.json +49 -8
- package/src/index.d.ts +7 -2
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/lib/analog-plugin-interop.d.ts +78 -0
- package/src/lib/analog-plugin-interop.js +97 -0
- package/src/lib/analog-plugin-interop.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +8 -4
- package/src/lib/angular-build-optimizer-plugin.js +66 -31
- 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 +28 -6
- 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.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +79 -69
- package/src/lib/angular-vite-plugin.js +774 -352
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +26 -21
- package/src/lib/angular-vitest-plugin.js +34 -25
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +24 -0
- package/src/lib/compilation-api/compilation-api-plugin.js +547 -0
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
- package/src/lib/compilation-api/index.d.ts +1 -0
- package/src/lib/compilation-api/index.js +1 -0
- package/src/lib/compiler/angular-version.d.ts +19 -0
- package/src/lib/compiler/angular-version.js +31 -0
- package/src/lib/compiler/angular-version.js.map +1 -0
- package/src/lib/compiler/class-field-lowering.d.ts +23 -0
- package/src/lib/compiler/class-field-lowering.js +131 -0
- package/src/lib/compiler/class-field-lowering.js.map +1 -0
- package/src/lib/compiler/compile.d.ts +50 -0
- package/src/lib/compiler/compile.js +814 -0
- package/src/lib/compiler/compile.js.map +1 -0
- package/src/lib/compiler/constants.d.ts +24 -0
- package/src/lib/compiler/constants.js +59 -0
- package/src/lib/compiler/constants.js.map +1 -0
- package/src/lib/compiler/debug.d.ts +22 -0
- package/src/lib/compiler/debug.js +20 -0
- package/src/lib/compiler/debug.js.map +1 -0
- package/src/lib/compiler/defer.d.ts +57 -0
- package/src/lib/compiler/defer.js +154 -0
- package/src/lib/compiler/defer.js.map +1 -0
- package/src/lib/compiler/dts-reader.d.ts +45 -0
- package/src/lib/compiler/dts-reader.js +395 -0
- package/src/lib/compiler/dts-reader.js.map +1 -0
- package/src/lib/compiler/hmr.d.ts +16 -0
- package/src/lib/compiler/hmr.js +69 -0
- package/src/lib/compiler/hmr.js.map +1 -0
- package/src/lib/compiler/index.d.ts +8 -0
- package/src/lib/compiler/index.js +8 -0
- package/src/lib/compiler/jit-metadata.d.ts +14 -0
- package/src/lib/compiler/jit-metadata.js +168 -0
- package/src/lib/compiler/jit-metadata.js.map +1 -0
- package/src/lib/compiler/jit-transform.d.ts +24 -0
- package/src/lib/compiler/jit-transform.js +204 -0
- package/src/lib/compiler/jit-transform.js.map +1 -0
- package/src/lib/compiler/js-emitter.d.ts +10 -0
- package/src/lib/compiler/js-emitter.js +446 -0
- package/src/lib/compiler/js-emitter.js.map +1 -0
- package/src/lib/compiler/metadata.d.ts +36 -0
- package/src/lib/compiler/metadata.js +710 -0
- package/src/lib/compiler/metadata.js.map +1 -0
- package/src/lib/compiler/registry.d.ts +56 -0
- package/src/lib/compiler/registry.js +176 -0
- package/src/lib/compiler/registry.js.map +1 -0
- package/src/lib/compiler/resource-inliner.d.ts +43 -0
- package/src/lib/compiler/resource-inliner.js +230 -0
- package/src/lib/compiler/resource-inliner.js.map +1 -0
- package/src/lib/compiler/style-ast.d.ts +9 -0
- package/src/lib/compiler/style-ast.js +54 -0
- package/src/lib/compiler/style-ast.js.map +1 -0
- package/src/lib/compiler/styles.d.ts +13 -0
- package/src/lib/compiler/test-helpers.d.ts +7 -0
- package/src/lib/compiler/type-elision.d.ts +28 -0
- package/src/lib/compiler/type-elision.js +211 -0
- package/src/lib/compiler/type-elision.js.map +1 -0
- package/src/lib/compiler/utils.d.ts +40 -0
- package/src/lib/compiler/utils.js +76 -0
- package/src/lib/compiler/utils.js.map +1 -0
- package/src/lib/compiler-plugin.d.ts +13 -12
- package/src/lib/compiler-plugin.js +18 -18
- package/src/lib/compiler-plugin.js.map +1 -1
- package/src/lib/component-resolvers.d.ts +20 -4
- package/src/lib/component-resolvers.js +34 -20
- package/src/lib/component-resolvers.js.map +1 -1
- package/src/lib/encapsulation-plugin.d.ts +23 -0
- package/src/lib/encapsulation-plugin.js +68 -0
- package/src/lib/encapsulation-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +23 -0
- package/src/lib/fast-compile-plugin.js +433 -0
- package/src/lib/fast-compile-plugin.js.map +1 -0
- package/src/lib/host.d.ts +10 -8
- package/src/lib/host.js +59 -17
- 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 +10 -0
- 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.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
- package/src/lib/plugins/file-replacements.plugin.js +6 -1
- 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 +14 -2
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-preprocessor.d.ts +35 -0
- package/src/lib/style-preprocessor.js +35 -0
- package/src/lib/style-preprocessor.js.map +1 -0
- package/src/lib/stylesheet-registry.d.ts +74 -0
- package/src/lib/stylesheet-registry.js +174 -0
- package/src/lib/stylesheet-registry.js.map +1 -0
- package/src/lib/tools/package.json +1 -3
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +7 -5
- 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 +16 -19
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/utils/compilation-shared.d.ts +62 -0
- package/src/lib/utils/compilation-shared.js +138 -0
- package/src/lib/utils/compilation-shared.js.map +1 -0
- package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
- package/src/lib/utils/css-extension-resolver.d.ts +32 -0
- package/src/lib/utils/css-extension-resolver.js +73 -0
- package/src/lib/utils/css-extension-resolver.js.map +1 -0
- package/src/lib/utils/css-preprocessor-workers.d.ts +6 -0
- package/src/lib/utils/css-preprocessor-workers.js +29 -0
- package/src/lib/utils/css-preprocessor-workers.js.map +1 -0
- package/src/lib/utils/debug-harness.d.ts +23 -0
- package/src/lib/utils/debug-harness.js +88 -0
- package/src/lib/utils/debug-harness.js.map +1 -0
- package/src/lib/utils/debug-log-file.d.ts +5 -0
- package/src/lib/utils/debug-log-file.js +56 -0
- package/src/lib/utils/debug-log-file.js.map +1 -0
- package/src/lib/utils/debug.d.ts +26 -0
- package/src/lib/utils/debug.js +35 -0
- package/src/lib/utils/debug.js.map +1 -0
- package/src/lib/utils/devkit.d.ts +14 -6
- package/src/lib/utils/devkit.js +40 -2
- package/src/lib/utils/devkit.js.map +1 -1
- package/src/lib/utils/hmr-candidates.d.ts +28 -28
- package/src/lib/utils/jit-inline-styles.d.ts +3 -0
- package/src/lib/utils/jit-inline-styles.js +16 -0
- package/src/lib/utils/jit-inline-styles.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +41 -0
- package/src/lib/utils/plugin-config.js +85 -0
- package/src/lib/utils/plugin-config.js.map +1 -0
- package/src/lib/utils/rolldown.d.ts +1 -1
- package/src/lib/utils/rolldown.js.map +1 -1
- package/src/lib/utils/safe-module-paths.d.ts +16 -0
- package/src/lib/utils/safe-module-paths.js +29 -0
- package/src/lib/utils/safe-module-paths.js.map +1 -0
- package/src/lib/utils/source-file-cache.d.ts +8 -15
- package/src/lib/utils/source-file-cache.js.map +1 -1
- package/src/lib/utils/transform-cache.d.ts +43 -0
- package/src/lib/utils/transform-cache.js +97 -0
- package/src/lib/utils/transform-cache.js.map +1 -0
- package/src/lib/utils/tsconfig-resolver.d.ts +34 -0
- package/src/lib/utils/tsconfig-resolver.js +205 -0
- package/src/lib/utils/tsconfig-resolver.js.map +1 -0
- package/src/lib/utils/virtual-ids.d.ts +4 -0
- package/src/lib/utils/virtual-ids.js +23 -0
- package/src/lib/utils/virtual-ids.js.map +1 -0
- package/src/lib/utils/virtual-resources.d.ts +19 -0
- package/src/lib/utils/virtual-resources.js +38 -0
- package/src/lib/utils/virtual-resources.js.map +1 -0
- package/src/lib/virtual-modules-plugin.d.ts +5 -0
- package/src/lib/virtual-modules-plugin.js +23 -0
- package/src/lib/virtual-modules-plugin.js.map +1 -0
- package/src/test-setup.d.ts +2 -0
- package/setup-vitest.d.ts +0 -4
- package/setup-vitest.js +0 -176
- package/setup-vitest.js.map +0 -1
- package/src/lib/tools/src/index.d.ts +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @analogjs/vite-plugin-angular
|
|
2
|
+
|
|
3
|
+
[](https://registry.vite.dev/plugin/@analogjs/vite-plugin-angular)
|
|
4
|
+
|
|
5
|
+
A Vite plugin for building Angular applications
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
With npm:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @analogjs/vite-plugin-angular --save-dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
With pnpm:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pnpm install @analogjs/vite-plugin-angular --save-dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
With yarn:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
yarn install @analogjs/vite-plugin-angular --dev
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
With bun:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
bun install @analogjs/vite-plugin-angular --dev
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Setup
|
|
34
|
+
|
|
35
|
+
Add the plugin to the `plugins` array in your Vite config
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { defineConfig } from 'vite';
|
|
39
|
+
import angular from '@analogjs/vite-plugin-angular';
|
|
40
|
+
|
|
41
|
+
// https://vitejs.dev/config/
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
resolve: {
|
|
44
|
+
mainFields: ['module'],
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
plugins: [angular()],
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> The `angular` plugin should be listed **first** in the plugins array.
|
|
52
|
+
|
|
53
|
+
## Fast Compile Mode
|
|
54
|
+
|
|
55
|
+
`fastCompile` opts the plugin into a single-pass compilation path that emits Ivy instructions directly and skips Angular's template type-checking. It's intended for content-focused apps and faster dev iteration where build throughput matters more than inline type-safety feedback.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
export default defineConfig({
|
|
59
|
+
plugins: [angular({ fastCompile: true })],
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
When `fastCompile` is enabled, template and input type errors will not surface during compilation — run `ngc -p tsconfig.app.json --noEmit` as a separate step in your build script to keep full type safety:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "ngc -p tsconfig.app.json --noEmit && vite build"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The fast compile path currently passes ~91% of Angular's conformance suite. Behavior and output may change between minor releases.
|
|
74
|
+
|
|
75
|
+
## Setting up the TypeScript config
|
|
76
|
+
|
|
77
|
+
The integration needs a `tsconfig.app.json` at the root of the project for compilation.
|
|
78
|
+
|
|
79
|
+
Create a `tsconfig.app.json` in the root of the project.
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"extends": "./tsconfig.json",
|
|
84
|
+
"compileOnSave": false,
|
|
85
|
+
"compilerOptions": {
|
|
86
|
+
"baseUrl": "./",
|
|
87
|
+
"outDir": "./dist/out-tsc",
|
|
88
|
+
"forceConsistentCasingInFileNames": true,
|
|
89
|
+
"strict": true,
|
|
90
|
+
"noImplicitOverride": true,
|
|
91
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
92
|
+
"noImplicitReturns": true,
|
|
93
|
+
"noFallthroughCasesInSwitch": true,
|
|
94
|
+
"sourceMap": true,
|
|
95
|
+
"declaration": false,
|
|
96
|
+
"downlevelIteration": true,
|
|
97
|
+
"experimentalDecorators": true,
|
|
98
|
+
"moduleResolution": "node",
|
|
99
|
+
"importHelpers": true,
|
|
100
|
+
"noEmit": false,
|
|
101
|
+
"target": "es2020",
|
|
102
|
+
"module": "es2020",
|
|
103
|
+
"lib": ["es2020", "dom"],
|
|
104
|
+
"skipLibCheck": true
|
|
105
|
+
},
|
|
106
|
+
"angularCompilerOptions": {
|
|
107
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
108
|
+
"strictInjectionParameters": true,
|
|
109
|
+
"strictInputAccessModifiers": true,
|
|
110
|
+
"strictTemplates": true
|
|
111
|
+
},
|
|
112
|
+
"files": [],
|
|
113
|
+
"include": ["src/**/*.ts"]
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Tailwind CSS v4
|
|
118
|
+
|
|
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
|
+
|
|
121
|
+
- https://analogjs.org/docs/integrations/tailwind
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NodePackageInstallTask } from "@angular-devkit/schematics/tasks";
|
|
2
|
+
//#region packages/vite-plugin-angular/migrations/migrate-setup-vitest/migrate-setup-vitest.ts
|
|
3
|
+
var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
|
|
4
|
+
var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
|
|
5
|
+
function addVitestAngularDependency(tree, context) {
|
|
6
|
+
const pkgPath = "/package.json";
|
|
7
|
+
const content = tree.read(pkgPath);
|
|
8
|
+
if (!content) return;
|
|
9
|
+
const pkg = JSON.parse(content.toString("utf-8"));
|
|
10
|
+
const devDeps = pkg["devDependencies"] || {};
|
|
11
|
+
const deps = pkg["dependencies"] || {};
|
|
12
|
+
if (!devDeps["@analogjs/vitest-angular"] && !deps["@analogjs/vitest-angular"]) {
|
|
13
|
+
const analogVersion = devDeps["@analogjs/vite-plugin-angular"] || deps["@analogjs/vite-plugin-angular"] || "*";
|
|
14
|
+
pkg["devDependencies"] = {
|
|
15
|
+
...devDeps,
|
|
16
|
+
"@analogjs/vitest-angular": analogVersion
|
|
17
|
+
};
|
|
18
|
+
tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
19
|
+
context.addTask(new NodePackageInstallTask());
|
|
20
|
+
context.logger.info(`Added '@analogjs/vitest-angular': '${analogVersion}' to devDependencies.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function migrateSetupVitest() {
|
|
24
|
+
return (tree, context) => {
|
|
25
|
+
const filesToUpdate = [];
|
|
26
|
+
tree.visit((filePath) => {
|
|
27
|
+
if (!filePath.endsWith(".ts") && !filePath.endsWith(".mts") && !filePath.endsWith(".js") && !filePath.endsWith(".mjs")) return;
|
|
28
|
+
if (filePath.includes("/node_modules/")) return;
|
|
29
|
+
const content = tree.read(filePath);
|
|
30
|
+
if (!content) return;
|
|
31
|
+
const text = content.toString("utf-8");
|
|
32
|
+
if (text.includes(OLD_IMPORT)) {
|
|
33
|
+
const updated = text.replace(new RegExp(OLD_IMPORT.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), NEW_IMPORT);
|
|
34
|
+
tree.overwrite(filePath, updated);
|
|
35
|
+
filesToUpdate.push(filePath);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (filesToUpdate.length > 0) {
|
|
39
|
+
context.logger.info(`Migrated ${filesToUpdate.length} file(s) from '${OLD_IMPORT}' to '${NEW_IMPORT}':`);
|
|
40
|
+
for (const file of filesToUpdate) context.logger.info(` - ${file}`);
|
|
41
|
+
}
|
|
42
|
+
if (filesToUpdate.length > 0) addVitestAngularDependency(tree, context);
|
|
43
|
+
return tree;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { migrateSetupVitest as default };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=migrate-setup-vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/migrate-setup-vitest/migrate-setup-vitest.ts"],"sourcesContent":["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\n\nfunction addVitestAngularDependency(\n tree: Tree,\n context: SchematicContext,\n): void {\n const pkgPath = '/package.json';\n const content = tree.read(pkgPath);\n if (!content) {\n return;\n }\n\n const pkg = JSON.parse(content.toString('utf-8'));\n const devDeps = pkg['devDependencies'] || {};\n const deps = pkg['dependencies'] || {};\n\n if (\n !devDeps['@analogjs/vitest-angular'] &&\n !deps['@analogjs/vitest-angular']\n ) {\n const analogVersion =\n devDeps['@analogjs/vite-plugin-angular'] ||\n deps['@analogjs/vite-plugin-angular'] ||\n '*';\n\n pkg['devDependencies'] = {\n ...devDeps,\n '@analogjs/vitest-angular': analogVersion,\n };\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + '\\n');\n context.addTask(new NodePackageInstallTask());\n context.logger.info(\n `Added '@analogjs/vitest-angular': '${analogVersion}' to devDependencies.`,\n );\n }\n}\n\nexport default function migrateSetupVitest(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const filesToUpdate: string[] = [];\n\n tree.visit((filePath) => {\n if (\n !filePath.endsWith('.ts') &&\n !filePath.endsWith('.mts') &&\n !filePath.endsWith('.js') &&\n !filePath.endsWith('.mjs')\n ) {\n return;\n }\n if (filePath.includes('/node_modules/')) {\n return;\n }\n\n const content = tree.read(filePath);\n if (!content) {\n return;\n }\n\n const text = content.toString('utf-8');\n if (text.includes(OLD_IMPORT)) {\n const updated = text.replace(\n new RegExp(OLD_IMPORT.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'),\n NEW_IMPORT,\n );\n tree.overwrite(filePath, updated);\n filesToUpdate.push(filePath);\n }\n });\n\n if (filesToUpdate.length > 0) {\n context.logger.info(\n `Migrated ${filesToUpdate.length} file(s) from '${OLD_IMPORT}' to '${NEW_IMPORT}':`,\n );\n for (const file of filesToUpdate) {\n context.logger.info(` - ${file}`);\n }\n }\n\n if (filesToUpdate.length > 0) {\n addVitestAngularDependency(tree, context);\n }\n\n return tree;\n };\n}\n"],"mappings":";;AAGA,IAAM,aAAa;AACnB,IAAM,aAAa;AAEnB,SAAS,2BACP,MACA,SACM;CACN,MAAM,UAAU;CAChB,MAAM,UAAU,KAAK,KAAK,QAAQ;AAClC,KAAI,CAAC,QACH;CAGF,MAAM,MAAM,KAAK,MAAM,QAAQ,SAAS,QAAQ,CAAC;CACjD,MAAM,UAAU,IAAI,sBAAsB,EAAE;CAC5C,MAAM,OAAO,IAAI,mBAAmB,EAAE;AAEtC,KACE,CAAC,QAAQ,+BACT,CAAC,KAAK,6BACN;EACA,MAAM,gBACJ,QAAQ,oCACR,KAAK,oCACL;AAEF,MAAI,qBAAqB;GACvB,GAAG;GACH,4BAA4B;GAC7B;AAED,OAAK,UAAU,SAAS,KAAK,UAAU,KAAK,MAAM,EAAE,GAAG,KAAK;AAC5D,UAAQ,QAAQ,IAAI,wBAAwB,CAAC;AAC7C,UAAQ,OAAO,KACb,sCAAsC,cAAc,uBACrD;;;AAIL,SAAwB,qBAA2B;AACjD,SAAQ,MAAY,YAA8B;EAChD,MAAM,gBAA0B,EAAE;AAElC,OAAK,OAAO,aAAa;AACvB,OACE,CAAC,SAAS,SAAS,MAAM,IACzB,CAAC,SAAS,SAAS,OAAO,IAC1B,CAAC,SAAS,SAAS,MAAM,IACzB,CAAC,SAAS,SAAS,OAAO,CAE1B;AAEF,OAAI,SAAS,SAAS,iBAAiB,CACrC;GAGF,MAAM,UAAU,KAAK,KAAK,SAAS;AACnC,OAAI,CAAC,QACH;GAGF,MAAM,OAAO,QAAQ,SAAS,QAAQ;AACtC,OAAI,KAAK,SAAS,WAAW,EAAE;IAC7B,MAAM,UAAU,KAAK,QACnB,IAAI,OAAO,WAAW,QAAQ,uBAAuB,OAAO,EAAE,IAAI,EAClE,WACD;AACD,SAAK,UAAU,UAAU,QAAQ;AACjC,kBAAc,KAAK,SAAS;;IAE9B;AAEF,MAAI,cAAc,SAAS,GAAG;AAC5B,WAAQ,OAAO,KACb,YAAY,cAAc,OAAO,iBAAiB,WAAW,QAAQ,WAAW,IACjF;AACD,QAAK,MAAM,QAAQ,cACjB,SAAQ,OAAO,KAAK,OAAO,OAAO;;AAItC,MAAI,cAAc,SAAS,EACzB,4BAA2B,MAAM,QAAQ;AAG3C,SAAO"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
-
"schematics": {
|
|
3
|
+
"schematics": {
|
|
4
|
+
"migrate-setup-vitest": {
|
|
5
|
+
"version": "3.0.0-alpha.16",
|
|
6
|
+
"description": "Migrate from @analogjs/vite-plugin-angular/setup-vitest to @analogjs/vitest-angular/setup-zone",
|
|
7
|
+
"factory": "./migrate-setup-vitest/migrate-setup-vitest"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
4
10
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"update-3-0-0-migrate-setup-vitest": {
|
|
4
|
+
"version": "3.0.0-alpha.25",
|
|
5
|
+
"description": "Migrate from @analogjs/vite-plugin-angular/setup-vitest to @analogjs/vitest-angular/setup-zone in Nx workspaces",
|
|
6
|
+
"implementation": "./update-3-0-0/migrate-setup-vitest"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { addDependenciesToPackageJson, readJson, runTasksInSerial, visitNotIgnoredFiles } from "@nx/devkit";
|
|
2
|
+
//#region packages/vite-plugin-angular/migrations/update-3-0-0/migrate-setup-vitest.ts
|
|
3
|
+
var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
|
|
4
|
+
var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
|
|
5
|
+
var SUPPORTED_EXTENSIONS = new Set([
|
|
6
|
+
".cjs",
|
|
7
|
+
".cts",
|
|
8
|
+
".js",
|
|
9
|
+
".jsx",
|
|
10
|
+
".mjs",
|
|
11
|
+
".mts",
|
|
12
|
+
".ts",
|
|
13
|
+
".tsx"
|
|
14
|
+
]);
|
|
15
|
+
function getAnalogVersion(tree) {
|
|
16
|
+
if (!tree.exists("package.json")) return "*";
|
|
17
|
+
const packageJson = readJson(tree, "package.json");
|
|
18
|
+
return packageJson.devDependencies?.["@analogjs/vite-plugin-angular"] || packageJson.dependencies?.["@analogjs/vite-plugin-angular"] || "*";
|
|
19
|
+
}
|
|
20
|
+
async function migrateSetupVitest(tree) {
|
|
21
|
+
const filesToUpdate = [];
|
|
22
|
+
visitNotIgnoredFiles(tree, "", (filePath) => {
|
|
23
|
+
const extension = filePath.slice(filePath.lastIndexOf("."));
|
|
24
|
+
if (!SUPPORTED_EXTENSIONS.has(extension)) return;
|
|
25
|
+
const content = tree.read(filePath, "utf-8");
|
|
26
|
+
if (!content?.includes(OLD_IMPORT)) return;
|
|
27
|
+
tree.write(filePath, content.replaceAll(OLD_IMPORT, NEW_IMPORT));
|
|
28
|
+
filesToUpdate.push(filePath);
|
|
29
|
+
});
|
|
30
|
+
if (filesToUpdate.length === 0) return;
|
|
31
|
+
return runTasksInSerial(addDependenciesToPackageJson(tree, {}, { "@analogjs/vitest-angular": getAnalogVersion(tree) }, "package.json", true));
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { migrateSetupVitest as default };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=migrate-setup-vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/update-3-0-0/migrate-setup-vitest.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n readJson,\n runTasksInSerial,\n Tree,\n visitNotIgnoredFiles,\n} from '@nx/devkit';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\nconst SUPPORTED_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n]);\n\nfunction getAnalogVersion(tree: Tree): string {\n if (!tree.exists('package.json')) {\n return '*';\n }\n\n const packageJson = readJson<{\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n }>(tree, 'package.json');\n\n return (\n packageJson.devDependencies?.['@analogjs/vite-plugin-angular'] ||\n packageJson.dependencies?.['@analogjs/vite-plugin-angular'] ||\n '*'\n );\n}\n\nexport default async function migrateSetupVitest(tree: Tree) {\n const filesToUpdate: string[] = [];\n\n visitNotIgnoredFiles(tree, '', (filePath) => {\n const extension = filePath.slice(filePath.lastIndexOf('.'));\n if (!SUPPORTED_EXTENSIONS.has(extension)) {\n return;\n }\n\n const content = tree.read(filePath, 'utf-8');\n if (!content?.includes(OLD_IMPORT)) {\n return;\n }\n\n tree.write(filePath, content.replaceAll(OLD_IMPORT, NEW_IMPORT));\n filesToUpdate.push(filePath);\n });\n\n if (filesToUpdate.length === 0) {\n return;\n }\n\n const installTask = addDependenciesToPackageJson(\n tree,\n {},\n {\n '@analogjs/vitest-angular': getAnalogVersion(tree),\n },\n 'package.json',\n true,\n );\n\n return runTasksInSerial(installTask);\n}\n"],"mappings":";;AAQA,IAAM,aAAa;AACnB,IAAM,aAAa;AACnB,IAAM,uBAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,iBAAiB,MAAoB;AAC5C,KAAI,CAAC,KAAK,OAAO,eAAe,CAC9B,QAAO;CAGT,MAAM,cAAc,SAGjB,MAAM,eAAe;AAExB,QACE,YAAY,kBAAkB,oCAC9B,YAAY,eAAe,oCAC3B;;AAIJ,eAA8B,mBAAmB,MAAY;CAC3D,MAAM,gBAA0B,EAAE;AAElC,sBAAqB,MAAM,KAAK,aAAa;EAC3C,MAAM,YAAY,SAAS,MAAM,SAAS,YAAY,IAAI,CAAC;AAC3D,MAAI,CAAC,qBAAqB,IAAI,UAAU,CACtC;EAGF,MAAM,UAAU,KAAK,KAAK,UAAU,QAAQ;AAC5C,MAAI,CAAC,SAAS,SAAS,WAAW,CAChC;AAGF,OAAK,MAAM,UAAU,QAAQ,WAAW,YAAY,WAAW,CAAC;AAChE,gBAAc,KAAK,SAAS;GAC5B;AAEF,KAAI,cAAc,WAAW,EAC3B;AAaF,QAAO,iBAVa,6BAClB,MACA,EAAE,EACF,EACE,4BAA4B,iBAAiB,KAAK,EACnD,EACD,gBACA,KACD,CAEmC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/vite-plugin-angular",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.90",
|
|
4
4
|
"description": "Vite Plugin for Angular",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/sponsors/brandonroberts"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@angular-devkit/build-angular": "^
|
|
28
|
-
"@angular/build": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0"
|
|
27
|
+
"@angular-devkit/build-angular": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
28
|
+
"@angular/build": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0 || ^22.0.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependenciesMeta": {
|
|
31
31
|
"@angular-devkit/build-angular": {
|
|
@@ -33,15 +33,46 @@
|
|
|
33
33
|
},
|
|
34
34
|
"@angular/build": {
|
|
35
35
|
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"vite": {
|
|
38
|
+
"optional": true
|
|
36
39
|
}
|
|
37
40
|
},
|
|
41
|
+
"compatiblePackages": {
|
|
42
|
+
"vite": [
|
|
43
|
+
"^6.0.0",
|
|
44
|
+
"^7.0.0",
|
|
45
|
+
"^8.0.0"
|
|
46
|
+
],
|
|
47
|
+
"rollup": [
|
|
48
|
+
"^4.0.0"
|
|
49
|
+
],
|
|
50
|
+
"rolldown": [
|
|
51
|
+
"^1.0.0"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
38
54
|
"dependencies": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
55
|
+
"es-toolkit": "^1.45.1",
|
|
56
|
+
"magic-string": "^0.30.21",
|
|
57
|
+
"obug": "^2.1.1",
|
|
58
|
+
"oxc-parser": "^0.124.0",
|
|
59
|
+
"oxc-resolver": "^11.19.1",
|
|
60
|
+
"rolldown": "^1.0.0-rc.13",
|
|
61
|
+
"tinyglobby": "^0.2.15"
|
|
43
62
|
},
|
|
44
63
|
"builders": "./src/lib/tools/builders.json",
|
|
64
|
+
"nx-migrations": {
|
|
65
|
+
"packageGroup": [
|
|
66
|
+
"@analogjs/platform",
|
|
67
|
+
"@analogjs/content",
|
|
68
|
+
"@analogjs/router",
|
|
69
|
+
"@analogjs/storybook-angular",
|
|
70
|
+
"@analogjs/vite-plugin-angular",
|
|
71
|
+
"@analogjs/vite-plugin-nitro",
|
|
72
|
+
"@analogjs/vitest-angular"
|
|
73
|
+
],
|
|
74
|
+
"migrations": "./migrations/migrations.json"
|
|
75
|
+
},
|
|
45
76
|
"ng-update": {
|
|
46
77
|
"packageGroup": [
|
|
47
78
|
"@analogjs/platform",
|
|
@@ -56,13 +87,23 @@
|
|
|
56
87
|
},
|
|
57
88
|
"exports": {
|
|
58
89
|
"./package.json": "./package.json",
|
|
90
|
+
"./migrations.json": "./migrations/migrations.json",
|
|
59
91
|
".": {
|
|
60
92
|
"types": "./src/index.d.ts",
|
|
61
93
|
"import": "./src/index.js",
|
|
62
94
|
"require": "./src/index.js",
|
|
63
95
|
"default": "./src/index.js"
|
|
64
96
|
},
|
|
65
|
-
"./
|
|
97
|
+
"./builders/vite": {
|
|
98
|
+
"import": "./src/lib/tools/src/builders/vite/vite-build.impl.js",
|
|
99
|
+
"require": "./src/lib/tools/src/builders/vite/vite-build.impl.js",
|
|
100
|
+
"default": "./src/lib/tools/src/builders/vite/vite-build.impl.js"
|
|
101
|
+
},
|
|
102
|
+
"./builders/vite-dev-server": {
|
|
103
|
+
"import": "./src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js",
|
|
104
|
+
"require": "./src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js",
|
|
105
|
+
"default": "./src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js"
|
|
106
|
+
}
|
|
66
107
|
},
|
|
67
108
|
"publishConfig": {
|
|
68
109
|
"access": "public",
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { angularCompilationPlugin, type AngularCompilationPluginOptions } from "./lib/compilation-api/index.js";
|
|
2
|
+
import { angular } from "./lib/angular-vite-plugin.js";
|
|
3
|
+
export { angular } from "./lib/angular-vite-plugin.js";
|
|
4
|
+
export type { PluginOptions } from "./lib/angular-vite-plugin.js";
|
|
5
|
+
export type { AnalogIntegrationPlugin, AnalogPluginContext, AnalogPluginHooks, ComponentRegistryEntries, StylesheetRegistryConfigurator, StylesheetRegistryContext, TransformFilter } from "./lib/analog-plugin-interop.js";
|
|
6
|
+
export type { RegistryEntry as ComponentRegistryEntry, RegistryInput as ComponentRegistryInput } from "./lib/compiler/registry.js";
|
|
7
|
+
export type { StylePreprocessor, StylesheetDependency, StylesheetDiagnostic, StylesheetRegistryReader, StylesheetTransformContext, StylesheetTransformResult } from "./lib/style-preprocessor.js";
|
|
3
8
|
export default angular;
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { angularCompilationPlugin } from "./lib/compilation-api/compilation-api-plugin.js";
|
|
2
|
+
import "./lib/compilation-api/index.js";
|
|
1
3
|
import { angular } from "./lib/angular-vite-plugin.js";
|
|
2
4
|
//#region packages/vite-plugin-angular/src/index.ts
|
|
3
5
|
var src_default = angular;
|
|
4
6
|
//#endregion
|
|
5
|
-
export { src_default as default };
|
|
7
|
+
export { angular, angularCompilationPlugin, src_default as default };
|
|
6
8
|
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export {\n angularCompilationPlugin,\n type AngularCompilationPluginOptions,\n} from './lib/compilation-api/index.js';\nimport { 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":";;;;AA6BA,IAAA,cAAe"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Plugin, ResolvedConfig } from "vite";
|
|
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>;
|
|
6
|
+
export interface StylesheetRegistryContext {
|
|
7
|
+
workspaceRoot: string;
|
|
8
|
+
}
|
|
9
|
+
export type StylesheetRegistryConfigurator = (registry: StylesheetRegistryReader, context: StylesheetRegistryContext) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Narrow framework context handed to a Vite plugin's `analog.setup()` hook.
|
|
12
|
+
* Only grows when a concrete integration needs another seam.
|
|
13
|
+
*/
|
|
14
|
+
export interface AnalogPluginContext {
|
|
15
|
+
/**
|
|
16
|
+
* Registers a pre-transform that runs on every Angular component stylesheet
|
|
17
|
+
* before it enters Vite's `preprocessCSS` pipeline.
|
|
18
|
+
*/
|
|
19
|
+
registerStylePreprocessor(preprocessor: StylePreprocessor): void;
|
|
20
|
+
/**
|
|
21
|
+
* Requests that component styles are externalized in dev and watch mode so
|
|
22
|
+
* they run through Vite's CSS plugin pipeline (for example
|
|
23
|
+
* `@tailwindcss/vite`) instead of being inlined through `preprocessCSS`,
|
|
24
|
+
* which only runs PostCSS and CSS preprocessors. Production builds keep
|
|
25
|
+
* inlining component styles.
|
|
26
|
+
*/
|
|
27
|
+
externalizeComponentStyles(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Receives the live stylesheet registry for externalized component styles
|
|
30
|
+
* each time a compilation creates one, so the plugin can map component
|
|
31
|
+
* stylesheet sources to their served ids, dependencies, and diagnostics.
|
|
32
|
+
*/
|
|
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;
|
|
47
|
+
/**
|
|
48
|
+
* Adds TypeScript include globs to the Angular compilation. Globs resolve
|
|
49
|
+
* against the same workspace root as `angular({ include })`, so a leading
|
|
50
|
+
* `/` means workspace-relative.
|
|
51
|
+
*/
|
|
52
|
+
addInclude(globs: string[]): void;
|
|
53
|
+
}
|
|
54
|
+
export interface AnalogPluginHooks {
|
|
55
|
+
setup?(context: AnalogPluginContext): void | Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A normal Vite plugin that optionally exposes an `analog` setup hook.
|
|
59
|
+
* Discovery is structural (`plugin.analog?.setup`), so this type is a DX aid
|
|
60
|
+
* rather than a requirement.
|
|
61
|
+
*/
|
|
62
|
+
export type AnalogIntegrationPlugin = Plugin & {
|
|
63
|
+
analog?: AnalogPluginHooks;
|
|
64
|
+
};
|
|
65
|
+
export interface AnalogIntegrations {
|
|
66
|
+
stylePreprocessor?: StylePreprocessor;
|
|
67
|
+
configureStylesheetRegistry?: StylesheetRegistryConfigurator;
|
|
68
|
+
transformFilter?: TransformFilter;
|
|
69
|
+
componentRegistries: ComponentRegistryEntries[];
|
|
70
|
+
include: string[];
|
|
71
|
+
externalizeStyles: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Runs every `analog.setup()` hook found in the resolved Vite plugin list,
|
|
75
|
+
* once per resolved config, and composes the registrations in plugin order.
|
|
76
|
+
*/
|
|
77
|
+
export declare function discoverAnalogIntegrations(config: ResolvedConfig): Promise<AnalogIntegrations>;
|
|
78
|
+
export declare function runAnalogSetupHooks(plugins: readonly Plugin[]): Promise<AnalogIntegrations>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { debugStylePipeline } from "./utils/debug.js";
|
|
2
|
+
import { composeStylePreprocessors } from "./style-preprocessor.js";
|
|
3
|
+
//#region packages/vite-plugin-angular/src/lib/analog-plugin-interop.ts
|
|
4
|
+
var integrationsByConfig = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* Runs every `analog.setup()` hook found in the resolved Vite plugin list,
|
|
7
|
+
* once per resolved config, and composes the registrations in plugin order.
|
|
8
|
+
*/
|
|
9
|
+
function discoverAnalogIntegrations(config) {
|
|
10
|
+
let pending = integrationsByConfig.get(config);
|
|
11
|
+
if (!pending) {
|
|
12
|
+
pending = runAnalogSetupHooks(config.plugins ?? []);
|
|
13
|
+
integrationsByConfig.set(config, pending);
|
|
14
|
+
}
|
|
15
|
+
return pending;
|
|
16
|
+
}
|
|
17
|
+
async function runAnalogSetupHooks(plugins) {
|
|
18
|
+
const preprocessors = [];
|
|
19
|
+
const registryConfigurators = [];
|
|
20
|
+
const transformFilters = [];
|
|
21
|
+
const componentRegistries = [];
|
|
22
|
+
const include = [];
|
|
23
|
+
let externalizeStyles = false;
|
|
24
|
+
for (const plugin of plugins) {
|
|
25
|
+
if (typeof plugin.analog?.setup !== "function") continue;
|
|
26
|
+
const registeredBefore = preprocessors.length;
|
|
27
|
+
const context = {
|
|
28
|
+
registerStylePreprocessor(preprocessor) {
|
|
29
|
+
preprocessors.push(wrapStylePreprocessor(plugin.name, preprocessor));
|
|
30
|
+
},
|
|
31
|
+
externalizeComponentStyles() {
|
|
32
|
+
externalizeStyles = true;
|
|
33
|
+
},
|
|
34
|
+
configureStylesheetRegistry(configure) {
|
|
35
|
+
registryConfigurators.push(wrapRegistryConfigurator(plugin.name, configure));
|
|
36
|
+
},
|
|
37
|
+
registerTransformFilter(filter) {
|
|
38
|
+
transformFilters.push(filter);
|
|
39
|
+
},
|
|
40
|
+
registerComponentRegistry(entries) {
|
|
41
|
+
componentRegistries.push(entries);
|
|
42
|
+
},
|
|
43
|
+
addInclude(globs) {
|
|
44
|
+
include.push(...globs);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
await plugin.analog.setup(context);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
throw new Error(`[analog] analog.setup() from plugin "${plugin.name}" failed: ${describeError(error)}`);
|
|
51
|
+
}
|
|
52
|
+
debugStylePipeline("analog.setup() completed", {
|
|
53
|
+
plugin: plugin.name,
|
|
54
|
+
stylePreprocessors: preprocessors.length - registeredBefore,
|
|
55
|
+
registryConfigurators: registryConfigurators.length,
|
|
56
|
+
transformFilters: transformFilters.length,
|
|
57
|
+
componentRegistries: componentRegistries.length,
|
|
58
|
+
include: include.length,
|
|
59
|
+
externalizeStyles
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
stylePreprocessor: composeStylePreprocessors(preprocessors),
|
|
64
|
+
configureStylesheetRegistry: registryConfigurators.length ? (registry, context) => {
|
|
65
|
+
for (const configure of registryConfigurators) configure(registry, context);
|
|
66
|
+
} : void 0,
|
|
67
|
+
transformFilter: transformFilters.length ? (code, id) => transformFilters.every((filter) => filter(code, id)) : void 0,
|
|
68
|
+
componentRegistries,
|
|
69
|
+
include,
|
|
70
|
+
externalizeStyles
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function wrapStylePreprocessor(pluginName, preprocessor) {
|
|
74
|
+
return (code, filename, context) => {
|
|
75
|
+
try {
|
|
76
|
+
return preprocessor(code, filename, context);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
throw new Error(`[analog] Style preprocessor from plugin "${pluginName}" failed for "${filename}": ${describeError(error)}`);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function wrapRegistryConfigurator(pluginName, configure) {
|
|
83
|
+
return (registry, context) => {
|
|
84
|
+
try {
|
|
85
|
+
configure(registry, context);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
throw new Error(`[analog] Stylesheet registry configurator from plugin "${pluginName}" failed: ${describeError(error)}`);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function describeError(error) {
|
|
92
|
+
return error instanceof Error ? error.message : String(error);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { discoverAnalogIntegrations };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=analog-plugin-interop.js.map
|
|
@@ -0,0 +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 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 * Adds TypeScript include globs to the Angular compilation. Globs resolve\n * against the same workspace root as `angular({ include })`, so a leading\n * `/` means workspace-relative.\n */\n addInclude(globs: string[]): 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 include: string[];\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 const include: string[] = [];\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 addInclude(globs) {\n include.push(...globs);\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 include: include.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 include,\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":";;;AAuFA,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,MAAM,UAAoB,EAAE;CAC5B,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;;GAEnC,WAAW,OAAO;AAChB,YAAQ,KAAK,GAAG,MAAM;;GAEzB;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,SAAS,QAAQ;GACjB;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;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,5 +1,9 @@
|
|
|
1
|
-
import type { Plugin } from
|
|
2
|
-
export declare function buildOptimizerPlugin({ jit
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
export declare function buildOptimizerPlugin({ jit }: {
|
|
3
|
+
supportedBrowsers: string[];
|
|
4
|
+
jit: boolean;
|
|
5
5
|
}): Plugin;
|
|
6
|
+
export declare function extractInlineSourceMap(code: string, id: string): {
|
|
7
|
+
code: string;
|
|
8
|
+
map: string | null;
|
|
9
|
+
};
|