@analogjs/platform 3.0.0-alpha.91 → 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 (33) 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/lib/clear-client-page-endpoint.js +1 -0
  6. package/src/lib/clear-client-page-endpoint.js.map +1 -1
  7. package/src/lib/deps-plugin.js +17 -6
  8. package/src/lib/deps-plugin.js.map +1 -1
  9. package/src/lib/nitro/analog-nitro-plugin.js +102 -45
  10. package/src/lib/nitro/analog-nitro-plugin.js.map +1 -1
  11. package/src/lib/nitro/get-server-fn-handlers.d.ts +29 -0
  12. package/src/lib/nitro/get-server-fn-handlers.js +66 -0
  13. package/src/lib/nitro/get-server-fn-handlers.js.map +1 -0
  14. package/src/lib/nitro/server-fn-endpoints.d.ts +41 -0
  15. package/src/lib/nitro/server-fn-endpoints.js +57 -0
  16. package/src/lib/nitro/server-fn-endpoints.js.map +1 -0
  17. package/src/lib/nx-plugin/src/generators/app/files/template-angular/src/server/routes/api/v1/hello.ts__template__ +2 -2
  18. package/src/lib/nx-plugin/src/generators/app/files/template-angular/vite.config.ts__template__ +4 -0
  19. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.d.ts +7 -5
  20. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js.map +1 -1
  21. package/src/lib/nx-plugin/src/generators/preset/__snapshots__/generator.spec.ts.snap +3 -1
  22. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.d.ts +5 -5
  23. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js +5 -5
  24. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js.map +1 -1
  25. package/src/lib/options.d.ts +8 -0
  26. package/src/lib/platform-plugin.js +34 -3
  27. package/src/lib/platform-plugin.js.map +1 -1
  28. package/src/lib/ssr/defer-streaming-plugin.js +97 -0
  29. package/src/lib/ssr/defer-streaming-plugin.js.map +1 -0
  30. package/src/lib/utils/rolldown.js +1 -1
  31. package/src/server-mode-plugin.d.ts +1 -1
  32. package/src/server-mode-plugin.js +13 -1
  33. package/src/server-mode-plugin.js.map +1 -1
@@ -1,13 +1,13 @@
1
- export declare const V19_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.91";
2
- export declare const V19_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.91";
1
+ export declare const V19_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.92";
2
+ export declare const V19_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.92";
3
3
  export declare const V19_X_MARKED = "^18.0.0";
4
4
  export declare const V19_X_MARKED_GFM_HEADING_ID = "^4.1.1";
5
5
  export declare const V19_X_MARKED_HIGHLIGHT = "^2.2.1";
6
6
  export declare const V19_X_MARKED_MANGLE = "^1.1.10";
7
7
  export declare const V19_X_PRISMJS = "^1.29.0";
8
- export declare const V19_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.91";
9
- export declare const V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.91";
10
- export declare const V19_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.91";
8
+ export declare const V19_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.92";
9
+ export declare const V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.92";
10
+ export declare const V19_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.92";
11
11
  export declare const V19_X_NX_ANGULAR = "^22.0.0";
12
12
  export declare const V19_X_NX_VITE = "^22.0.0";
13
13
  export declare const V19_X_JSDOM = "^22.0.0";
@@ -1,14 +1,14 @@
1
1
  //#region packages/nx-plugin/src/utils/versions/ng_19_X/versions.ts
2
- var V19_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.91";
3
- var V19_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.91";
2
+ var V19_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.92";
3
+ var V19_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.92";
4
4
  var V19_X_MARKED = "^18.0.0";
5
5
  var V19_X_MARKED_GFM_HEADING_ID = "^4.1.1";
6
6
  var V19_X_MARKED_HIGHLIGHT = "^2.2.1";
7
7
  var V19_X_MARKED_MANGLE = "^1.1.10";
8
8
  var V19_X_PRISMJS = "^1.29.0";
9
- var V19_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.91";
10
- var V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.91";
11
- var V19_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.91";
9
+ var V19_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.92";
10
+ var V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.92";
11
+ var V19_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.92";
12
12
  var V19_X_NX_VITE = "^22.0.0";
13
13
  var V19_X_JSDOM = "^22.0.0";
14
14
  var V19_X_VITE_TSCONFIG_PATHS = "^4.2.0";
