@analogjs/vite-plugin-angular 3.0.0-beta.2 → 3.0.0-beta.20
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 +40 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +13 -2
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- package/ngp/LICENSE +21 -0
- package/ngp/api.mjs +46048 -0
- package/ngp/build.json +4 -0
- package/ngp/ng_analyze.cjs +504 -0
- package/ngp/ng_analyze_bg.wasm +0 -0
- package/package.json +1 -14
- package/src/lib/angular-build-optimizer-plugin.js +6 -3
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +20 -5
- package/src/lib/angular-vite-plugin.js +28 -13
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/compiler/compile.js +5 -2
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +5 -0
- package/src/lib/compiler/dts-reader.js +9 -3
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.d.ts +4 -0
- package/src/lib/compiler/hmr.js +7 -2
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.d.ts +2 -2
- package/src/lib/compiler/index.js +3 -3
- package/src/lib/compiler/jit-metadata.d.ts +3 -1
- package/src/lib/compiler/jit-metadata.js +10 -8
- package/src/lib/compiler/jit-metadata.js.map +1 -1
- package/src/lib/compiler/registry.d.ts +6 -0
- package/src/lib/compiler/registry.js +21 -1
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/fast-compile-plugin.d.ts +3 -0
- package/src/lib/fast-compile-plugin.js +97 -15
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/live-reload-plugin.d.ts +4 -3
- package/src/lib/live-reload-plugin.js +4 -3
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-plugin.d.ts +3 -0
- package/src/lib/ngp-compile-plugin.js +344 -0
- package/src/lib/ngp-compile-plugin.js.map +1 -0
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/src/lib/utils/hmr-component-updates.d.ts +7 -0
- package/src/lib/utils/hmr-component-updates.js +87 -0
- package/src/lib/utils/hmr-component-updates.js.map +1 -0
- package/src/lib/utils/lsp-type-checker.d.ts +55 -0
- package/src/lib/utils/lsp-type-checker.js +502 -0
- package/src/lib/utils/lsp-type-checker.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +9 -0
- package/src/lib/utils/plugin-config.js +10 -1
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/migrations/migrations.json +0 -9
- package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +0 -2
- package/migrations/update-3-0-0/migrate-setup-vitest.js +0 -37
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +0 -1
package/README.md
CHANGED
|
@@ -50,6 +50,46 @@ export default defineConfig({
|
|
|
50
50
|
|
|
51
51
|
> The `angular` plugin should be listed **first** in the plugins array.
|
|
52
52
|
|
|
53
|
+
## Plugin Options
|
|
54
|
+
|
|
55
|
+
All options are optional.
|
|
56
|
+
|
|
57
|
+
| Option | Default | Description |
|
|
58
|
+
| ----------------------- | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `tsconfig` | `tsconfig.app.json` | Path to the tsconfig used for compilation, or a function returning it. Libraries default to `tsconfig.lib.json` and tests to `tsconfig.spec.json`. |
|
|
60
|
+
| `workspaceRoot` | `NX_WORKSPACE_ROOT`, then `process.cwd()` | Absolute path to the workspace root. Set it in monorepos where the app is not the working directory. |
|
|
61
|
+
| `inlineStylesExtension` | `'css'` | Stylesheet language for inline component `styles`, such as `'scss'`. See [CSS Pre-processors](https://analogjs.org/docs/packages/vite-plugin-angular/css-preprocessors). |
|
|
62
|
+
| `jit` | `true` in tests, `false` otherwise | Compile components in JIT mode instead of AOT. |
|
|
63
|
+
| `include` | `[]` | Additional globs, relative to the workspace root, to add to compilation, such as components from a library outside the tsconfig `include`. |
|
|
64
|
+
| `liveReload` | `true` | Enables Angular component HMR during development. This is separate from Vite's `server.hmr` transport option. |
|
|
65
|
+
| `disableTypeChecking` | `true` | Skips semantic and template diagnostics during compilation. Set to `false` to report type errors from the Vite build. |
|
|
66
|
+
| `fileReplacements` | `[]` | Replaces source files at build time, like `fileReplacements` in `angular.json`. Use `{ replace, with }`, or `{ replace, ssr }` for the SSR build. `with` and `ssr` paths resolve against `workspaceRoot`. |
|
|
67
|
+
| `fastCompile` | `false` | Opts into the [fast compile path](#fast-compile-mode). |
|
|
68
|
+
| `fastCompileMode` | `'full'` | Output mode for `fastCompile`: `'full'` for apps, `'partial'` for publishing libraries. |
|
|
69
|
+
| `debug` | `false` | Enables `analog:angular:*` debug logging. |
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { defineConfig } from 'vite';
|
|
73
|
+
import angular from '@analogjs/vite-plugin-angular';
|
|
74
|
+
|
|
75
|
+
export default defineConfig(({ mode }) => ({
|
|
76
|
+
plugins: [
|
|
77
|
+
angular({
|
|
78
|
+
inlineStylesExtension: 'scss',
|
|
79
|
+
fileReplacements:
|
|
80
|
+
mode === 'production'
|
|
81
|
+
? [
|
|
82
|
+
{
|
|
83
|
+
replace: 'src/environments/environment.ts',
|
|
84
|
+
with: 'src/environments/environment.prod.ts',
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
: [],
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
}));
|
|
91
|
+
```
|
|
92
|
+
|
|
53
93
|
## Fast Compile Mode
|
|
54
94
|
|
|
55
95
|
`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.
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { NodePackageInstallTask } from "@angular-devkit/schematics/tasks";
|
|
1
|
+
import { NodePackageInstallTask } from "@angular-devkit/schematics/tasks/index.js";
|
|
2
2
|
//#region packages/vite-plugin-angular/migrations/migrate-setup-vitest/migrate-setup-vitest.ts
|
|
3
3
|
var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
|
|
4
4
|
var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
|
|
5
|
+
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6
|
+
".cjs",
|
|
7
|
+
".cts",
|
|
8
|
+
".js",
|
|
9
|
+
".jsx",
|
|
10
|
+
".mjs",
|
|
11
|
+
".mts",
|
|
12
|
+
".ts",
|
|
13
|
+
".tsx"
|
|
14
|
+
]);
|
|
5
15
|
function addVitestAngularDependency(tree, context) {
|
|
6
16
|
const pkgPath = "/package.json";
|
|
7
17
|
const content = tree.read(pkgPath);
|
|
@@ -24,7 +34,8 @@ function migrateSetupVitest() {
|
|
|
24
34
|
return (tree, context) => {
|
|
25
35
|
const filesToUpdate = [];
|
|
26
36
|
tree.visit((filePath) => {
|
|
27
|
-
|
|
37
|
+
const extension = filePath.slice(filePath.lastIndexOf("."));
|
|
38
|
+
if (!SUPPORTED_EXTENSIONS.has(extension)) return;
|
|
28
39
|
if (filePath.includes("/node_modules/")) return;
|
|
29
40
|
const content = tree.read(filePath);
|
|
30
41
|
if (!content) return;
|
|
@@ -1 +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
|
|
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/index.js';\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 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 const extension = filePath.slice(filePath.lastIndexOf('.'));\n if (!SUPPORTED_EXTENSIONS.has(extension)) {\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;AACnB,IAAM,uCAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,2BACP,MACA,SACM;CACN,MAAM,UAAU;CAChB,MAAM,UAAU,KAAK,KAAK,OAAO;CACjC,IAAI,CAAC,SACH;CAGF,MAAM,MAAM,KAAK,MAAM,QAAQ,SAAS,OAAO,CAAC;CAChD,MAAM,UAAU,IAAI,sBAAsB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
Copyright (c) 2010-2026 Google LLC. https://angular.dev/license
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|