@analogjs/platform 3.0.0-alpha.90 → 3.0.0-alpha.92

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 (53) hide show
  1. package/migrations/migrate-to-separated-plugins/migrate-to-separated-plugins.d.ts +2 -0
  2. package/migrations/migrate-to-separated-plugins/migrate-to-separated-plugins.js +203 -0
  3. package/migrations/migrate-to-separated-plugins/migrate-to-separated-plugins.js.map +1 -0
  4. package/package.json +11 -7
  5. package/src/index.d.ts +1 -2
  6. package/src/index.js +1 -2
  7. package/src/index.js.map +1 -1
  8. package/src/lib/clear-client-page-endpoint.js +1 -0
  9. package/src/lib/clear-client-page-endpoint.js.map +1 -1
  10. package/src/lib/deps-plugin.js +17 -6
  11. package/src/lib/deps-plugin.js.map +1 -1
  12. package/src/lib/nitro/analog-nitro-plugin.js +102 -45
  13. package/src/lib/nitro/analog-nitro-plugin.js.map +1 -1
  14. package/src/lib/nitro/get-server-fn-handlers.d.ts +29 -0
  15. package/src/lib/nitro/get-server-fn-handlers.js +66 -0
  16. package/src/lib/nitro/get-server-fn-handlers.js.map +1 -0
  17. package/src/lib/nitro/server-fn-endpoints.d.ts +41 -0
  18. package/src/lib/nitro/server-fn-endpoints.js +57 -0
  19. package/src/lib/nitro/server-fn-endpoints.js.map +1 -0
  20. package/src/lib/nx-plugin/src/generators/app/files/template-angular/src/server/routes/api/v1/hello.ts__template__ +2 -2
  21. package/src/lib/nx-plugin/src/generators/app/files/template-angular/vite.config.ts__template__ +4 -0
  22. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.d.ts +7 -5
  23. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js.map +1 -1
  24. package/src/lib/nx-plugin/src/generators/preset/__snapshots__/generator.spec.ts.snap +3 -1
  25. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.d.ts +5 -5
  26. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js +5 -5
  27. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js.map +1 -1
  28. package/src/lib/options.d.ts +9 -49
  29. package/src/lib/platform-plugin.js +42 -6
  30. package/src/lib/platform-plugin.js.map +1 -1
  31. package/src/lib/route-file-discovery.d.ts +3 -1
  32. package/src/lib/route-file-discovery.js +19 -8
  33. package/src/lib/route-file-discovery.js.map +1 -1
  34. package/src/lib/route-manifest.d.ts +22 -26
  35. package/src/lib/route-manifest.js +58 -189
  36. package/src/lib/route-manifest.js.map +1 -1
  37. package/src/lib/ssr/defer-streaming-plugin.js +97 -0
  38. package/src/lib/ssr/defer-streaming-plugin.js.map +1 -0
  39. package/src/lib/typed-routes-plugin.d.ts +6 -43
  40. package/src/lib/typed-routes-plugin.js +80 -195
  41. package/src/lib/typed-routes-plugin.js.map +1 -1
  42. package/src/lib/utils/debug.js +4 -7
  43. package/src/lib/utils/debug.js.map +1 -1
  44. package/src/lib/utils/rolldown.js +1 -1
  45. package/src/server-mode-plugin.d.ts +1 -1
  46. package/src/server-mode-plugin.js +13 -1
  47. package/src/server-mode-plugin.js.map +1 -1
  48. package/src/lib/json-ld-manifest-plugin.d.ts +0 -41
  49. package/src/lib/json-ld-manifest-plugin.js +0 -84
  50. package/src/lib/json-ld-manifest-plugin.js.map +0 -1
  51. package/src/lib/route-generation-plugin.d.ts +0 -3
  52. package/src/lib/route-generation-plugin.js +0 -45
  53. package/src/lib/route-generation-plugin.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import { Rule } from "@angular-devkit/schematics";