@@ -1 +1 @@
1
- {"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../../../nx-plugin/src/utils/versions/ng_19_X/versions.ts"],"sourcesContent":["// V19_X\nexport const V19_X_ANALOG_JS_ROUTER = '^3.0.0-alpha.91';\nexport const V19_X_ANALOG_JS_CONTENT = '^3.0.0-alpha.91';\nexport const V19_X_MARKED = '^18.0.0';\nexport const V19_X_MARKED_GFM_HEADING_ID = '^4.1.1';\nexport const V19_X_MARKED_HIGHLIGHT = '^2.2.1';\nexport const V19_X_MARKED_MANGLE = '^1.1.10';\nexport const V19_X_PRISMJS = '^1.29.0';\n\n// devDependencies\nexport const V19_X_ANALOG_JS_PLATFORM = '^3.0.0-alpha.91';\nexport const V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-alpha.91';\nexport const V19_X_ANALOG_JS_VITEST_ANGULAR = '^3.0.0-alpha.91';\nexport const V19_X_NX_ANGULAR = '^22.0.0';\nexport const V19_X_NX_VITE = '^22.0.0';\nexport const V19_X_JSDOM = '^22.0.0';\nexport const V19_X_VITE_TSCONFIG_PATHS = '^4.2.0';\nexport const V19_X_VITEST = '^3.0.0';\nexport const V19_X_VITE = '^6.0.0';\nexport const NX_X_LATEST_VITE = '^8.0.0';\nexport const NX_X_LATEST_VITEST = '^4.0.0';\nexport const NX_X_LATEST_NX = '^23.0.0';\n"],"mappings":";AACA,IAAa,yBAAyB;AACtC,IAAa,0BAA0B;AACvC,IAAa,eAAe;AAC5B,IAAa,8BAA8B;AAC3C,IAAa,yBAAyB;AACtC,IAAa,sBAAsB;AACnC,IAAa,gBAAgB;AAG7B,IAAa,2BAA2B;AACxC,IAAa,sCAAsC;AACnD,IAAa,iCAAiC;AAE9C,IAAa,gBAAgB;AAC7B,IAAa,cAAc;AAC3B,IAAa,4BAA4B;AACzC,IAAa,eAAe;AAC5B,IAAa,aAAa;AAC1B,IAAa,mBAAmB;AAChC,IAAa,qBAAqB;AAClC,IAAa,iBAAiB"}
1
+ {"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../../../nx-plugin/src/utils/versions/ng_19_X/versions.ts"],"sourcesContent":["// V19_X\nexport const V19_X_ANALOG_JS_ROUTER = '^3.0.0-alpha.92';\nexport const V19_X_ANALOG_JS_CONTENT = '^3.0.0-alpha.92';\nexport const V19_X_MARKED = '^18.0.0';\nexport const V19_X_MARKED_GFM_HEADING_ID = '^4.1.1';\nexport const V19_X_MARKED_HIGHLIGHT = '^2.2.1';\nexport const V19_X_MARKED_MANGLE = '^1.1.10';\nexport const V19_X_PRISMJS = '^1.29.0';\n\n// devDependencies\nexport const V19_X_ANALOG_JS_PLATFORM = '^3.0.0-alpha.92';\nexport const V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-alpha.92';\nexport const V19_X_ANALOG_JS_VITEST_ANGULAR = '^3.0.0-alpha.92';\nexport const V19_X_NX_ANGULAR = '^22.0.0';\nexport const V19_X_NX_VITE = '^22.0.0';\nexport const V19_X_JSDOM = '^22.0.0';\nexport const V19_X_VITE_TSCONFIG_PATHS = '^4.2.0';\nexport const V19_X_VITEST = '^3.0.0';\nexport const V19_X_VITE = '^6.0.0';\nexport const NX_X_LATEST_VITE = '^8.0.0';\nexport const NX_X_LATEST_VITEST = '^4.0.0';\nexport const NX_X_LATEST_NX = '^23.0.0';\n"],"mappings":";AACA,IAAa,yBAAyB;AACtC,IAAa,0BAA0B;AACvC,IAAa,eAAe;AAC5B,IAAa,8BAA8B;AAC3C,IAAa,yBAAyB;AACtC,IAAa,sBAAsB;AACnC,IAAa,gBAAgB;AAG7B,IAAa,2BAA2B;AACxC,IAAa,sCAAsC;AACnD,IAAa,iCAAiC;AAE9C,IAAa,gBAAgB;AAC7B,IAAa,cAAc;AAC3B,IAAa,4BAA4B;AACzC,IAAa,eAAe;AAC5B,IAAa,aAAa;AAC1B,IAAa,mBAAmB;AAChC,IAAa,qBAAqB;AAClC,IAAa,iBAAiB"}
@@ -117,6 +117,14 @@ export interface Options {
117
117
  experimental?: {
118
118
  /** Generate route declarations and enable typed navigation helpers. */
119
119
  typedRouting?: boolean | import("./typed-routes-plugin.js").TypedRoutingOptions;
120
+ /**
121
+ * Opt into progressive streaming SSR. When enabled, the SSR build patches
122
+ * `@angular/core` with a per-`@defer` block resolution hook so
123
+ * `@analogjs/router`'s `renderStream` can flush the document head first and
124
+ * each `@defer (hydrate …)` block as it resolves on the server. Has no
125
+ * effect unless the server entry uses `renderStream`.
126
+ */
127
+ streaming?: boolean;
120
128
  };
121
129
  }
122
130
  export type { PrerenderContentDir, PrerenderContentFile, PrerenderSitemapConfig, SitemapConfig, SitemapEntry, SitemapExcludeRule, SitemapPriority, SitemapRouteDefinition, SitemapRouteInput, SitemapRouteSource, SitemapTransform };
@@ -6,13 +6,29 @@ import { contentPlugin } from "./content-plugin.js";
6
6
  import { clearClientPageEndpointsPlugin } from "./clear-client-page-endpoint.js";
7
7
  import { depsPlugin } from "./deps-plugin.js";
8
8
  import { injectHTMLPlugin } from "./ssr/inject-html-plugin.js";
9
+ import { deferStreamingPlugin, streamingSupportedOnAngular } from "./ssr/defer-streaming-plugin.js";
9
10
  import { serverModePlugin } from "../server-mode-plugin.js";
10
11
  import { typedRoutes } from "./typed-routes-plugin.js";
11
12
  import { i18nComponentRegistryPlugin } from "./i18n-component-registry-plugin.js";
12
13
  import { analogNitroPlugin } from "./nitro/analog-nitro-plugin.js";
13
- import "node:module";
14
- import "node:path";
14
+ import { createRequire } from "node:module";
15
+ import { join } from "node:path";
15
16
  //#region packages/platform/src/lib/platform-plugin.ts
