( nodeVersion: NodeVersion, entrypointDir: string, rootDir: string, serverBuildPath: string, serverEntryPoint: string | undefined, remixVersion: string, config: ResolvedNodeRouteConfig )
| 648 | } |
| 649 | |
| 650 | async function createRenderNodeFunction( |
| 651 | nodeVersion: NodeVersion, |
| 652 | entrypointDir: string, |
| 653 | rootDir: string, |
| 654 | serverBuildPath: string, |
| 655 | serverEntryPoint: string | undefined, |
| 656 | remixVersion: string, |
| 657 | config: ResolvedNodeRouteConfig |
| 658 | ): Promise<NodejsLambda> { |
| 659 | const files: Files = {}; |
| 660 | |
| 661 | let handler = relative(rootDir, serverBuildPath); |
| 662 | let handlerPath = join(rootDir, handler); |
| 663 | if (!serverEntryPoint) { |
| 664 | const baseServerBuildPath = basename(serverBuildPath, '.js'); |
| 665 | handler = join(dirname(handler), `server-${baseServerBuildPath}.mjs`); |
| 666 | handlerPath = join(rootDir, handler); |
| 667 | |
| 668 | // Copy the `server-node.mjs` file into the "build" directory |
| 669 | const nodeServerSrc = await nodeServerSrcPromise; |
| 670 | await writeEntrypointFile( |
| 671 | handlerPath, |
| 672 | nodeServerSrc.replace( |
| 673 | '@remix-run/dev/server-build', |
| 674 | `./${baseServerBuildPath}.js` |
| 675 | ), |
| 676 | rootDir |
| 677 | ); |
| 678 | } |
| 679 | |
| 680 | // Trace the handler with `@vercel/nft` |
| 681 | const trace = await nodeFileTrace([handlerPath], { |
| 682 | base: rootDir, |
| 683 | processCwd: entrypointDir, |
| 684 | }); |
| 685 | |
| 686 | for (const warning of trace.warnings) { |
| 687 | debug(`Warning from trace: ${warning.message}`); |
| 688 | } |
| 689 | |
| 690 | for (const file of trace.fileList) { |
| 691 | files[file] = await FileFsRef.fromFsPath({ fsPath: join(rootDir, file) }); |
| 692 | } |
| 693 | |
| 694 | const fn = new NodejsLambda({ |
| 695 | files, |
| 696 | handler, |
| 697 | runtime: nodeVersion.runtime, |
| 698 | shouldAddHelpers: false, |
| 699 | shouldAddSourcemapSupport: false, |
| 700 | operationType: 'SSR', |
| 701 | supportsResponseStreaming: true, |
| 702 | regions: config.regions, |
| 703 | memory: config.memory, |
| 704 | maxDuration: config.maxDuration, |
| 705 | framework: { |
| 706 | slug: 'remix', |
| 707 | version: remixVersion, |
no test coverage detected