34 lines
1.5 KiB
Plaintext
34 lines
1.5 KiB
Plaintext
import { getModuleBuildInfo } from "../get-module-build-info";
|
|
import { stringifyRequest } from "../../stringify-request";
|
|
import { WEBPACK_RESOURCE_QUERIES } from "../../../../lib/constants";
|
|
const EdgeAppRouteLoader = function() {
|
|
const { page, absolutePagePath, preferredRegion, appDirLoader: appDirLoaderBase64 = "", middlewareConfig: middlewareConfigBase64 = "" } = this.getOptions();
|
|
const appDirLoader = Buffer.from(appDirLoaderBase64, "base64").toString();
|
|
const middlewareConfig = JSON.parse(Buffer.from(middlewareConfigBase64, "base64").toString());
|
|
// Ensure we only run this loader for as a module.
|
|
if (!this._module) throw new Error("This loader is only usable as a module");
|
|
const buildInfo = getModuleBuildInfo(this._module);
|
|
buildInfo.nextEdgeSSR = {
|
|
isServerComponent: false,
|
|
page: page,
|
|
isAppDir: true
|
|
};
|
|
buildInfo.route = {
|
|
page,
|
|
absolutePagePath,
|
|
preferredRegion,
|
|
middlewareConfig
|
|
};
|
|
const stringifiedPagePath = stringifyRequest(this, absolutePagePath);
|
|
const modulePath = `${appDirLoader}${stringifiedPagePath.substring(1, stringifiedPagePath.length - 1)}?${WEBPACK_RESOURCE_QUERIES.edgeSSREntry}`;
|
|
return `
|
|
import { EdgeRouteModuleWrapper } from 'next/dist/esm/server/web/edge-route-module-wrapper'
|
|
import * as module from ${JSON.stringify(modulePath)}
|
|
|
|
export const ComponentMod = module
|
|
|
|
export default EdgeRouteModuleWrapper.wrap(module.routeModule)`;
|
|
};
|
|
export default EdgeAppRouteLoader;
|
|
|
|
//# sourceMappingURL=index.js.map |