17
+ /**
18
+ * The installed `@angular/core` major version, resolved from the workspace root
19
+ * (where the app's Angular is installed). Returns `null` when it cannot be
20
+ * detected, in which case streaming is not blocked and the build-time
21
+ * anchor-drift detection is relied on instead.
22
+ */
23
+ function getAngularCoreMajor(workspaceRoot) {
24
+ try {
25
+ const { version } = createRequire(join(workspaceRoot, "noop.js"))("@angular/core/package.json");
26
+ const major = Number.parseInt(version.split(".")[0], 10);
27
+ return Number.isNaN(major) ? null : major;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
16
32
  function platformPlugin(opts = {}) {
17
33
  applyDebugOption(opts.debug, opts.workspaceRoot);
18
34
  const isTest = process.env.NODE_ENV === "test" || !!process.env["VITEST"];
@@ -20,6 +36,16 @@ function platformPlugin(opts = {}) {
20
36
  ssr: true,
21
37
  ...opts
22
38
  };
39
+ if (platformOptions.ssr && platformOptions.experimental?.streaming) {
40
+ const major = getAngularCoreMajor(platformOptions.workspaceRoot ?? process.cwd());
41
+ if (!streamingSupportedOnAngular(major)) {
42
+ console.warn(`[@analogjs/platform] experimental.streaming requires Angular 21+ (detected v${major}); streaming is disabled and rendering falls back to buffered SSR.`);
43
+ platformOptions.experimental = {
44
+ ...platformOptions.experimental,
45
+ streaming: false
46
+ };
47
+ }
48
+ }
23
49
  debugPlatform("experimental options resolved", { typedRouting: platformOptions.experimental?.typedRouting });
24
50
  return [
25
51
  ...platformOptions.experimental?.typedRouting ? [typedRoutes({
@@ -34,14 +60,19 @@ function platformPlugin(opts = {}) {
34
60
  activateDeferredDebug(command);
35
61
  }
36
62
  },
63
+ {
64
+ name: "@analogjs/platform-options",
65
+ api: { analogOptions: platformOptions }
66
+ },
37
67
  ...!isTest ? [analogNitroPlugin(platformOptions)] : [],
38
68
  ...platformOptions.ssr ? [...ssrBuildPlugin(), ...injectHTMLPlugin()] : [],
69
+ ...platformOptions.ssr && platformOptions.experimental?.streaming ? [deferStreamingPlugin()] : [],
39
70
  ...!isTest ? depsPlugin(platformOptions) : [],
40
71
  ...routerPlugin(platformOptions),
41
72
  analogIntegrationPlugin(platformOptions),
42
73
  ...contentPlugin(platformOptions?.content, platformOptions),
43
74
  ...platformOptions.i18n ? [i18nComponentRegistryPlugin()] : [],
44
- ...serverModePlugin(),
75
+ ...serverModePlugin(platformOptions.entryServer),
45
76
  clearClientPageEndpointsPlugin()
46
77
  ];
47
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"platform-plugin.js","names":[],"sources":["../../../src/lib/platform-plugin.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { Plugin } from 'vite';\n\nimport { Options } from './options.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugPlatform,\n} from './utils/debug.js';\nimport { routerPlugin } from './router-plugin.js';\nimport { analogIntegrationPlugin } from './analog-integration-plugin.js';\nimport { ssrBuildPlugin } from './ssr/ssr-build-plugin.js';\nimport { contentPlugin } from './content-plugin.js';\nimport { clearClientPageEndpointsPlugin } from './clear-client-page-endpoint.js';\nimport { depsPlugin } from './deps-plugin.js';\nimport { injectHTMLPlugin } from './ssr/inject-html-plugin.js';\nimport { serverModePlugin } from '../server-mode-plugin.js';\nimport { typedRoutes } from './typed-routes-plugin.js';\nimport { i18nComponentRegistryPlugin } from './i18n-component-registry-plugin.js';\nimport { analogNitroPlugin } from './nitro/analog-nitro-plugin.js';\n\n/**\n * The installed `@angular/core` major version, resolved from the workspace root\n * (where the app's Angular is installed). Returns `null` when it cannot be\n * detected, in which case streaming is not blocked and the build-time\n * anchor-drift detection is relied on instead.\n */\nfunction getAngularCoreMajor(workspaceRoot: string): number | null {\n try {\n const req = createRequire(join(workspaceRoot, 'noop.js'));\n const { version } = req('@angular/core/package.json') as {\n version: string;\n };\n const major = Number.parseInt(version.split('.')[0], 10);\n return Number.isNaN(major) ? null : major;\n } catch {\n return null;\n }\n}\n\nexport function platformPlugin(opts: Options = {}): Plugin[] {\n applyDebugOption(opts.debug, opts.workspaceRoot);\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const { ...platformOptions } = {\n ssr: true,\n ...opts,\n };\n\n debugPlatform('experimental options resolved', {\n typedRouting: platformOptions.experimental?.typedRouting,\n });\n\n return [\n ...(platformOptions.experimental?.typedRouting\n ? [\n typedRoutes({\n ...(typeof platformOptions.experimental.typedRouting === 'object'\n ? platformOptions.experimental.typedRouting\n : {}),\n workspaceRoot: platformOptions.workspaceRoot,\n additionalPagesDirs: platformOptions.additionalPagesDirs,\n additionalContentDirs: platformOptions.additionalContentDirs,\n }),\n ]\n : []),\n {\n name: 'analogjs-debug-activate',\n config(_, { command }) {\n activateDeferredDebug(command);\n },\n },\n ...(!isTest ? [analogNitroPlugin(platformOptions)] : []),\n ...(platformOptions.ssr\n ? [...ssrBuildPlugin(), ...injectHTMLPlugin()]\n : []),\n ...(!isTest ? depsPlugin(platformOptions) : []),\n ...routerPlugin(platformOptions),\n analogIntegrationPlugin(platformOptions),\n ...contentPlugin(platformOptions?.content, platformOptions),\n ...(platformOptions.i18n ? [i18nComponentRegistryPlugin()] : []),\n ...serverModePlugin(),\n clearClientPageEndpointsPlugin(),\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,SAAgB,eAAe,OAAgB,EAAE,EAAY;AAC3D,kBAAiB,KAAK,OAAO,KAAK,cAAc;CAEhD,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,EAAE,GAAG,oBAAoB;EAC7B,KAAK;EACL,GAAG;EACJ;AAED,eAAc,iCAAiC,EAC7C,cAAc,gBAAgB,cAAc,cAC7C,CAAC;AAEF,QAAO;EACL,GAAI,gBAAgB,cAAc,eAC9B,CACE,YAAY;GACV,GAAI,OAAO,gBAAgB,aAAa,iBAAiB,WACrD,gBAAgB,aAAa,eAC7B,EAAE;GACN,eAAe,gBAAgB;GAC/B,qBAAqB,gBAAgB;GACrC,uBAAuB,gBAAgB;GACxC,CAAC,CACH,GACD,EAAE;EACN;GACE,MAAM;GACN,OAAO,GAAG,EAAE,WAAW;AACrB,0BAAsB,QAAQ;;GAEjC;EACD,GAAI,CAAC,SAAS,CAAC,kBAAkB,gBAAgB,CAAC,GAAG,EAAE;EACvD,GAAI,gBAAgB,MAChB,CAAC,GAAG,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,GAC5C,EAAE;EACN,GAAI,CAAC,SAAS,WAAW,gBAAgB,GAAG,EAAE;EAC9C,GAAG,aAAa,gBAAgB;EAChC,wBAAwB,gBAAgB;EACxC,GAAG,cAAc,iBAAiB,SAAS,gBAAgB;EAC3D,GAAI,gBAAgB,OAAO,CAAC,6BAA6B,CAAC,GAAG,EAAE;EAC/D,GAAG,kBAAkB;EACrB,gCAAgC;EACjC"}
1
+ {"version":3,"file":"platform-plugin.js","names":[],"sources":["../../../src/lib/platform-plugin.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { Plugin } from 'vite';\n\nimport { Options } from './options.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugPlatform,\n} from './utils/debug.js';\nimport { routerPlugin } from './router-plugin.js';\nimport { analogIntegrationPlugin } from './analog-integration-plugin.js';\nimport { ssrBuildPlugin } from './ssr/ssr-build-plugin.js';\nimport { contentPlugin } from './content-plugin.js';\nimport { clearClientPageEndpointsPlugin } from './clear-client-page-endpoint.js';\nimport { depsPlugin } from './deps-plugin.js';\nimport { injectHTMLPlugin } from './ssr/inject-html-plugin.js';\nimport {\n deferStreamingPlugin,\n MIN_STREAMING_ANGULAR_MAJOR,\n streamingSupportedOnAngular,\n} from './ssr/defer-streaming-plugin.js';\nimport { serverModePlugin } from '../server-mode-plugin.js';\nimport { typedRoutes } from './typed-routes-plugin.js';\nimport { i18nComponentRegistryPlugin } from './i18n-component-registry-plugin.js';\nimport { analogNitroPlugin } from './nitro/analog-nitro-plugin.js';\n\n/**\n * The installed `@angular/core` major version, resolved from the workspace root\n * (where the app's Angular is installed). Returns `null` when it cannot be\n * detected, in which case streaming is not blocked and the build-time\n * anchor-drift detection is relied on instead.\n */\nfunction getAngularCoreMajor(workspaceRoot: string): number | null {\n try {\n const req = createRequire(join(workspaceRoot, 'noop.js'));\n const { version } = req('@angular/core/package.json') as {\n version: string;\n };\n const major = Number.parseInt(version.split('.')[0], 10);\n return Number.isNaN(major) ? null : major;\n } catch {\n return null;\n }\n}\n\nexport function platformPlugin(opts: Options = {}): Plugin[] {\n applyDebugOption(opts.debug, opts.workspaceRoot);\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const { ...platformOptions } = {\n ssr: true,\n ...opts,\n };\n\n // Streaming patches the compiled @angular/core, which needs a supported\n // Angular version. Turn it off otherwise so the renderer stays buffered.\n if (platformOptions.ssr && platformOptions.experimental?.streaming) {\n const major = getAngularCoreMajor(\n platformOptions.workspaceRoot ?? process.cwd(),\n );\n if (!streamingSupportedOnAngular(major)) {\n console.warn(\n `[@analogjs/platform] experimental.streaming requires Angular ` +\n `${MIN_STREAMING_ANGULAR_MAJOR}+ (detected v${major}); streaming is ` +\n `disabled and rendering falls back to buffered SSR.`,\n );\n platformOptions.experimental = {\n ...platformOptions.experimental,\n streaming: false,\n };\n }\n }\n\n debugPlatform('experimental options resolved', {\n typedRouting: platformOptions.experimental?.typedRouting,\n });\n\n return [\n ...(platformOptions.experimental?.typedRouting\n ? [\n typedRoutes({\n ...(typeof platformOptions.experimental.typedRouting === 'object'\n ? platformOptions.experimental.typedRouting\n : {}),\n workspaceRoot: platformOptions.workspaceRoot,\n additionalPagesDirs: platformOptions.additionalPagesDirs,\n additionalContentDirs: platformOptions.additionalContentDirs,\n }),\n ]\n : []),\n {\n name: 'analogjs-debug-activate',\n config(_, { command }) {\n activateDeferredDebug(command);\n },\n },\n // `nitro()` from `@analogjs/vite-plugin-nitro` reads these as its defaults.\n {\n name: '@analogjs/platform-options',\n api: { analogOptions: platformOptions },\n },\n ...(!isTest ? [analogNitroPlugin(platformOptions)] : []),\n ...(platformOptions.ssr\n ? [...ssrBuildPlugin(), ...injectHTMLPlugin()]\n : []),\n ...(platformOptions.ssr && platformOptions.experimental?.streaming\n ? [deferStreamingPlugin()]\n : []),\n ...(!isTest ? depsPlugin(platformOptions) : []),\n ...routerPlugin(platformOptions),\n analogIntegrationPlugin(platformOptions),\n ...contentPlugin(platformOptions?.content, platformOptions),\n ...(platformOptions.i18n ? [i18nComponentRegistryPlugin()] : []),\n ...serverModePlugin(platformOptions.entryServer),\n clearClientPageEndpointsPlugin(),\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,oBAAoB,eAAsC;AACjE,KAAI;EAEF,MAAM,EAAE,YADI,cAAc,KAAK,eAAe,UAAU,CAAC,CACjC,6BAA6B;EAGrD,MAAM,QAAQ,OAAO,SAAS,QAAQ,MAAM,IAAI,CAAC,IAAI,GAAG;AACxD,SAAO,OAAO,MAAM,MAAM,GAAG,OAAO;SAC9B;AACN,SAAO;;;AAIX,SAAgB,eAAe,OAAgB,EAAE,EAAY;AAC3D,kBAAiB,KAAK,OAAO,KAAK,cAAc;CAEhD,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,EAAE,GAAG,oBAAoB;EAC7B,KAAK;EACL,GAAG;EACJ;AAID,KAAI,gBAAgB,OAAO,gBAAgB,cAAc,WAAW;EAClE,MAAM,QAAQ,oBACZ,gBAAgB,iBAAiB,QAAQ,KAAK,CAC/C;AACD,MAAI,CAAC,4BAA4B,MAAM,EAAE;AACvC,WAAQ,KACN,+EACgD,MAAM,oEAEvD;AACD,mBAAgB,eAAe;IAC7B,GAAG,gBAAgB;IACnB,WAAW;IACZ;;;AAIL,eAAc,iCAAiC,EAC7C,cAAc,gBAAgB,cAAc,cAC7C,CAAC;AAEF,QAAO;EACL,GAAI,gBAAgB,cAAc,eAC9B,CACE,YAAY;GACV,GAAI,OAAO,gBAAgB,aAAa,iBAAiB,WACrD,gBAAgB,aAAa,eAC7B,EAAE;GACN,eAAe,gBAAgB;GAC/B,qBAAqB,gBAAgB;GACrC,uBAAuB,gBAAgB;GACxC,CAAC,CACH,GACD,EAAE;EACN;GACE,MAAM;GACN,OAAO,GAAG,EAAE,WAAW;AACrB,0BAAsB,QAAQ;;GAEjC;EAED;GACE,MAAM;GACN,KAAK,EAAE,eAAe,iBAAiB;GACxC;EACD,GAAI,CAAC,SAAS,CAAC,kBAAkB,gBAAgB,CAAC,GAAG,EAAE;EACvD,GAAI,gBAAgB,MAChB,CAAC,GAAG,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,GAC5C,EAAE;EACN,GAAI,gBAAgB,OAAO,gBAAgB,cAAc,YACrD,CAAC,sBAAsB,CAAC,GACxB,EAAE;EACN,GAAI,CAAC,SAAS,WAAW,gBAAgB,GAAG,EAAE;EAC9C,GAAG,aAAa,gBAAgB;EAChC,wBAAwB,gBAAgB;EACxC,GAAG,cAAc,iBAAiB,SAAS,gBAAgB;EAC3D,GAAI,gBAAgB,OAAO,CAAC,6BAA6B,CAAC,GAAG,EAAE;EAC/D,GAAG,iBAAiB,gBAAgB,YAAY;EAChD,gCAAgC;EACjC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Whether the streaming SSR patch can be applied to the installed Angular.
3
+ * A `null` major (version undetectable) returns `true`: don't block on a failed
4
+ * detection — the plugin's anchor-drift detection catches a real mismatch at
5
+ * build time and falls back to buffered rendering.
6
+ */
7
+ function streamingSupportedOnAngular(major) {
8
+ return major === null || major >= 21;
9
+ }
10
+ /**
11
+ * Pure transform that injects the streaming-SSR per-block resolution hook into
12
+ * `@angular/core`'s compiled output. It is the same class of transform as
13
+ * `i18nDefRegistryPlugin` in ./ssr-build-plugin — a string patch of Angular's
14
+ * bundle applied only to SSR builds. Exported separately so it can be unit
15
+ * tested against a bundle string.
16
+ *
17
+ * Two edits, both keyed on single-occurrence anchors in the module that holds
18
+ * the defer runtime:
19
+ * 1. Inside `applyDeferBlockState`, fire `globalThis.__analogSsrDeferCapture`
20
+ * when a `@defer` block reaches `Complete` on the server, passing the
21
+ * block's live `lContainer` — this is the per-block resolution signal a
22
+ * streaming renderer consumes.
23
+ * 2. Expose `collectNativeNodesInLContainer` via `globalThis.__analogSsrInternals`
24
+ * so the renderer can serialize a block's subtree.
25
+ *
26
+ * Returns `null` when the module is not the one carrying the defer runtime, so
27
+ * it is a no-op on every other Angular module.
28
+ */
29
+ function injectDeferStreamingHook(code) {
30
+ const END_ANCHOR = "profiler(ProfilerEvent.DeferBlockStateEnd);";
31
+ if (!code.includes("function applyDeferBlockState(") || !code.includes(END_ANCHOR)) return null;
32
+ let out = code.replace(END_ANCHOR, "try { if (newState === DeferBlockState.Complete && typeof ngServerMode !== 'undefined' && ngServerMode && typeof globalThis.__analogSsrDeferCapture === 'function') { globalThis.__analogSsrDeferCapture({ ssrUniqueId: lDetails[SSR_UNIQUE_ID], lContainer, hostLView }); } } catch (e) {}\n " + END_ANCHOR);
33
+ if (code.includes("function collectNativeNodesInLContainer(")) out += "\nglobalThis.__analogSsrInternals = Object.assign(globalThis.__analogSsrInternals || {}, { collectNativeNodesInLContainer });\n";
34
+ return out;
35
+ }
36
+ /**
37
+ * Classify an `@angular/core` module for the streaming patch. The patch anchors
38
+ * on internal symbol names, so when Angular changes those the transform would
39
+ * otherwise become a silent no-op and streaming would degrade to buffered with
40
+ * no signal. This distinguishes "not the target module" (skip quietly) from
41
+ * "this IS the `@defer` runtime module but the anchors drifted" (worth warning).
42
+ */
43
+ function inspectAngularCoreModule(code) {
44
+ if (!code.includes("function applyDeferBlockState(")) return { kind: "not-target" };
45
+ const missing = [];
46
+ if (!code.includes("profiler(ProfilerEvent.DeferBlockStateEnd);")) missing.push("DeferBlockStateEnd profiler anchor");
47
+ if (!code.includes("function collectNativeNodesInLContainer(")) missing.push("collectNativeNodesInLContainer");
48
+ return missing.length === 0 ? { kind: "patchable" } : {
49
+ kind: "drifted",
50
+ reason: `missing ${missing.join(", ")}`
51
+ };
52
+ }
53
+ /**
54
+ * Vite plugin that applies {@link injectDeferStreamingHook} to `@angular/core`
55
+ * during SSR builds, so `@analogjs/router`'s `renderStream` can flush `@defer`
56
+ * blocks as they resolve on the server — without hand-patching node_modules.
57
+ *
58
+ * Only active for SSR. Mirrors the enforce/filter/ssr-gate shape of
59
+ * `i18nDefRegistryPlugin`. If the `@defer` runtime module is found but its
60
+ * anchors have drifted (Angular changed internals), or if it is never
61
+ * encountered at all, the plugin warns rather than silently producing a build
62
+ * that falls back to buffered rendering.
63
+ */
64
+ function deferStreamingPlugin() {
65
+ let applied = false;
66
+ let warnedDrift = false;
67
+ return {
68
+ name: "analogjs-defer-streaming",
69
+ enforce: "post",
70
+ transform: {
71
+ filter: { id: /\/@angular\/core\// },
72
+ handler(code, _id, options) {
73
+ if (!options?.ssr) return;
74
+ const info = inspectAngularCoreModule(code);
75
+ if (info.kind === "not-target") return;
76
+ if (info.kind === "drifted") {
77
+ if (!warnedDrift) {
78
+ warnedDrift = true;
79
+ this.warn(`experimental streaming SSR: found @angular/core's @defer runtime but could not apply the resolution hook (${info.reason}). The installed Angular version likely changed internals the patch depends on; streaming will fall back to buffered rendering.`);
80
+ }
81
+ return;
82
+ }
83
+ const out = injectDeferStreamingHook(code);
84
+ if (!out) return;
85
+ applied = true;
86
+ return { code: out };
87
+ }
88
+ },
89
+ buildEnd() {
90
+ if (!applied && !warnedDrift) this.warn("experimental streaming SSR is enabled but @angular/core's @defer runtime module was never encountered during the SSR build, so the resolution hook was not injected. Streaming will fall back to buffered rendering.");
91
+ }
92
+ };
93
+ }
94
+ //#endregion
95
+ export { deferStreamingPlugin, streamingSupportedOnAngular };
96
+
97
+ //# sourceMappingURL=defer-streaming-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defer-streaming-plugin.js","names":[],"sources":["../../../../src/lib/ssr/defer-streaming-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\n/**\n * Minimum Angular major whose compiled `@angular/core` FESM matches the\n * streaming patch anchors. Incremental hydration is a stable public API from\n * v20 (`withIncrementalHydration`, `@publicApi 20.0`), but v20's FESM inlines\n * the injection anchor's `DeferBlockStateEnd` profiler event to its numeric\n * ordinal, whereas v21+ keeps the symbolic `ProfilerEvent.DeferBlockStateEnd`\n * form the anchor matches on. Keying on the literal ordinal would be fragile\n * (enum values shift between versions), so v21 is the floor.\n */\nexport const MIN_STREAMING_ANGULAR_MAJOR = 21;\n\n/**\n * Whether the streaming SSR patch can be applied to the installed Angular.\n * A `null` major (version undetectable) returns `true`: don't block on a failed\n * detection — the plugin's anchor-drift detection catches a real mismatch at\n * build time and falls back to buffered rendering.\n */\nexport function streamingSupportedOnAngular(major: number | null): boolean {\n return major === null || major >= MIN_STREAMING_ANGULAR_MAJOR;\n}\n\n/**\n * Pure transform that injects the streaming-SSR per-block resolution hook into\n * `@angular/core`'s compiled output. It is the same class of transform as\n * `i18nDefRegistryPlugin` in ./ssr-build-plugin — a string patch of Angular's\n * bundle applied only to SSR builds. Exported separately so it can be unit\n * tested against a bundle string.\n *\n * Two edits, both keyed on single-occurrence anchors in the module that holds\n * the defer runtime:\n * 1. Inside `applyDeferBlockState`, fire `globalThis.__analogSsrDeferCapture`\n * when a `@defer` block reaches `Complete` on the server, passing the\n * block's live `lContainer` — this is the per-block resolution signal a\n * streaming renderer consumes.\n * 2. Expose `collectNativeNodesInLContainer` via `globalThis.__analogSsrInternals`\n * so the renderer can serialize a block's subtree.\n *\n * Returns `null` when the module is not the one carrying the defer runtime, so\n * it is a no-op on every other Angular module.\n */\nexport function injectDeferStreamingHook(code: string): string | null {\n const END_ANCHOR = 'profiler(ProfilerEvent.DeferBlockStateEnd);';\n if (\n !code.includes('function applyDeferBlockState(') ||\n !code.includes(END_ANCHOR)\n ) {\n return null;\n }\n\n // Wrap the entire guard — not just the call — so a drifted Angular runtime\n // that still matches the anchors but renamed these locals fails as a silent\n // no-op instead of throwing a ReferenceError inside applyDeferBlockState.\n const capture =\n `try { if (newState === DeferBlockState.Complete && ` +\n `typeof ngServerMode !== 'undefined' && ngServerMode && ` +\n `typeof globalThis.__analogSsrDeferCapture === 'function') { ` +\n `globalThis.__analogSsrDeferCapture({ ssrUniqueId: lDetails[SSR_UNIQUE_ID], lContainer, hostLView }); } } catch (e) {}\\n `;\n\n let out = code.replace(END_ANCHOR, capture + END_ANCHOR);\n\n if (code.includes('function collectNativeNodesInLContainer(')) {\n out +=\n '\\nglobalThis.__analogSsrInternals = Object.assign(globalThis.__analogSsrInternals || {}, { collectNativeNodesInLContainer });\\n';\n }\n\n return out;\n}\n\n/**\n * Classify an `@angular/core` module for the streaming patch. The patch anchors\n * on internal symbol names, so when Angular changes those the transform would\n * otherwise become a silent no-op and streaming would degrade to buffered with\n * no signal. This distinguishes \"not the target module\" (skip quietly) from\n * \"this IS the `@defer` runtime module but the anchors drifted\" (worth warning).\n */\nexport function inspectAngularCoreModule(\n code: string,\n):\n | { kind: 'not-target' }\n | { kind: 'patchable' }\n | { kind: 'drifted'; reason: string } {\n if (!code.includes('function applyDeferBlockState(')) {\n return { kind: 'not-target' };\n }\n const missing: string[] = [];\n if (!code.includes('profiler(ProfilerEvent.DeferBlockStateEnd);')) {\n missing.push('DeferBlockStateEnd profiler anchor');\n }\n if (!code.includes('function collectNativeNodesInLContainer(')) {\n missing.push('collectNativeNodesInLContainer');\n }\n return missing.length === 0\n ? { kind: 'patchable' }\n : { kind: 'drifted', reason: `missing ${missing.join(', ')}` };\n}\n\n/**\n * Vite plugin that applies {@link injectDeferStreamingHook} to `@angular/core`\n * during SSR builds, so `@analogjs/router`'s `renderStream` can flush `@defer`\n * blocks as they resolve on the server — without hand-patching node_modules.\n *\n * Only active for SSR. Mirrors the enforce/filter/ssr-gate shape of\n * `i18nDefRegistryPlugin`. If the `@defer` runtime module is found but its\n * anchors have drifted (Angular changed internals), or if it is never\n * encountered at all, the plugin warns rather than silently producing a build\n * that falls back to buffered rendering.\n */\nexport function deferStreamingPlugin(): Plugin {\n let applied = false;\n let warnedDrift = false;\n return {\n name: 'analogjs-defer-streaming',\n enforce: 'post',\n transform: {\n filter: {\n id: /\\/@angular\\/core\\//,\n },\n handler(code, _id, options) {\n if (!options?.ssr) return;\n const info = inspectAngularCoreModule(code);\n if (info.kind === 'not-target') return;\n if (info.kind === 'drifted') {\n if (!warnedDrift) {\n warnedDrift = true;\n this.warn(\n `experimental streaming SSR: found @angular/core's @defer runtime ` +\n `but could not apply the resolution hook (${info.reason}). The ` +\n `installed Angular version likely changed internals the patch ` +\n `depends on; streaming will fall back to buffered rendering.`,\n );\n }\n return;\n }\n const out = injectDeferStreamingHook(code);\n if (!out) return;\n applied = true;\n return { code: out };\n },\n },\n buildEnd() {\n if (!applied && !warnedDrift) {\n this.warn(\n `experimental streaming SSR is enabled but @angular/core's @defer ` +\n `runtime module was never encountered during the SSR build, so the ` +\n `resolution hook was not injected. Streaming will fall back to ` +\n `buffered rendering.`,\n );\n }\n },\n };\n}\n"],"mappings":";;;;;;AAmBA,SAAgB,4BAA4B,OAA+B;AACzE,QAAO,UAAU,QAAQ,SAAA;;;;;;;;;;;;;;;;;;;;;AAsB3B,SAAgB,yBAAyB,MAA6B;CACpE,MAAM,aAAa;AACnB,KACE,CAAC,KAAK,SAAS,iCAAiC,IAChD,CAAC,KAAK,SAAS,WAAW,CAE1B,QAAO;CAYT,IAAI,MAAM,KAAK,QAAQ,YALrB,oSAK2C,WAAW;AAExD,KAAI,KAAK,SAAS,2CAA2C,CAC3D,QACE;AAGJ,QAAO;;;;;;;;;AAUT,SAAgB,yBACd,MAIsC;AACtC,KAAI,CAAC,KAAK,SAAS,iCAAiC,CAClD,QAAO,EAAE,MAAM,cAAc;CAE/B,MAAM,UAAoB,EAAE;AAC5B,KAAI,CAAC,KAAK,SAAS,8CAA8C,CAC/D,SAAQ,KAAK,qCAAqC;AAEpD,KAAI,CAAC,KAAK,SAAS,2CAA2C,CAC5D,SAAQ,KAAK,iCAAiC;AAEhD,QAAO,QAAQ,WAAW,IACtB,EAAE,MAAM,aAAa,GACrB;EAAE,MAAM;EAAW,QAAQ,WAAW,QAAQ,KAAK,KAAK;EAAI;;;;;;;;;;;;;AAclE,SAAgB,uBAA+B;CAC7C,IAAI,UAAU;CACd,IAAI,cAAc;AAClB,QAAO;EACL,MAAM;EACN,SAAS;EACT,WAAW;GACT,QAAQ,EACN,IAAI,sBACL;GACD,QAAQ,MAAM,KAAK,SAAS;AAC1B,QAAI,CAAC,SAAS,IAAK;IACnB,MAAM,OAAO,yBAAyB,KAAK;AAC3C,QAAI,KAAK,SAAS,aAAc;AAChC,QAAI,KAAK,SAAS,WAAW;AAC3B,SAAI,CAAC,aAAa;AAChB,oBAAc;AACd,WAAK,KACH,6GAC8C,KAAK,OAAO,iIAG3D;;AAEH;;IAEF,MAAM,MAAM,yBAAyB,KAAK;AAC1C,QAAI,CAAC,IAAK;AACV,cAAU;AACV,WAAO,EAAE,MAAM,KAAK;;GAEvB;EACD,WAAW;AACT,OAAI,CAAC,WAAW,CAAC,YACf,MAAK,KACH,uNAID;;EAGN"}
@@ -10,6 +10,6 @@ function getBundleOptionsKey() {
10
10
  return isRolldown() ? "rolldownOptions" : "rollupOptions";
11
11
  }
12
12
  //#endregion
13
- export { getBundleOptionsKey, getJsTransformConfigKey };
13
+ export { getBundleOptionsKey, getJsTransformConfigKey, isRolldown };
14
14
 
15
15
  //# sourceMappingURL=rolldown.js.map
@@ -10,4 +10,4 @@ export declare const SERVER_MODE_ID = "virtual:@analogjs/platform/server-mode";
10
10
  * first so the flag is set before any application module evaluates. A text
11
11
  * replacement cannot do this because Angular is pre-bundled for SSR.
12
12
  */
13
- export declare function serverModePlugin(): Plugin[];
13
+ export declare function serverModePlugin(entryServer?: string): Plugin[];
@@ -1,3 +1,5 @@
1
+ import { resolve } from "node:path";
2
+ import { normalizePath } from "vite";
1
3
  //#region packages/platform/src/server-mode-plugin.ts
2
4
  var SERVER_MODE_ID = "virtual:@analogjs/platform/server-mode";
3
5
  var RESOLVED_SERVER_MODE_ID = `\0${SERVER_MODE_ID}`;
@@ -11,9 +13,19 @@ var RESOLVED_SERVER_MODE_ID = `\0${SERVER_MODE_ID}`;
11
13
  * first so the flag is set before any application module evaluates. A text
12
14
  * replacement cannot do this because Angular is pre-bundled for SSR.
13
15
  */
14
- function serverModePlugin() {
16
+ function serverModePlugin(entryServer) {
17
+ let entryServerPath = "";
15
18
  return [{
16
19
  name: "analogjs-server-mode-plugin",
20
+ configResolved(config) {
21
+ entryServerPath = normalizePath(resolve(config.root, entryServer ?? "src/main.server.ts"));
22
+ },
23
+ transform(code, id, options) {
24
+ if (options?.ssr && normalizePath(id) === entryServerPath) return {
25
+ code: `import ${JSON.stringify(SERVER_MODE_ID)};\n${code}`,
26
+ map: null
27
+ };
28
+ },
17
29
  resolveId(id) {
18
30
  return id === "virtual:@analogjs/platform/server-mode" ? RESOLVED_SERVER_MODE_ID : void 0;
19
31
  },
@@ -1 +1 @@
1
- {"version":3,"file":"server-mode-plugin.js","names":[],"sources":["../../src/server-mode-plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\n\nexport const SERVER_MODE_ID = 'virtual:@analogjs/platform/server-mode';\nconst RESOLVED_SERVER_MODE_ID = `\\0${SERVER_MODE_ID}`;\n\n/**\n * Serves a module that sets `globalThis.ngServerMode = true`.\n *\n * Angular decides at provider-creation time whether browser-only features\n * such as event replay apply, and `provideClientHydration()` runs while the\n * app config module evaluates, before `platformServer()` or\n * `provideServerRendering()` set the flag. The SSR entry imports this module\n * first so the flag is set before any application module evaluates. A text\n * replacement cannot do this because Angular is pre-bundled for SSR.\n */\nexport function serverModePlugin(): Plugin[] {\n return [\n {\n name: 'analogjs-server-mode-plugin',\n resolveId(id) {\n return id === SERVER_MODE_ID ? RESOLVED_SERVER_MODE_ID : undefined;\n },\n load(id) {\n return id === RESOLVED_SERVER_MODE_ID\n ? 'globalThis.ngServerMode = true;\\nexport {};\\n'\n : undefined;\n },\n },\n ];\n}\n"],"mappings":";AAEA,IAAa,iBAAiB;AAC9B,IAAM,0BAA0B,KAAK;;;;;;;;;;;AAYrC,SAAgB,mBAA6B;AAC3C,QAAO,CACL;EACE,MAAM;EACN,UAAU,IAAI;AACZ,UAAO,OAAA,2CAAwB,0BAA0B,KAAA;;EAE3D,KAAK,IAAI;AACP,UAAO,OAAO,0BACV,kDACA,KAAA;;EAEP,CACF"}
1
+ {"version":3,"file":"server-mode-plugin.js","names":[],"sources":["../../src/server-mode-plugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { Plugin, normalizePath } from 'vite';\n\nexport const SERVER_MODE_ID = 'virtual:@analogjs/platform/server-mode';\nconst RESOLVED_SERVER_MODE_ID = `\\0${SERVER_MODE_ID}`;\n\n/**\n * Serves a module that sets `globalThis.ngServerMode = true`.\n *\n * Angular decides at provider-creation time whether browser-only features\n * such as event replay apply, and `provideClientHydration()` runs while the\n * app config module evaluates, before `platformServer()` or\n * `provideServerRendering()` set the flag. The SSR entry imports this module\n * first so the flag is set before any application module evaluates. A text\n * replacement cannot do this because Angular is pre-bundled for SSR.\n */\nexport function serverModePlugin(entryServer?: string): Plugin[] {\n let entryServerPath = '';\n\n return [\n {\n name: 'analogjs-server-mode-plugin',\n configResolved(config) {\n entryServerPath = normalizePath(\n resolve(config.root, entryServer ?? 'src/main.server.ts'),\n );\n },\n // Nitro v2 builds `main.server.ts` as the SSR entry directly, so set the\n // flag there too.\n transform(code, id, options) {\n if (options?.ssr && normalizePath(id) === entryServerPath) {\n return {\n code: `import ${JSON.stringify(SERVER_MODE_ID)};\\n${code}`,\n map: null,\n };\n }\n return undefined;\n },\n resolveId(id) {\n return id === SERVER_MODE_ID ? RESOLVED_SERVER_MODE_ID : undefined;\n },\n load(id) {\n return id === RESOLVED_SERVER_MODE_ID\n ? 'globalThis.ngServerMode = true;\\nexport {};\\n'\n : undefined;\n },\n },\n ];\n}\n"],"mappings":";;;AAGA,IAAa,iBAAiB;AAC9B,IAAM,0BAA0B,KAAK;;;;;;;;;;;AAYrC,SAAgB,iBAAiB,aAAgC;CAC/D,IAAI,kBAAkB;AAEtB,QAAO,CACL;EACE,MAAM;EACN,eAAe,QAAQ;AACrB,qBAAkB,cAChB,QAAQ,OAAO,MAAM,eAAe,qBAAqB,CAC1D;;EAIH,UAAU,MAAM,IAAI,SAAS;AAC3B,OAAI,SAAS,OAAO,cAAc,GAAG,KAAK,gBACxC,QAAO;IACL,MAAM,UAAU,KAAK,UAAU,eAAe,CAAC,KAAK;IACpD,KAAK;IACN;;EAIL,UAAU,IAAI;AACZ,UAAO,OAAA,2CAAwB,0BAA0B,KAAA;;EAE3D,KAAK,IAAI;AACP,UAAO,OAAO,0BACV,kDACA,KAAA;;EAEP,CACF"}