@analogjs/vite-plugin-angular 3.0.0-alpha.8 → 3.0.0-alpha.81
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 +30 -0
- 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 +51 -14
- package/src/index.d.ts +6 -2
- package/src/index.js +6 -2
- package/src/index.js.map +1 -1
- package/src/lib/analog-plugin-interop.d.ts +78 -0
- package/src/lib/analog-plugin-interop.js +97 -0
- package/src/lib/analog-plugin-interop.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
- package/src/lib/angular-build-optimizer-plugin.js +57 -63
- 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 +49 -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 +82 -69
- package/src/lib/angular-vite-plugin.js +1201 -1085
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +26 -21
- package/src/lib/angular-vitest-plugin.js +106 -135
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +18 -0
- package/src/lib/compilation-api/compilation-api-plugin.js +488 -0
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
- package/src/lib/compilation-api/index.d.ts +1 -0
- package/src/lib/compilation-api/index.js +1 -0
- package/src/lib/compiler/angular-version.d.ts +19 -0
- package/src/lib/compiler/angular-version.js +31 -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 +50 -0
- package/src/lib/compiler/compile.js +814 -0
- package/src/lib/compiler/compile.js.map +1 -0
- package/src/lib/compiler/constants.d.ts +24 -0
- package/src/lib/compiler/constants.js +59 -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 +57 -0
- package/src/lib/compiler/defer.js +154 -0
- package/src/lib/compiler/defer.js.map +1 -0
- package/src/lib/compiler/dts-reader.d.ts +45 -0
- package/src/lib/compiler/dts-reader.js +395 -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 +8 -0
- package/src/lib/compiler/index.js +8 -0
- package/src/lib/compiler/jit-metadata.d.ts +14 -0
- package/src/lib/compiler/jit-metadata.js +168 -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 +204 -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 +446 -0
- package/src/lib/compiler/js-emitter.js.map +1 -0
- package/src/lib/compiler/metadata.d.ts +36 -0
- package/src/lib/compiler/metadata.js +710 -0
- package/src/lib/compiler/metadata.js.map +1 -0
- package/src/lib/compiler/registry.d.ts +56 -0
- package/src/lib/compiler/registry.js +176 -0
- package/src/lib/compiler/registry.js.map +1 -0
- package/src/lib/compiler/resource-inliner.d.ts +43 -0
- package/src/lib/compiler/resource-inliner.js +230 -0
- package/src/lib/compiler/resource-inliner.js.map +1 -0
- package/src/lib/compiler/style-ast.d.ts +9 -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 +28 -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 +40 -0
- package/src/lib/compiler/utils.js +76 -0
- package/src/lib/compiler/utils.js.map +1 -0
- package/src/lib/compiler-plugin.d.ts +13 -12
- package/src/lib/compiler-plugin.js +40 -44
- package/src/lib/compiler-plugin.js.map +1 -1
- package/src/lib/component-resolvers.d.ts +20 -4
- package/src/lib/component-resolvers.js +101 -120
- package/src/lib/component-resolvers.js.map +1 -1
- package/src/lib/encapsulation-plugin.d.ts +18 -0
- package/src/lib/encapsulation-plugin.js +53 -0
- package/src/lib/encapsulation-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +13 -0
- package/src/lib/fast-compile-plugin.js +419 -0
- package/src/lib/fast-compile-plugin.js.map +1 -0
- package/src/lib/host.d.ts +10 -8
- package/src/lib/host.js +111 -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 +61 -63
- 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 +35 -23
- package/src/lib/router-plugin.js.map +1 -1
- 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 +74 -0
- package/src/lib/stylesheet-registry.js +174 -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 +33 -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/compilation-shared.d.ts +62 -0
- package/src/lib/utils/compilation-shared.js +138 -0
- package/src/lib/utils/compilation-shared.js.map +1 -0
- package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
- package/src/lib/utils/css-extension-resolver.d.ts +32 -0
- package/src/lib/utils/css-extension-resolver.js +73 -0
- package/src/lib/utils/css-extension-resolver.js.map +1 -0
- 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/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 +41 -0
- package/src/lib/utils/plugin-config.js +85 -0
- package/src/lib/utils/plugin-config.js.map +1 -0
- package/src/lib/utils/rolldown.d.ts +1 -1
- package/src/lib/utils/rolldown.js +9 -5
- package/src/lib/utils/rolldown.js.map +1 -1
- package/src/lib/utils/safe-module-paths.d.ts +16 -0
- package/src/lib/utils/safe-module-paths.js +29 -0
- package/src/lib/utils/safe-module-paths.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/transform-cache.d.ts +43 -0
- package/src/lib/utils/transform-cache.js +97 -0
- package/src/lib/utils/transform-cache.js.map +1 -0
- package/src/lib/utils/tsconfig-resolver.d.ts +34 -0
- package/src/lib/utils/tsconfig-resolver.js +203 -0
- package/src/lib/utils/tsconfig-resolver.js.map +1 -0
- package/src/lib/utils/virtual-ids.d.ts +4 -0
- package/src/lib/utils/virtual-ids.js +23 -0
- package/src/lib/utils/virtual-ids.js.map +1 -0
- package/src/lib/utils/virtual-resources.d.ts +19 -0
- package/src/lib/utils/virtual-resources.js +38 -0
- package/src/lib/utils/virtual-resources.js.map +1 -0
- package/src/lib/virtual-modules-plugin.d.ts +5 -0
- package/src/lib/virtual-modules-plugin.js +23 -0
- package/src/lib/virtual-modules-plugin.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,65 +1,59 @@
|
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
const sideEffects = jit && id.includes('@angular/compiler') ? true : false;
|
|
57
|
-
const result = await javascriptTransformer.transformData(id, code, false, sideEffects);
|
|
58
|
-
return {
|
|
59
|
-
code: Buffer.from(result).toString(),
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
1
|
+
import { jt } from "./utils/devkit.js";
|
|
2
|
+
import { isProdMode } from "./utils/plugin-config.js";
|
|
3
|
+
import { getJsTransformConfigKey } from "./utils/rolldown.js";
|
|
4
|
+
//#region packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts
|
|
5
|
+
function buildOptimizerPlugin({ jit }) {
|
|
6
|
+
let javascriptTransformer;
|
|
7
|
+
let isProd = false;
|
|
8
|
+
let preserveVendorMaps = false;
|
|
9
|
+
return {
|
|
10
|
+
name: "@analogjs/vite-plugin-angular-optimizer",
|
|
11
|
+
apply(_config, env) {
|
|
12
|
+
return env.command === "build" || process.env.NODE_ENV === "production";
|
|
13
|
+
},
|
|
14
|
+
config(userConfig) {
|
|
15
|
+
isProd = isProdMode(userConfig.mode);
|
|
16
|
+
javascriptTransformer ??= new jt({
|
|
17
|
+
sourcemap: false,
|
|
18
|
+
thirdPartySourcemaps: false,
|
|
19
|
+
advancedOptimizations: isProd,
|
|
20
|
+
jit: true
|
|
21
|
+
}, 1);
|
|
22
|
+
const jsTransformConfigKey = getJsTransformConfigKey();
|
|
23
|
+
return {
|
|
24
|
+
define: isProd ? {
|
|
25
|
+
ngJitMode: "false",
|
|
26
|
+
ngI18nClosureMode: "false",
|
|
27
|
+
ngDevMode: "false",
|
|
28
|
+
ngServerMode: `${!!userConfig.build?.ssr}`
|
|
29
|
+
} : {},
|
|
30
|
+
[jsTransformConfigKey]: { define: isProd ? {
|
|
31
|
+
ngDevMode: "false",
|
|
32
|
+
ngJitMode: "false",
|
|
33
|
+
ngI18nClosureMode: "false",
|
|
34
|
+
ngServerMode: `${!!userConfig.build?.ssr}`
|
|
35
|
+
} : void 0 }
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
configResolved(config) {
|
|
39
|
+
preserveVendorMaps = !!config.build.sourcemap;
|
|
40
|
+
},
|
|
41
|
+
transform: {
|
|
42
|
+
filter: { id: /\.[cm]?js(?:\?|$)/ },
|
|
43
|
+
async handler(code, id) {
|
|
44
|
+
const cleanId = id.split("?")[0];
|
|
45
|
+
if (!/fesm20/.test(cleanId)) return {
|
|
46
|
+
code: isProd && !preserveVendorMaps ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, "") : code,
|
|
47
|
+
map: preserveVendorMaps ? null : { mappings: "" }
|
|
48
|
+
};
|
|
49
|
+
const sideEffects = jit && cleanId.includes("@angular/compiler") ? true : false;
|
|
50
|
+
const result = await javascriptTransformer.transformData(cleanId, code, false, sideEffects);
|
|
51
|
+
return { code: Buffer.from(result).toString() };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
64
55
|
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { buildOptimizerPlugin };
|
|
58
|
+
|
|
65
59
|
//# 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 { isProdMode } from './utils/plugin-config.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function buildOptimizerPlugin({\n jit,\n}: {\n supportedBrowsers: string[];\n jit: boolean;\n}): Plugin {\n let javascriptTransformer: InstanceType<typeof JavaScriptTransformer>;\n let isProd = false;\n let preserveVendorMaps = false;\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 javascriptTransformer ??= new JavaScriptTransformer(\n {\n sourcemap: false,\n thirdPartySourcemaps: false,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\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 configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\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 result: Uint8Array = await javascriptTransformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n return {\n code: Buffer.from(result).toString(),\n };\n },\n },\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,qBAAqB,EACnC,OAIS;CACT,IAAI;CACJ,IAAI,SAAS;CACb,IAAI,qBAAqB;AAEzB,QAAO;EACL,MAAM;EASN,MAAM,SAAS,KAAK;AAClB,UACE,IAAI,YAAY,WAAA,QAAA,IAAA,aAAuC;;EAG3D,OAAO,YAAY;AACjB,YAAS,WAAW,WAAW,KAAK;AAGpC,6BAA0B,IAAI,GAC5B;IACE,WAAW;IACX,sBAAsB;IACtB,uBAAuB;IACvB,KAAK;IACN,EACD,EACD;GACD,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,eAAe,QAAQ;AACrB,wBAAqB,CAAC,CAAC,OAAO,MAAM;;EAEtC,WAAW;GACT,QAAQ,EAON,IAAI,qBACL;GACD,MAAM,QAAQ,MAAM,IAAI;IAGtB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC;AAG9B,QAAI,CAFmB,SAAS,KAAK,QAAQ,CAM3C,QAAO;KACL,MACE,UAAU,CAAC,qBACP,KAAK,QAAQ,sCAAsC,GAAG,GACtD;KACN,KAAK,qBAAqB,OAAO,EAAE,UAAU,IAAI;KAClD;IAGH,MAAM,cACJ,OAAO,QAAQ,SAAS,oBAAoB,GAAG,OAAO;IACxD,MAAM,SAAqB,MAAM,sBAAsB,cACrD,SACA,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,51 @@
|
|
|
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
|
-
|
|
1
|
+
import { getJitInlineStyles } from "./utils/jit-inline-styles.js";
|
|
2
|
+
import { debugStyles } from "./utils/debug.js";
|
|
3
|
+
import { discoverAnalogIntegrations } from "./analog-plugin-interop.js";
|
|
4
|
+
import { preprocessStylesheet } from "./stylesheet-registry.js";
|
|
5
|
+
import { preprocessCSS } from "vite";
|
|
6
|
+
//#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
|
|
7
|
+
function jitPlugin({ inlineStylesExtension }) {
|
|
8
|
+
let config;
|
|
9
|
+
let stylePreprocessor;
|
|
10
|
+
return {
|
|
11
|
+
name: "@analogjs/vite-plugin-angular-jit",
|
|
12
|
+
configResolved(_config) {
|
|
13
|
+
config = _config;
|
|
14
|
+
},
|
|
15
|
+
async buildStart() {
|
|
16
|
+
stylePreprocessor = (await discoverAnalogIntegrations(config)).stylePreprocessor;
|
|
17
|
+
},
|
|
18
|
+
resolveId(id) {
|
|
19
|
+
if (id.startsWith("virtual:angular")) return `\0${id}`;
|
|
20
|
+
},
|
|
21
|
+
async load(id) {
|
|
22
|
+
if (id.includes("virtual:angular:jit:style:inline;")) {
|
|
23
|
+
const styleIdHash = id.split("style:inline;")[1];
|
|
24
|
+
const encodedStyles = getJitInlineStyles(styleIdHash);
|
|
25
|
+
if (encodedStyles === void 0) return;
|
|
26
|
+
const decodedStyles = Buffer.from(decodeURIComponent(encodedStyles), "base64").toString();
|
|
27
|
+
const filename = `${styleIdHash}.${inlineStylesExtension}`;
|
|
28
|
+
const preprocessed = preprocessStylesheet(decodedStyles, filename, stylePreprocessor, {
|
|
29
|
+
filename,
|
|
30
|
+
inline: true
|
|
31
|
+
});
|
|
32
|
+
let styles = "";
|
|
33
|
+
try {
|
|
34
|
+
styles = (await preprocessCSS(preprocessed, `${filename}?direct`, config))?.code;
|
|
35
|
+
} catch (e) {
|
|
36
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
37
|
+
debugStyles("jit css compilation error", {
|
|
38
|
+
styleIdHash,
|
|
39
|
+
error: errorMessage
|
|
40
|
+
});
|
|
41
|
+
console.warn("[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s", styleIdHash, errorMessage);
|
|
42
|
+
}
|
|
43
|
+
return `export default \`${styles}\``;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
38
47
|
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { jitPlugin };
|
|
50
|
+
|
|
39
51
|
//# 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 { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport {\n JIT_INLINE_STYLE_PREFIX,\n getJitInlineStyles,\n} from './utils/jit-inline-styles.js';\nimport { debugStyles } from './utils/debug.js';\nimport { discoverAnalogIntegrations } from './analog-plugin-interop.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\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 },\n async buildStart() {\n stylePreprocessor = (await discoverAnalogIntegrations(config))\n .stylePreprocessor;\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 styleIdHash = id.split('style:inline;')[1];\n const encodedStyles = getJitInlineStyles(styleIdHash);\n\n if (encodedStyles === undefined) {\n return;\n }\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(encodedStyles),\n 'base64',\n ).toString();\n const filename = `${styleIdHash}.${inlineStylesExtension}`;\n const preprocessed = preprocessStylesheet(\n decodedStyles,\n filename,\n stylePreprocessor,\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,\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":";;;;;;AAUA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;CACJ,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,eAAe,SAAS;AACtB,YAAS;;EAEX,MAAM,aAAa;AACjB,wBAAqB,MAAM,2BAA2B,OAAO,EAC1D;;EAEL,UAAU,IAAY;AACpB,OAAI,GAAG,WAAW,kBAAkB,CAClC,QAAO,KAAK;;EAKhB,MAAM,KAAK,IAAY;AACrB,OAAI,GAAG,SAAA,oCAAiC,EAAE;IACxC,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC;IAC9C,MAAM,gBAAgB,mBAAmB,YAAY;AAErD,QAAI,kBAAkB,KAAA,EACpB;IAGF,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,cAAc,EACjC,SACD,CAAC,UAAU;IACZ,MAAM,WAAW,GAAG,YAAY,GAAG;IACnC,MAAM,eAAe,qBACnB,eACA,UACA,mBACA;KAAE;KAAU,QAAQ;KAAM,CAC3B;IAED,IAAI,SAA6B;AAEjC,QAAI;AAMF,eALiB,MAAM,cACrB,cACA,GAAG,SAAS,UACZ,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,76 +1,89 @@
|
|
|
1
|
-
import { NgtscProgram } from
|
|
2
|
-
import * as ts from
|
|
3
|
-
import { Plugin } from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Syntactic = 2,
|
|
9
|
-
Semantic = 4,
|
|
10
|
-
All = 7
|
|
11
|
-
}
|
|
1
|
+
import { NgtscProgram } from "@angular/compiler-cli";
|
|
2
|
+
import * as ts from "typescript";
|
|
3
|
+
import { ModuleNode, Plugin, ViteDevServer } from "vite";
|
|
4
|
+
import { type DebugOption } from "./utils/debug.js";
|
|
5
|
+
import { FileReplacement } from "./plugins/file-replacements.plugin.js";
|
|
6
|
+
import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
|
|
7
|
+
export { DiagnosticModes, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, toAngularCompilationFileReplacements, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, describeStylesheetContent, isTestWatchMode } from "./utils/compilation-shared.js";
|
|
12
8
|
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
|
-
|
|
9
|
+
tsconfig?: string | (() => string);
|
|
10
|
+
workspaceRoot?: string;
|
|
11
|
+
inlineStylesExtension?: string;
|
|
12
|
+
jit?: boolean;
|
|
13
|
+
supportedBrowsers?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Additional files to include in compilation
|
|
16
|
+
*/
|
|
17
|
+
include?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Enables Analog's Angular live-reload/HMR pipeline during development/watch mode.
|
|
20
|
+
*
|
|
21
|
+
* This is separate from Vite's `server.hmr` option, which configures the
|
|
22
|
+
* HMR client transport.
|
|
23
|
+
*
|
|
24
|
+
* Defaults to `true` for watch mode. Set to `false` to disable Angular
|
|
25
|
+
* reload updates while keeping other stylesheet externalization behavior
|
|
26
|
+
* available when needed.
|
|
27
|
+
*/
|
|
28
|
+
liveReload?: boolean;
|
|
29
|
+
disableTypeChecking?: boolean;
|
|
30
|
+
fileReplacements?: FileReplacement[];
|
|
31
|
+
/**
|
|
32
|
+
* Opt into the fast compile path. Skips Angular's template type-checking
|
|
33
|
+
* and routes compilation through an internal single-pass transform.
|
|
34
|
+
* Defaults to `false`.
|
|
35
|
+
*/
|
|
36
|
+
fastCompile?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Compilation output mode used when `fastCompile` is enabled.
|
|
39
|
+
* - `'full'` (default): Emit final Ivy definitions for application builds.
|
|
40
|
+
* - `'partial'`: Emit partial declarations for library publishing.
|
|
41
|
+
*/
|
|
42
|
+
fastCompileMode?: "full" | "partial";
|
|
43
|
+
experimental?: {
|
|
44
|
+
useAngularCompilationAPI?: boolean;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Enable debug logging for specific scopes.
|
|
48
|
+
*
|
|
49
|
+
* - `true` → enables all `analog:angular:*` scopes
|
|
50
|
+
* - `string[]` → enables listed namespaces (e.g. `['analog:angular:hmr']`)
|
|
51
|
+
* - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`
|
|
52
|
+
* to restrict output to a specific Vite command (omit for both)
|
|
53
|
+
*
|
|
54
|
+
* Also responds to the `DEBUG` env var (Node.js) or `localStorage.debug`
|
|
55
|
+
* (browser), using the `obug` convention.
|
|
56
|
+
*/
|
|
57
|
+
debug?: DebugOption;
|
|
36
58
|
}
|
|
59
|
+
export declare function evictDeletedFileMetadata(file: string, { classNamesMap, fileTransformMap }: {
|
|
60
|
+
classNamesMap: Map<string, string>;
|
|
61
|
+
fileTransformMap: Map<string, string>;
|
|
62
|
+
}): void;
|
|
37
63
|
export declare function angular(options?: PluginOptions): Plugin[];
|
|
38
64
|
export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
|
|
39
65
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export declare function
|
|
66
|
+
* Returns every live Vite module that can legitimately represent a changed
|
|
67
|
+
* Angular resource file.
|
|
68
|
+
*
|
|
69
|
+
* For normal files, `getModulesByFile()` is enough. For Angular component
|
|
70
|
+
* stylesheets, it is not: the browser often holds virtual hashed requests
|
|
71
|
+
* (`/abc123.css?direct&ngcomp=...` and `/abc123.css?ngcomp=...`) that are no
|
|
72
|
+
* longer discoverable from the original source path alone. We therefore merge:
|
|
73
|
+
* - watcher event modules
|
|
74
|
+
* - module-graph modules by source file
|
|
75
|
+
* - registry-tracked live request ids resolved back through the module graph
|
|
76
|
+
*/
|
|
77
|
+
export declare function getModulesForChangedFile(server: ViteDevServer, file: string, eventModules?: readonly ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
|
|
78
|
+
export declare function isModuleForChangedResource(mod: ModuleNode, changedFile: string, stylesheetRegistry?: AnalogStylesheetRegistry): boolean;
|
|
79
|
+
export declare function findComponentStylesheetWrapperModules(server: ViteDevServer, changedFile: string, directModule: ModuleNode, fileModules: ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
|
|
80
|
+
export declare function findTemplateOwnerModules(server: ViteDevServer, resourceFile: string): ModuleNode[];
|
|
52
81
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).
|
|
61
|
-
*/
|
|
62
|
-
export declare function mapTemplateUpdatesToFiles(templateUpdates: ReadonlyMap<string, string> | undefined): Map<string, {
|
|
63
|
-
className: string;
|
|
64
|
-
code: string;
|
|
65
|
-
}>;
|
|
66
|
-
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram['compiler'], liveReload?: boolean, disableTypeChecking?: boolean): (file: string) => {
|
|
67
|
-
errors?: string[];
|
|
68
|
-
warnings?: (string | ts.DiagnosticMessageChain)[];
|
|
69
|
-
hmrUpdateCode?: string | null;
|
|
70
|
-
hmrEligible?: boolean;
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean): (file: string) => {
|
|
85
|
+
errors?: string[];
|
|
86
|
+
warnings?: (string | ts.DiagnosticMessageChain)[];
|
|
87
|
+
hmrUpdateCode?: string | null;
|
|
88
|
+
hmrEligible?: boolean;
|
|
71
89
|
};
|
|
72
|
-
/**
|
|
73
|
-
* Checks for vitest run from the command line
|
|
74
|
-
* @returns boolean
|
|
75
|
-
*/
|
|
76
|
-
export declare function isTestWatchMode(args?: string[]): boolean;
|