2
+ export default function migrateToSeparatedPlugins(): Rule;
@@ -0,0 +1,203 @@
1
+ import { NodePackageInstallTask } from "@angular-devkit/schematics/tasks/index.js";
2
+ import * as ts from "typescript";
3
+ //#region packages/platform/migrations/migrate-to-separated-plugins/migrate-to-separated-plugins.ts
4
+ var ANALOG_PLATFORM_IMPORT = `from '@analogjs/platform'`;
5
+ var ANGULAR_PLUGIN_IMPORT = `from '@analogjs/vite-plugin-angular'`;
6
+ var NITRO_IMPORTS = [`from '@analogjs/vite-plugin-nitro'`, `from 'nitro/vite'`];
7
+ var ANGULAR_PLUGIN_PKG = "@analogjs/vite-plugin-angular";
8
+ var NITRO_PLUGIN_PKG = "@analogjs/vite-plugin-nitro";
9
+ var MIGRATION_DOC_URL = "https://analogjs.org/docs/guides/migrating-v2-to-v3#analog-angular-and-nitro-are-now-separate-plugins";
10
+ var VITE_CONFIG_EXTENSIONS = [
11
+ ".ts",
12
+ ".mts",
13
+ ".js",
14
+ ".mjs"
15
+ ];
16
+ function isViteConfig(filePath) {
17
+ const file = filePath.slice(filePath.lastIndexOf("/") + 1);
18
+ if (!file.startsWith("vite.config.")) return false;
19
+ return VITE_CONFIG_EXTENSIONS.some((ext) => file.endsWith(ext));
20
+ }
21
+ function usesLegacyPluginShape(source) {
22
+ if (!source.includes(ANALOG_PLATFORM_IMPORT)) return false;
23
+ if (source.includes(ANGULAR_PLUGIN_IMPORT) && NITRO_IMPORTS.some((nitroImport) => source.includes(nitroImport))) return false;
24
+ return /\banalog\s*\(/.test(source);
25
+ }
26
+ function readPackageJson(tree) {
27
+ const content = tree.read("/package.json");
28
+ if (!content) return null;
29
+ const raw = content.toString("utf-8");
30
+ try {
31
+ return {
32
+ raw,
33
+ pkg: JSON.parse(raw)
34
+ };
35
+ } catch {
36
+ return null;
37
+ }
38
+ }
39
+ function getDepVersion(pkg, name) {
40
+ const dev = pkg["devDependencies"] ?? {};
41
+ const reg = pkg["dependencies"] ?? {};
42
+ return dev[name] ?? reg[name];
43
+ }
44
+ function addDependencies(tree, context) {
45
+ const info = readPackageJson(tree);
46
+ if (!info) return false;
47
+ const { pkg, raw } = info;
48
+ const devDeps = { ...pkg["devDependencies"] ?? {} };
49
+ let changed = false;
50
+ const platformVersion = getDepVersion(pkg, "@analogjs/platform") ?? "*";
51
+ const missingPlugins = [ANGULAR_PLUGIN_PKG, NITRO_PLUGIN_PKG].filter((name) => !getDepVersion(pkg, name) && !(name === NITRO_PLUGIN_PKG && getDepVersion(pkg, "nitro")));
52
+ for (const name of missingPlugins) {
53
+ devDeps[name] = platformVersion;
54
+ changed = true;
55
+ context.logger.info(`Added '${name}': '${platformVersion}' to devDependencies.`);
56
+ }
57
+ if (!changed) return false;
58
+ pkg["devDependencies"] = devDeps;
59
+ const trailingNewline = raw.endsWith("\n") ? "\n" : "";
60
+ tree.overwrite("/package.json", JSON.stringify(pkg, null, 2) + trailingNewline);
61
+ context.addTask(new NodePackageInstallTask());
62
+ return true;
63
+ }
64
+ function applyEdits(source, edits) {
65
+ const sorted = [...edits].sort((a, b) => b.start - a.start);
66
+ let result = source;
67
+ for (const edit of sorted) result = result.slice(0, edit.start) + edit.text + result.slice(edit.end);
68
+ return result;
69
+ }
70
+ function getLineIndent(source, pos) {
71
+ let lineStart = pos;
72
+ while (lineStart > 0 && source[lineStart - 1] !== "\n") lineStart--;
73
+ let indent = "";
74
+ for (let i = lineStart; i < source.length; i++) {
75
+ const ch = source[i];
76
+ if (ch === " " || ch === " ") indent += ch;
77
+ else break;
78
+ }
79
+ return indent;
80
+ }
81
+ /**
82
+ * Tries to lift `vite: {...}` and `nitro: {...}` properties off the
83
+ * single `analog(...)` call into companion `angular(...)` / `nitro(...)`
84
+ * calls. Returns the rewritten source on success, or null if the file
85
+ * doesn't match the supported pattern (we then fall back to logging
86
+ * instructions rather than risking a corrupted file).
87
+ *
88
+ * Supported pattern: exactly one `analog(...)` call whose argument is
89
+ * an object literal. Properties named `vite` and `nitro` are recognized;
90
+ * everything else stays on `analog`.
91
+ */
92
+ function tryTransformViteConfig(filePath, source) {
93
+ let sourceFile;
94
+ try {
95
+ sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
96
+ } catch {
97
+ return null;
98
+ }
99
+ let analogImportEnd = -1;
100
+ let angularImported = false;
101
+ let nitroImported = false;
102
+ const analogCalls = [];
103
+ function visit(node) {
104
+ if (ts.isImportDeclaration(node)) {
105
+ const ml = node.moduleSpecifier;
106
+ if (ts.isStringLiteral(ml)) {
107
+ if (ml.text === "@analogjs/platform") analogImportEnd = node.end;
108
+ else if (ml.text === "@analogjs/vite-plugin-angular") angularImported = true;
109
+ else if (ml.text === "@analogjs/vite-plugin-nitro" || ml.text === "nitro/vite") nitroImported = true;
110
+ }
111
+ } else if (ts.isCallExpression(node)) {
112
+ if (ts.isIdentifier(node.expression) && node.expression.text === "analog") analogCalls.push(node);
113
+ }
114
+ ts.forEachChild(node, visit);
115
+ }
116
+ visit(sourceFile);
117
+ if (analogImportEnd === -1) return null;
118
+ if (analogCalls.length !== 1) return null;
119
+ const analogCall = analogCalls[0];
120
+ const callStart = analogCall.getStart(sourceFile);
121
+ const callEnd = analogCall.getEnd();
122
+ let viteValueText = null;
123
+ let nitroValueText = null;
124
+ let remainingPropsText = null;
125
+ const arg = analogCall.arguments[0];
126
+ if (arg && ts.isObjectLiteralExpression(arg)) {
127
+ const remaining = [];
128
+ for (const prop of arg.properties) if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && (prop.name.text === "vite" || prop.name.text === "nitro")) {
129
+ const value = prop.initializer;
130
+ const text = source.slice(value.getStart(sourceFile), value.getEnd());
131
+ if (prop.name.text === "vite") viteValueText = text;
132
+ else nitroValueText = text;
133
+ } else remaining.push(prop);
134
+ if (remaining.length > 0) {
135
+ const propTexts = remaining.map((p) => source.slice(p.getStart(sourceFile), p.getEnd()));
136
+ const indent = getLineIndent(source, arg.getStart(sourceFile));
137
+ const propIndent = indent + " ";
138
+ remainingPropsText = `{\n${propTexts.map((t) => `${propIndent}${t}`).join(",\n")},\n${indent}}`;
139
+ }
140
+ } else if (arg !== void 0) return null;
141
+ const indent = getLineIndent(source, callStart);
142
+ const parts = [remainingPropsText ? `analog(${remainingPropsText})` : `analog()`];
143
+ if (viteValueText !== null) parts.push(`angular(${viteValueText})`);
144
+ else parts.push("angular()");
145
+ if (nitroValueText !== null) parts.push(`nitro(${nitroValueText})`);
146
+ else parts.push("nitro()");
147
+ const edits = [{
148
+ start: callStart,
149
+ end: callEnd,
150
+ text: parts.join(`,\n${indent}`)
151
+ }];
152
+ const importsToAdd = [];
153
+ if (!angularImported) importsToAdd.push(`import angular from '@analogjs/vite-plugin-angular';`);
154
+ if (!nitroImported) importsToAdd.push(`import nitro from '@analogjs/vite-plugin-nitro';`);
155
+ if (importsToAdd.length > 0) edits.push({
156
+ start: analogImportEnd,
157
+ end: analogImportEnd,
158
+ text: `\n${importsToAdd.join("\n")}`
159
+ });
160
+ return {
161
+ source: applyEdits(source, edits),
162
+ movedVite: viteValueText !== null,
163
+ movedNitro: nitroValueText !== null
164
+ };
165
+ }
166
+ function migrateToSeparatedPlugins() {
167
+ return (tree, context) => {
168
+ const filesUsingLegacyShape = [];
169
+ const rewrittenFiles = [];
170
+ const unhandledFiles = [];
171
+ tree.visit((filePath) => {
172
+ if (filePath.includes("/node_modules/")) return;
173
+ if (!isViteConfig(filePath)) return;
174
+ const content = tree.read(filePath);
175
+ if (!content) return;
176
+ const source = content.toString("utf-8");
177
+ if (!usesLegacyPluginShape(source)) return;
178
+ filesUsingLegacyShape.push(filePath);
179
+ const transformed = tryTransformViteConfig(filePath, source);
180
+ if (transformed) {
181
+ tree.overwrite(filePath, transformed.source);
182
+ rewrittenFiles.push(filePath);
183
+ } else unhandledFiles.push(filePath);
184
+ });
185
+ if (filesUsingLegacyShape.length === 0) return tree;
186
+ if (rewrittenFiles.length > 0) {
187
+ context.logger.info(`Rewrote ${rewrittenFiles.length} vite.config file(s) to the separated \`analog() + angular() + nitro()\` shape:`);
188
+ for (const file of rewrittenFiles) context.logger.info(` - ${file}`);
189
+ context.logger.info(`Review the result — only \`vite\` and \`nitro\` were moved automatically. Other angular-passthrough options (\`liveReload\`, \`fastCompile\`, \`fileReplacements\`, etc.) still need to be relocated by hand.\nSee ${MIGRATION_DOC_URL}`);
190
+ }
191
+ if (unhandledFiles.length > 0) {
192
+ context.logger.info(`Could not safely rewrite ${unhandledFiles.length} vite.config file(s); migrate them by hand:`);
193
+ for (const file of unhandledFiles) context.logger.info(` - ${file}`);
194
+ context.logger.info(`Split \`analog()\` into \`analog() + angular() + nitro()\` and move each option to its owning plugin.\nSee ${MIGRATION_DOC_URL}`);
195
+ }
196
+ addDependencies(tree, context);
197
+ return tree;
198
+ };
199
+ }
200
+ //#endregion
201
+ export { migrateToSeparatedPlugins as default };
202
+
203
+ //# sourceMappingURL=migrate-to-separated-plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-to-separated-plugins.js","names":[],"sources":["../../../migrations/migrate-to-separated-plugins/migrate-to-separated-plugins.ts"],"sourcesContent":["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\n// The explicit file path resolves when this runs as native ESM.\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks/index.js';\nimport * as ts from 'typescript';\n\nconst ANALOG_PLATFORM_IMPORT = `from '@analogjs/platform'`;\nconst ANGULAR_PLUGIN_IMPORT = `from '@analogjs/vite-plugin-angular'`;\nconst NITRO_IMPORTS = [\n `from '@analogjs/vite-plugin-nitro'`,\n `from 'nitro/vite'`,\n];\nconst ANGULAR_PLUGIN_PKG = '@analogjs/vite-plugin-angular';\nconst NITRO_PLUGIN_PKG = '@analogjs/vite-plugin-nitro';\nconst MIGRATION_DOC_URL =\n 'https://analogjs.org/docs/guides/migrating-v2-to-v3#analog-angular-and-nitro-are-now-separate-plugins';\n\nconst VITE_CONFIG_EXTENSIONS = ['.ts', '.mts', '.js', '.mjs'];\n\nfunction isViteConfig(filePath: string): boolean {\n const file = filePath.slice(filePath.lastIndexOf('/') + 1);\n if (!file.startsWith('vite.config.')) {\n return false;\n }\n return VITE_CONFIG_EXTENSIONS.some((ext) => file.endsWith(ext));\n}\n\nfunction usesLegacyPluginShape(source: string): boolean {\n if (!source.includes(ANALOG_PLATFORM_IMPORT)) {\n return false;\n }\n if (\n source.includes(ANGULAR_PLUGIN_IMPORT) &&\n NITRO_IMPORTS.some((nitroImport) => source.includes(nitroImport))\n ) {\n return false;\n }\n return /\\banalog\\s*\\(/.test(source);\n}\n\nfunction readPackageJson(\n tree: Tree,\n): { raw: string; pkg: Record<string, unknown> } | null {\n const content = tree.read('/package.json');\n if (!content) return null;\n const raw = content.toString('utf-8');\n try {\n return { raw, pkg: JSON.parse(raw) };\n } catch {\n return null;\n }\n}\n\nfunction getDepVersion(\n pkg: Record<string, unknown>,\n name: string,\n): string | undefined {\n const dev =\n (pkg['devDependencies'] as Record<string, string> | undefined) ?? {};\n const reg = (pkg['dependencies'] as Record<string, string> | undefined) ?? {};\n return dev[name] ?? reg[name];\n}\n\nfunction addDependencies(tree: Tree, context: SchematicContext): boolean {\n const info = readPackageJson(tree);\n if (!info) return false;\n\n const { pkg, raw } = info;\n const devDeps = {\n ...((pkg['devDependencies'] as Record<string, string> | undefined) ?? {}),\n };\n let changed = false;\n\n // Match the @analogjs/platform pin so the plugins stay aligned with the\n // rest of the Analog packages already in this workspace.\n const platformVersion = getDepVersion(pkg, '@analogjs/platform') ?? '*';\n const missingPlugins = [ANGULAR_PLUGIN_PKG, NITRO_PLUGIN_PKG].filter(\n (name) =>\n !getDepVersion(pkg, name) &&\n // Apps already on Nitro v3 keep `nitro()` from `nitro/vite`.\n !(name === NITRO_PLUGIN_PKG && getDepVersion(pkg, 'nitro')),\n );\n for (const name of missingPlugins) {\n devDeps[name] = platformVersion;\n changed = true;\n context.logger.info(\n `Added '${name}': '${platformVersion}' to devDependencies.`,\n );\n }\n\n if (!changed) return false;\n\n pkg['devDependencies'] = devDeps;\n const trailingNewline = raw.endsWith('\\n') ? '\\n' : '';\n tree.overwrite(\n '/package.json',\n JSON.stringify(pkg, null, 2) + trailingNewline,\n );\n context.addTask(new NodePackageInstallTask());\n return true;\n}\n\ninterface TransformResult {\n source: string;\n movedVite: boolean;\n movedNitro: boolean;\n}\n\ninterface Edit {\n start: number;\n end: number;\n text: string;\n}\n\nfunction applyEdits(source: string, edits: Edit[]): string {\n // Apply right-to-left so earlier offsets stay valid.\n const sorted = [...edits].sort((a, b) => b.start - a.start);\n let result = source;\n for (const edit of sorted) {\n result = result.slice(0, edit.start) + edit.text + result.slice(edit.end);\n }\n return result;\n}\n\nfunction getLineIndent(source: string, pos: number): string {\n let lineStart = pos;\n while (lineStart > 0 && source[lineStart - 1] !== '\\n') {\n lineStart--;\n }\n let indent = '';\n for (let i = lineStart; i < source.length; i++) {\n const ch = source[i];\n if (ch === ' ' || ch === '\\t') indent += ch;\n else break;\n }\n return indent;\n}\n\n/**\n * Tries to lift `vite: {...}` and `nitro: {...}` properties off the\n * single `analog(...)` call into companion `angular(...)` / `nitro(...)`\n * calls. Returns the rewritten source on success, or null if the file\n * doesn't match the supported pattern (we then fall back to logging\n * instructions rather than risking a corrupted file).\n *\n * Supported pattern: exactly one `analog(...)` call whose argument is\n * an object literal. Properties named `vite` and `nitro` are recognized;\n * everything else stays on `analog`.\n */\nfunction tryTransformViteConfig(\n filePath: string,\n source: string,\n): TransformResult | null {\n let sourceFile: ts.SourceFile;\n try {\n sourceFile = ts.createSourceFile(\n filePath,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n } catch {\n return null;\n }\n\n let analogImportEnd = -1;\n let angularImported = false;\n let nitroImported = false;\n const analogCalls: ts.CallExpression[] = [];\n\n function visit(node: ts.Node): void {\n if (ts.isImportDeclaration(node)) {\n const ml = node.moduleSpecifier;\n if (ts.isStringLiteral(ml)) {\n if (ml.text === '@analogjs/platform') {\n analogImportEnd = node.end;\n } else if (ml.text === '@analogjs/vite-plugin-angular') {\n angularImported = true;\n } else if (\n ml.text === '@analogjs/vite-plugin-nitro' ||\n ml.text === 'nitro/vite'\n ) {\n nitroImported = true;\n }\n }\n } else if (ts.isCallExpression(node)) {\n if (\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'analog'\n ) {\n analogCalls.push(node);\n }\n }\n ts.forEachChild(node, visit);\n }\n visit(sourceFile);\n\n if (analogImportEnd === -1) return null;\n if (analogCalls.length !== 1) return null;\n\n const analogCall = analogCalls[0];\n const callStart = analogCall.getStart(sourceFile);\n const callEnd = analogCall.getEnd();\n\n let viteValueText: string | null = null;\n let nitroValueText: string | null = null;\n let remainingPropsText: string | null = null;\n\n const arg = analogCall.arguments[0];\n if (arg && ts.isObjectLiteralExpression(arg)) {\n const remaining: ts.ObjectLiteralElementLike[] = [];\n for (const prop of arg.properties) {\n if (\n ts.isPropertyAssignment(prop) &&\n ts.isIdentifier(prop.name) &&\n (prop.name.text === 'vite' || prop.name.text === 'nitro')\n ) {\n const value = prop.initializer;\n const text = source.slice(value.getStart(sourceFile), value.getEnd());\n if (prop.name.text === 'vite') viteValueText = text;\n else nitroValueText = text;\n } else {\n remaining.push(prop);\n }\n }\n\n if (remaining.length > 0) {\n // Reconstruct the analog object literal from the remaining props,\n // preserving their original source text (comments, spacing).\n const propTexts = remaining.map((p) =>\n source.slice(p.getStart(sourceFile), p.getEnd()),\n );\n const objStart = arg.getStart(sourceFile);\n const indent = getLineIndent(source, objStart);\n const propIndent = indent + ' ';\n remainingPropsText = `{\\n${propTexts.map((t) => `${propIndent}${t}`).join(',\\n')},\\n${indent}}`;\n }\n } else if (arg !== undefined) {\n // analog(otherExpression) — can't statically split a variable or call\n // expression. Fall back to logging instructions.\n return null;\n }\n // analog() with no argument falls through to the rewrite below; we just\n // emit `analog(), angular(), nitro()` to scaffold the new plugin chain.\n\n const indent = getLineIndent(source, callStart);\n const newAnalogCall = remainingPropsText\n ? `analog(${remainingPropsText})`\n : `analog()`;\n const parts: string[] = [newAnalogCall];\n if (viteValueText !== null) parts.push(`angular(${viteValueText})`);\n else parts.push('angular()');\n if (nitroValueText !== null) parts.push(`nitro(${nitroValueText})`);\n else parts.push('nitro()');\n const replacement = parts.join(`,\\n${indent}`);\n\n const edits: Edit[] = [{ start: callStart, end: callEnd, text: replacement }];\n\n const importsToAdd: string[] = [];\n if (!angularImported) {\n importsToAdd.push(`import angular from '@analogjs/vite-plugin-angular';`);\n }\n if (!nitroImported) {\n importsToAdd.push(`import nitro from '@analogjs/vite-plugin-nitro';`);\n }\n if (importsToAdd.length > 0) {\n edits.push({\n start: analogImportEnd,\n end: analogImportEnd,\n text: `\\n${importsToAdd.join('\\n')}`,\n });\n }\n\n const rewritten = applyEdits(source, edits);\n\n return {\n source: rewritten,\n movedVite: viteValueText !== null,\n movedNitro: nitroValueText !== null,\n };\n}\n\nexport default function migrateToSeparatedPlugins(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const filesUsingLegacyShape: string[] = [];\n const rewrittenFiles: string[] = [];\n const unhandledFiles: string[] = [];\n\n tree.visit((filePath) => {\n if (filePath.includes('/node_modules/')) return;\n if (!isViteConfig(filePath)) return;\n\n const content = tree.read(filePath);\n if (!content) return;\n\n const source = content.toString('utf-8');\n if (!usesLegacyPluginShape(source)) return;\n\n filesUsingLegacyShape.push(filePath);\n\n const transformed = tryTransformViteConfig(filePath, source);\n if (transformed) {\n tree.overwrite(filePath, transformed.source);\n rewrittenFiles.push(filePath);\n } else {\n unhandledFiles.push(filePath);\n }\n });\n\n if (filesUsingLegacyShape.length === 0) {\n return tree;\n }\n\n if (rewrittenFiles.length > 0) {\n context.logger.info(\n `Rewrote ${rewrittenFiles.length} vite.config file(s) to the separated \\`analog() + angular() + nitro()\\` shape:`,\n );\n for (const file of rewrittenFiles) {\n context.logger.info(` - ${file}`);\n }\n context.logger.info(\n `Review the result — only \\`vite\\` and \\`nitro\\` were moved automatically. Other angular-passthrough options (\\`liveReload\\`, \\`fastCompile\\`, \\`fileReplacements\\`, etc.) still need to be relocated by hand.\\nSee ${MIGRATION_DOC_URL}`,\n );\n }\n\n if (unhandledFiles.length > 0) {\n context.logger.info(\n `Could not safely rewrite ${unhandledFiles.length} vite.config file(s); migrate them by hand:`,\n );\n for (const file of unhandledFiles) {\n context.logger.info(` - ${file}`);\n }\n context.logger.info(\n `Split \\`analog()\\` into \\`analog() + angular() + nitro()\\` and move each option to its owning plugin.\\nSee ${MIGRATION_DOC_URL}`,\n );\n }\n\n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sB,OAAO,CAAE;AAEpC,yBAAsB,KAAK,SAAS;GAEpC,MAAM,cAAc,uBAAuB,UAAU,OAAO;AAC5D,OAAI,aAAa;AACf,SAAK,UAAU,UAAU,YAAY,OAAO;AAC5C,mBAAe,KAAK,SAAS;SAE7B,gBAAe,KAAK,SAAS;IAE/B;AAEF,MAAI,sBAAsB,WAAW,EACnC,QAAO;AAGT,MAAI,eAAe,SAAS,GAAG;AAC7B,WAAQ,OAAO,KACb,WAAW,eAAe,OAAO,iFAClC;AACD,QAAK,MAAM,QAAQ,eACjB,SAAQ,OAAO,KAAK,OAAO,OAAO;AAEpC,WAAQ,OAAO,KACb,sNAAsN,oBACvN;;AAGH,MAAI,eAAe,SAAS,GAAG;AAC7B,WAAQ,OAAO,KACb,4BAA4B,eAAe,OAAO,6CACnD;AACD,QAAK,MAAM,QAAQ,eACjB,SAAQ,OAAO,KAAK,OAAO,OAAO;AAEpC,WAAQ,OAAO,KACb,8GAA8G,oBAC/G;;AAGH,kBAAgB,MAAM,QAAQ;AAE9B,SAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/platform",
3
- "version": "3.0.0-alpha.90",
3
+ "version": "3.0.0-alpha.92",
4
4
  "description": "The fullstack meta-framework for Angular",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -31,12 +31,10 @@
