Initial boiler plate project
This commit is contained in:
42
node_modules/next/dist/esm/build/webpack/loaders/next-edge-function-loader.js
generated
vendored
Normal file
42
node_modules/next/dist/esm/build/webpack/loaders/next-edge-function-loader.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
import { getModuleBuildInfo } from "./get-module-build-info";
|
||||
import { stringifyRequest } from "../stringify-request";
|
||||
const nextEdgeFunctionLoader = function nextEdgeFunctionLoader() {
|
||||
const { absolutePagePath, page, rootDir, preferredRegion, middlewareConfig: middlewareConfigBase64 } = this.getOptions();
|
||||
const stringifiedPagePath = stringifyRequest(this, absolutePagePath);
|
||||
const buildInfo = getModuleBuildInfo(this._module);
|
||||
const middlewareConfig = JSON.parse(Buffer.from(middlewareConfigBase64, "base64").toString());
|
||||
buildInfo.route = {
|
||||
page: page || "/",
|
||||
absolutePagePath,
|
||||
preferredRegion,
|
||||
middlewareConfig
|
||||
};
|
||||
buildInfo.nextEdgeApiFunction = {
|
||||
page: page || "/"
|
||||
};
|
||||
buildInfo.rootDir = rootDir;
|
||||
return `
|
||||
import 'next/dist/esm/server/web/globals'
|
||||
import { adapter } from 'next/dist/esm/server/web/adapter'
|
||||
import { IncrementalCache } from 'next/dist/esm/server/lib/incremental-cache'
|
||||
import { wrapApiHandler } from 'next/dist/esm/server/api-utils'
|
||||
|
||||
import handler from ${stringifiedPagePath}
|
||||
|
||||
if (typeof handler !== 'function') {
|
||||
throw new Error('The Edge Function "pages${page}" must export a \`default\` function');
|
||||
}
|
||||
|
||||
export default function nHandler (opts) {
|
||||
return adapter({
|
||||
...opts,
|
||||
IncrementalCache,
|
||||
page: ${JSON.stringify(page)},
|
||||
handler: wrapApiHandler(${JSON.stringify(page)}, handler),
|
||||
})
|
||||
}
|
||||
`;
|
||||
};
|
||||
export default nextEdgeFunctionLoader;
|
||||
|
||||
//# sourceMappingURL=next-edge-function-loader.js.map
|
||||
Reference in New Issue
Block a user