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

Function filterStaticPages

packages/next/src/utils.ts:894–937  ·  view source on GitHub ↗
(
  staticPageFiles: FileMap,
  dynamicPages: string[],
  entryDirectory: string,
  htmlContentType: string,
  prerenderManifest: NextPrerenderedRoutes,
  nextVersion: string,
  routesManifest?: RoutesManifest
)

Source from the content-addressed store, hash-verified

892type FileMap = { [page: string]: FileFsRef };
893
894export function filterStaticPages(
895 staticPageFiles: FileMap,
896 dynamicPages: string[],
897 entryDirectory: string,
898 htmlContentType: string,
899 prerenderManifest: NextPrerenderedRoutes,
900 nextVersion: string,
901 routesManifest?: RoutesManifest
902) {
903 const staticPages: FileMap = {};
904
905 Object.keys(staticPageFiles).forEach((page: string) => {
906 const pathname = page.replace(/\.html$/, '');
907 const routeName = normalizeLocalePath(
908 normalizePage(pathname),
909 routesManifest?.i18n?.locales
910 ).pathname;
911
912 // Prerendered routes emit a `.html` file but should not be treated as a
913 // static page.
914 // Lazily prerendered routes have a fallback `.html` file on newer
915 // Next.js versions so we need to also not treat it as a static page here.
916 if (
917 prerenderManifest.staticRoutes[routeName] ||
918 prerenderManifest.fallbackRoutes[routeName] ||
919 prerenderManifest.staticRoutes[normalizePage(pathname)] ||
920 prerenderManifest.fallbackRoutes[normalizePage(pathname)]
921 ) {
922 return;
923 }
924
925 const staticRoute = path.posix.join(entryDirectory, pathname);
926
927 staticPages[staticRoute] = staticPageFiles[page];
928 staticPages[staticRoute].contentType = htmlContentType;
929
930 if (isDynamicRoute(pathname, nextVersion)) {
931 dynamicPages.push(routeName);
932 return;
933 }
934 });
935
936 return staticPages;
937}
938
939export function getFilesMapFromReasons(
940 fileList: ReadonlySet<string>,

Callers 1

buildFunction · 0.90

Calls 7

isDynamicRouteFunction · 0.90
normalizeLocalePathFunction · 0.85
normalizePageFunction · 0.85
replaceMethod · 0.80
pushMethod · 0.65
keysMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected