MCPcopy Create free account
hub / github.com/vercel/vercel / createRenderNodeFunction

Function createRenderNodeFunction

packages/remix/src/build-legacy.ts:650–715  ·  view source on GitHub ↗
(
  nodeVersion: NodeVersion,
  entrypointDir: string,
  rootDir: string,
  serverBuildPath: string,
  serverEntryPoint: string | undefined,
  remixVersion: string,
  config: ResolvedNodeRouteConfig
)

Source from the content-addressed store, hash-verified

648}
649
650async 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,

Callers 1

buildFunction · 0.85

Calls 6

relativeFunction · 0.90
debugFunction · 0.90
writeEntrypointFileFunction · 0.85
nodeFileTraceFunction · 0.85
replaceMethod · 0.80
fromFsPathMethod · 0.80

Tested by

no test coverage detected