@analogjs/vite-plugin-angular 3.0.0-alpha.36 → 3.0.0-alpha.38
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 +22 -0
- package/package.json +3 -4
- package/src/lib/angular-jit-plugin.js +3 -0
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +12 -7
- package/src/lib/angular-vite-plugin.js +7 -5
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/compiler/angular-version.d.ts +19 -0
- package/src/lib/compiler/angular-version.js +16 -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 +44 -0
- package/src/lib/compiler/compile.js +731 -0
- package/src/lib/compiler/compile.js.map +1 -0
- package/src/lib/compiler/constants.d.ts +18 -0
- package/src/lib/compiler/constants.js +52 -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 +47 -0
- package/src/lib/compiler/defer.js +138 -0
- package/src/lib/compiler/defer.js.map +1 -0
- package/src/lib/compiler/dts-reader.d.ts +35 -0
- package/src/lib/compiler/dts-reader.js +365 -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 +7 -0
- package/src/lib/compiler/index.js +7 -0
- package/src/lib/compiler/jit-metadata.d.ts +14 -0
- package/src/lib/compiler/jit-metadata.js +146 -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 +200 -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 +420 -0
- package/src/lib/compiler/js-emitter.js.map +1 -0
- package/src/lib/compiler/metadata.d.ts +45 -0
- package/src/lib/compiler/metadata.js +633 -0
- package/src/lib/compiler/metadata.js.map +1 -0
- package/src/lib/compiler/registry.d.ts +49 -0
- package/src/lib/compiler/registry.js +164 -0
- package/src/lib/compiler/registry.js.map +1 -0
- package/src/lib/compiler/resource-inliner.d.ts +21 -0
- package/src/lib/compiler/resource-inliner.js +152 -0
- package/src/lib/compiler/resource-inliner.js.map +1 -0
- package/src/lib/compiler/style-ast.d.ts +8 -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 +26 -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 +10 -0
- package/src/lib/compiler/utils.js +35 -0
- package/src/lib/compiler/utils.js.map +1 -0
- package/src/lib/{analog-compiler-plugin.d.ts → fast-compile-plugin.d.ts} +3 -3
- package/src/lib/{analog-compiler-plugin.js → fast-compile-plugin.js} +46 -33
- package/src/lib/fast-compile-plugin.js.map +1 -0
- package/src/lib/utils/virtual-resources.d.ts +16 -0
- package/src/lib/utils/virtual-resources.js +31 -2
- package/src/lib/utils/virtual-resources.js.map +1 -1
- package/src/lib/analog-compiler-plugin.js.map +0 -1
package/README.md
CHANGED
|
@@ -48,6 +48,28 @@ export default defineConfig({
|
|
|
48
48
|
|
|
49
49
|
> The `angular` plugin should be listed **first** in the plugins array.
|
|
50
50
|
|
|
51
|
+
## Fast Compile Mode
|
|
52
|
+
|
|
53
|
+
`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.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
export default defineConfig({
|
|
57
|
+
plugins: [angular({ fastCompile: true })],
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
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:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "ngc -p tsconfig.app.json --noEmit && vite build"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The fast compile path currently passes ~91% of Angular's conformance suite. Behavior and output may change between minor releases.
|
|
72
|
+
|
|
51
73
|
## Setting up the TypeScript config
|
|
52
74
|
|
|
53
75
|
The integration needs a `tsconfig.app.json` at the root of the project for compilation.
|
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.38",
|
|
4
4
|
"description": "Vite Plugin for Angular",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@analogjs/angular-compiler": "3.0.0-alpha.36",
|
|
40
39
|
"es-toolkit": "^1.45.1",
|
|
40
|
+
"magic-string": "^0.30.21",
|
|
41
41
|
"obug": "^2.1.1",
|
|
42
42
|
"oxc-parser": "^0.124.0",
|
|
43
43
|
"oxc-resolver": "^11.19.1",
|
|
@@ -65,8 +65,7 @@
|
|
|
65
65
|
"@analogjs/storybook-angular",
|
|
66
66
|
"@analogjs/vite-plugin-angular",
|
|
67
67
|
"@analogjs/vite-plugin-nitro",
|
|
68
|
-
"@analogjs/vitest-angular"
|
|
69
|
-
"@analogjs/angular-compiler"
|
|
68
|
+
"@analogjs/vitest-angular"
|
|
70
69
|
],
|
|
71
70
|
"migrations": "./migrations/migration.json"
|
|
72
71
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { debugStyles } from "./utils/debug.js";
|
|
2
2
|
import { isTailwindReferenceError } from "./utils/tailwind-reference.js";
|
|
3
|
+
import { shouldPreprocessTestCss } from "./utils/virtual-resources.js";
|
|
3
4
|
import { createHash } from "node:crypto";
|
|
4
5
|
import { preprocessCSS } from "vite";
|
|
5
6
|
//#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
|
|
@@ -19,6 +20,8 @@ function jitPlugin({ inlineStylesExtension }) {
|
|
|
19
20
|
const styleIdHash = createHash("sha256").update(styleId).digest("hex").slice(0, 16);
|
|
20
21
|
const decodedStyles = Buffer.from(decodeURIComponent(styleId), "base64").toString();
|
|
21
22
|
let styles = "";
|
|
23
|
+
const inlineStyleId = `${styleIdHash}.${inlineStylesExtension}`;
|
|
24
|
+
if (!shouldPreprocessTestCss(config, inlineStyleId)) return `export default \`\``;
|
|
22
25
|
try {
|
|
23
26
|
styles = (await preprocessCSS(decodedStyles, `${styleIdHash}.${inlineStylesExtension}?direct`, config))?.code;
|
|
24
27
|
} catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport { debugStyles } from './utils/debug.js';\nimport { isTailwindReferenceError } from './utils/tailwind-reference.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\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('virtual:angular:jit:style:inline;')) {\n const styleId = id.split('style:inline;')[1];\n // styleId may exceed 255 bytes of base64-encoded content, limit to 16\n const styleIdHash = createHash('sha256')\n .update(styleId)\n .digest('hex')\n .slice(0, 16);\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(styleId),\n 'base64',\n ).toString();\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n decodedStyles,\n `${styleIdHash}.${inlineStylesExtension}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n if (isTailwindReferenceError(e)) {\n throw e;\n }\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":"
|
|
1
|
+
{"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport { debugStyles } from './utils/debug.js';\nimport { isTailwindReferenceError } from './utils/tailwind-reference.js';\n\nimport { shouldPreprocessTestCss } from './utils/virtual-resources.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\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('virtual:angular:jit:style:inline;')) {\n const styleId = id.split('style:inline;')[1];\n // styleId may exceed 255 bytes of base64-encoded content, limit to 16\n const styleIdHash = createHash('sha256')\n .update(styleId)\n .digest('hex')\n .slice(0, 16);\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(styleId),\n 'base64',\n ).toString();\n\n let styles: string | undefined = '';\n\n // In tests, mirror Vitest's `test.css` rules — defaults to no\n // preprocessing (matches Vite's CSS pipeline behavior). Inline\n // component styles have no real file path to match include/exclude\n // patterns against, so only `test.css: true` opts them in. (#2297)\n const inlineStyleId = `${styleIdHash}.${inlineStylesExtension}`;\n if (!shouldPreprocessTestCss(config, inlineStyleId)) {\n return `export default \\`\\``;\n }\n\n try {\n const compiled = await preprocessCSS(\n decodedStyles,\n `${styleIdHash}.${inlineStylesExtension}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n if (isTailwindReferenceError(e)) {\n throw e;\n }\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":";;;;;;AAOA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,eAAe,SAAS;AACtB,YAAS;;EAEX,UAAU,IAAY;AACpB,OAAI,GAAG,WAAW,kBAAkB,CAClC,QAAO,KAAK;;EAKhB,MAAM,KAAK,IAAY;AACrB,OAAI,GAAG,SAAS,oCAAoC,EAAE;IACpD,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC;IAE1C,MAAM,cAAc,WAAW,SAAS,CACrC,OAAO,QAAQ,CACf,OAAO,MAAM,CACb,MAAM,GAAG,GAAG;IAEf,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,QAAQ,EAC3B,SACD,CAAC,UAAU;IAEZ,IAAI,SAA6B;IAMjC,MAAM,gBAAgB,GAAG,YAAY,GAAG;AACxC,QAAI,CAAC,wBAAwB,QAAQ,cAAc,CACjD,QAAO;AAGT,QAAI;AAMF,eALiB,MAAM,cACrB,eACA,GAAG,YAAY,GAAG,sBAAsB,UACxC,OACD,GACkB;aACZ,GAAG;AACV,SAAI,yBAAyB,EAAE,CAC7B,OAAM;KAER,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"}
|
|
@@ -44,15 +44,20 @@ export interface PluginOptions {
|
|
|
44
44
|
liveReload?: boolean;
|
|
45
45
|
disableTypeChecking?: boolean;
|
|
46
46
|
fileReplacements?: FileReplacement[];
|
|
47
|
+
/**
|
|
48
|
+
* Opt into the fast compile path. Skips Angular's template type-checking
|
|
49
|
+
* and routes compilation through an internal single-pass transform.
|
|
50
|
+
* Defaults to `false`.
|
|
51
|
+
*/
|
|
52
|
+
fastCompile?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Compilation output mode used when `fastCompile` is enabled.
|
|
55
|
+
* - `'full'` (default): Emit final Ivy definitions for application builds.
|
|
56
|
+
* - `'partial'`: Emit partial declarations for library publishing.
|
|
57
|
+
*/
|
|
58
|
+
fastCompileMode?: "full" | "partial";
|
|
47
59
|
experimental?: {
|
|
48
60
|
useAngularCompilationAPI?: boolean;
|
|
49
|
-
useAnalogCompiler?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Compilation output mode for the Analog compiler.
|
|
52
|
-
* - `'full'` (default): Emit final Ivy definitions for application builds.
|
|
53
|
-
* - `'partial'`: Emit partial declarations for library publishing.
|
|
54
|
-
*/
|
|
55
|
-
analogCompilationMode?: "full" | "partial";
|
|
56
61
|
};
|
|
57
62
|
/**
|
|
58
63
|
* Enable debug logging for specific scopes.
|
|
@@ -3,6 +3,8 @@ import { getJsTransformConfigKey, isRolldown } from "./utils/rolldown.js";
|
|
|
3
3
|
import { buildOptimizerPlugin } from "./angular-build-optimizer-plugin.js";
|
|
4
4
|
import { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugCompilerV, debugEmit, debugEmitV, debugHmr, debugHmrV, debugStyles, debugStylesV, debugTailwind, debugTailwindV } from "./utils/debug.js";
|
|
5
5
|
import { inspectCssTailwindDirectives, isTailwindReferenceError, throwTailwindReferenceTextError } from "./utils/tailwind-reference.js";
|
|
6
|
+
import { toVirtualRawId, toVirtualStyleId } from "./utils/virtual-ids.js";
|
|
7
|
+
import { loadVirtualRawModule, loadVirtualStyleModule } from "./utils/virtual-resources.js";
|
|
6
8
|
import { jitPlugin } from "./angular-jit-plugin.js";
|
|
7
9
|
import { createCompilerPlugin, createRolldownCompilerPlugin } from "./compiler-plugin.js";
|
|
8
10
|
import { StyleUrlsResolver, TemplateUrlsResolver, getAngularComponentMetadata } from "./component-resolvers.js";
|
|
@@ -10,9 +12,7 @@ import { composeStylePreprocessors, normalizeStylesheetDependencies } from "./st
|
|
|
10
12
|
import { AnalogStylesheetRegistry, preprocessStylesheet, preprocessStylesheetResult, registerStylesheetContent, rewriteRelativeCssImports } from "./stylesheet-registry.js";
|
|
11
13
|
import { augmentHostWithCaching, augmentHostWithResources, augmentProgramWithVersioning, mergeTransformers } from "./host.js";
|
|
12
14
|
import { TS_EXT_REGEX, createTsConfigGetter, getTsConfigPath } from "./utils/plugin-config.js";
|
|
13
|
-
import {
|
|
14
|
-
import { loadVirtualRawModule, loadVirtualStyleModule } from "./utils/virtual-resources.js";
|
|
15
|
-
import { analogCompilerPlugin } from "./analog-compiler-plugin.js";
|
|
15
|
+
import { fastCompilePlugin } from "./fast-compile-plugin.js";
|
|
16
16
|
import { angularVitestPlugins } from "./angular-vitest-plugin.js";
|
|
17
17
|
import { pendingTasksPlugin } from "./angular-pending-tasks.plugin.js";
|
|
18
18
|
import { liveReloadPlugin } from "./live-reload-plugin.js";
|
|
@@ -135,6 +135,8 @@ function angular(options) {
|
|
|
135
135
|
disableTypeChecking: options?.disableTypeChecking ?? true,
|
|
136
136
|
fileReplacements: options?.fileReplacements ?? [],
|
|
137
137
|
useAngularCompilationAPI: options?.experimental?.useAngularCompilationAPI ?? false,
|
|
138
|
+
fastCompile: options?.fastCompile ?? false,
|
|
139
|
+
fastCompileMode: options?.fastCompileMode ?? "full",
|
|
138
140
|
hasTailwindCss: !!options?.tailwindCss,
|
|
139
141
|
tailwindCss: options?.tailwindCss,
|
|
140
142
|
stylePreprocessor: buildStylePreprocessor(options)
|
|
@@ -980,7 +982,7 @@ function angular(options) {
|
|
|
980
982
|
}
|
|
981
983
|
};
|
|
982
984
|
}
|
|
983
|
-
pluginOptions.
|
|
985
|
+
pluginOptions.fastCompile ? fastCompilePlugin({
|
|
984
986
|
tsconfigGetter: pluginOptions.tsconfigGetter,
|
|
985
987
|
workspaceRoot: pluginOptions.workspaceRoot,
|
|
986
988
|
inlineStylesExtension: pluginOptions.inlineStylesExtension,
|
|
@@ -990,7 +992,7 @@ function angular(options) {
|
|
|
990
992
|
transformFilter: options?.transformFilter,
|
|
991
993
|
isTest,
|
|
992
994
|
isAstroIntegration,
|
|
993
|
-
|
|
995
|
+
fastCompileMode: pluginOptions.fastCompileMode
|
|
994
996
|
}) : angularPlugin();
|
|
995
997
|
return [
|
|
996
998
|
replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),
|