@analogjs/vite-plugin-angular 3.0.0-alpha.3 → 3.0.0-alpha.31
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/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 +27 -13
- package/src/index.d.ts +3 -2
- package/src/index.js +6 -2
- package/src/index.js.map +1 -1
- package/src/lib/analog-compiler-plugin.d.ts +14 -0
- package/src/lib/analog-compiler-plugin.js +257 -0
- package/src/lib/analog-compiler-plugin.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
- package/src/lib/angular-build-optimizer-plugin.js +48 -62
- 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 +37 -37
- 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 +17 -18
- package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +231 -40
- package/src/lib/angular-vite-plugin.js +1948 -964
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +19 -15
- package/src/lib/angular-vitest-plugin.js +99 -114
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compiler-plugin.d.ts +11 -11
- package/src/lib/compiler-plugin.js +43 -44
- package/src/lib/compiler-plugin.js.map +1 -1
- package/src/lib/component-resolvers.d.ts +23 -5
- package/src/lib/component-resolvers.js +153 -63
- package/src/lib/component-resolvers.js.map +1 -1
- package/src/lib/host.d.ts +10 -8
- package/src/lib/host.js +109 -101
- 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 +57 -62
- 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 +18 -16
- 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 +40 -62
- 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 +23 -23
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-pipeline.d.ts +15 -0
- package/src/lib/style-pipeline.js +31 -0
- package/src/lib/style-pipeline.js.map +1 -0
- 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 +73 -0
- package/src/lib/stylesheet-registry.js +168 -0
- package/src/lib/stylesheet-registry.js.map +1 -0
- package/src/lib/tools/package.json +2 -7
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +31 -38
- 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 +51 -62
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/tools/src/index.js +0 -2
- package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
- 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 +6 -6
- package/src/lib/utils/devkit.js +34 -38
- package/src/lib/utils/devkit.js.map +1 -1
- package/src/lib/utils/hmr-candidates.d.ts +28 -28
- package/src/lib/utils/plugin-config.d.ts +30 -0
- package/src/lib/utils/plugin-config.js +64 -0
- package/src/lib/utils/plugin-config.js.map +1 -0
- package/src/lib/utils/rolldown.d.ts +2 -0
- package/src/lib/utils/rolldown.js +12 -0
- package/src/lib/utils/rolldown.js.map +1 -0
- package/src/lib/utils/source-file-cache.d.ts +8 -15
- package/src/lib/utils/source-file-cache.js +35 -37
- package/src/lib/utils/source-file-cache.js.map +1 -1
- package/src/lib/utils/virtual-ids.d.ts +8 -0
- package/src/lib/utils/virtual-ids.js +35 -0
- package/src/lib/utils/virtual-ids.js.map +1 -0
- package/src/lib/utils/virtual-resources.d.ts +31 -0
- package/src/lib/utils/virtual-resources.js +60 -0
- package/src/lib/utils/virtual-resources.js.map +1 -0
- package/src/test-setup.d.ts +2 -0
- package/setup-vitest.d.ts +0 -4
- package/setup-vitest.js +0 -215
- package/setup-vitest.js.map +0 -1
- package/src/lib/models.js +0 -1
- package/src/lib/models.js.map +0 -1
- package/src/lib/tools/README.md +0 -3
- package/src/lib/tools/src/index.d.ts +0 -0
- package/src/lib/tools/src/index.js.map +0 -1
- package/src/lib/utils/compiler-plugin-options.js +0 -1
- package/src/lib/utils/compiler-plugin-options.js.map +0 -1
- package/src/lib/utils/hmr-candidates.js +0 -272
- package/src/lib/utils/hmr-candidates.js.map +0 -1
|
@@ -1,64 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
code: isProd
|
|
48
|
-
? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '')
|
|
49
|
-
: code,
|
|
50
|
-
map: {
|
|
51
|
-
mappings: '',
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const sideEffects = jit && id.includes('@angular/compiler') ? true : false;
|
|
56
|
-
const result = await javascriptTransformer.transformData(id, code, false, sideEffects);
|
|
57
|
-
return {
|
|
58
|
-
code: Buffer.from(result).toString(),
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
};
|
|
1
|
+
import { jt } from "./utils/devkit.js";
|
|
2
|
+
import { getJsTransformConfigKey } from "./utils/rolldown.js";
|
|
3
|
+
//#region packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts
|
|
4
|
+
function buildOptimizerPlugin({ jit }) {
|
|
5
|
+
const javascriptTransformer = new jt({
|
|
6
|
+
sourcemap: false,
|
|
7
|
+
thirdPartySourcemaps: false,
|
|
8
|
+
advancedOptimizations: true,
|
|
9
|
+
jit: true
|
|
10
|
+
}, 1);
|
|
11
|
+
let isProd = false;
|
|
12
|
+
return {
|
|
13
|
+
name: "@analogjs/vite-plugin-angular-optimizer",
|
|
14
|
+
apply: "build",
|
|
15
|
+
config(userConfig) {
|
|
16
|
+
isProd = userConfig.mode === "production" || process.env.NODE_ENV === "production";
|
|
17
|
+
const jsTransformConfigKey = getJsTransformConfigKey();
|
|
18
|
+
return {
|
|
19
|
+
define: isProd ? {
|
|
20
|
+
ngJitMode: "false",
|
|
21
|
+
ngI18nClosureMode: "false",
|
|
22
|
+
ngDevMode: "false",
|
|
23
|
+
ngServerMode: `${!!userConfig.build?.ssr}`
|
|
24
|
+
} : {},
|
|
25
|
+
[jsTransformConfigKey]: { define: isProd ? {
|
|
26
|
+
ngDevMode: "false",
|
|
27
|
+
ngJitMode: "false",
|
|
28
|
+
ngI18nClosureMode: "false",
|
|
29
|
+
ngServerMode: `${!!userConfig.build?.ssr}`
|
|
30
|
+
} : void 0 }
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
transform: {
|
|
34
|
+
filter: { id: /\.[cm]?js$/ },
|
|
35
|
+
async handler(code, id) {
|
|
36
|
+
if (!/fesm20/.test(id)) return {
|
|
37
|
+
code: isProd ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, "") : code,
|
|
38
|
+
map: { mappings: "" }
|
|
39
|
+
};
|
|
40
|
+
const sideEffects = jit && id.includes("@angular/compiler") ? true : false;
|
|
41
|
+
const result = await javascriptTransformer.transformData(id, code, false, sideEffects);
|
|
42
|
+
return { code: Buffer.from(result).toString() };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
63
46
|
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { buildOptimizerPlugin };
|
|
49
|
+
|
|
64
50
|
//# sourceMappingURL=angular-build-optimizer-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-build-optimizer-plugin.js","
|
|
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 { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function buildOptimizerPlugin({\n jit,\n}: {\n supportedBrowsers: string[];\n jit: boolean;\n}): Plugin {\n const javascriptTransformer = new JavaScriptTransformer(\n {\n sourcemap: false,\n thirdPartySourcemaps: false,\n advancedOptimizations: true,\n jit: true,\n },\n 1,\n );\n let isProd = false;\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n apply: 'build',\n config(userConfig) {\n isProd =\n userConfig.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n const jsTransformConfigKey = getJsTransformConfigKey();\n\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n [jsTransformConfigKey]: {\n define: isProd\n ? {\n ngDevMode: 'false',\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : undefined,\n },\n } as UserConfig;\n },\n transform: {\n filter: {\n id: /\\.[cm]?js$/,\n },\n async handler(code, id) {\n const angularPackage = /fesm20/.test(id);\n\n if (!angularPackage) {\n return {\n code: isProd\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: {\n mappings: '',\n },\n };\n }\n\n const sideEffects =\n jit && id.includes('@angular/compiler') ? true : false;\n const result: Uint8Array = await javascriptTransformer.transformData(\n id,\n code,\n false,\n sideEffects,\n );\n\n return {\n code: Buffer.from(result).toString(),\n };\n },\n },\n };\n}\n"],"mappings":";;;AAIA,SAAgB,qBAAqB,EACnC,OAIS;CACT,MAAM,wBAAwB,IAAI,GAChC;EACE,WAAW;EACX,sBAAsB;EACtB,uBAAuB;EACvB,KAAK;EACN,EACD,EACD;CACD,IAAI,SAAS;AAEb,QAAO;EACL,MAAM;EACN,OAAO;EACP,OAAO,YAAY;AACjB,YACE,WAAW,SAAS,gBAAA,QAAA,IAAA,aACQ;GAC9B,MAAM,uBAAuB,yBAAyB;AAEtD,UAAO;IACL,QAAQ,SACJ;KACE,WAAW;KACX,mBAAmB;KACnB,WAAW;KACX,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;KACtC,GACD,EAAE;KACL,uBAAuB,EACtB,QAAQ,SACJ;KACE,WAAW;KACX,WAAW;KACX,mBAAmB;KACnB,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;KACtC,GACD,KAAA,GACL;IACF;;EAEH,WAAW;GACT,QAAQ,EACN,IAAI,cACL;GACD,MAAM,QAAQ,MAAM,IAAI;AAGtB,QAAI,CAFmB,SAAS,KAAK,GAAG,CAGtC,QAAO;KACL,MAAM,SACF,KAAK,QAAQ,sCAAsC,GAAG,GACtD;KACJ,KAAK,EACH,UAAU,IACX;KACF;IAGH,MAAM,cACJ,OAAO,GAAG,SAAS,oBAAoB,GAAG,OAAO;IACnD,MAAM,SAAqB,MAAM,sBAAsB,cACrD,IACA,MACA,OACA,YACD;AAED,WAAO,EACL,MAAM,OAAO,KAAK,OAAO,CAAC,UAAU,EACrC;;GAEJ;EACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
export declare function jitPlugin({ inlineStylesExtension
|
|
3
|
-
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
export declare function jitPlugin({ inlineStylesExtension }: {
|
|
3
|
+
inlineStylesExtension: string;
|
|
4
4
|
}): Plugin;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return;
|
|
36
|
-
},
|
|
37
|
-
};
|
|
1
|
+
import { debugStyles } from "./utils/debug.js";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { preprocessCSS } from "vite";
|
|
4
|
+
//#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
|
|
5
|
+
function jitPlugin({ inlineStylesExtension }) {
|
|
6
|
+
let config;
|
|
7
|
+
return {
|
|
8
|
+
name: "@analogjs/vite-plugin-angular-jit",
|
|
9
|
+
configResolved(_config) {
|
|
10
|
+
config = _config;
|
|
11
|
+
},
|
|
12
|
+
resolveId(id) {
|
|
13
|
+
if (id.startsWith("virtual:angular")) return `\0${id}`;
|
|
14
|
+
},
|
|
15
|
+
async load(id) {
|
|
16
|
+
if (id.includes("virtual:angular:jit:style:inline;")) {
|
|
17
|
+
const styleId = id.split("style:inline;")[1];
|
|
18
|
+
const styleIdHash = createHash("sha256").update(styleId).digest("hex").slice(0, 16);
|
|
19
|
+
const decodedStyles = Buffer.from(decodeURIComponent(styleId), "base64").toString();
|
|
20
|
+
let styles = "";
|
|
21
|
+
try {
|
|
22
|
+
styles = (await preprocessCSS(decodedStyles, `${styleIdHash}.${inlineStylesExtension}?direct`, config))?.code;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
25
|
+
debugStyles("jit css compilation error", {
|
|
26
|
+
styleIdHash,
|
|
27
|
+
error: errorMessage
|
|
28
|
+
});
|
|
29
|
+
console.warn("[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s", styleIdHash, errorMessage);
|
|
30
|
+
}
|
|
31
|
+
return `export default \`${styles}\``;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
38
35
|
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { jitPlugin };
|
|
38
|
+
|
|
39
39
|
//# sourceMappingURL=angular-jit-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-jit-plugin.js","
|
|
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';\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 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":";;;;AAIA,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;AAEjC,QAAI;AAMF,eALiB,MAAM,cACrB,eACA,GAAG,YAAY,GAAG,sBAAsB,UACxC,OACD,GACkB;aACZ,GAAG;KACV,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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
* This plugin is a workaround for the ɵPendingTasks symbol being renamed
|
|
4
|
+
* to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of
|
|
5
|
+
* Angular with Analog that used the ɵPendingTasks symbol.
|
|
6
|
+
*
|
|
7
|
+
* Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4
|
|
8
|
+
*/
|
|
9
9
|
export declare function pendingTasksPlugin(): Plugin;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
//#region packages/vite-plugin-angular/src/lib/angular-pending-tasks.plugin.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
return;
|
|
18
|
-
},
|
|
19
|
-
};
|
|
3
|
+
* This plugin is a workaround for the ɵPendingTasks symbol being renamed
|
|
4
|
+
* to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of
|
|
5
|
+
* Angular with Analog that used the ɵPendingTasks symbol.
|
|
6
|
+
*
|
|
7
|
+
* Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4
|
|
8
|
+
*/
|
|
9
|
+
function pendingTasksPlugin() {
|
|
10
|
+
return {
|
|
11
|
+
name: "analogjs-pending-tasks-plugin",
|
|
12
|
+
transform(code, id) {
|
|
13
|
+
if (id.includes("analogjs-content.mjs")) return { code: code.replace("ɵPendingTasksInternal", "ɵPendingTasks") };
|
|
14
|
+
}
|
|
15
|
+
};
|
|
20
16
|
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { pendingTasksPlugin };
|
|
19
|
+
|
|
21
20
|
//# sourceMappingURL=angular-pending-tasks.plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-pending-tasks.plugin.js","
|
|
1
|
+
{"version":3,"file":"angular-pending-tasks.plugin.js","names":[],"sources":["../../../src/lib/angular-pending-tasks.plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\n\nimport { angularFullVersion } from './utils/devkit.js';\n\n/**\n * This plugin is a workaround for the ɵPendingTasks symbol being renamed\n * to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of\n * Angular with Analog that used the ɵPendingTasks symbol.\n *\n * Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4\n */\nexport function pendingTasksPlugin(): Plugin {\n return {\n name: 'analogjs-pending-tasks-plugin',\n transform(code, id) {\n if (id.includes('analogjs-content.mjs')) {\n return {\n code: code.replace('ɵPendingTasksInternal', 'ɵPendingTasks'),\n };\n }\n return;\n },\n };\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,qBAA6B;AAC3C,QAAO;EACL,MAAM;EACN,UAAU,MAAM,IAAI;AAClB,OAAI,GAAG,SAAS,uBAAuB,CACrC,QAAO,EACL,MAAM,KAAK,QAAQ,yBAAyB,gBAAgB,EAC7D;;EAIN"}
|
|
@@ -1,48 +1,239 @@
|
|
|
1
|
-
import { NgtscProgram } from
|
|
2
|
-
import * as ts from
|
|
3
|
-
import { Plugin } from
|
|
4
|
-
import {
|
|
1
|
+
import { NgtscProgram } from "@angular/compiler-cli";
|
|
2
|
+
import * as ts from "typescript";
|
|
3
|
+
import { ModuleNode, Plugin, ViteDevServer } from "vite";
|
|
4
|
+
import type { StylePreprocessor } from "./style-preprocessor.js";
|
|
5
|
+
import { type DebugOption } from "./utils/debug.js";
|
|
6
|
+
import { FileReplacement } from "./plugins/file-replacements.plugin.js";
|
|
7
|
+
import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
|
|
8
|
+
import { type AngularStylePipelineOptions } from "./style-pipeline.js";
|
|
5
9
|
export declare enum DiagnosticModes {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
None = 0,
|
|
11
|
+
Option = 1,
|
|
12
|
+
Syntactic = 2,
|
|
13
|
+
Semantic = 4,
|
|
14
|
+
All = 7
|
|
11
15
|
}
|
|
12
16
|
export interface PluginOptions {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
tsconfig?: string | (() => string);
|
|
18
|
+
workspaceRoot?: string;
|
|
19
|
+
inlineStylesExtension?: string;
|
|
20
|
+
jit?: boolean;
|
|
21
|
+
advanced?: {
|
|
22
|
+
/**
|
|
23
|
+
* Custom TypeScript transformers that are run before Angular compilation
|
|
24
|
+
*/
|
|
25
|
+
tsTransformers?: ts.CustomTransformers;
|
|
26
|
+
};
|
|
27
|
+
supportedBrowsers?: string[];
|
|
28
|
+
transformFilter?: (code: string, id: string) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Additional files to include in compilation
|
|
31
|
+
*/
|
|
32
|
+
include?: string[];
|
|
33
|
+
additionalContentDirs?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* Enables Angular's HMR during development/watch mode.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to `true` for watch mode. Set to `false` to disable HMR while
|
|
38
|
+
* keeping other stylesheet externalization behavior available when needed.
|
|
39
|
+
*/
|
|
40
|
+
hmr?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use `hmr` instead. Kept as a compatibility alias.
|
|
43
|
+
*/
|
|
44
|
+
liveReload?: boolean;
|
|
45
|
+
disableTypeChecking?: boolean;
|
|
46
|
+
fileReplacements?: FileReplacement[];
|
|
47
|
+
experimental?: {
|
|
48
|
+
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
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Enable debug logging for specific scopes.
|
|
59
|
+
*
|
|
60
|
+
* - `true` → enables all `analog:angular:*` scopes
|
|
61
|
+
* - `string[]` → enables listed namespaces (e.g. `['analog:angular:tailwind']`)
|
|
62
|
+
* - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`
|
|
63
|
+
* to restrict output to a specific Vite command (omit for both)
|
|
64
|
+
*
|
|
65
|
+
* Also responds to the `DEBUG` env var (Node.js) or `localStorage.debug`
|
|
66
|
+
* (browser), using the `obug` convention.
|
|
67
|
+
*/
|
|
68
|
+
debug?: DebugOption;
|
|
69
|
+
/**
|
|
70
|
+
* Optional preprocessor that transforms component CSS before it enters Vite's
|
|
71
|
+
* preprocessCSS pipeline. Runs on every component stylesheet (both external
|
|
72
|
+
* `.component.css` files and inline `styles: [...]` blocks).
|
|
73
|
+
*
|
|
74
|
+
* @param code - Raw CSS content of the component stylesheet
|
|
75
|
+
* @param filename - Resolved file path of the stylesheet (or containing .ts file for inline styles)
|
|
76
|
+
* @returns Transformed CSS string, or the original code if no transformation is needed
|
|
77
|
+
*/
|
|
78
|
+
stylePreprocessor?: StylePreprocessor;
|
|
79
|
+
/**
|
|
80
|
+
* Experimental Angular stylesheet-resource hooks for community-maintained
|
|
81
|
+
* style-pipeline plugins.
|
|
82
|
+
*
|
|
83
|
+
* These hooks run inside the Angular resource pipeline, which is the seam a
|
|
84
|
+
* standalone Vite plugin cannot own on its own.
|
|
85
|
+
*/
|
|
86
|
+
stylePipeline?: AngularStylePipelineOptions;
|
|
87
|
+
/**
|
|
88
|
+
* First-class Tailwind CSS v4 integration for Angular component styles.
|
|
89
|
+
*
|
|
90
|
+
* Angular's compiler processes component CSS through Vite's `preprocessCSS()`,
|
|
91
|
+
* which runs `@tailwindcss/vite` — but each component stylesheet is processed
|
|
92
|
+
* in isolation without access to the root Tailwind configuration (prefix, @theme,
|
|
93
|
+
* @custom-variant, @plugin definitions). This causes errors like:
|
|
94
|
+
*
|
|
95
|
+
* "Cannot apply utility class `sa:grid` because the `sa` variant does not exist"
|
|
96
|
+
*
|
|
97
|
+
* The `tailwindCss` option solves this by auto-injecting a `@reference` directive
|
|
98
|
+
* into every component CSS file that uses Tailwind utilities, pointing it to the
|
|
99
|
+
* root Tailwind stylesheet so `@tailwindcss/vite` can resolve the full configuration.
|
|
100
|
+
*
|
|
101
|
+
* @example Basic usage — reference a root Tailwind CSS file:
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { resolve } from 'node:path';
|
|
104
|
+
*
|
|
105
|
+
* angular({
|
|
106
|
+
* tailwindCss: {
|
|
107
|
+
* rootStylesheet: resolve(__dirname, 'src/styles/tailwind.css'),
|
|
108
|
+
* },
|
|
109
|
+
* })
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @example With prefix detection — only inject for files using specific prefixes:
|
|
113
|
+
* ```ts
|
|
114
|
+
* angular({
|
|
115
|
+
* tailwindCss: {
|
|
116
|
+
* rootStylesheet: resolve(__dirname, 'src/styles/tailwind.css'),
|
|
117
|
+
* // Only inject @reference into files that use these prefixed classes
|
|
118
|
+
* prefixes: ['sa:', 'tw:'],
|
|
119
|
+
* },
|
|
120
|
+
* })
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @example AnalogJS platform — passed through the `vite` option:
|
|
124
|
+
* ```ts
|
|
125
|
+
* analog({
|
|
126
|
+
* vite: {
|
|
127
|
+
* tailwindCss: {
|
|
128
|
+
* rootStylesheet: resolve(__dirname, '../../../libs/meritos/tailwind.config.css'),
|
|
129
|
+
* },
|
|
130
|
+
* },
|
|
131
|
+
* })
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
tailwindCss?: {
|
|
135
|
+
/**
|
|
136
|
+
* Absolute path to the root Tailwind CSS file that contains `@import "tailwindcss"`,
|
|
137
|
+
* `@theme`, `@custom-variant`, and `@plugin` definitions.
|
|
138
|
+
*
|
|
139
|
+
* A `@reference` directive pointing to this file will be auto-injected into
|
|
140
|
+
* component CSS files that use Tailwind utilities.
|
|
141
|
+
*/
|
|
142
|
+
rootStylesheet: string;
|
|
143
|
+
/**
|
|
144
|
+
* Optional list of class prefixes to detect (e.g. `['sa:', 'tw:']`).
|
|
145
|
+
* When provided, `@reference` is only injected into component CSS files that
|
|
146
|
+
* contain at least one of these prefixes. When omitted, `@reference` is injected
|
|
147
|
+
* into all component CSS files that contain `@apply` or `@` directives.
|
|
148
|
+
*
|
|
149
|
+
* @default undefined — inject into all component CSS files with `@apply`
|
|
150
|
+
*/
|
|
151
|
+
prefixes?: string[];
|
|
152
|
+
};
|
|
36
153
|
}
|
|
154
|
+
export declare function normalizeIncludeGlob(workspaceRoot: string, glob: string): string;
|
|
155
|
+
export declare function evictDeletedFileMetadata(file: string, { removeActiveGraphMetadata, removeStyleOwnerMetadata, classNamesMap, fileTransformMap }: {
|
|
156
|
+
removeActiveGraphMetadata: (file: string) => void;
|
|
157
|
+
removeStyleOwnerMetadata: (file: string) => void;
|
|
158
|
+
classNamesMap: Map<string, string>;
|
|
159
|
+
fileTransformMap: Map<string, string>;
|
|
160
|
+
}): void;
|
|
161
|
+
export declare function injectViteIgnoreForHmrMetadata(code: string): string;
|
|
162
|
+
export declare function isIgnoredHmrFile(file: string): boolean;
|
|
37
163
|
export declare function angular(options?: PluginOptions): Plugin[];
|
|
38
|
-
export declare function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
164
|
+
export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Convert Analog/Angular CLI-style file replacements into the flat record
|
|
167
|
+
* expected by `AngularHostOptions.fileReplacements`.
|
|
168
|
+
*
|
|
169
|
+
* Only browser replacements (`{ replace, with }`) are converted. SSR-only
|
|
170
|
+
* replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to
|
|
171
|
+
* handle — they should not be baked into the Angular compilation host because
|
|
172
|
+
* that would apply them to both browser and server builds.
|
|
173
|
+
*
|
|
174
|
+
* Relative paths are resolved against `workspaceRoot` so that the host
|
|
175
|
+
* receives the same absolute paths it would get from the Angular CLI.
|
|
176
|
+
*/
|
|
177
|
+
export declare function toAngularCompilationFileReplacements(replacements: FileReplacement[], workspaceRoot: string): Record<string, string> | undefined;
|
|
178
|
+
/**
|
|
179
|
+
* Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)
|
|
180
|
+
* back to absolute file paths with their associated HMR code and component
|
|
181
|
+
* class name.
|
|
182
|
+
*
|
|
183
|
+
* Angular's private Compilation API emits template update keys in the form
|
|
184
|
+
* `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve
|
|
185
|
+
* them so the caller can look up updates by the same normalized absolute path
|
|
186
|
+
* used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).
|
|
187
|
+
*/
|
|
188
|
+
export declare function mapTemplateUpdatesToFiles(templateUpdates: ReadonlyMap<string, string> | undefined): Map<string, {
|
|
189
|
+
className: string;
|
|
190
|
+
code: string;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Returns every live Vite module that can legitimately represent a changed
|
|
194
|
+
* Angular resource file.
|
|
195
|
+
*
|
|
196
|
+
* For normal files, `getModulesByFile()` is enough. For Angular component
|
|
197
|
+
* stylesheets, it is not: the browser often holds virtual hashed requests
|
|
198
|
+
* (`/abc123.css?direct&ngcomp=...` and `/abc123.css?ngcomp=...`) that are no
|
|
199
|
+
* longer discoverable from the original source path alone. We therefore merge:
|
|
200
|
+
* - watcher event modules
|
|
201
|
+
* - module-graph modules by source file
|
|
202
|
+
* - registry-tracked live request ids resolved back through the module graph
|
|
203
|
+
*/
|
|
204
|
+
export declare function getModulesForChangedFile(server: ViteDevServer, file: string, eventModules?: readonly ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
|
|
205
|
+
export declare function isModuleForChangedResource(mod: ModuleNode, changedFile: string, stylesheetRegistry?: AnalogStylesheetRegistry): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Refreshes any already-served stylesheet records that map back to a changed
|
|
208
|
+
* source file.
|
|
209
|
+
*
|
|
210
|
+
* This is the critical bridge for externalized Angular component styles during
|
|
211
|
+
* HMR. Angular's resource watcher can notice that `/src/...component.css`
|
|
212
|
+
* changed before Angular recompilation has had a chance to repopulate the
|
|
213
|
+
* stylesheet registry. If we emit a CSS update against the existing virtual
|
|
214
|
+
* stylesheet id without first refreshing the registry content, the browser gets
|
|
215
|
+
* a hot update containing stale CSS. By rewriting the existing served records
|
|
216
|
+
* from disk up front, HMR always pushes the latest source content.
|
|
217
|
+
*/
|
|
218
|
+
export declare function refreshStylesheetRegistryForFile(file: string, stylesheetRegistry?: AnalogStylesheetRegistry, stylePreprocessor?: StylePreprocessor): void;
|
|
219
|
+
export declare function findComponentStylesheetWrapperModules(server: ViteDevServer, changedFile: string, directModule: ModuleNode, fileModules: ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
|
|
220
|
+
interface TemplateClassBindingIssue {
|
|
221
|
+
line: number;
|
|
222
|
+
column: number;
|
|
223
|
+
snippet: string;
|
|
224
|
+
}
|
|
225
|
+
export declare function findStaticClassAndBoundClassConflicts(template: string): TemplateClassBindingIssue[];
|
|
226
|
+
export declare function findBoundClassAndNgClassConflicts(template: string): TemplateClassBindingIssue[];
|
|
227
|
+
export declare function findTemplateOwnerModules(server: ViteDevServer, resourceFile: string): ModuleNode[];
|
|
228
|
+
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean): (file: string) => {
|
|
229
|
+
errors?: string[];
|
|
230
|
+
warnings?: (string | ts.DiagnosticMessageChain)[];
|
|
231
|
+
hmrUpdateCode?: string | null;
|
|
232
|
+
hmrEligible?: boolean;
|
|
43
233
|
};
|
|
44
234
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
235
|
+
* Checks for vitest run from the command line
|
|
236
|
+
* @returns boolean
|
|
237
|
+
*/
|
|
48
238
|
export declare function isTestWatchMode(args?: string[]): boolean;
|
|
239
|
+
export {};
|