@analogjs/vite-plugin-angular 3.0.0-alpha.64 → 3.0.0-alpha.66
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/angular-build-optimizer-plugin.js +23 -14
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.js +5 -4
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.js +51 -6
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.js +1 -1
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.js +2 -2
- package/src/lib/compiler/compile.js +1 -1
- package/src/lib/compiler/js-emitter.js +5 -4
- package/src/lib/compiler/js-emitter.js.map +1 -1
- package/src/lib/fast-compile-plugin.js +3 -3
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/template-class-binding-guard-plugin.js +1 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +3 -1
- 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 +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- 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 +8 -1
- package/src/lib/utils/plugin-config.js +17 -3
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/transform-cache.js +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
//#region packages/vite-plugin-angular/src/lib/utils/jit-inline-styles.ts
|
|
3
|
+
var JIT_INLINE_STYLE_PREFIX = "virtual:angular:jit:style:inline;";
|
|
4
|
+
var inlineStyles = /* @__PURE__ */ new Map();
|
|
5
|
+
function toJitInlineStyleId(encodedStyles) {
|
|
6
|
+
const hash = createHash("sha256").update(encodedStyles).digest("hex").slice(0, 16);
|
|
7
|
+
inlineStyles.set(hash, encodedStyles);
|
|
8
|
+
return `${JIT_INLINE_STYLE_PREFIX}${hash}`;
|
|
9
|
+
}
|
|
10
|
+
function getJitInlineStyles(hash) {
|
|
11
|
+
return inlineStyles.get(hash);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JIT_INLINE_STYLE_PREFIX, getJitInlineStyles, toJitInlineStyleId };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=jit-inline-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jit-inline-styles.js","names":[],"sources":["../../../../src/lib/utils/jit-inline-styles.ts"],"sourcesContent":["// Angular's JIT resource transformer emits inline component styles as\n// `angular:jit:style:inline;<base64 of the whole stylesheet>`. Keeping that\n// payload in the module id makes the emitted chunk name grow with the\n// stylesheet, so a large inline style blows past the 255-byte filename\n// limit and the build fails with ENAMETOOLONG. Hash the payload into the\n// id and keep the base64 in a lookup table instead. (#2459)\n\nimport { createHash } from 'node:crypto';\n\nexport const JIT_INLINE_STYLE_PREFIX = 'virtual:angular:jit:style:inline;';\n\nconst inlineStyles = new Map<string, string>();\n\nexport function toJitInlineStyleId(encodedStyles: string): string {\n const hash = createHash('sha256')\n .update(encodedStyles)\n .digest('hex')\n .slice(0, 16);\n inlineStyles.set(hash, encodedStyles);\n return `${JIT_INLINE_STYLE_PREFIX}${hash}`;\n}\n\nexport function getJitInlineStyles(hash: string): string | undefined {\n return inlineStyles.get(hash);\n}\n"],"mappings":";;AASA,IAAa,0BAA0B;AAEvC,IAAM,+BAAe,IAAI,KAAqB;AAE9C,SAAgB,mBAAmB,eAA+B;CAChE,MAAM,OAAO,WAAW,SAAS,CAC9B,OAAO,cAAc,CACrB,OAAO,MAAM,CACb,MAAM,GAAG,GAAG;AACf,cAAa,IAAI,MAAM,cAAc;AACrC,QAAO,GAAG,0BAA0B;;AAGtC,SAAgB,mBAAmB,MAAkC;AACnE,QAAO,aAAa,IAAI,KAAK"}
|
|
@@ -11,12 +11,19 @@
|
|
|
11
11
|
* and similar extensions matched by accident.
|
|
12
12
|
*/
|
|
13
13
|
export declare const TS_EXT_REGEX: unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves whether Angular should be compiled for production. An explicit
|
|
16
|
+
* `development` mode wins over an ambient production `NODE_ENV` (e.g. set by
|
|
17
|
+
* `storybook build` at CLI entry), so a build can opt into Angular's
|
|
18
|
+
* development compilation. See #2458 and #2462.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isProdMode(mode: string | undefined): boolean;
|
|
14
21
|
export interface TsConfigResolutionContext {
|
|
15
22
|
root: string;
|
|
16
23
|
isProd: boolean;
|
|
17
24
|
isLib: boolean;
|
|
18
25
|
}
|
|
19
|
-
export declare function getTsConfigPath(root: string, tsconfig: string, isProd: boolean, isTest: boolean, isLib: boolean);
|
|
26
|
+
export declare function getTsConfigPath(root: string, tsconfig: string, isProd: boolean, isTest: boolean, isLib: boolean, workspaceRoot?: string);
|
|
20
27
|
export declare function createTsConfigGetter(tsconfigOrGetter?: string | (() => string));
|
|
21
28
|
export interface DepOptimizerOptions {
|
|
22
29
|
tsconfig: string;
|
|
@@ -17,7 +17,17 @@ import * as vite from "vite";
|
|
|
17
17
|
* and similar extensions matched by accident.
|
|
18
18
|
*/
|
|
19
19
|
var TS_EXT_REGEX = /\.[cm]?ts(?![a-z])/;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Resolves whether Angular should be compiled for production. An explicit
|
|
22
|
+
* `development` mode wins over an ambient production `NODE_ENV` (e.g. set by
|
|
23
|
+
* `storybook build` at CLI entry), so a build can opt into Angular's
|
|
24
|
+
* development compilation. See #2458 and #2462.
|
|
25
|
+
*/
|
|
26
|
+
function isProdMode(mode) {
|
|
27
|
+
if (mode === "development") return false;
|
|
28
|
+
return mode === "production" || process.env.NODE_ENV === "production";
|
|
29
|
+
}
|
|
30
|
+
function getTsConfigPath(root, tsconfig, isProd, isTest, isLib, workspaceRoot) {
|
|
21
31
|
if (tsconfig && isAbsolute(tsconfig)) {
|
|
22
32
|
if (!existsSync(tsconfig)) console.error(`[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the "tsconfig" property with an absolute path.`);
|
|
23
33
|
return tsconfig;
|
|
@@ -27,7 +37,11 @@ function getTsConfigPath(root, tsconfig, isProd, isTest, isLib) {
|
|
|
27
37
|
if (isTest) tsconfigFilePath = "./tsconfig.spec.json";
|
|
28
38
|
if (tsconfig) tsconfigFilePath = tsconfig;
|
|
29
39
|
const resolvedPath = resolve(root, tsconfigFilePath);
|
|
30
|
-
if (
|
|
40
|
+
if (existsSync(resolvedPath)) return resolvedPath;
|
|
41
|
+
const workspacePath = workspaceRoot ? resolve(workspaceRoot, tsconfigFilePath) : void 0;
|
|
42
|
+
if (workspacePath && existsSync(workspacePath)) return workspacePath;
|
|
43
|
+
const attemptedPaths = workspacePath && workspacePath !== resolvedPath ? `${resolvedPath} or ${workspacePath}` : resolvedPath;
|
|
44
|
+
console.error(`[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${attemptedPaths}. This causes compilation issues. Check the path or set the "tsconfig" property with an absolute path.`);
|
|
31
45
|
return resolvedPath;
|
|
32
46
|
}
|
|
33
47
|
function createTsConfigGetter(tsconfigOrGetter) {
|
|
@@ -66,6 +80,6 @@ function createDepOptimizerConfig(opts) {
|
|
|
66
80
|
} };
|
|
67
81
|
}
|
|
68
82
|
//#endregion
|
|
69
|
-
export { TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath };
|
|
83
|
+
export { TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath, isProdMode };
|
|
70
84
|
|
|
71
85
|
//# sourceMappingURL=plugin-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-config.js","names":[],"sources":["../../../../src/lib/utils/plugin-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport * as vite from 'vite';\n\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n createPersistentTransformCache,\n resolveTransformCacheDir,\n} from './transform-cache.js';\n\n/**\n * TypeScript file extension regex\n * Match .ts / .cts / .mts extensions with an optional ?query suffix.\n * Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via\n * a negative-lookahead on a following ASCII letter, so only genuine TS\n * files pass.\n *\n * Previous form `/\\.[cm]?(ts)[^x]?\\??/` was intended to exclude `.tsx`\n * specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows\n * zero characters, and any non-`x` letter was admitted — so `.tsrx`\n * and similar extensions matched by accident.\n */\nexport const TS_EXT_REGEX = /\\.[cm]?ts(?![a-z])/;\n\nexport interface TsConfigResolutionContext {\n root: string;\n isProd: boolean;\n isLib: boolean;\n}\n\nexport function getTsConfigPath(\n root: string,\n tsconfig: string,\n isProd: boolean,\n isTest: boolean,\n isLib: boolean,\n) {\n if (tsconfig && isAbsolute(tsconfig)) {\n if (!existsSync(tsconfig)) {\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n }\n\n return tsconfig;\n }\n\n let tsconfigFilePath = './tsconfig.app.json';\n\n if (isLib) {\n tsconfigFilePath = isProd\n ? './tsconfig.lib.prod.json'\n : './tsconfig.lib.json';\n }\n\n if (isTest) {\n tsconfigFilePath = './tsconfig.spec.json';\n }\n\n if (tsconfig) {\n tsconfigFilePath = tsconfig;\n }\n\n const resolvedPath = resolve(root, tsconfigFilePath);\n\n if (
|
|
1
|
+
{"version":3,"file":"plugin-config.js","names":[],"sources":["../../../../src/lib/utils/plugin-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport * as vite from 'vite';\n\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n createPersistentTransformCache,\n resolveTransformCacheDir,\n} from './transform-cache.js';\n\n/**\n * TypeScript file extension regex\n * Match .ts / .cts / .mts extensions with an optional ?query suffix.\n * Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via\n * a negative-lookahead on a following ASCII letter, so only genuine TS\n * files pass.\n *\n * Previous form `/\\.[cm]?(ts)[^x]?\\??/` was intended to exclude `.tsx`\n * specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows\n * zero characters, and any non-`x` letter was admitted — so `.tsrx`\n * and similar extensions matched by accident.\n */\nexport const TS_EXT_REGEX = /\\.[cm]?ts(?![a-z])/;\n\n/**\n * Resolves whether Angular should be compiled for production. An explicit\n * `development` mode wins over an ambient production `NODE_ENV` (e.g. set by\n * `storybook build` at CLI entry), so a build can opt into Angular's\n * development compilation. See #2458 and #2462.\n */\nexport function isProdMode(mode: string | undefined): boolean {\n if (mode === 'development') {\n return false;\n }\n\n return mode === 'production' || process.env['NODE_ENV'] === 'production';\n}\n\nexport interface TsConfigResolutionContext {\n root: string;\n isProd: boolean;\n isLib: boolean;\n}\n\nexport function getTsConfigPath(\n root: string,\n tsconfig: string,\n isProd: boolean,\n isTest: boolean,\n isLib: boolean,\n workspaceRoot?: string,\n) {\n if (tsconfig && isAbsolute(tsconfig)) {\n if (!existsSync(tsconfig)) {\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n }\n\n return tsconfig;\n }\n\n let tsconfigFilePath = './tsconfig.app.json';\n\n if (isLib) {\n tsconfigFilePath = isProd\n ? './tsconfig.lib.prod.json'\n : './tsconfig.lib.json';\n }\n\n if (isTest) {\n tsconfigFilePath = './tsconfig.spec.json';\n }\n\n if (tsconfig) {\n tsconfigFilePath = tsconfig;\n }\n\n const resolvedPath = resolve(root, tsconfigFilePath);\n\n if (existsSync(resolvedPath)) {\n return resolvedPath;\n }\n\n // Callers such as Storybook's Angular builder document their `tsConfig` as\n // workspace-relative while setting the Vite root to the project directory,\n // so the path joins onto the project root twice. Fall back to the workspace\n // root before failing.\n const workspacePath = workspaceRoot\n ? resolve(workspaceRoot, tsconfigFilePath)\n : undefined;\n\n if (workspacePath && existsSync(workspacePath)) {\n return workspacePath;\n }\n\n const attemptedPaths =\n workspacePath && workspacePath !== resolvedPath\n ? `${resolvedPath} or ${workspacePath}`\n : resolvedPath;\n\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${attemptedPaths}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n\n return resolvedPath;\n}\n\nexport function createTsConfigGetter(\n tsconfigOrGetter?: string | (() => string),\n) {\n if (typeof tsconfigOrGetter === 'function') {\n return tsconfigOrGetter;\n }\n\n return () => tsconfigOrGetter || '';\n}\n\nexport interface DepOptimizerOptions {\n tsconfig: string;\n isProd: boolean;\n jit: boolean;\n watchMode: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n}\n\nexport function createDepOptimizerConfig(opts: DepOptimizerOptions) {\n const defineOptions = {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ...(opts.watchMode ? {} : { ngDevMode: 'false' }),\n };\n\n // Persist linked dependency output across dep-optimizer runs. The\n // transformer's own key covers file bytes + options, and the directory\n // is namespaced by Angular version, so entries never go stale.\n const transformCacheDir = resolveTransformCacheDir(dirname(opts.tsconfig));\n const transformCache = transformCacheDir\n ? createPersistentTransformCache(transformCacheDir)\n : undefined;\n\n const rolldownOptions: vite.DepOptimizationOptions['rolldownOptions'] = {\n plugins: [\n createRolldownCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n };\n\n const esbuildOptions: vite.DepOptimizationOptions['esbuildOptions'] = {\n plugins: [\n createCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n define: defineOptions,\n };\n\n // No top-level `resolve` block: the `style` package-export condition\n // is now scoped to `.css`-extension requests via\n // `cssExtensionStyleResolverPlugin`, so this dep optimizer config no\n // longer needs to leak it into Vite's global `resolve.conditions`.\n return {\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs'],\n exclude: ['@angular/platform-server'],\n ...(vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }),\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,IAAa,eAAe;;;;;;;AAQ5B,SAAgB,WAAW,MAAmC;AAC5D,KAAI,SAAS,cACX,QAAO;AAGT,QAAO,SAAS,gBAAA,QAAA,IAAA,aAA4C;;AAS9D,SAAgB,gBACd,MACA,UACA,QACA,QACA,OACA,eACA;AACA,KAAI,YAAY,WAAW,SAAS,EAAE;AACpC,MAAI,CAAC,WAAW,SAAS,CACvB,SAAQ,MACN,kEAAkE,SAAS,wGAC5E;AAGH,SAAO;;CAGT,IAAI,mBAAmB;AAEvB,KAAI,MACF,oBAAmB,SACf,6BACA;AAGN,KAAI,OACF,oBAAmB;AAGrB,KAAI,SACF,oBAAmB;CAGrB,MAAM,eAAe,QAAQ,MAAM,iBAAiB;AAEpD,KAAI,WAAW,aAAa,CAC1B,QAAO;CAOT,MAAM,gBAAgB,gBAClB,QAAQ,eAAe,iBAAiB,GACxC,KAAA;AAEJ,KAAI,iBAAiB,WAAW,cAAc,CAC5C,QAAO;CAGT,MAAM,iBACJ,iBAAiB,kBAAkB,eAC/B,GAAG,aAAa,MAAM,kBACtB;AAEN,SAAQ,MACN,kEAAkE,eAAe,wGAClF;AAED,QAAO;;AAGT,SAAgB,qBACd,kBACA;AACA,KAAI,OAAO,qBAAqB,WAC9B,QAAO;AAGT,cAAa,oBAAoB;;AAYnC,SAAgB,yBAAyB,MAA2B;CAClE,MAAM,gBAAgB;EACpB,WAAW;EACX,mBAAmB;EACnB,GAAI,KAAK,YAAY,EAAE,GAAG,EAAE,WAAW,SAAS;EACjD;CAKD,MAAM,oBAAoB,yBAAyB,QAAQ,KAAK,SAAS,CAAC;CAC1E,MAAM,iBAAiB,oBACnB,+BAA+B,kBAAkB,GACjD,KAAA;CAEJ,MAAM,kBAAkE,EACtE,SAAS,CACP,6BACE;EACE,UAAU,KAAK;EACf,WAAW,CAAC,KAAK;EACjB,uBAAuB,KAAK;EAC5B,KAAK,KAAK;EACV,aAAa,KAAK;EACnB,EACD,KAAK,QACL,CAAC,KAAK,oBACN,eACD,CACF,EACF;CAED,MAAM,iBAAgE;EACpE,SAAS,CACP,qBACE;GACE,UAAU,KAAK;GACf,WAAW,CAAC,KAAK;GACjB,uBAAuB,KAAK;GAC5B,KAAK,KAAK;GACV,aAAa,KAAK;GACnB,EACD,KAAK,QACL,CAAC,KAAK,oBACN,eACD,CACF;EACD,QAAQ;EACT;AAMD,QAAO,EACL,cAAc;EACZ,SAAS,CAAC,kBAAkB,OAAO;EACnC,SAAS,CAAC,2BAA2B;EACrC,GAAI,KAAK,kBAAkB,EAAE,iBAAiB,GAAG,EAAE,gBAAgB;EACpE,EACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path$1 from "node:path";
|
|
3
3
|
import * as crypto from "node:crypto";
|
|
4
|
-
import { createDebug } from "obug";
|
|
5
4
|
import { VERSION } from "@angular/compiler";
|
|
5
|
+
import { createDebug } from "obug";
|
|
6
6
|
//#region packages/vite-plugin-angular/src/lib/utils/transform-cache.ts
|
|
7
7
|
var debugCache = createDebug("analog-transform-cache");
|
|
8
8
|
/**
|