@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.
Files changed (109) hide show
  1. package/migrations/migrate-setup-vitest/migrate-setup-vitest.d.ts +2 -0
  2. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +49 -0
  3. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -0
  4. package/migrations/migration.json +7 -1
  5. package/migrations/migrations.json +9 -0
  6. package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +2 -0
  7. package/migrations/update-3-0-0/migrate-setup-vitest.js +36 -0
  8. package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -0
  9. package/package.json +27 -13
  10. package/src/index.d.ts +3 -2
  11. package/src/index.js +6 -2
  12. package/src/index.js.map +1 -1
  13. package/src/lib/analog-compiler-plugin.d.ts +14 -0
  14. package/src/lib/analog-compiler-plugin.js +257 -0
  15. package/src/lib/analog-compiler-plugin.js.map +1 -0
  16. package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
  17. package/src/lib/angular-build-optimizer-plugin.js +48 -62
  18. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  19. package/src/lib/angular-jit-plugin.d.ts +3 -3
  20. package/src/lib/angular-jit-plugin.js +37 -37
  21. package/src/lib/angular-jit-plugin.js.map +1 -1
  22. package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
  23. package/src/lib/angular-pending-tasks.plugin.js +17 -18
  24. package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
  25. package/src/lib/angular-vite-plugin.d.ts +231 -40
  26. package/src/lib/angular-vite-plugin.js +1948 -964
  27. package/src/lib/angular-vite-plugin.js.map +1 -1
  28. package/src/lib/angular-vitest-plugin.d.ts +19 -15
  29. package/src/lib/angular-vitest-plugin.js +99 -114
  30. package/src/lib/angular-vitest-plugin.js.map +1 -1
  31. package/src/lib/compiler-plugin.d.ts +11 -11
  32. package/src/lib/compiler-plugin.js +43 -44
  33. package/src/lib/compiler-plugin.js.map +1 -1
  34. package/src/lib/component-resolvers.d.ts +23 -5
  35. package/src/lib/component-resolvers.js +153 -63
  36. package/src/lib/component-resolvers.js.map +1 -1
  37. package/src/lib/host.d.ts +10 -8
  38. package/src/lib/host.js +109 -101
  39. package/src/lib/host.js.map +1 -1
  40. package/src/lib/live-reload-plugin.d.ts +5 -5
  41. package/src/lib/live-reload-plugin.js +57 -62
  42. package/src/lib/live-reload-plugin.js.map +1 -1
  43. package/src/lib/models.d.ts +9 -9
  44. package/src/lib/nx-folder-plugin.d.ts +5 -5
  45. package/src/lib/nx-folder-plugin.js +18 -16
  46. package/src/lib/nx-folder-plugin.js.map +1 -1
  47. package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
  48. package/src/lib/plugins/file-replacements.plugin.js +40 -62
  49. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  50. package/src/lib/router-plugin.d.ts +1 -1
  51. package/src/lib/router-plugin.js +23 -23
  52. package/src/lib/router-plugin.js.map +1 -1
  53. package/src/lib/style-pipeline.d.ts +15 -0
  54. package/src/lib/style-pipeline.js +31 -0
  55. package/src/lib/style-pipeline.js.map +1 -0
  56. package/src/lib/style-preprocessor.d.ts +35 -0
  57. package/src/lib/style-preprocessor.js +35 -0
  58. package/src/lib/style-preprocessor.js.map +1 -0
  59. package/src/lib/stylesheet-registry.d.ts +73 -0
  60. package/src/lib/stylesheet-registry.js +168 -0
  61. package/src/lib/stylesheet-registry.js.map +1 -0
  62. package/src/lib/tools/package.json +2 -7
  63. package/src/lib/tools/src/builders/vite/vite-build.impl.js +31 -38
  64. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  65. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +51 -62
  66. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  67. package/src/lib/tools/src/index.js +0 -2
  68. package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
  69. package/src/lib/utils/debug-harness.d.ts +23 -0
  70. package/src/lib/utils/debug-harness.js +88 -0
  71. package/src/lib/utils/debug-harness.js.map +1 -0
  72. package/src/lib/utils/debug-log-file.d.ts +5 -0
  73. package/src/lib/utils/debug-log-file.js +56 -0
  74. package/src/lib/utils/debug-log-file.js.map +1 -0
  75. package/src/lib/utils/debug.d.ts +26 -0
  76. package/src/lib/utils/debug.js +35 -0
  77. package/src/lib/utils/debug.js.map +1 -0
  78. package/src/lib/utils/devkit.d.ts +6 -6
  79. package/src/lib/utils/devkit.js +34 -38
  80. package/src/lib/utils/devkit.js.map +1 -1
  81. package/src/lib/utils/hmr-candidates.d.ts +28 -28
  82. package/src/lib/utils/plugin-config.d.ts +30 -0
  83. package/src/lib/utils/plugin-config.js +64 -0
  84. package/src/lib/utils/plugin-config.js.map +1 -0
  85. package/src/lib/utils/rolldown.d.ts +2 -0
  86. package/src/lib/utils/rolldown.js +12 -0
  87. package/src/lib/utils/rolldown.js.map +1 -0
  88. package/src/lib/utils/source-file-cache.d.ts +8 -15
  89. package/src/lib/utils/source-file-cache.js +35 -37
  90. package/src/lib/utils/source-file-cache.js.map +1 -1
  91. package/src/lib/utils/virtual-ids.d.ts +8 -0
  92. package/src/lib/utils/virtual-ids.js +35 -0
  93. package/src/lib/utils/virtual-ids.js.map +1 -0
  94. package/src/lib/utils/virtual-resources.d.ts +31 -0
  95. package/src/lib/utils/virtual-resources.js +60 -0
  96. package/src/lib/utils/virtual-resources.js.map +1 -0
  97. package/src/test-setup.d.ts +2 -0
  98. package/setup-vitest.d.ts +0 -4
  99. package/setup-vitest.js +0 -215
  100. package/setup-vitest.js.map +0 -1
  101. package/src/lib/models.js +0 -1
  102. package/src/lib/models.js.map +0 -1
  103. package/src/lib/tools/README.md +0 -3
  104. package/src/lib/tools/src/index.d.ts +0 -0
  105. package/src/lib/tools/src/index.js.map +0 -1
  106. package/src/lib/utils/compiler-plugin-options.js +0 -1
  107. package/src/lib/utils/compiler-plugin-options.js.map +0 -1
  108. package/src/lib/utils/hmr-candidates.js +0 -272
  109. package/src/lib/utils/hmr-candidates.js.map +0 -1
@@ -0,0 +1,73 @@
1
+ import type { StylePreprocessor, StylesheetDependency, StylesheetDiagnostic, StylesheetTransformResult, StylesheetTransformContext } from "./style-preprocessor.js";
2
+ export interface AnalogStylesheetRecord {
3
+ publicId: string;
4
+ sourcePath?: string;
5
+ originalCode?: string;
6
+ normalizedCode: string;
7
+ dependencies?: StylesheetDependency[];
8
+ diagnostics?: StylesheetDiagnostic[];
9
+ tags?: string[];
10
+ }
11
+ export declare class AnalogStylesheetRegistry {
12
+ private servedById;
13
+ private servedAliasToId;
14
+ private externalRequestToSource;
15
+ /**
16
+ * Maps a real source stylesheet path back to the generated public stylesheet
17
+ * ids Analog serves for Angular. This is stable across requests and lets HMR
18
+ * reason about "which virtual stylesheet came from this source file?"
19
+ */
20
+ private sourceToPublicIds;
21
+ /**
22
+ * Tracks the live request ids Vite/Angular have actually served for a source
23
+ * stylesheet, including both `?direct&ngcomp=...` CSS modules and
24
+ * `?ngcomp=...` JS wrapper modules. HMR must use these live request ids
25
+ * because Angular component styles are no longer addressed by their original
26
+ * file paths once externalized.
27
+ */
28
+ private sourceToRequestIds;
29
+ private sourceToDependencies;
30
+ private sourceToDiagnostics;
31
+ private sourceToTags;
32
+ /**
33
+ * Canonicalizes browser-facing stylesheet request ids so Vite timestamp
34
+ * variants (`?t=...`) and path-shape variants (`abc.css?...` vs
35
+ * `/abc.css?...`) all collapse onto one logical module identity.
36
+ *
37
+ * This is critical for Angular component stylesheet HMR because the browser
38
+ * can keep both timestamped and non-timestamped requests alive for the same
39
+ * externalized stylesheet. If Analog tracks them as distinct resources, HMR
40
+ * can update one module while the browser continues rendering another stale
41
+ * module for the same public stylesheet id.
42
+ */
43
+ private normalizeRequestId;
44
+ get servedCount(): number;
45
+ get externalCount(): number;
46
+ hasServed(requestId: string): boolean;
47
+ getServedContent(requestId: string): string | undefined;
48
+ resolveExternalSource(requestId: string): string | undefined;
49
+ getPublicIdsForSource(sourcePath: string): string[];
50
+ getRequestIdsForSource(sourcePath: string): string[];
51
+ getDependenciesForSource(sourcePath: string): StylesheetDependency[];
52
+ getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[];
53
+ getTagsForSource(sourcePath: string): string[];
54
+ registerExternalRequest(requestId: string, sourcePath: string): void;
55
+ registerActiveRequest(requestId: string): void;
56
+ registerServedStylesheet(record: AnalogStylesheetRecord, aliases?: string[]): void;
57
+ private recomputeSourceMetadata;
58
+ private resolveServedRecord;
59
+ }
60
+ export declare function preprocessStylesheet(code: string, filename: string, stylePreprocessor?: StylePreprocessor, context?: StylesheetTransformContext): string;
61
+ export declare function preprocessStylesheetResult(code: string, filename: string, stylePreprocessor?: StylePreprocessor, context?: StylesheetTransformContext): StylesheetTransformResult;
62
+ export declare function rewriteRelativeCssImports(code: string, filename: string): string;
63
+ export declare function registerStylesheetContent(registry: AnalogStylesheetRegistry, { code, dependencies, diagnostics, tags, containingFile, className, order, inlineStylesExtension, resourceFile }: {
64
+ code: string;
65
+ dependencies?: StylesheetDependency[];
66
+ diagnostics?: StylesheetDiagnostic[];
67
+ tags?: string[];
68
+ containingFile: string;
69
+ className?: string;
70
+ order?: number;
71
+ inlineStylesExtension: string;
72
+ resourceFile?: string;
73
+ }): string;
@@ -0,0 +1,168 @@
1
+ import { normalizeStylesheetTransformResult } from "./style-preprocessor.js";
2
+ import { createHash } from "node:crypto";
3
+ import { dirname, normalize, resolve } from "node:path";
4
+ import { normalizePath } from "vite";
5
+ //#region packages/vite-plugin-angular/src/lib/stylesheet-registry.ts
6
+ var AnalogStylesheetRegistry = class {
7
+ servedById = /* @__PURE__ */ new Map();
8
+ servedAliasToId = /* @__PURE__ */ new Map();
9
+ externalRequestToSource = /* @__PURE__ */ new Map();
10
+ /**
11
+ * Maps a real source stylesheet path back to the generated public stylesheet
12
+ * ids Analog serves for Angular. This is stable across requests and lets HMR
13
+ * reason about "which virtual stylesheet came from this source file?"
14
+ */
15
+ sourceToPublicIds = /* @__PURE__ */ new Map();
16
+ /**
17
+ * Tracks the live request ids Vite/Angular have actually served for a source
18
+ * stylesheet, including both `?direct&ngcomp=...` CSS modules and
19
+ * `?ngcomp=...` JS wrapper modules. HMR must use these live request ids
20
+ * because Angular component styles are no longer addressed by their original
21
+ * file paths once externalized.
22
+ */
23
+ sourceToRequestIds = /* @__PURE__ */ new Map();
24
+ sourceToDependencies = /* @__PURE__ */ new Map();
25
+ sourceToDiagnostics = /* @__PURE__ */ new Map();
26
+ sourceToTags = /* @__PURE__ */ new Map();
27
+ /**
28
+ * Canonicalizes browser-facing stylesheet request ids so Vite timestamp
29
+ * variants (`?t=...`) and path-shape variants (`abc.css?...` vs
30
+ * `/abc.css?...`) all collapse onto one logical module identity.
31
+ *
32
+ * This is critical for Angular component stylesheet HMR because the browser
33
+ * can keep both timestamped and non-timestamped requests alive for the same
34
+ * externalized stylesheet. If Analog tracks them as distinct resources, HMR
35
+ * can update one module while the browser continues rendering another stale
36
+ * module for the same public stylesheet id.
37
+ */
38
+ normalizeRequestId(requestId) {
39
+ const [rawPathname, rawSearch = ""] = requestId.split("?");
40
+ const normalizedPathname = rawPathname.replace(/^\//, "");
41
+ if (!rawSearch) return normalizedPathname;
42
+ const normalizedSearch = rawSearch.split("&").filter((segment) => segment.length > 0).filter((segment) => {
43
+ const [key] = segment.split("=");
44
+ return key !== "t";
45
+ }).join("&");
46
+ return normalizedSearch ? `${normalizedPathname}?${normalizedSearch}` : normalizedPathname;
47
+ }
48
+ get servedCount() {
49
+ return this.servedById.size;
50
+ }
51
+ get externalCount() {
52
+ return this.externalRequestToSource.size;
53
+ }
54
+ hasServed(requestId) {
55
+ return this.resolveServedRecord(requestId) !== void 0;
56
+ }
57
+ getServedContent(requestId) {
58
+ return this.resolveServedRecord(requestId)?.normalizedCode;
59
+ }
60
+ resolveExternalSource(requestId) {
61
+ const normalizedRequestId = this.normalizeRequestId(requestId);
62
+ return this.externalRequestToSource.get(normalizedRequestId);
63
+ }
64
+ getPublicIdsForSource(sourcePath) {
65
+ return [...this.sourceToPublicIds.get(sourcePath) ?? []];
66
+ }
67
+ getRequestIdsForSource(sourcePath) {
68
+ return [...this.sourceToRequestIds.get(sourcePath) ?? []];
69
+ }
70
+ getDependenciesForSource(sourcePath) {
71
+ return [...this.sourceToDependencies.get(sourcePath) ?? []];
72
+ }
73
+ getDiagnosticsForSource(sourcePath) {
74
+ return [...this.sourceToDiagnostics.get(sourcePath) ?? []];
75
+ }
76
+ getTagsForSource(sourcePath) {
77
+ return [...this.sourceToTags.get(sourcePath) ?? []];
78
+ }
79
+ registerExternalRequest(requestId, sourcePath) {
80
+ this.externalRequestToSource.set(this.normalizeRequestId(requestId), sourcePath);
81
+ }
82
+ registerActiveRequest(requestId) {
83
+ const normalizedRequestId = this.normalizeRequestId(requestId);
84
+ const requestPath = normalizedRequestId.split("?")[0];
85
+ const sourcePath = this.resolveExternalSource(requestPath) ?? this.resolveExternalSource(requestPath.replace(/^\//, ""));
86
+ if (!sourcePath) return;
87
+ const requestIds = this.sourceToRequestIds.get(sourcePath) ?? /* @__PURE__ */ new Set();
88
+ requestIds.add(normalizedRequestId);
89
+ if (normalizedRequestId.includes("?direct&ngcomp=")) requestIds.add(normalizedRequestId.replace("?direct&ngcomp=", "?ngcomp="));
90
+ this.sourceToRequestIds.set(sourcePath, requestIds);
91
+ }
92
+ registerServedStylesheet(record, aliases = []) {
93
+ const publicId = this.normalizeRequestId(record.publicId);
94
+ this.servedById.set(publicId, {
95
+ ...record,
96
+ publicId
97
+ });
98
+ this.servedAliasToId.set(publicId, publicId);
99
+ for (const alias of aliases) this.servedAliasToId.set(this.normalizeRequestId(alias), publicId);
100
+ if (record.sourcePath) {
101
+ const publicIds = this.sourceToPublicIds.get(record.sourcePath) ?? /* @__PURE__ */ new Set();
102
+ publicIds.add(publicId);
103
+ this.sourceToPublicIds.set(record.sourcePath, publicIds);
104
+ this.recomputeSourceMetadata(record.sourcePath);
105
+ }
106
+ }
107
+ recomputeSourceMetadata(sourcePath) {
108
+ const dependencies = /* @__PURE__ */ new Map();
109
+ const diagnostics = /* @__PURE__ */ new Map();
110
+ const tags = /* @__PURE__ */ new Set();
111
+ for (const publicId of this.sourceToPublicIds.get(sourcePath) ?? []) {
112
+ const record = this.servedById.get(publicId);
113
+ if (!record) continue;
114
+ for (const dependency of record.dependencies ?? []) {
115
+ const key = `${dependency.kind ?? "unknown"}:${dependency.id}:${dependency.owner ?? ""}`;
116
+ dependencies.set(key, dependency);
117
+ }
118
+ for (const diagnostic of record.diagnostics ?? []) {
119
+ const key = `${diagnostic.severity}:${diagnostic.code}:${diagnostic.message}`;
120
+ diagnostics.set(key, diagnostic);
121
+ }
122
+ for (const tag of record.tags ?? []) tags.add(tag);
123
+ }
124
+ this.sourceToDependencies.set(sourcePath, [...dependencies.values()]);
125
+ this.sourceToDiagnostics.set(sourcePath, [...diagnostics.values()]);
126
+ this.sourceToTags.set(sourcePath, [...tags]);
127
+ }
128
+ resolveServedRecord(requestId) {
129
+ const normalizedRequestId = this.normalizeRequestId(requestId);
130
+ const publicId = this.servedAliasToId.get(normalizedRequestId) ?? this.servedAliasToId.get(normalizedRequestId.split("?")[0]) ?? normalizedRequestId.split("?")[0];
131
+ return this.servedById.get(publicId);
132
+ }
133
+ };
134
+ function preprocessStylesheet(code, filename, stylePreprocessor, context) {
135
+ return preprocessStylesheetResult(code, filename, stylePreprocessor, context).code;
136
+ }
137
+ function preprocessStylesheetResult(code, filename, stylePreprocessor, context) {
138
+ return normalizeStylesheetTransformResult(stylePreprocessor?.(code, filename, context), code);
139
+ }
140
+ function rewriteRelativeCssImports(code, filename) {
141
+ const cssDir = dirname(filename);
142
+ return code.replace(/@import\s+(?:url\(\s*(["']?)(\.[^'")\s;]+)\1\s*\)|(["'])(\.[^'"]+)\3)/g, (_match, urlQuote, urlPath, stringQuote, stringPath) => {
143
+ const absPath = resolve(cssDir, urlPath ?? stringPath);
144
+ if (typeof urlPath === "string") return `@import url(${urlQuote}${absPath}${urlQuote})`;
145
+ return `@import ${stringQuote}${absPath}${stringQuote}`;
146
+ });
147
+ }
148
+ function registerStylesheetContent(registry, { code, dependencies, diagnostics, tags, containingFile, className, order, inlineStylesExtension, resourceFile }) {
149
+ const stylesheetId = `${createHash("sha256").update(containingFile).update(className ?? "").update(String(order ?? 0)).update(code).digest("hex")}.${inlineStylesExtension}`;
150
+ const aliases = [];
151
+ if (resourceFile) {
152
+ const normalizedResourceFile = normalizePath(normalize(resourceFile));
153
+ aliases.push(resourceFile, normalizedResourceFile, resourceFile.replace(/^\//, ""), normalizedResourceFile.replace(/^\//, ""));
154
+ }
155
+ registry.registerServedStylesheet({
156
+ publicId: stylesheetId,
157
+ sourcePath: resourceFile,
158
+ normalizedCode: code,
159
+ dependencies,
160
+ diagnostics,
161
+ tags
162
+ }, aliases);
163
+ return stylesheetId;
164
+ }
165
+ //#endregion
166
+ export { AnalogStylesheetRegistry, preprocessStylesheet, preprocessStylesheetResult, registerStylesheetContent, rewriteRelativeCssImports };
167
+
168
+ //# sourceMappingURL=stylesheet-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stylesheet-registry.js","names":[],"sources":["../../../src/lib/stylesheet-registry.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { dirname, normalize, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\nimport type {\n StylePreprocessor,\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetTransformResult,\n StylesheetTransformContext,\n} from './style-preprocessor.js';\nimport { normalizeStylesheetTransformResult as normalizeTransformResult } from './style-preprocessor.js';\n\nexport interface AnalogStylesheetRecord {\n publicId: string;\n sourcePath?: string;\n originalCode?: string;\n normalizedCode: string;\n dependencies?: StylesheetDependency[];\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n}\n\nexport class AnalogStylesheetRegistry {\n private servedById = new Map<string, AnalogStylesheetRecord>();\n private servedAliasToId = new Map<string, string>();\n private externalRequestToSource = new Map<string, string>();\n /**\n * Maps a real source stylesheet path back to the generated public stylesheet\n * ids Analog serves for Angular. This is stable across requests and lets HMR\n * reason about \"which virtual stylesheet came from this source file?\"\n */\n private sourceToPublicIds = new Map<string, Set<string>>();\n /**\n * Tracks the live request ids Vite/Angular have actually served for a source\n * stylesheet, including both `?direct&ngcomp=...` CSS modules and\n * `?ngcomp=...` JS wrapper modules. HMR must use these live request ids\n * because Angular component styles are no longer addressed by their original\n * file paths once externalized.\n */\n private sourceToRequestIds = new Map<string, Set<string>>();\n private sourceToDependencies = new Map<string, StylesheetDependency[]>();\n private sourceToDiagnostics = new Map<string, StylesheetDiagnostic[]>();\n private sourceToTags = new Map<string, string[]>();\n\n /**\n * Canonicalizes browser-facing stylesheet request ids so Vite timestamp\n * variants (`?t=...`) and path-shape variants (`abc.css?...` vs\n * `/abc.css?...`) all collapse onto one logical module identity.\n *\n * This is critical for Angular component stylesheet HMR because the browser\n * can keep both timestamped and non-timestamped requests alive for the same\n * externalized stylesheet. If Analog tracks them as distinct resources, HMR\n * can update one module while the browser continues rendering another stale\n * module for the same public stylesheet id.\n */\n private normalizeRequestId(requestId: string): string {\n const [rawPathname, rawSearch = ''] = requestId.split('?');\n const normalizedPathname = rawPathname.replace(/^\\//, '');\n\n if (!rawSearch) {\n return normalizedPathname;\n }\n\n // Preserve bare query flags like `?direct&ngcomp=...` exactly. Using\n // URLSearchParams reserializes `direct` as `direct=`, which changes the\n // module identity and breaks Vite module-graph lookups for Angular's\n // externalized component stylesheet requests.\n const normalizedSearch = rawSearch\n .split('&')\n .filter((segment) => segment.length > 0)\n .filter((segment) => {\n const [key] = segment.split('=');\n return key !== 't';\n })\n .join('&');\n\n return normalizedSearch\n ? `${normalizedPathname}?${normalizedSearch}`\n : normalizedPathname;\n }\n\n get servedCount(): number {\n return this.servedById.size;\n }\n\n get externalCount(): number {\n return this.externalRequestToSource.size;\n }\n\n hasServed(requestId: string): boolean {\n return this.resolveServedRecord(requestId) !== undefined;\n }\n\n getServedContent(requestId: string): string | undefined {\n return this.resolveServedRecord(requestId)?.normalizedCode;\n }\n\n resolveExternalSource(requestId: string): string | undefined {\n const normalizedRequestId = this.normalizeRequestId(requestId);\n return this.externalRequestToSource.get(normalizedRequestId);\n }\n\n getPublicIdsForSource(sourcePath: string): string[] {\n return [...(this.sourceToPublicIds.get(sourcePath) ?? [])];\n }\n\n getRequestIdsForSource(sourcePath: string): string[] {\n return [...(this.sourceToRequestIds.get(sourcePath) ?? [])];\n }\n\n getDependenciesForSource(sourcePath: string): StylesheetDependency[] {\n return [...(this.sourceToDependencies.get(sourcePath) ?? [])];\n }\n\n getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[] {\n return [...(this.sourceToDiagnostics.get(sourcePath) ?? [])];\n }\n\n getTagsForSource(sourcePath: string): string[] {\n return [...(this.sourceToTags.get(sourcePath) ?? [])];\n }\n\n registerExternalRequest(requestId: string, sourcePath: string): void {\n this.externalRequestToSource.set(\n this.normalizeRequestId(requestId),\n sourcePath,\n );\n }\n\n registerActiveRequest(requestId: string): void {\n // Requests arrive in multiple shapes depending on who asked for the\n // stylesheet (`abc123.css?...` vs `/abc123.css?...`). Normalize both back to\n // the source file so later HMR events for `/src/...component.css` can find\n // the currently active virtual requests.\n const normalizedRequestId = this.normalizeRequestId(requestId);\n const requestPath = normalizedRequestId.split('?')[0];\n const sourcePath =\n this.resolveExternalSource(requestPath) ??\n this.resolveExternalSource(requestPath.replace(/^\\//, ''));\n if (!sourcePath) {\n return;\n }\n\n const requestIds = this.sourceToRequestIds.get(sourcePath) ?? new Set();\n requestIds.add(normalizedRequestId);\n // Angular component styles are served through both a direct CSS request\n // (`?direct&ngcomp=...`) and a JS wrapper request (`?ngcomp=...`). The\n // browser can already have the wrapper loaded even when Vite's live module\n // graph only surfaces the direct request during a CSS-only edit. Track the\n // derived wrapper id eagerly so HMR can reason about the browser-visible\n // stylesheet identity without waiting for that wrapper request to be\n // observed later in the session.\n if (normalizedRequestId.includes('?direct&ngcomp=')) {\n requestIds.add(\n normalizedRequestId.replace('?direct&ngcomp=', '?ngcomp='),\n );\n }\n this.sourceToRequestIds.set(sourcePath, requestIds);\n }\n\n registerServedStylesheet(\n record: AnalogStylesheetRecord,\n aliases: string[] = [],\n ): void {\n const publicId = this.normalizeRequestId(record.publicId);\n this.servedById.set(publicId, { ...record, publicId });\n this.servedAliasToId.set(publicId, publicId);\n\n for (const alias of aliases) {\n this.servedAliasToId.set(this.normalizeRequestId(alias), publicId);\n }\n\n if (record.sourcePath) {\n const publicIds =\n this.sourceToPublicIds.get(record.sourcePath) ?? new Set();\n publicIds.add(publicId);\n this.sourceToPublicIds.set(record.sourcePath, publicIds);\n this.recomputeSourceMetadata(record.sourcePath);\n }\n }\n\n private recomputeSourceMetadata(sourcePath: string): void {\n const dependencies = new Map<string, StylesheetDependency>();\n const diagnostics = new Map<string, StylesheetDiagnostic>();\n const tags = new Set<string>();\n\n for (const publicId of this.sourceToPublicIds.get(sourcePath) ?? []) {\n const record = this.servedById.get(publicId);\n if (!record) {\n continue;\n }\n\n for (const dependency of record.dependencies ?? []) {\n const key = `${dependency.kind ?? 'unknown'}:${dependency.id}:${dependency.owner ?? ''}`;\n dependencies.set(key, dependency);\n }\n\n for (const diagnostic of record.diagnostics ?? []) {\n const key = `${diagnostic.severity}:${diagnostic.code}:${diagnostic.message}`;\n diagnostics.set(key, diagnostic);\n }\n\n for (const tag of record.tags ?? []) {\n tags.add(tag);\n }\n }\n\n this.sourceToDependencies.set(sourcePath, [...dependencies.values()]);\n this.sourceToDiagnostics.set(sourcePath, [...diagnostics.values()]);\n this.sourceToTags.set(sourcePath, [...tags]);\n }\n\n private resolveServedRecord(\n requestId: string,\n ): AnalogStylesheetRecord | undefined {\n const normalizedRequestId = this.normalizeRequestId(requestId);\n const publicId =\n this.servedAliasToId.get(normalizedRequestId) ??\n this.servedAliasToId.get(normalizedRequestId.split('?')[0]) ??\n normalizedRequestId.split('?')[0];\n return this.servedById.get(publicId);\n }\n}\n\nexport function preprocessStylesheet(\n code: string,\n filename: string,\n stylePreprocessor?: StylePreprocessor,\n context?: StylesheetTransformContext,\n): string {\n return preprocessStylesheetResult(code, filename, stylePreprocessor, context)\n .code;\n}\n\nexport function preprocessStylesheetResult(\n code: string,\n filename: string,\n stylePreprocessor?: StylePreprocessor,\n context?: StylesheetTransformContext,\n): StylesheetTransformResult {\n return normalizeTransformResult(\n stylePreprocessor?.(code, filename, context),\n code,\n );\n}\n\nexport function rewriteRelativeCssImports(\n code: string,\n filename: string,\n): string {\n const cssDir = dirname(filename);\n return code.replace(\n /@import\\s+(?:url\\(\\s*([\"']?)(\\.[^'\")\\s;]+)\\1\\s*\\)|([\"'])(\\.[^'\"]+)\\3)/g,\n (_match, urlQuote, urlPath, stringQuote, stringPath) => {\n const relPath = urlPath ?? stringPath;\n const absPath = resolve(cssDir, relPath);\n\n if (typeof urlPath === 'string') {\n return `@import url(${urlQuote}${absPath}${urlQuote})`;\n }\n\n return `@import ${stringQuote}${absPath}${stringQuote}`;\n },\n );\n}\n\nexport function registerStylesheetContent(\n registry: AnalogStylesheetRegistry,\n {\n code,\n dependencies,\n diagnostics,\n tags,\n containingFile,\n className,\n order,\n inlineStylesExtension,\n resourceFile,\n }: {\n code: string;\n dependencies?: StylesheetDependency[];\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n containingFile: string;\n className?: string;\n order?: number;\n inlineStylesExtension: string;\n resourceFile?: string;\n },\n): string {\n const id = createHash('sha256')\n .update(containingFile)\n .update(className ?? '')\n .update(String(order ?? 0))\n .update(code)\n .digest('hex');\n const stylesheetId = `${id}.${inlineStylesExtension}`;\n\n const aliases: string[] = [];\n\n if (resourceFile) {\n const normalizedResourceFile = normalizePath(normalize(resourceFile));\n // Avoid basename-only aliases here: shared filenames like `index.css`\n // can collide across components and break HMR lookups.\n aliases.push(\n resourceFile,\n normalizedResourceFile,\n resourceFile.replace(/^\\//, ''),\n normalizedResourceFile.replace(/^\\//, ''),\n );\n }\n\n registry.registerServedStylesheet(\n {\n publicId: stylesheetId,\n sourcePath: resourceFile,\n normalizedCode: code,\n dependencies,\n diagnostics,\n tags,\n },\n aliases,\n );\n\n return stylesheetId;\n}\n"],"mappings":";;;;;AAsBA,IAAa,2BAAb,MAAsC;CACpC,6BAAqB,IAAI,KAAqC;CAC9D,kCAA0B,IAAI,KAAqB;CACnD,0CAAkC,IAAI,KAAqB;;;;;;CAM3D,oCAA4B,IAAI,KAA0B;;;;;;;;CAQ1D,qCAA6B,IAAI,KAA0B;CAC3D,uCAA+B,IAAI,KAAqC;CACxE,sCAA8B,IAAI,KAAqC;CACvE,+BAAuB,IAAI,KAAuB;;;;;;;;;;;;CAalD,mBAA2B,WAA2B;EACpD,MAAM,CAAC,aAAa,YAAY,MAAM,UAAU,MAAM,IAAI;EAC1D,MAAM,qBAAqB,YAAY,QAAQ,OAAO,GAAG;AAEzD,MAAI,CAAC,UACH,QAAO;EAOT,MAAM,mBAAmB,UACtB,MAAM,IAAI,CACV,QAAQ,YAAY,QAAQ,SAAS,EAAE,CACvC,QAAQ,YAAY;GACnB,MAAM,CAAC,OAAO,QAAQ,MAAM,IAAI;AAChC,UAAO,QAAQ;IACf,CACD,KAAK,IAAI;AAEZ,SAAO,mBACH,GAAG,mBAAmB,GAAG,qBACzB;;CAGN,IAAI,cAAsB;AACxB,SAAO,KAAK,WAAW;;CAGzB,IAAI,gBAAwB;AAC1B,SAAO,KAAK,wBAAwB;;CAGtC,UAAU,WAA4B;AACpC,SAAO,KAAK,oBAAoB,UAAU,KAAK,KAAA;;CAGjD,iBAAiB,WAAuC;AACtD,SAAO,KAAK,oBAAoB,UAAU,EAAE;;CAG9C,sBAAsB,WAAuC;EAC3D,MAAM,sBAAsB,KAAK,mBAAmB,UAAU;AAC9D,SAAO,KAAK,wBAAwB,IAAI,oBAAoB;;CAG9D,sBAAsB,YAA8B;AAClD,SAAO,CAAC,GAAI,KAAK,kBAAkB,IAAI,WAAW,IAAI,EAAE,CAAE;;C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,UACA,mBACA,SACQ;AACR,QAAO,2BAA2B,MAAM,UAAU,mBAAmB,QAAQ,CAC1E;;AAGL,SAAgB,2BACd,MACA,UACA,mBACA,SAC2B;AAC3B,QAAO,mCACL,oBAAoB,MAAM,UAAU,QAAQ,EAC5C,KACD;;AAGH,SAAgB,0BACd,MACA,UACQ;CACR,MAAM,SAAS,QAAQ,SAAS;AAChC,QAAO,KAAK,QACV,2EACC,QAAQ,UAAU,SAAS,aAAa,eAAe;EAEtD,MAAM,UAAU,QAAQ,QADR,WAAW,WACa;AAExC,MAAI,OAAO,YAAY,SACrB,QAAO,eAAe,WAAW,UAAU,SAAS;AAGtD,SAAO,WAAW,cAAc,UAAU;GAE7C;;AAGH,SAAgB,0BACd,UACA,EACE,MACA,cACA,aACA,MACA,gBACA,WACA,OACA,uBACA,gBAYM;CAOR,MAAM,eAAe,GANV,WAAW,SAAS,CAC5B,OAAO,eAAe,CACtB,OAAO,aAAa,GAAG,CACvB,OAAO,OAAO,SAAS,EAAE,CAAC,CAC1B,OAAO,KAAK,CACZ,OAAO,MAAM,CACW,GAAG;CAE9B,MAAM,UAAoB,EAAE;AAE5B,KAAI,cAAc;EAChB,MAAM,yBAAyB,cAAc,UAAU,aAAa,CAAC;AAGrE,UAAQ,KACN,cACA,wBACA,aAAa,QAAQ,OAAO,GAAG,EAC/B,uBAAuB,QAAQ,OAAO,GAAG,CAC1C;;AAGH,UAAS,yBACP;EACE,UAAU;EACV,YAAY;EACZ,gBAAgB;EAChB;EACA;EACA;EACD,EACD,QACD;AAED,QAAO"}
@@ -1,8 +1,3 @@
1
1
  {
2
- "name": "@analogjs/vite-plugin-angular-tools",
3
- "version": "0.0.1",
4
- "main": "src/index.js",
5
- "types": "./src/index.d.ts",
6
- "module": "./src/index.js",
7
- "type": "module"
8
- }
2
+ "type": "commonjs"
3
+ }
@@ -1,41 +1,34 @@
1
- import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect';
1
+ let _angular_devkit_architect = require("@angular-devkit/architect");
2
+ //#region packages/vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts
2
3
  async function viteBuilder(options, context) {
3
- const { createBuilder } = await Function('return import("vite")')();
4
- if (!context.target) {
5
- throw new Error('Builder must be executed with a target');
6
- }
7
- const projectConfig = await context.getProjectMetadata(context.target);
8
- const projectName = context.target.project;
9
- const configuration = context.target.configuration || 'production';
10
- const buildTargetSpecifier = `::${configuration}`;
11
- const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');
12
- const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
13
- const rawBuildOptions = await context.getTargetOptions(buildTarget);
14
- const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
15
- const buildConfig = {
16
- configFile: options.configFile,
17
- root: projectConfig.root,
18
- mode: (process.env.NODE_ENV ??
19
- buildOptions.mode ??
20
- configuration),
21
- build: {
22
- outDir: options.outputPath,
23
- sourcemap: !!buildOptions.sourcemap,
24
- },
25
- };
26
- try {
27
- const builder = await createBuilder(buildConfig, false);
28
- await builder.buildApp();
29
- return {
30
- success: true,
31
- };
32
- }
33
- catch (e) {
34
- console.error(e);
35
- return {
36
- success: false,
37
- };
38
- }
4
+ const { createBuilder } = await Function("return import(\"vite\")")();
5
+ if (!context.target) throw new Error("Builder must be executed with a target");
6
+ const projectConfig = await context.getProjectMetadata(context.target);
7
+ const projectName = context.target.project;
8
+ const configuration = context.target.configuration || "production";
9
+ const buildTarget = (0, _angular_devkit_architect.targetFromTargetString)(`::${configuration}`, projectName, "build");
10
+ const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
11
+ const rawBuildOptions = await context.getTargetOptions(buildTarget);
12
+ const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
13
+ const buildConfig = {
14
+ configFile: options.configFile,
15
+ root: projectConfig.root,
16
+ mode: process.env.NODE_ENV ?? buildOptions.mode ?? configuration,
17
+ build: {
18
+ outDir: options.outputPath,
19
+ sourcemap: !!buildOptions.sourcemap
20
+ }
21
+ };
22
+ try {
23
+ await (await createBuilder(buildConfig, false)).buildApp();
24
+ return { success: true };
25
+ } catch (e) {
26
+ console.error(e);
27
+ return { success: false };
28
+ }
39
29
  }
40
- export default createBuilder(viteBuilder);
30
+ var vite_build_impl_default = (0, _angular_devkit_architect.createBuilder)(viteBuilder);
31
+ //#endregion
32
+ module.exports = vite_build_impl_default;
33
+
41
34
  //# sourceMappingURL=vite-build.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-build.impl.js","sourceRoot":"","sources":["../../../../../../../../../packages/vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAInC,KAAK,UAAU,WAAW,CACxB,OAAwB,EACxB,OAAuB;IAEvB,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;IACpE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;IAC3C,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,YAAY,CAAC;IACnE,MAAM,oBAAoB,GAAG,KAAK,aAAa,EAAE,CAAC;IAClD,MAAM,WAAW,GAAG,sBAAsB,CACxC,oBAAoB,EACpB,WAAW,EACX,OAAO,CACR,CAAC;IAEF,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC9E,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,eAAe,CAChD,eAAe,EACf,kBAAkB,CACnB,CAAC;IAEF,MAAM,WAAW,GAAiB;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,IAAI,EAAE,aAAa,CAAC,IAAc;QAClC,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ;YACzB,YAAY,CAAC,IAAI;YACjB,aAAa,CAAW;QAC1B,KAAK,EAAE;YACL,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS;SACpC;KACF,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACxD,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEzB,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;AACH,CAAC;AAED,eAAe,aAAa,CAAC,WAAW,CAAQ,CAAC"}
1
+ {"version":3,"file":"vite-build.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteBuildSchema } from './schema';\n\nasync function viteBuilder(\n options: ViteBuildSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createBuilder } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const configuration = context.target.configuration || 'production';\n const buildTargetSpecifier = `::${configuration}`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n const buildConfig: InlineConfig = {\n configFile: options.configFile,\n root: projectConfig.root as string,\n mode: (process.env.NODE_ENV ??\n buildOptions.mode ??\n configuration) as string,\n build: {\n outDir: options.outputPath,\n sourcemap: !!buildOptions.sourcemap,\n },\n };\n\n try {\n const builder = await createBuilder(buildConfig, false);\n await builder.buildApp();\n\n return {\n success: true,\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n };\n }\n}\n\nexport default createBuilder(viteBuilder) as any;\n"],"mappings":";;AASA,eAAe,YACb,SACA,SACwB;CACxB,MAAM,EAAE,kBAAkB,MAAM,SAAS,0BAAwB,EAAE;AACnE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CACnC,MAAM,gBAAgB,QAAQ,OAAO,iBAAiB;CAEtD,MAAM,eAAA,GAAA,0BAAA,wBADuB,KAAK,iBAGhC,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAED,MAAM,cAA4B;EAChC,YAAY,QAAQ;EACpB,MAAM,cAAc;EACpB,MAAA,QAAA,IAAA,YACE,aAAa,QACb;EACF,OAAO;GACL,QAAQ,QAAQ;GAChB,WAAW,CAAC,CAAC,aAAa;GAC3B;EACF;AAED,KAAI;AAEF,SADgB,MAAM,cAAc,aAAa,MAAM,EACzC,UAAU;AAExB,SAAO,EACL,SAAS,MACV;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO,EACL,SAAS,OACV;;;AAIL,IAAA,2BAAA,GAAA,0BAAA,eAA6B,YAAY"}
@@ -1,65 +1,54 @@
1
- import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect';
1
+ let _angular_devkit_architect = require("@angular-devkit/architect");
2
+ //#region packages/vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts
2
3
  async function viteDevServerBuilder(options, context) {
3
- const { createServer } = await Function('return import("vite")')();
4
- if (!context.target) {
5
- throw new Error('Builder must be executed with a target');
6
- }
7
- const projectConfig = await context.getProjectMetadata(context.target);
8
- const projectName = context.target.project;
9
- const buildTargetSpecifier = options.buildTarget ?? `::development`;
10
- const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');
11
- const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
12
- const rawBuildOptions = await context.getTargetOptions(buildTarget);
13
- const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
14
- const serverConfig = {
15
- configFile: buildOptions.configFile,
16
- root: projectConfig.root,
17
- mode: (process.env.NODE_ENV ??
18
- buildOptions.mode ??
19
- 'development'),
20
- build: {
21
- sourcemap: !!buildOptions.sourcemap,
22
- },
23
- server: {
24
- hmr: options?.hmr,
25
- port: options?.port,
26
- },
27
- };
28
- try {
29
- const server = await createServer(serverConfig);
30
- await runViteDevServer(server);
31
- const resolvedUrls = [
32
- ...server.resolvedUrls.local,
33
- ...server.resolvedUrls.network,
34
- ];
35
- await new Promise((resolve) => {
36
- process.once('SIGINT', () => resolve());
37
- process.once('SIGTERM', () => resolve());
38
- process.once('exit', () => resolve());
39
- });
40
- return {
41
- success: true,
42
- baseUrl: resolvedUrls[0] ?? '',
43
- };
44
- }
45
- catch (e) {
46
- console.error(e);
47
- return {
48
- success: false,
49
- baseUrl: '',
50
- };
51
- }
4
+ const { createServer } = await Function("return import(\"vite\")")();
5
+ if (!context.target) throw new Error("Builder must be executed with a target");
6
+ const projectConfig = await context.getProjectMetadata(context.target);
7
+ const projectName = context.target.project;
8
+ const buildTarget = (0, _angular_devkit_architect.targetFromTargetString)(options.buildTarget ?? `::development`, projectName, "build");
9
+ const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
10
+ const rawBuildOptions = await context.getTargetOptions(buildTarget);
11
+ const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
12
+ const serverConfig = {
13
+ configFile: buildOptions.configFile,
14
+ root: projectConfig.root,
15
+ mode: process.env.NODE_ENV ?? buildOptions.mode ?? "development",
16
+ build: { sourcemap: !!buildOptions.sourcemap },
17
+ server: {
18
+ hmr: options?.hmr,
19
+ port: options?.port
20
+ }
21
+ };
22
+ try {
23
+ const server = await createServer(serverConfig);
24
+ await server.listen();
25
+ server.printUrls();
26
+ const resolvedUrls = [...server.resolvedUrls.local, ...server.resolvedUrls.network];
27
+ const processOnExit = async () => {
28
+ await server.close();
29
+ };
30
+ await new Promise((resolve) => {
31
+ const shutdown = () => {
32
+ processOnExit().then(() => resolve(), () => resolve());
33
+ };
34
+ process.once("SIGINT", shutdown);
35
+ process.once("SIGTERM", shutdown);
36
+ process.once("exit", shutdown);
37
+ });
38
+ return {
39
+ success: true,
40
+ baseUrl: resolvedUrls[0] ?? ""
41
+ };
42
+ } catch (e) {
43
+ console.error(e);
44
+ return {
45
+ success: false,
46
+ baseUrl: ""
47
+ };
48
+ }
52
49
  }
53
- // vite ViteDevServer
54
- async function runViteDevServer(server) {
55
- await server.listen();
56
- server.printUrls();
57
- const processOnExit = async () => {
58
- await server.close();
59
- };
60
- process.once('SIGINT', processOnExit);
61
- process.once('SIGTERM', processOnExit);
62
- process.once('exit', processOnExit);
63
- }
64
- export default createBuilder(viteDevServerBuilder);
50
+ var dev_server_impl_default = (0, _angular_devkit_architect.createBuilder)(viteDevServerBuilder);
51
+ //#endregion
52
+ module.exports = dev_server_impl_default;
53
+
65
54
  //# sourceMappingURL=dev-server.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev-server.impl.js","sourceRoot":"","sources":["../../../../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I,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AACtC,CAAC;AAED,eAAe,aAAa,CAAC,oBAAoB,CAAQ,CAAC"}
1
+ {"version":3,"file":"dev-server.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteDevServerSchema } from './schema';\n\nasync function viteDevServerBuilder(\n options: ViteDevServerSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createServer } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const buildTargetSpecifier = options.buildTarget ?? `::development`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n const serverConfig: InlineConfig = {\n configFile: buildOptions.configFile as string,\n root: projectConfig.root as string,\n mode: (process.env.NODE_ENV ??\n buildOptions.mode ??\n 'development') as string,\n build: {\n sourcemap: !!buildOptions.sourcemap,\n },\n server: {\n hmr: options?.hmr,\n port: options?.port,\n },\n };\n\n try {\n const server = await createServer(serverConfig);\n await server.listen();\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n const processOnExit = async () => {\n await server.close();\n };\n\n // Use process.once to avoid listener accumulation when Nx invokes\n // multiple builders in the same process during a large build graph.\n await new Promise<void>((resolve) => {\n const shutdown = () => {\n processOnExit().then(\n () => resolve(),\n () => resolve(),\n );\n };\n process.once('SIGINT', shutdown);\n process.once('SIGTERM', shutdown);\n process.once('exit', shutdown);\n });\n\n return {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n baseUrl: '',\n };\n }\n}\n\nexport default createBuilder(viteDevServerBuilder) as any;\n"],"mappings":";;AASA,eAAe,qBACb,SACA,SACwB;CACxB,MAAM,EAAE,iBAAiB,MAAM,SAAS,0BAAwB,EAAE;AAClE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CAEnC,MAAM,eAAA,GAAA,0BAAA,wBADuB,QAAQ,eAAe,iBAGlD,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAED,MAAM,eAA6B;EACjC,YAAY,aAAa;EACzB,MAAM,cAAc;EACpB,MAAA,QAAA,IAAA,YACE,aAAa,QACb;EACF,OAAO,EACL,WAAW,CAAC,CAAC,aAAa,WAC3B;EACD,QAAQ;GACN,KAAK,SAAS;GACd,MAAM,SAAS;GAChB;EACF;AAED,KAAI;EACF,MAAM,SAAS,MAAM,aAAa,aAAa;AAC/C,QAAM,OAAO,QAAQ;AACrB,SAAO,WAAW;EAElB,MAAM,eAAe,CACnB,GAAG,OAAO,aAAa,OACvB,GAAG,OAAO,aAAa,QACxB;EAED,MAAM,gBAAgB,YAAY;AAChC,SAAM,OAAO,OAAO;;AAKtB,QAAM,IAAI,SAAe,YAAY;GACnC,MAAM,iBAAiB;AACrB,mBAAe,CAAC,WACR,SAAS,QACT,SAAS,CAChB;;AAEH,WAAQ,KAAK,UAAU,SAAS;AAChC,WAAQ,KAAK,WAAW,SAAS;AACjC,WAAQ,KAAK,QAAQ,SAAS;IAC9B;AAEF,SAAO;GACL,SAAS;GACT,SAAS,aAAa,MAAM;GAC7B;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO;GACL,SAAS;GACT,SAAS;GACV;;;AAIL,IAAA,2BAAA,GAAA,0BAAA,eAA6B,qBAAqB"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=index.js.map
@@ -1,13 +1,13 @@
1
- import { SourceFileCache } from './source-file-cache';
1
+ import { SourceFileCache } from "./source-file-cache";
2
2
  export interface CompilerPluginOptions {
3
- sourcemap: boolean;
4
- tsconfig: string;
5
- jit?: boolean;
6
- /** Skip TypeScript compilation setup. This is useful to re-use the TypeScript compilation from another plugin. */
7
- noopTypeScriptCompilation?: boolean;
8
- advancedOptimizations?: boolean;
9
- thirdPartySourcemaps?: boolean;
10
- fileReplacements?: Record<string, string>;
11
- sourceFileCache?: SourceFileCache;
12
- incremental: boolean;
3
+ sourcemap: boolean;
4
+ tsconfig: string;
5
+ jit?: boolean;
6
+ /** Skip TypeScript compilation setup. This is useful to re-use the TypeScript compilation from another plugin. */
7
+ noopTypeScriptCompilation?: boolean;
8
+ advancedOptimizations?: boolean;
9
+ thirdPartySourcemaps?: boolean;
10
+ fileReplacements?: Record<string, string>;
11
+ sourceFileCache?: SourceFileCache;
12
+ incremental: boolean;
13
13
  }
@@ -0,0 +1,23 @@
1
+ import type { Debugger } from "obug";
2
+ export type DebugMode = "build" | "dev";
3
+ export interface DebugModeOptions<S extends string = string> {
4
+ scopes?: boolean | S[];
5
+ mode?: DebugMode;
6
+ /**
7
+ * Write debug output to log files under `tmp/debug/` in the workspace root.
8
+ * - `true` or `'single'` — all output to `tmp/debug/analog.log`
9
+ * - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`
10
+ */
11
+ logFile?: boolean | "single" | "scoped";
12
+ }
13
+ export type DebugOption<S extends string = string> = boolean | S[] | DebugModeOptions<S> | DebugModeOptions<S>[];
14
+ export interface DebugHarness<S extends string = string> {
15
+ applyDebugOption(debug: DebugOption<S> | undefined, workspaceRoot?: string): void;
16
+ activateDeferredDebug(command: "build" | "serve"): void;
17
+ /** @internal test-only reset */
18
+ _resetDeferredDebug(): void;
19
+ }
20
+ export declare function createDebugHarness<S extends string = string>(config: {
21
+ fallbackNamespace: string;
22
+ instanceGroups: Debugger[][];
23
+ }): DebugHarness<S>;