* This is used to persist cache scopes across * prefetch -> full route requests for cache components * it's only fully used in dev
(options: ServerOptions)
| 440 | */ |
| 441 | |
| 442 | public constructor(options: ServerOptions) { |
| 443 | const { |
| 444 | dir = '.', |
| 445 | quiet = false, |
| 446 | conf, |
| 447 | dev = false, |
| 448 | minimalMode = false, |
| 449 | hostname, |
| 450 | port, |
| 451 | experimentalTestProxy, |
| 452 | } = options |
| 453 | |
| 454 | this.dev = dev |
| 455 | this.experimentalTestProxy = experimentalTestProxy |
| 456 | this.serverOptions = options |
| 457 | |
| 458 | this.dir = path.resolve(/* turbopackIgnore: true */ dir) |
| 459 | |
| 460 | this.quiet = quiet |
| 461 | this.loadEnvConfig({ dev, forceReload: false }) |
| 462 | |
| 463 | // TODO: should conf be normalized to prevent missing |
| 464 | // values from causing issues as this can be user provided |
| 465 | this.nextConfig = conf as NextConfigRuntime |
| 466 | |
| 467 | if (this.nextConfig.experimental.runtimeServerDeploymentId) { |
| 468 | if (!process.env.NEXT_DEPLOYMENT_ID) { |
| 469 | throw new Error( |
| 470 | 'process.env.NEXT_DEPLOYMENT_ID is missing but runtimeServerDeploymentId is enabled' |
| 471 | ) |
| 472 | } |
| 473 | this.deploymentId = process.env.NEXT_DEPLOYMENT_ID |
| 474 | } else { |
| 475 | let id = this.nextConfig.experimental.useSkewCookie |
| 476 | ? '' |
| 477 | : this.nextConfig.deploymentId || '' |
| 478 | |
| 479 | this.deploymentId = id |
| 480 | process.env.NEXT_DEPLOYMENT_ID = id |
| 481 | } |
| 482 | ;(globalThis as any).NEXT_CLIENT_ASSET_SUFFIX = |
| 483 | this.nextConfig.experimental.immutableAssetToken || this.deploymentId |
| 484 | ? `?dpl=${this.nextConfig.experimental.immutableAssetToken || this.deploymentId}` |
| 485 | : '' |
| 486 | |
| 487 | this.hostname = hostname |
| 488 | if (this.hostname) { |
| 489 | // we format the hostname so that it can be fetched |
| 490 | this.fetchHostname = formatHostname(this.hostname) |
| 491 | } |
| 492 | this.port = port |
| 493 | this.distDir = path.join( |
| 494 | /* turbopackIgnore: true */ this.dir, |
| 495 | this.nextConfig.distDir |
| 496 | ) |
| 497 | this.publicDir = this.getPublicDir() |
| 498 | this.hasStaticDir = !minimalMode && this.getHasStaticDir() |
| 499 |
nothing calls this directly
no test coverage detected