31
31
  "url": "https://github.com/sponsors/brandonroberts"
32
32
  },
33
33
  "dependencies": {
34
- "@analogjs/vite-plugin-angular": "3.0.0-alpha.90",
34
+ "@analogjs/vite-plugin-angular": "3.0.0-alpha.92",
35
35
  "es-toolkit": "^1.45.1",
36
36
  "front-matter": "^4.0.2",
37
- "h3": "^2.0.1-rc.31",
38
37
  "magic-string": "^0.30.21",
39
- "nitro": "3.0.260903-beta",
40
38
  "obug": "^2.1.1",
41
39
  "ofetch": "2.0.0-alpha.3",
42
40
  "oxc-parser": "^0.124.0",
@@ -46,7 +44,9 @@
46
44
  "xmlbuilder2": "^4.0.3"
47
45
  },
48
46
  "devDependencies": {
49
- "@babel/core": "^8.0.0"
47
+ "@babel/core": "^8.0.0",
48
+ "h3": "^2.0.1-rc.31",
49
+ "nitro": "3.0.260903-beta"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@nx/angular": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0 || ^22.0.0 || ^23.0.0 || ^23",
@@ -57,6 +57,7 @@
57
57
  "marked-highlight": "^2.2.3",
58
58
  "marked-mangle": "^1.1.12",
59
59
  "marked-shiki": "^1.2.1",
60
+ "nitro": "3.0.260903-beta",
60
61
  "shiki": "^1.29.2 || ^4.0.2",
61
62
  "vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
62
63
  },
