Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
94
node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/index.js
generated
vendored
Normal file
94
node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
import { getModuleBuildInfo } from '../get-module-build-info';
|
||||
import { WEBPACK_RESOURCE_QUERIES } from '../../../../lib/constants';
|
||||
import { RouteKind } from '../../../../server/route-kind';
|
||||
import { normalizePagePath } from '../../../../shared/lib/page-path/normalize-page-path';
|
||||
import { loadEntrypoint } from '../../../load-entrypoint';
|
||||
/*
|
||||
For pages SSR'd at the edge, we bundle them with the ESM version of Next in order to
|
||||
benefit from the better tree-shaking and thus, smaller bundle sizes.
|
||||
|
||||
The absolute paths for _app, _error and _document, used in this loader, link to the regular CJS modules.
|
||||
They are generated in `createPagesMapping` where we don't have access to `isEdgeRuntime`,
|
||||
so we have to do it here. It's not that bad because it keeps all references to ESM modules magic in this place.
|
||||
*/ function swapDistFolderWithEsmDistFolder(path) {
|
||||
return path.replace('next/dist/pages', 'next/dist/esm/pages');
|
||||
}
|
||||
function getRouteModuleOptions(page) {
|
||||
const options = {
|
||||
definition: {
|
||||
kind: RouteKind.PAGES,
|
||||
page: normalizePagePath(page),
|
||||
pathname: page,
|
||||
// The following aren't used in production.
|
||||
bundlePath: '',
|
||||
filename: ''
|
||||
}
|
||||
};
|
||||
return options;
|
||||
}
|
||||
const edgeSSRLoader = async function edgeSSRLoader() {
|
||||
const { dev, page, absolutePagePath, absoluteAppPath, absoluteDocumentPath, absolute500Path, absoluteErrorPath, isServerComponent, stringifiedConfig: stringifiedConfigBase64, appDirLoader: appDirLoaderBase64, pagesType, sriEnabled, cacheHandler, cacheHandlers: cacheHandlersStringified, preferredRegion, middlewareConfig: middlewareConfigBase64, serverActions } = this.getOptions();
|
||||
const cacheHandlers = JSON.parse(cacheHandlersStringified || '{}');
|
||||
if (!cacheHandlers.default) {
|
||||
cacheHandlers.default = require.resolve('../../../../server/lib/cache-handlers/default');
|
||||
}
|
||||
const middlewareConfig = JSON.parse(Buffer.from(middlewareConfigBase64, 'base64').toString());
|
||||
const stringifiedConfig = Buffer.from(stringifiedConfigBase64 || '', 'base64').toString();
|
||||
const appDirLoader = Buffer.from(appDirLoaderBase64 || '', 'base64').toString();
|
||||
const isAppDir = pagesType === 'app';
|
||||
const buildInfo = getModuleBuildInfo(this._module);
|
||||
buildInfo.nextEdgeSSR = {
|
||||
isServerComponent,
|
||||
page: page,
|
||||
isAppDir
|
||||
};
|
||||
buildInfo.route = {
|
||||
page,
|
||||
absolutePagePath,
|
||||
preferredRegion,
|
||||
middlewareConfig
|
||||
};
|
||||
const pagePath = this.utils.contextify(this.context || this.rootContext, absolutePagePath);
|
||||
const appPath = this.utils.contextify(this.context || this.rootContext, swapDistFolderWithEsmDistFolder(absoluteAppPath));
|
||||
const errorPath = this.utils.contextify(this.context || this.rootContext, swapDistFolderWithEsmDistFolder(absoluteErrorPath));
|
||||
const documentPath = this.utils.contextify(this.context || this.rootContext, swapDistFolderWithEsmDistFolder(absoluteDocumentPath));
|
||||
const userland500Path = absolute500Path ? this.utils.contextify(this.context || this.rootContext, swapDistFolderWithEsmDistFolder(absolute500Path)) : null;
|
||||
const stringifiedPagePath = JSON.stringify(pagePath);
|
||||
const pageModPath = `${appDirLoader}${stringifiedPagePath.substring(1, stringifiedPagePath.length - 1)}${isAppDir ? `?${WEBPACK_RESOURCE_QUERIES.edgeSSREntry}` : ''}`;
|
||||
if (isAppDir) {
|
||||
return await loadEntrypoint('edge-ssr-app', {
|
||||
VAR_USERLAND: pageModPath,
|
||||
VAR_PAGE: page
|
||||
}, {
|
||||
sriEnabled: JSON.stringify(sriEnabled),
|
||||
nextConfig: stringifiedConfig,
|
||||
isServerComponent: JSON.stringify(isServerComponent),
|
||||
dev: JSON.stringify(dev),
|
||||
serverActions: typeof serverActions === 'undefined' ? 'undefined' : JSON.stringify(serverActions)
|
||||
}, {
|
||||
incrementalCacheHandler: cacheHandler ?? null
|
||||
});
|
||||
} else {
|
||||
return await loadEntrypoint('edge-ssr', {
|
||||
VAR_USERLAND: pageModPath,
|
||||
VAR_PAGE: page,
|
||||
VAR_MODULE_DOCUMENT: documentPath,
|
||||
VAR_MODULE_APP: appPath,
|
||||
VAR_MODULE_GLOBAL_ERROR: errorPath
|
||||
}, {
|
||||
pagesType: JSON.stringify(pagesType),
|
||||
sriEnabled: JSON.stringify(sriEnabled),
|
||||
nextConfig: stringifiedConfig,
|
||||
dev: JSON.stringify(dev),
|
||||
pageRouteModuleOptions: JSON.stringify(getRouteModuleOptions(page)),
|
||||
errorRouteModuleOptions: JSON.stringify(getRouteModuleOptions('/_error')),
|
||||
user500RouteModuleOptions: JSON.stringify(getRouteModuleOptions('/500'))
|
||||
}, {
|
||||
userland500Page: userland500Path,
|
||||
incrementalCacheHandler: cacheHandler ?? null
|
||||
});
|
||||
}
|
||||
};
|
||||
export default edgeSSRLoader;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/index.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
104
node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render.js
generated
vendored
Normal file
104
node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render.js
generated
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
import WebServer from '../../../../server/web-server';
|
||||
import { WebNextRequest, WebNextResponse } from '../../../../server/base-http/web';
|
||||
import { SERVER_RUNTIME } from '../../../../lib/constants';
|
||||
import { normalizeAppPath } from '../../../../shared/lib/router/utils/app-paths';
|
||||
import { internal_getCurrentFunctionWaitUntil } from '../../../../server/web/internal-edge-wait-until';
|
||||
export function getRender({ dev, page, appMod, pageMod, errorMod, error500Mod, pagesType, Document, buildManifest, reactLoadableManifest, dynamicCssManifest, interceptionRouteRewrites, renderToHTML, clientReferenceManifest, subresourceIntegrityManifest, serverActionsManifest, serverActions, config, buildId, nextFontManifest, incrementalCacheHandler }) {
|
||||
const isAppPath = pagesType === 'app';
|
||||
const baseLoadComponentResult = {
|
||||
dev,
|
||||
buildManifest,
|
||||
reactLoadableManifest,
|
||||
dynamicCssManifest,
|
||||
subresourceIntegrityManifest,
|
||||
Document,
|
||||
App: appMod == null ? void 0 : appMod.default,
|
||||
clientReferenceManifest
|
||||
};
|
||||
const server = new WebServer({
|
||||
dev,
|
||||
buildId,
|
||||
conf: config,
|
||||
minimalMode: true,
|
||||
webServerConfig: {
|
||||
page,
|
||||
pathname: isAppPath ? normalizeAppPath(page) : page,
|
||||
pagesType,
|
||||
interceptionRouteRewrites,
|
||||
extendRenderOpts: {
|
||||
runtime: SERVER_RUNTIME.experimentalEdge,
|
||||
supportsDynamicResponse: true,
|
||||
disableOptimizedLoading: true,
|
||||
serverActionsManifest,
|
||||
serverActions,
|
||||
nextFontManifest
|
||||
},
|
||||
renderToHTML,
|
||||
incrementalCacheHandler,
|
||||
loadComponent: async (inputPage)=>{
|
||||
if (inputPage === page) {
|
||||
return {
|
||||
...baseLoadComponentResult,
|
||||
Component: pageMod.default,
|
||||
pageConfig: pageMod.config || {},
|
||||
getStaticProps: pageMod.getStaticProps,
|
||||
getServerSideProps: pageMod.getServerSideProps,
|
||||
getStaticPaths: pageMod.getStaticPaths,
|
||||
ComponentMod: pageMod,
|
||||
isAppPath: !!pageMod.__next_app__,
|
||||
page: inputPage,
|
||||
routeModule: pageMod.routeModule
|
||||
};
|
||||
}
|
||||
// If there is a custom 500 page, we need to handle it separately.
|
||||
if (inputPage === '/500' && error500Mod) {
|
||||
return {
|
||||
...baseLoadComponentResult,
|
||||
Component: error500Mod.default,
|
||||
pageConfig: error500Mod.config || {},
|
||||
getStaticProps: error500Mod.getStaticProps,
|
||||
getServerSideProps: error500Mod.getServerSideProps,
|
||||
getStaticPaths: error500Mod.getStaticPaths,
|
||||
ComponentMod: error500Mod,
|
||||
page: inputPage,
|
||||
routeModule: error500Mod.routeModule
|
||||
};
|
||||
}
|
||||
if (inputPage === '/_error') {
|
||||
return {
|
||||
...baseLoadComponentResult,
|
||||
Component: errorMod.default,
|
||||
pageConfig: errorMod.config || {},
|
||||
getStaticProps: errorMod.getStaticProps,
|
||||
getServerSideProps: errorMod.getServerSideProps,
|
||||
getStaticPaths: errorMod.getStaticPaths,
|
||||
ComponentMod: errorMod,
|
||||
page: inputPage,
|
||||
routeModule: errorMod.routeModule
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
const handler = server.getRequestHandler();
|
||||
return async function render(request, event) {
|
||||
const extendedReq = new WebNextRequest(request);
|
||||
const extendedRes = new WebNextResponse(undefined);
|
||||
handler(extendedReq, extendedRes);
|
||||
const result = await extendedRes.toResponse();
|
||||
request.fetchMetrics = extendedReq.fetchMetrics;
|
||||
if (event == null ? void 0 : event.waitUntil) {
|
||||
// TODO(after):
|
||||
// remove `internal_runWithWaitUntil` and the `internal-edge-wait-until` module
|
||||
// when consumers switch to `after`.
|
||||
const waitUntilPromise = internal_getCurrentFunctionWaitUntil();
|
||||
if (waitUntilPromise) {
|
||||
event.waitUntil(waitUntilPromise);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=render.js.map
|
||||
1
node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue