@analogjs/vite-plugin-angular 3.0.0-beta.37 → 3.0.0-beta.39
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/package.json +1 -1
- package/src/lib/analog-plugin-interop.js +1 -1
- package/src/lib/angular-build-context.d.ts +215 -0
- package/src/lib/angular-build-context.js +361 -0
- package/src/lib/angular-build-context.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +6 -4
- package/src/lib/angular-build-optimizer-plugin.js +4 -2
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +5 -3
- package/src/lib/angular-jit-plugin.js +14 -6
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +6 -124
- package/src/lib/angular-vite-plugin.js +8 -1276
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +3 -2
- package/src/lib/angular-vitest-plugin.js +5 -3
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/companion-plugins.d.ts +7 -0
- package/src/lib/companion-plugins.js +38 -0
- package/src/lib/companion-plugins.js.map +1 -0
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +11 -2
- package/src/lib/compilation-api/compilation-api-plugin.js +154 -285
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/component-styles-plugin.d.ts +52 -0
- package/src/lib/component-styles-plugin.js +353 -0
- package/src/lib/component-styles-plugin.js.map +1 -0
- package/src/lib/compose-angular-plugins.d.ts +12 -0
- package/src/lib/compose-angular-plugins.js +31 -0
- package/src/lib/compose-angular-plugins.js.map +1 -0
- package/src/lib/dev-server-mode-plugin.d.ts +7 -0
- package/src/lib/dev-server-mode-plugin.js +23 -0
- package/src/lib/dev-server-mode-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +3 -1
- package/src/lib/fast-compile-plugin.js +93 -49
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.js +3 -3
- package/src/lib/live-reload-plugin.d.ts +3 -1
- package/src/lib/live-reload-plugin.js +11 -5
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-plugin.d.ts +2 -1
- package/src/lib/ngp-compile-plugin.js +90 -24
- package/src/lib/ngp-compile-plugin.js.map +1 -1
- package/src/lib/ngtsc-compile-plugin.d.ts +23 -0
- package/src/lib/ngtsc-compile-plugin.js +762 -0
- package/src/lib/ngtsc-compile-plugin.js.map +1 -0
- package/src/lib/nx-folder-plugin.d.ts +6 -5
- package/src/lib/nx-folder-plugin.js +12 -7
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +6 -0
- package/src/lib/plugins/file-replacements.plugin.js +1 -0
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +5 -1
- package/src/lib/router-plugin.js +13 -4
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/utils/compilation-shared.js +1 -1
- package/src/lib/utils/devkit.js +1 -1
- package/src/lib/utils/lsp-type-checker.js +1 -1
- package/src/lib/utils/plugin-config.d.ts +6 -8
- package/src/lib/utils/plugin-config.js +8 -4
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.js +1 -1
- package/src/lib/virtual-modules-plugin.d.ts +11 -3
- package/src/lib/virtual-modules-plugin.js +43 -12
- package/src/lib/virtual-modules-plugin.js.map +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { type AngularBuildContext } from "./angular-build-context.js";
|
|
3
|
+
export interface BuildOptimizerPluginOptions {
|
|
4
|
+
jit?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function buildOptimizerPlugin(ctxOrOptions?: AngularBuildContext | BuildOptimizerPluginOptions): Plugin;
|
|
7
|
+
export declare function extractInlineSourceMap(code: string, _id: string): {
|
|
6
8
|
code: string;
|
|
7
9
|
map: string | null;
|
|
8
10
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { JavaScriptTransformer } from "./utils/devkit.js";
|
|
2
2
|
import { isProdMode, isServerEnvironment } from "./utils/plugin-config.js";
|
|
3
|
+
import { isAngularBuildContext } from "./angular-build-context.js";
|
|
3
4
|
//#region packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts
|
|
4
|
-
function buildOptimizerPlugin(
|
|
5
|
+
function buildOptimizerPlugin(ctxOrOptions) {
|
|
6
|
+
const jit = isAngularBuildContext(ctxOrOptions) ? ctxOrOptions.options.jit : ctxOrOptions?.jit ?? false;
|
|
5
7
|
const transformers = /* @__PURE__ */ new Map();
|
|
6
8
|
let isProd = false;
|
|
7
9
|
let isWatch = false;
|
|
@@ -71,7 +73,7 @@ function buildOptimizerPlugin({ jit }) {
|
|
|
71
73
|
}
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
|
-
function extractInlineSourceMap(code,
|
|
76
|
+
function extractInlineSourceMap(code, _id) {
|
|
75
77
|
const sourceMapMatch = code.match(/\n?\/\/# sourceMappingURL=data:application\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\s*$/);
|
|
76
78
|
if (!sourceMapMatch || sourceMapMatch.index === void 0) return {
|
|
77
79
|
code,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { isProdMode, isServerEnvironment } from './utils/plugin-config.js';\n\nexport function buildOptimizerPlugin(
|
|
1
|
+
{"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport {\n isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { isProdMode, isServerEnvironment } from './utils/plugin-config.js';\n\nexport interface BuildOptimizerPluginOptions {\n jit?: boolean;\n}\n\nexport function buildOptimizerPlugin(\n ctxOrOptions?: AngularBuildContext | BuildOptimizerPluginOptions,\n): Plugin {\n const jit = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions.options.jit\n : (ctxOrOptions?.jit ?? false);\n\n const transformers = new Map<\n string,\n InstanceType<typeof JavaScriptTransformer>\n >();\n let isProd = false;\n let isWatch = false;\n let preserveVendorMaps = false;\n\n function getTransformer(envName = 'default') {\n let transformer = transformers.get(envName);\n if (!transformer) {\n transformer = new JavaScriptTransformer(\n {\n sourcemap: preserveVendorMaps,\n thirdPartySourcemaps: preserveVendorMaps,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\n transformers.set(envName, transformer);\n }\n return transformer;\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n // Normally build-only. Astro's Cloudflare integration (`@astrojs/cloudflare`)\n // transforms SSR modules through a serve-style `workerd` runner *during*\n // `astro build`; an `apply: 'build'` plugin is excluded from that pipeline,\n // so the Angular linker never runs on the worker's partially-compiled\n // packages and they fall back to the JIT compiler. Also apply under a\n // production `NODE_ENV` (which `astro build` sets) so the linker runs in\n // that runner too. Regular Analog dev servers run with a development\n // `NODE_ENV`, so their behavior is unchanged.\n apply(_config, env) {\n return (\n env.command === 'build' || process.env['NODE_ENV'] === 'production'\n );\n },\n config(userConfig) {\n isProd = isProdMode(userConfig.mode);\n // Advanced optimizations paired with dev-mode defines would strip\n // dev-only code the debug API needs, so both key off `isProd`.\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n } as UserConfig;\n },\n // The top-level define keys `ngServerMode` off the legacy `build.ssr`\n // flag. Environment API builds run the server through a server\n // environment while `build.ssr` stays unset, so give that environment its\n // own value; otherwise the guard compiles to `false` and browser-only\n // hydration features run during SSR. Runs after other plugins' hooks, so\n // a consumer they set is taken into account.\n configEnvironment: {\n order: 'post',\n handler(name, config) {\n if (isProd && isServerEnvironment(name, config)) {\n return { define: { ngServerMode: 'true' } };\n }\n return undefined;\n },\n },\n configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\n isWatch = config.command === 'serve' || !!config.build?.watch;\n },\n transform: {\n filter: {\n // Allow an optional `?query` after the extension. Some environments\n // (e.g. Cloudflare's `workerd`, used by Astro's Cloudflare integration)\n // reference optimized deps with a `?v=<hash>` suffix, e.g.\n // `.../fesm2022/_platform_location-chunk.mjs?v=a786a9ff`. A `$`-anchored\n // extension match skips those, so the Angular linker never runs and the\n // partially-compiled package falls back to the JIT compiler at runtime.\n id: /\\.[cm]?js(?:\\?|$)/,\n },\n async handler(code, id) {\n // Strip the `?query` so the fesm check and the transformer see a real\n // filename rather than `foo.mjs?v=<hash>`.\n const cleanId = id.split('?')[0];\n const angularPackage = /fesm20/.test(cleanId);\n\n if (!angularPackage) {\n // `{ mappings: '' }` declares zero segments, dropping the module's own\n // map from the chain; `null` keeps it. Removing `sourceMappingURL` is\n // what makes that map unreachable, so it only runs when discarding.\n return {\n code:\n isProd && !preserveVendorMaps\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: preserveVendorMaps ? null : { mappings: '' },\n };\n }\n\n const sideEffects =\n jit && cleanId.includes('@angular/compiler') ? true : false;\n const envName = this.environment?.name ?? 'default';\n const transformer = getTransformer(envName);\n const result: Uint8Array = await transformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n const transformed = Buffer.from(result).toString();\n return preserveVendorMaps\n ? extractInlineSourceMap(transformed, cleanId)\n : { code: transformed, map: { mappings: '' } };\n },\n },\n async closeBundle() {\n if (isWatch) {\n return;\n }\n const envName = this.environment?.name ?? 'default';\n const transformer = transformers.get(envName);\n if (transformer) {\n transformers.delete(envName);\n await transformer.close();\n }\n },\n };\n}\n\nexport function extractInlineSourceMap(\n code: string,\n _id: string,\n): { code: string; map: string | null } {\n const sourceMapMatch = code.match(\n /\\n?\\/\\/# sourceMappingURL=data:application\\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\\s*$/,\n );\n if (!sourceMapMatch || sourceMapMatch.index === undefined) {\n return {\n code,\n map: null,\n };\n }\n return {\n code: code.slice(0, sourceMapMatch.index),\n map: Buffer.from(sourceMapMatch[1]!, 'base64').toString(),\n };\n}\n"],"mappings":";;;;AAYA,SAAgB,qBACd,cACQ;CACR,MAAM,MAAM,sBAAsB,YAAY,IAC1C,aAAa,QAAQ,MACpB,cAAc,OAAO;CAE1B,MAAM,+BAAe,IAAI,IAGvB;CACF,IAAI,SAAS;CACb,IAAI,UAAU;CACd,IAAI,qBAAqB;CAEzB,SAAS,eAAe,UAAU,WAAW;EAC3C,IAAI,cAAc,aAAa,IAAI,OAAO;EAC1C,IAAI,CAAC,aAAa;GAChB,cAAc,IAAI,sBAChB;IACE,WAAW;IACX,sBAAsB;IACtB,uBAAuB;IACvB,KAAK;GACP,GACA,CACF;GACA,aAAa,IAAI,SAAS,WAAW;EACvC;EACA,OAAO;CACT;CAEA,OAAO;EACL,MAAM;EASN,MAAM,SAAS,KAAK;GAClB,OACE,IAAI,YAAY,WAAA,QAAA,IAAA,aAAuC;EAE3D;EACA,OAAO,YAAY;GACjB,SAAS,WAAW,WAAW,IAAI;GAGnC,OAAO,EACL,QAAQ,SACJ;IACE,WAAW;IACX,mBAAmB;IACnB,WAAW;IACX,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;GACvC,IACA,CAAC,EACP;EACF;EAOA,mBAAmB;GACjB,OAAO;GACP,QAAQ,MAAM,QAAQ;IACpB,IAAI,UAAU,oBAAoB,MAAM,MAAM,GAC5C,OAAO,EAAE,QAAQ,EAAE,cAAc,OAAO,EAAE;GAG9C;EACF;EACA,eAAe,QAAQ;GACrB,qBAAqB,CAAC,CAAC,OAAO,MAAM;GACpC,UAAU,OAAO,YAAY,WAAW,CAAC,CAAC,OAAO,OAAO;EAC1D;EACA,WAAW;GACT,QAAQ,EAON,IAAI,oBACN;GACA,MAAM,QAAQ,MAAM,IAAI;IAGtB,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC;IAG9B,IAAI,CAFmB,SAAS,KAAK,OAEhC,GAIH,OAAO;KACL,MACE,UAAU,CAAC,qBACP,KAAK,QAAQ,sCAAsC,EAAE,IACrD;KACN,KAAK,qBAAqB,OAAO,EAAE,UAAU,GAAG;IAClD;IAGF,MAAM,cACJ,OAAO,QAAQ,SAAS,mBAAmB,IAAI,OAAO;IAGxD,MAAM,SAAqB,MADP,eADJ,KAAK,aAAa,QAAQ,SAET,CAAA,CAAY,cAC3C,SACA,MACA,OACA,WACF;IAEA,MAAM,cAAc,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS;IACjD,OAAO,qBACH,uBAAuB,aAAa,OAAO,IAC3C;KAAE,MAAM;KAAa,KAAK,EAAE,UAAU,GAAG;IAAE;GACjD;EACF;EACA,MAAM,cAAc;GAClB,IAAI,SACF;GAEF,MAAM,UAAU,KAAK,aAAa,QAAQ;GAC1C,MAAM,cAAc,aAAa,IAAI,OAAO;GAC5C,IAAI,aAAa;IACf,aAAa,OAAO,OAAO;IAC3B,MAAM,YAAY,MAAM;GAC1B;EACF;CACF;AACF;AAEA,SAAgB,uBACd,MACA,KACsC;CACtC,MAAM,iBAAiB,KAAK,MAC1B,mGACF;CACA,IAAI,CAAC,kBAAkB,eAAe,UAAU,KAAA,GAC9C,OAAO;EACL;EACA,KAAK;CACP;CAEF,OAAO;EACL,MAAM,KAAK,MAAM,GAAG,eAAe,KAAK;EACxC,KAAK,OAAO,KAAK,eAAe,IAAK,QAAQ,CAAC,CAAC,SAAS;CAC1D;AACF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { type AngularBuildContext } from "./angular-build-context.js";
|
|
3
|
+
export interface JitPluginOptions {
|
|
4
|
+
inlineStylesExtension?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function jitPlugin(ctxOrOptions?: AngularBuildContext | JitPluginOptions): Plugin;
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { debugStyles } from "./utils/debug.js";
|
|
2
|
-
import { preprocessStylesheet } from "./stylesheet-registry.js";
|
|
3
2
|
import { discoverAnalogIntegrations } from "./analog-plugin-interop.js";
|
|
4
|
-
import {
|
|
3
|
+
import { preprocessStylesheet } from "./stylesheet-registry.js";
|
|
4
|
+
import { isAngularBuildContext } from "./angular-build-context.js";
|
|
5
5
|
import { releaseCssPreprocessorWorkers } from "./utils/css-preprocessor-workers.js";
|
|
6
|
+
import { getJitInlineStyles, hashJitInlineStyles } from "./utils/jit-inline-styles.js";
|
|
6
7
|
import { preprocessCSS } from "vite";
|
|
7
8
|
//#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
|
|
8
|
-
function jitPlugin(
|
|
9
|
+
function jitPlugin(ctxOrOptions) {
|
|
10
|
+
const sharedCtx = isAngularBuildContext(ctxOrOptions) ? ctxOrOptions : void 0;
|
|
11
|
+
const inlineStylesExtension = isAngularBuildContext(ctxOrOptions) ? ctxOrOptions.options.inlineStylesExtension : ctxOrOptions?.inlineStylesExtension ?? "css";
|
|
9
12
|
let config;
|
|
10
13
|
let stylePreprocessor;
|
|
11
14
|
return {
|
|
12
15
|
name: "@analogjs/vite-plugin-angular-jit",
|
|
13
16
|
configResolved(_config) {
|
|
14
17
|
config = _config;
|
|
18
|
+
sharedCtx?.setResolvedConfig(_config);
|
|
15
19
|
},
|
|
16
20
|
async buildStart() {
|
|
17
|
-
|
|
21
|
+
if (sharedCtx) {
|
|
22
|
+
await sharedCtx.refreshIntegrations(config);
|
|
23
|
+
stylePreprocessor = sharedCtx.stylePreprocessor;
|
|
24
|
+
} else stylePreprocessor = (await discoverAnalogIntegrations(config)).stylePreprocessor;
|
|
18
25
|
},
|
|
19
26
|
resolveId(id) {
|
|
20
27
|
if (id.startsWith("virtual:angular")) return `\0${id}`;
|
|
@@ -25,13 +32,14 @@ function jitPlugin({ inlineStylesExtension }) {
|
|
|
25
32
|
const styleIdHash = hashJitInlineStyles(encodedStyles);
|
|
26
33
|
const decodedStyles = Buffer.from(decodeURIComponent(encodedStyles), "base64").toString();
|
|
27
34
|
const filename = `${styleIdHash}.${inlineStylesExtension}`;
|
|
28
|
-
const
|
|
35
|
+
const activePreprocessor = stylePreprocessor ?? sharedCtx?.stylePreprocessor;
|
|
36
|
+
const preprocessed = preprocessStylesheet(decodedStyles, filename, activePreprocessor, {
|
|
29
37
|
filename,
|
|
30
38
|
inline: true
|
|
31
39
|
});
|
|
32
40
|
let styles = "";
|
|
33
41
|
try {
|
|
34
|
-
styles = (await preprocessCSS(preprocessed, `${filename}?direct`, config))?.code;
|
|
42
|
+
styles = (await preprocessCSS(preprocessed, `${filename}?direct`, config ?? sharedCtx?.resolvedConfig))?.code;
|
|
35
43
|
} catch (e) {
|
|
36
44
|
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
37
45
|
debugStyles("jit css compilation error", {
|
|
@@ -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
|
|
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 isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { discoverAnalogIntegrations } from './analog-plugin-interop.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { debugStyles } from './utils/debug.js';\nimport {\n JIT_INLINE_STYLE_PREFIX,\n getJitInlineStyles,\n hashJitInlineStyles,\n} from './utils/jit-inline-styles.js';\n\nexport interface JitPluginOptions {\n inlineStylesExtension?: string;\n}\n\nexport function jitPlugin(\n ctxOrOptions?: AngularBuildContext | JitPluginOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions\n : undefined;\n const inlineStylesExtension = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions.options.inlineStylesExtension\n : (ctxOrOptions?.inlineStylesExtension ?? 'css');\n\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 sharedCtx?.setResolvedConfig(_config);\n },\n async buildStart() {\n if (sharedCtx) {\n await sharedCtx.refreshIntegrations(config);\n stylePreprocessor = sharedCtx.stylePreprocessor;\n } else {\n stylePreprocessor = (await discoverAnalogIntegrations(config))\n .stylePreprocessor;\n }\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 encodedStyles = getJitInlineStyles(id.split('style:inline;')[1]);\n const styleIdHash = hashJitInlineStyles(encodedStyles);\n const decodedStyles = Buffer.from(\n decodeURIComponent(encodedStyles),\n 'base64',\n ).toString();\n const filename = `${styleIdHash}.${inlineStylesExtension}`;\n const activePreprocessor =\n stylePreprocessor ?? sharedCtx?.stylePreprocessor;\n const preprocessed = preprocessStylesheet(\n decodedStyles,\n filename,\n activePreprocessor,\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 ?? sharedCtx?.resolvedConfig!,\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 closeBundle() {\n if (!this.meta?.watchMode) {\n releaseCssPreprocessorWorkers();\n }\n },\n };\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgB,UACd,cACQ;CACR,MAAM,YAAY,sBAAsB,YAAY,IAChD,eACA,KAAA;CACJ,MAAM,wBAAwB,sBAAsB,YAAY,IAC5D,aAAa,QAAQ,wBACpB,cAAc,yBAAyB;CAE5C,IAAI;CACJ,IAAI;CAEJ,OAAO;EACL,MAAM;EACN,eAAe,SAAS;GACtB,SAAS;GACT,WAAW,kBAAkB,OAAO;EACtC;EACA,MAAM,aAAa;GACjB,IAAI,WAAW;IACb,MAAM,UAAU,oBAAoB,MAAM;IAC1C,oBAAoB,UAAU;GAChC,OACE,qBAAqB,MAAM,2BAA2B,MAAM,EAAA,CACzD;EAEP;EACA,UAAU,IAAY;GACpB,IAAI,GAAG,WAAW,iBAAiB,GACjC,OAAO,KAAK;EAIhB;EACA,MAAM,KAAK,IAAY;GACrB,IAAI,GAAG,SAAA,mCAAgC,GAAG;IACxC,MAAM,gBAAgB,mBAAmB,GAAG,MAAM,eAAe,CAAC,CAAC,EAAE;IACrE,MAAM,cAAc,oBAAoB,aAAa;IACrD,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,aAAa,GAChC,QACF,CAAC,CAAC,SAAS;IACX,MAAM,WAAW,GAAG,YAAY,GAAG;IACnC,MAAM,qBACJ,qBAAqB,WAAW;IAClC,MAAM,eAAe,qBACnB,eACA,UACA,oBACA;KAAE;KAAU,QAAQ;IAAK,CAC3B;IAEA,IAAI,SAA6B;IAEjC,IAAI;KAMF,UAAS,MALc,cACrB,cACA,GAAG,SAAS,UACZ,UAAU,WAAW,cACvB,EAAA,EACmB;IACrB,SAAS,GAAG;KACV,MAAM,eAAe,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;KAC9D,YAAY,6BAA6B;MACvC;MACA,OAAO;KACT,CAAC;KACD,QAAQ,KACN,6HACA,aACA,YACF;IACF;IAEA,OAAO,oBAAoB,OAAO;GACpC;EAGF;EACA,cAAc;GACZ,IAAI,CAAC,KAAK,MAAM,WACd,8BAA8B;EAElC;CACF;AACF"}
|
|
@@ -1,125 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { DiagnosticModes, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, toAngularCompilationFileReplacements, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, describeStylesheetContent, isTestWatchMode, getBrowserModeCliOverride } from "./utils/compilation-shared.js";
|
|
8
|
-
import type { TypeCheckerOption } from "./utils/lsp-type-checker.js";
|
|
9
|
-
export interface PluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Path to the tsconfig used for compilation, or a function returning it.
|
|
12
|
-
* Defaults to `tsconfig.app.json` (`tsconfig.lib.json` for libraries,
|
|
13
|
-
* `tsconfig.spec.json` in tests).
|
|
14
|
-
*/
|
|
15
|
-
tsconfig?: string | (() => string);
|
|
16
|
-
/**
|
|
17
|
-
* Absolute path to the workspace root. Defaults to `NX_WORKSPACE_ROOT`,
|
|
18
|
-
* then `process.cwd()`.
|
|
19
|
-
*/
|
|
20
|
-
workspaceRoot?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Stylesheet extension used for inline component `styles`. Defaults to `css`.
|
|
23
|
-
*/
|
|
24
|
-
inlineStylesExtension?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Compile components in JIT mode. Defaults to `true` in tests and `false`
|
|
27
|
-
* otherwise.
|
|
28
|
-
*/
|
|
29
|
-
jit?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Additional files to include in compilation, as globs relative to the
|
|
32
|
-
* workspace root.
|
|
33
|
-
*/
|
|
34
|
-
include?: string[];
|
|
35
|
-
/**
|
|
36
|
-
* Enables Analog's Angular live-reload/HMR pipeline during development/watch mode.
|
|
37
|
-
*
|
|
38
|
-
* This is separate from Vite's `server.hmr` option, which configures the
|
|
39
|
-
* HMR client transport.
|
|
40
|
-
*
|
|
41
|
-
* Defaults to `true` for watch mode, or `false` with `compilation: 'ngp'`,
|
|
42
|
-
* which reloads the page on every change unless this is `true`. Set to
|
|
43
|
-
* `false` to disable Angular reload updates while keeping other stylesheet
|
|
44
|
-
* externalization behavior available when needed.
|
|
45
|
-
*/
|
|
46
|
-
liveReload?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Skip semantic and Angular template diagnostics during compilation.
|
|
49
|
-
* Defaults to `true`, or `false` with `compilation: 'ngp'`, which requires
|
|
50
|
-
* a TypeScript 7 type checker (see `typeChecker`).
|
|
51
|
-
*/
|
|
52
|
-
disableTypeChecking?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* TypeScript 7 type checker used with `compilation: 'ngp'`: `'tsgo'`
|
|
55
|
-
* (default), `'tsrs'`, or a command serving the TypeScript 7 language
|
|
56
|
-
* server over stdio (`args` defaults to `['--lsp', '--stdio']`).
|
|
57
|
-
*/
|
|
58
|
-
typeChecker?: TypeCheckerOption;
|
|
59
|
-
/**
|
|
60
|
-
* Replace source files at build time, like `fileReplacements` in
|
|
61
|
-
* `angular.json`.
|
|
62
|
-
*/
|
|
63
|
-
fileReplacements?: FileReplacement[];
|
|
64
|
-
/**
|
|
65
|
-
* Opt into the fast compile path. Skips Angular's template type-checking
|
|
66
|
-
* and routes compilation through an internal single-pass transform when
|
|
67
|
-
* `compilation` is not specified.
|
|
68
|
-
* Defaults to `false`.
|
|
69
|
-
*/
|
|
70
|
-
fastCompile?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Selects the compilation path, overriding fastCompile. Defaults to 'ngtsc';
|
|
73
|
-
* 'ngp' is experimental and falls back to 'ngtsc' under Vitest's JIT default.
|
|
74
|
-
*/
|
|
75
|
-
compilation?: "ngtsc" | "ngp";
|
|
76
|
-
/**
|
|
77
|
-
* Compilation output mode used when `fastCompile` is enabled.
|
|
78
|
-
* - `'full'` (default): Emit final Ivy definitions for application builds.
|
|
79
|
-
* - `'partial'`: Emit partial declarations for library publishing.
|
|
80
|
-
*/
|
|
81
|
-
fastCompileMode?: "full" | "partial";
|
|
82
|
-
/**
|
|
83
|
-
* Enable debug logging for specific scopes.
|
|
84
|
-
*
|
|
85
|
-
* - `true` → enables all `analog:angular:*` scopes
|
|
86
|
-
* - `string[]` → enables listed namespaces (e.g. `['analog:angular:hmr']`)
|
|
87
|
-
* - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`
|
|
88
|
-
* to restrict output to a specific Vite command (omit for both)
|
|
89
|
-
*
|
|
90
|
-
* Also responds to the `DEBUG` env var (Node.js) or `localStorage.debug`
|
|
91
|
-
* (browser), using the `obug` convention.
|
|
92
|
-
*/
|
|
93
|
-
debug?: DebugOption;
|
|
94
|
-
}
|
|
95
|
-
export declare function evictDeletedFileMetadata(file: string, { classNamesMap, fileTransformMap }: {
|
|
96
|
-
classNamesMap: Map<string, string>;
|
|
97
|
-
fileTransformMap: Map<string, string>;
|
|
98
|
-
}): void;
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import { type PluginOptions } from "./angular-build-context.js";
|
|
3
|
+
export type { PluginOptions } from "./angular-build-context.js";
|
|
4
|
+
export { createFsWatcherCacheInvalidator, evictDeletedFileMetadata, getFileMetadata, type FileMetadataResult } from "./ngtsc-compile-plugin.js";
|
|
5
|
+
export { diagnoseComponentStylesheetPipeline, findComponentStylesheetWrapperModules, findTemplateOwnerModules, getModulesForChangedFile, handleDirectComponentStyleHmr, isModuleForChangedResource, markModuleSelfAccepting, type ComponentStylesheetPipelineDiagnosis } from "./component-styles-plugin.js";
|
|
6
|
+
export { DiagnosticModes, describeStylesheetContent, getBrowserModeCliOverride, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, isTestWatchMode, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, toAngularCompilationFileReplacements } from "./utils/compilation-shared.js";
|
|
99
7
|
export declare function angular(options?: PluginOptions): Plugin[];
|
|
100
|
-
export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* Returns every live Vite module that can legitimately represent a changed
|
|
103
|
-
* Angular resource file.
|
|
104
|
-
*
|
|
105
|
-
* For normal files, `getModulesByFile()` is enough. For Angular component
|
|
106
|
-
* stylesheets, it is not: the browser often holds virtual hashed requests
|
|
107
|
-
* (`/abc123.css?direct&ngcomp=...` and `/abc123.css?ngcomp=...`) that are no
|
|
108
|
-
* longer discoverable from the original source path alone. We therefore merge:
|
|
109
|
-
* - watcher event modules
|
|
110
|
-
* - module-graph modules by source file
|
|
111
|
-
* - registry-tracked live request ids resolved back through the module graph
|
|
112
|
-
*/
|
|
113
|
-
export declare function getModulesForChangedFile(server: ViteDevServer, file: string, eventModules?: readonly ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
|
|
114
|
-
export declare function isModuleForChangedResource(mod: ModuleNode, changedFile: string, stylesheetRegistry?: AnalogStylesheetRegistry): boolean;
|
|
115
|
-
export declare function findComponentStylesheetWrapperModules(server: ViteDevServer, changedFile: string, directModule: ModuleNode, fileModules: ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
|
|
116
|
-
export declare function findTemplateOwnerModules(server: ViteDevServer, resourceFile: string): ModuleNode[];
|
|
117
|
-
/**
|
|
118
|
-
* @internal
|
|
119
|
-
*/
|
|
120
|
-
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean): (file: string) => {
|
|
121
|
-
errors?: string[];
|
|
122
|
-
warnings?: (string | ts.DiagnosticMessageChain)[];
|
|
123
|
-
hmrUpdateCode?: string | null;
|
|
124
|
-
hmrEligible?: boolean;
|
|
125
|
-
};
|