@@ -70,16 +71,19 @@
70
71
  "@nx/vite": {
71
72
  "optional": true
72
73
  },
73
- "shiki": {
74
+ "marked-highlight": {
74
75
  "optional": true
75
76
  },
76
77
  "marked-shiki": {
77
78
  "optional": true
78
79
  },
80
+ "nitro": {
81
+ "optional": true
82
+ },
79
83
  "prismjs": {
80
84
  "optional": true
81
85
  },
82
- "marked-highlight": {
86
+ "shiki": {
83
87
  "optional": true
84
88
  }
85
89
  },
package/src/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { platformPlugin } from "./lib/platform-plugin.js";
2
- export type { Options, PrerenderSitemapConfig, TypedRouterOptions, PrerenderContentFile, SitemapConfig, SitemapEntry, SitemapExcludeRule, SitemapPriority, SitemapRouteDefinition, SitemapRouteInput, SitemapRouteSource, SitemapTransform } from "./lib/options.js";
2
+ export type { Options, PrerenderSitemapConfig, PrerenderContentFile, SitemapConfig, SitemapEntry, SitemapExcludeRule, SitemapPriority, SitemapRouteDefinition, SitemapRouteInput, SitemapRouteSource, SitemapTransform } from "./lib/options.js";
3
3
  export { discoverLibraryRoutes } from "./lib/discover-library-routes.js";
4
4
  export type { DiscoveredLibraryRoutes } from "./lib/discover-library-routes.js";
5
- export { routeGenerationPlugin } from "./lib/route-generation-plugin.js";
6
5
  export default platformPlugin;
package/src/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { discoverLibraryRoutes } from "./lib/discover-library-routes.js";
2
- import { routeGenerationPlugin } from "./lib/route-generation-plugin.js";
3
2
  import { platformPlugin } from "./lib/platform-plugin.js";
4
3
  //#region packages/platform/src/index.ts
5
4
  var src_default = platformPlugin;
6
5
  //#endregion
7
- export { src_default as default, discoverLibraryRoutes, routeGenerationPlugin };
6
+ export { src_default as default, discoverLibraryRoutes };
8
7
 
9
8
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { platformPlugin } from './lib/platform-plugin.js';\n\nexport type {\n Options,\n PrerenderSitemapConfig,\n TypedRouterOptions,\n PrerenderContentFile,\n SitemapConfig,\n SitemapEntry,\n SitemapExcludeRule,\n SitemapPriority,\n SitemapRouteDefinition,\n SitemapRouteInput,\n SitemapRouteSource,\n SitemapTransform,\n} from './lib/options.js';\nexport { discoverLibraryRoutes } from './lib/discover-library-routes.js';\nexport type { DiscoveredLibraryRoutes } from './lib/discover-library-routes.js';\nexport { routeGenerationPlugin } from './lib/route-generation-plugin.js';\nexport default platformPlugin;\n"],"mappings":";;;;AAmBA,IAAA,cAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { platformPlugin } from './lib/platform-plugin.js';\n\nexport type {\n Options,\n PrerenderSitemapConfig,\n PrerenderContentFile,\n SitemapConfig,\n SitemapEntry,\n SitemapExcludeRule,\n SitemapPriority,\n SitemapRouteDefinition,\n SitemapRouteInput,\n SitemapRouteSource,\n SitemapTransform,\n} from './lib/options.js';\nexport { discoverLibraryRoutes } from './lib/discover-library-routes.js';\nexport type { DiscoveredLibraryRoutes } from './lib/discover-library-routes.js';\nexport default platformPlugin;\n"],"mappings":";;;AAiBA,IAAA,cAAe"}
@@ -8,6 +8,7 @@ function clearClientPageEndpointsPlugin() {
8
8
  let isBuild = true;
9
9
  return {
10
10
  name: "analogjs-platform-clear-client-page-endpoint",
11
+ enforce: "post",
11
12
  config() {
12
13
  return { build: { rollupOptions: { onwarn(warning) {
13
14
  if (warning.message.includes("empty chunk") && warning.message.endsWith(".server")) return;
@@ -1 +1 @@
1
- {"version":3,"file":"clear-client-page-endpoint.js","names":[],"sources":["../../../src/lib/clear-client-page-endpoint.ts"],"sourcesContent":["import { Plugin, normalizePath } from 'vite';\nimport { injectServerFnIds } from './inject-server-fn-ids.js';\nimport { serverFnFileId } from './server-fn-id.js';\n\nimport { scrubServerFnModule } from './server-fn-client-transform.js';\n\nexport function clearClientPageEndpointsPlugin(): Plugin {\n let projectRoot = process.cwd();\n let isBuild = true;\n\n return {\n name: 'analogjs-platform-clear-client-page-endpoint',\n config() {\n return {\n build: {\n rollupOptions: {\n onwarn(warning) {\n if (\n warning.message.includes('empty chunk') &&\n warning.message.endsWith('.server')\n ) {\n return;\n }\n },\n },\n },\n };\n },\n configResolved(config) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n transform(code, id, options) {\n if (!id.endsWith('.server.ts')) {\n return;\n }\n\n // Server-function ids are derived from the project-root-relative path so\n // the client proxy and the server registration always resolve to the same\n // opaque, collision-free route.\n const fileId = serverFnFileId(id, projectRoot);\n\n if (options?.ssr) {\n // SSR build keeps the real handlers but stamps the derived id into each\n // serverFn config so it registers under the route the client calls.\n const injected = injectServerFnIds(code, fileId);\n return injected ? { code: injected.code, map: null } : undefined;\n }\n\n // Client build: a `.server.ts` defining server functions is rewritten to\n // client-safe proxies (the `{ id, url, method }` refs the browser\n // dispatches through); handlers and server imports are dropped so they\n // tree-shake away.\n const scrubbed = scrubServerFnModule(code, fileId);\n if (scrubbed) {\n // An empty mapping, not `null`: a null map lets the original module —\n // handlers and all — survive in `sourcesContent` further down the\n // pipeline, which would ship the server code to the browser after the\n // scrub went to the trouble of removing it.\n return { code: scrubbed.code, map: { mappings: '' } };\n }\n\n // Page load/action endpoints carry no client-consumable exports. Only the\n // client build empties them; the dev server never pulls them into the\n // browser graph, and emptying them there would break the SSR request.\n if (isBuild && id.includes(normalizePath('src/app/pages'))) {\n return {\n code: 'export default undefined;',\n map: null,\n };\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;;;AAMA,SAAgB,iCAAyC;CACvD,IAAI,cAAc,QAAQ,KAAK;CAC/B,IAAI,UAAU;AAEd,QAAO;EACL,MAAM;EACN,SAAS;AACP,UAAO,EACL,OAAO,EACL,eAAe,EACb,OAAO,SAAS;AACd,QACE,QAAQ,QAAQ,SAAS,cAAc,IACvC,QAAQ,QAAQ,SAAS,UAAU,CAEnC;MAGL,EACF,EACF;;EAEH,eAAe,QAAQ;AACrB,iBAAc,OAAO;AACrB,aAAU,OAAO,YAAY;;EAE/B,UAAU,MAAM,IAAI,SAAS;AAC3B,OAAI,CAAC,GAAG,SAAS,aAAa,CAC5B;GAMF,MAAM,SAAS,eAAe,IAAI,YAAY;AAE9C,OAAI,SAAS,KAAK;IAGhB,MAAM,WAAW,kBAAkB,MAAM,OAAO;AAChD,WAAO,WAAW;KAAE,MAAM,SAAS;KAAM,KAAK;KAAM,GAAG,KAAA;;GAOzD,MAAM,WAAW,oBAAoB,MAAM,OAAO;AAClD,OAAI,SAKF,QAAO;IAAE,MAAM,SAAS;IAAM,KAAK,EAAE,UAAU,IAAI;IAAE;AAMvD,OAAI,WAAW,GAAG,SAAS,cAAc,gBAAgB,CAAC,CACxD,QAAO;IACL,MAAM;IACN,KAAK;IACN;;EAKN"}
1
+ {"version":3,"file":"clear-client-page-endpoint.js","names":[],"sources":["../../../src/lib/clear-client-page-endpoint.ts"],"sourcesContent":["import { Plugin, normalizePath } from 'vite';\nimport { injectServerFnIds } from './inject-server-fn-ids.js';\nimport { serverFnFileId } from './server-fn-id.js';\n\nimport { scrubServerFnModule } from './server-fn-client-transform.js';\n\nexport function clearClientPageEndpointsPlugin(): Plugin {\n let projectRoot = process.cwd();\n let isBuild = true;\n\n return {\n name: 'analogjs-platform-clear-client-page-endpoint',\n // After Angular compilation, which re-emits `.server.ts` files from its own\n // program and would otherwise drop this transform's output.\n enforce: 'post',\n config() {\n return {\n build: {\n rollupOptions: {\n onwarn(warning) {\n if (\n warning.message.includes('empty chunk') &&\n warning.message.endsWith('.server')\n ) {\n return;\n }\n },\n },\n },\n };\n },\n configResolved(config) {\n projectRoot = config.root;\n isBuild = config.command === 'build';\n },\n transform(code, id, options) {\n if (!id.endsWith('.server.ts')) {\n return;\n }\n\n // Server-function ids are derived from the project-root-relative path so\n // the client proxy and the server registration always resolve to the same\n // opaque, collision-free route.\n const fileId = serverFnFileId(id, projectRoot);\n\n if (options?.ssr) {\n // SSR build keeps the real handlers but stamps the derived id into each\n // serverFn config so it registers under the route the client calls.\n const injected = injectServerFnIds(code, fileId);\n return injected ? { code: injected.code, map: null } : undefined;\n }\n\n // Client build: a `.server.ts` defining server functions is rewritten to\n // client-safe proxies (the `{ id, url, method }` refs the browser\n // dispatches through); handlers and server imports are dropped so they\n // tree-shake away.\n const scrubbed = scrubServerFnModule(code, fileId);\n if (scrubbed) {\n // An empty mapping, not `null`: a null map lets the original module —\n // handlers and all — survive in `sourcesContent` further down the\n // pipeline, which would ship the server code to the browser after the\n // scrub went to the trouble of removing it.\n return { code: scrubbed.code, map: { mappings: '' } };\n }\n\n // Page load/action endpoints carry no client-consumable exports. Only the\n // client build empties them; the dev server never pulls them into the\n // browser graph, and emptying them there would break the SSR request.\n if (isBuild && id.includes(normalizePath('src/app/pages'))) {\n return {\n code: 'export default undefined;',\n map: null,\n };\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;;;AAMA,SAAgB,iCAAyC;CACvD,IAAI,cAAc,QAAQ,KAAK;CAC/B,IAAI,UAAU;AAEd,QAAO;EACL,MAAM;EAGN,SAAS;EACT,SAAS;AACP,UAAO,EACL,OAAO,EACL,eAAe,EACb,OAAO,SAAS;AACd,QACE,QAAQ,QAAQ,SAAS,cAAc,IACvC,QAAQ,QAAQ,SAAS,UAAU,CAEnC;MAGL,EACF,EACF;;EAEH,eAAe,QAAQ;AACrB,iBAAc,OAAO;AACrB,aAAU,OAAO,YAAY;;EAE/B,UAAU,MAAM,IAAI,SAAS;AAC3B,OAAI,CAAC,GAAG,SAAS,aAAa,CAC5B;GAMF,MAAM,SAAS,eAAe,IAAI,YAAY;AAE9C,OAAI,SAAS,KAAK;IAGhB,MAAM,WAAW,kBAAkB,MAAM,OAAO;AAChD,WAAO,WAAW;KAAE,MAAM,SAAS;KAAM,KAAK;KAAM,GAAG,KAAA;;GAOzD,MAAM,WAAW,oBAAoB,MAAM,OAAO;AAClD,OAAI,SAKF,QAAO;IAAE,MAAM,SAAS;IAAM,KAAK,EAAE,UAAU,IAAI;IAAE;AAMvD,OAAI,WAAW,GAAG,SAAS,cAAc,gBAAgB,CAAC,CACxD,QAAO;IACL,MAAM;IACN,KAAK;IACN;;EAKN"}
@@ -1,8 +1,15 @@
1
1
  import { debugPlatform } from "./utils/debug.js";
2
- import { getJsTransformConfigKey } from "./utils/rolldown.js";
2
+ import { getJsTransformConfigKey, isRolldown } from "./utils/rolldown.js";
3
+ import { angularLinkerPlugin } from "./nitro/angular-linker-plugin.js";
3
4
  import { VERSION } from "@angular/compiler-cli";
4
5
  import { crawlFrameworkPkgs } from "vitefu";
5
6
  //#region packages/platform/src/lib/deps-plugin.ts
7
+ var ANGULAR_LINKED_SSR_DEPS = [
8
+ "@angular/compiler",
9
+ "@angular/core",
10
+ "@angular/platform-browser",
11
+ "@angular/platform-server"
12
+ ];
6
13
  function depsPlugin(options) {
7
14
  const workspaceRoot = options?.workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd();
8
15
  return [{
@@ -26,11 +33,15 @@ function depsPlugin(options) {
26
33
  "@taiga-ui/**",
27
34
  "@tanstack/angular-query-experimental"
28
35
  ],
29
- optimizeDeps: { include: [
30
- "@angular/common",
31
- "@angular/common/http",
32
- ...Number(VERSION.major) > 15 ? ["@angular/core/rxjs-interop"] : []
33
- ] }
36
+ optimizeDeps: {
37
+ include: [
38
+ ...isRolldown() ? ANGULAR_LINKED_SSR_DEPS : [],
39
+ "@angular/common",
40
+ "@angular/common/http",
41
+ ...Number(VERSION.major) > 15 ? ["@angular/core/rxjs-interop"] : []
42
+ ],
43
+ ...isRolldown() ? { rolldownOptions: { plugins: [angularLinkerPlugin()] } } : {}
44
+ }
34
45
  },
35
46
  optimizeDeps: {
36
47
  include: [
@@ -1 +1 @@
1
- {"version":3,"file":"deps-plugin.js","names":[],"sources":["../../../src/lib/deps-plugin.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport type { Plugin } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nimport { Options } from './options.js';\nimport { debugPlatform } from './utils/debug.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function depsPlugin(options?: Options): Plugin[] {\n const workspaceRoot =\n options?.workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd();\n\n return [\n {\n name: 'analogjs-deps-plugin',\n config() {\n // Skip Vite's built-in ts/js transform so `@analogjs/vite-plugin-angular`\n // (when the user includes it) owns Angular file compilation. Users who\n // run an alternative compiler or compile through Angular's own\n // compilation API can override this in their own Vite config.\n const transformConfig = { exclude: ['**/*.ts', '**/*.js'] };\n debugPlatform('deps transform config', {\n jsTransformKey: getJsTransformConfigKey(),\n transformExcluded: true,\n });\n\n return {\n [getJsTransformConfigKey()]: transformConfig,\n ssr: {\n noExternal: [\n '@analogjs/**',\n 'es-toolkit',\n 'firebase/**',\n 'firebase-admin/**',\n 'rxfire',\n '@ng-web-apis/**',\n '@taiga-ui/**',\n '@tanstack/angular-query-experimental',\n ],\n // The server pre-bundle is resolved separately from the client\n // one, so a secondary entry point left out of it loads its own\n // copy of `@angular/core`. `inject()` then runs against a runtime\n // with no active injection context and SSR fails with NG0203.\n optimizeDeps: {\n include: [\n '@angular/common',\n '@angular/common/http',\n ...(Number(VERSION.major) > 15\n ? ['@angular/core/rxjs-interop']\n : []),\n ],\n },\n },\n optimizeDeps: {\n include: [\n '@angular/common',\n '@angular/common/http',\n ...(Number(VERSION.major) > 15\n ? ['@angular/core/rxjs-interop']\n : []),\n 'front-matter',\n ],\n exclude: [\n '@angular/platform-server',\n '@analogjs/content',\n '@analogjs/router',\n '@nx/angular',\n '@nx/vite',\n '@nx/devkit',\n '@nx/js',\n '@nx/devkit',\n '@nx/cypress',\n '@nx/jest',\n '@nx/js',\n '@nx/eslint',\n '@nx/webpack',\n '@nx/web',\n '@nx/workspace',\n '@nx/eslint',\n '@nx/module-federation',\n '@nx/rspack',\n 'webpack',\n 'fsevents',\n 'nx',\n ],\n },\n };\n },\n },\n {\n name: 'analogjs-auto-discover-deps',\n async config(config, { command }) {\n const pkgConfig = await crawlFrameworkPkgs({\n root: workspaceRoot,\n isBuild: command === 'build',\n viteUserConfig: config,\n isSemiFrameworkPkgByJson(pkgJson) {\n return pkgJson['module'] && pkgJson['module'].includes('fesm');\n },\n });\n return pkgConfig;\n },\n },\n ];\n}\n"],"mappings":";;;;;AAQA,SAAgB,WAAW,SAA6B;CACtD,MAAM,gBACJ,SAAS,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK;AAE7E,QAAO,CACL;EACE,MAAM;EACN,SAAS;GAKP,MAAM,kBAAkB,EAAE,SAAS,CAAC,WAAW,UAAU,EAAE;AAC3D,iBAAc,yBAAyB;IACrC,gBAAgB,yBAAyB;IACzC,mBAAmB;IACpB,CAAC;AAEF,UAAO;KACJ,yBAAyB,GAAG;IAC7B,KAAK;KACH,YAAY;MACV;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACD;KAKD,cAAc,EACZ,SAAS;MACP;MACA;MACA,GAAI,OAAO,QAAQ,MAAM,GAAG,KACxB,CAAC,6BAA6B,GAC9B,EAAE;MACP,EACF;KACF;IACD,cAAc;KACZ,SAAS;MACP;MACA;MACA,GAAI,OAAO,QAAQ,MAAM,GAAG,KACxB,CAAC,6BAA6B,GAC9B,EAAE;MACN;MACD;KACD,SAAS;MACP;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACD;KACF;IACF;;EAEJ,EACD;EACE,MAAM;EACN,MAAM,OAAO,QAAQ,EAAE,WAAW;AAShC,UARkB,MAAM,mBAAmB;IACzC,MAAM;IACN,SAAS,YAAY;IACrB,gBAAgB;IAChB,yBAAyB,SAAS;AAChC,YAAO,QAAQ,aAAa,QAAQ,UAAU,SAAS,OAAO;;IAEjE,CAAC;;EAGL,CACF"}
1
+ {"version":3,"file":"deps-plugin.js","names":[],"sources":["../../../src/lib/deps-plugin.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport type { Plugin } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nimport { angularLinkerPlugin } from './nitro/angular-linker-plugin.js';\nimport { Options } from './options.js';\nimport { debugPlatform } from './utils/debug.js';\nimport { getJsTransformConfigKey, isRolldown } from './utils/rolldown.js';\n\nconst ANGULAR_LINKED_SSR_DEPS = [\n '@angular/compiler',\n '@angular/core',\n '@angular/platform-browser',\n '@angular/platform-server',\n];\n\nexport function depsPlugin(options?: Options): Plugin[] {\n const workspaceRoot =\n options?.workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd();\n\n return [\n {\n name: 'analogjs-deps-plugin',\n config() {\n // Skip Vite's built-in ts/js transform so `@analogjs/vite-plugin-angular`\n // (when the user includes it) owns Angular file compilation. Users who\n // run an alternative compiler or compile through Angular's own\n // compilation API can override this in their own Vite config.\n const transformConfig = { exclude: ['**/*.ts', '**/*.js'] };\n debugPlatform('deps transform config', {\n jsTransformKey: getJsTransformConfigKey(),\n transformExcluded: true,\n });\n\n return {\n [getJsTransformConfigKey()]: transformConfig,\n ssr: {\n noExternal: [\n '@analogjs/**',\n 'es-toolkit',\n 'firebase/**',\n 'firebase-admin/**',\n 'rxfire',\n '@ng-web-apis/**',\n '@taiga-ui/**',\n '@tanstack/angular-query-experimental',\n ],\n // The server pre-bundle is resolved separately from the client\n // one, so a secondary entry point left out of it loads its own\n // copy of `@angular/core`. `inject()` then runs against a runtime\n // with no active injection context and SSR fails with NG0203.\n // With Rolldown, the rest of Angular is pre-bundled too and the\n // partial-compilation packages are linked, so the server needs no JIT.\n optimizeDeps: {\n include: [\n ...(isRolldown() ? ANGULAR_LINKED_SSR_DEPS : []),\n '@angular/common',\n '@angular/common/http',\n ...(Number(VERSION.major) > 15\n ? ['@angular/core/rxjs-interop']\n : []),\n ],\n ...(isRolldown()\n ? { rolldownOptions: { plugins: [angularLinkerPlugin()] } }\n : {}),\n },\n },\n optimizeDeps: {\n include: [\n '@angular/common',\n '@angular/common/http',\n ...(Number(VERSION.major) > 15\n ? ['@angular/core/rxjs-interop']\n : []),\n 'front-matter',\n ],\n exclude: [\n '@angular/platform-server',\n '@analogjs/content',\n '@analogjs/router',\n '@nx/angular',\n '@nx/vite',\n '@nx/devkit',\n '@nx/js',\n '@nx/devkit',\n '@nx/cypress',\n '@nx/jest',\n '@nx/js',\n '@nx/eslint',\n '@nx/webpack',\n '@nx/web',\n '@nx/workspace',\n '@nx/eslint',\n '@nx/module-federation',\n '@nx/rspack',\n 'webpack',\n 'fsevents',\n 'nx',\n ],\n },\n };\n },\n },\n {\n name: 'analogjs-auto-discover-deps',\n async config(config, { command }) {\n const pkgConfig = await crawlFrameworkPkgs({\n root: workspaceRoot,\n isBuild: command === 'build',\n viteUserConfig: config,\n isSemiFrameworkPkgByJson(pkgJson) {\n return pkgJson['module'] && pkgJson['module'].includes('fesm');\n },\n });\n return pkgConfig;\n },\n },\n ];\n}\n"],"mappings":";;;;;;AASA,IAAM,0BAA0B;CAC9B;CACA;CACA;CACA;CACD;AAED,SAAgB,WAAW,SAA6B;CACtD,MAAM,gBACJ,SAAS,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK;AAE7E,QAAO,CACL;EACE,MAAM;EACN,SAAS;GAKP,MAAM,kBAAkB,EAAE,SAAS,CAAC,WAAW,UAAU,EAAE;AAC3D,iBAAc,yBAAyB;IACrC,gBAAgB,yBAAyB;IACzC,mBAAmB;IACpB,CAAC;AAEF,UAAO;KACJ,yBAAyB,GAAG;IAC7B,KAAK;KACH,YAAY;MACV;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACD;KAOD,cAAc;MACZ,SAAS;OACP,GAAI,YAAY,GAAG,0BAA0B,EAAE;OAC/C;OACA;OACA,GAAI,OAAO,QAAQ,MAAM,GAAG,KACxB,CAAC,6BAA6B,GAC9B,EAAE;OACP;MACD,GAAI,YAAY,GACZ,EAAE,iBAAiB,EAAE,SAAS,CAAC,qBAAqB,CAAC,EAAE,EAAE,GACzD,EAAE;MACP;KACF;IACD,cAAc;KACZ,SAAS;MACP;MACA;MACA,GAAI,OAAO,QAAQ,MAAM,GAAG,KACxB,CAAC,6BAA6B,GAC9B,EAAE;MACN;MACD;KACD,SAAS;MACP;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACD;KACF;IACF;;EAEJ,EACD;EACE,MAAM;EACN,MAAM,OAAO,QAAQ,EAAE,WAAW;AAShC,UARkB,MAAM,mBAAmB;IACzC,MAAM;IACN,SAAS,YAAY;IACrB,gBAAgB;IAChB,yBAAyB,SAAS;AAChC,YAAO,QAAQ,aAAa,QAAQ,UAAU,SAAS,OAAO;;IAEjE,CAAC;;EAGL,CACF"}