@gigadrive/network-config 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -327,6 +327,8 @@ var AVAILABLE_REGIONS = [...REGION_DEFINITIONS];
327
327
 
328
328
  // src/detection/frameworks/nextjs.ts
329
329
  var toPortablePath = (value) => value.replaceAll("\\", "/");
330
+ var MAXIMUM_ENTRY_PAGE_PATHS = 50;
331
+ var STANDALONE_SERVER_MEMORY_MB = 1024;
330
332
  var resolveStandaloneServer = Effect4.fn("nextjs.resolveStandaloneServer")(function* (projectFolder, distDir, repoRootToProject) {
331
333
  const fs = yield* FileSystem4.FileSystem;
332
334
  const pathService = yield* Path3.Path;
@@ -417,14 +419,9 @@ var createStandaloneConfig = Effect4.fn("nextjs.createStandaloneConfig")(functio
417
419
  };
418
420
  });
419
421
  var createStandaloneV2Config = Effect4.fn("nextjs.createStandaloneV2Config")(function* (defaults, projectFolder, manifest) {
420
- const pathService = yield* Path3.Path;
421
422
  const resolved = yield* resolveStandaloneServer(projectFolder, manifest.distDir, manifest.repoRootToProject);
422
423
  if (!resolved) return defaults;
423
424
  const { standaloneRoot, serverDirectory, entrypoint } = resolved;
424
- let repoRoot = projectFolder;
425
- if (manifest.repoRootToProject !== ".") {
426
- repoRoot = manifest.repoRootToProject.split("/").reduce((root) => pathService.dirname(root), repoRoot);
427
- }
428
425
  const publicAssets = yield* buildStandalonePublicAssets(projectFolder, standaloneRoot, serverDirectory);
429
426
  const assetPaths = [...publicAssets.assetPaths];
430
427
  const assetOverrides = { ...publicAssets.assetOverrides };
@@ -435,24 +432,16 @@ var createStandaloneV2Config = Effect4.fn("nextjs.createStandaloneV2Config")(fun
435
432
  immutable: staticAsset.immutable,
436
433
  populateCache: true
437
434
  }));
438
- const prerenders = manifest.outputs.prerenders.map((output) => {
439
- if (!output.fallback?.filePath) return output;
440
- const absolutePath = pathService.join(repoRoot, output.fallback.filePath);
441
- const projectRelativePath = toPortablePath(pathService.relative(projectFolder, absolutePath));
442
- if (projectRelativePath.startsWith("../")) return output;
443
- const internalAssetPath = `_gigadrive/prerender/${encodeURIComponent(output.id)}.html`;
444
- assetPaths.push(projectRelativePath);
445
- assetOverrides[projectRelativePath] = { path: internalAssetPath };
446
- return {
447
- ...output,
448
- fallback: { ...output.fallback, filePath: `/${internalAssetPath}` }
449
- };
450
- });
435
+ const entryPagePaths = [
436
+ ...new Set(
437
+ manifest.outputs.prerenders.filter((output) => !output.fallback?.postponedState).map((output) => output.pathname).filter((pathname) => pathname.startsWith("/") && !pathname.includes("["))
438
+ )
439
+ ].sort((left, right) => left.split("/").length - right.split("/").length || left.localeCompare(right)).slice(0, MAXIMUM_ENTRY_PAGE_PATHS);
451
440
  const singleEntrypoint = {
452
441
  displayName: "next-server",
453
442
  path: entrypoint,
454
443
  runtime: defaults.runtime,
455
- memory: defaults.memory,
444
+ memory: Math.max(defaults.memory, STANDALONE_SERVER_MEMORY_MB),
456
445
  maxDuration: manifest.server.maxDuration ?? defaults.maxDuration,
457
446
  streaming: true,
458
447
  environmentVariables: {
@@ -474,7 +463,11 @@ var createStandaloneV2Config = Effect4.fn("nextjs.createStandaloneV2Config")(fun
474
463
  server: manifest.server,
475
464
  config: manifest.config,
476
465
  routing: manifest.routing,
477
- outputs: { prerenders, staticAssets: manifest.outputs.staticAssets },
466
+ // The prerender table is deliberately not forwarded: the standalone server
467
+ // serves build-time prerenders from its own bundle, so the platform only
468
+ // needs the warming sample below.
469
+ outputs: { prerenders: [], staticAssets: manifest.outputs.staticAssets },
470
+ entryPagePaths,
478
471
  type: "nextjs",
479
472
  schemaVersion: 2
480
473
  };