Rocky_Mountain_Vending/.pnpm-store/v10/files/07/dcb99341ad64921b725c46bbd68684ec033f4ed0dca69dde71078b4ac95e4c45469c5980eb6bd4f8ea72856faea0360daa619e483f0bd407803fb664b60762
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

90 lines
No EOL
4.5 KiB
Text

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: ''
},
// edge runtime doesn't read from distDir or projectDir
distDir: '',
relativeProjectDir: ''
};
return options;
}
const edgeSSRLoader = async function edgeSSRLoader() {
const { page, absolutePagePath, absoluteAppPath, absoluteDocumentPath, absolute500Path, absoluteErrorPath, isServerComponent, stringifiedConfig: stringifiedConfigBase64, appDirLoader: appDirLoaderBase64, pagesType, cacheHandler, cacheHandlers: cacheHandlersStringified, preferredRegion, middlewareConfig: middlewareConfigBase64 } = this.getOptions();
const cacheHandlers = JSON.parse(cacheHandlersStringified || '{}');
if (!cacheHandlers.default) {
cacheHandlers.default = require.resolve('../../../../server/lib/cache-handlers/default.external');
}
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 = absoluteAppPath ? this.utils.contextify(this.context || this.rootContext, swapDistFolderWithEsmDistFolder(absoluteAppPath)) : '';
const errorPath = absoluteErrorPath ? this.utils.contextify(this.context || this.rootContext, swapDistFolderWithEsmDistFolder(absoluteErrorPath)) : '';
const documentPath = absoluteDocumentPath ? 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
}, {
nextConfig: stringifiedConfig
}, {
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
}, {
nextConfig: stringifiedConfig,
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