This commit is contained in:
Kismet Hasanaj
2026-05-02 20:07:02 +02:00
parent ce8672e283
commit 34dc9aec52
9428 changed files with 1733330 additions and 0 deletions
@@ -0,0 +1,12 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
export type EdgeAppRouteLoaderQuery = {
absolutePagePath: string;
page: string;
appDirLoader: string;
preferredRegion: string | string[] | undefined;
middlewareConfig: string;
cacheHandler?: string;
cacheHandlers: string;
};
declare const EdgeAppRouteLoader: webpack.LoaderDefinitionFunction<EdgeAppRouteLoaderQuery>;
export default EdgeAppRouteLoader;
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _default;
}
});
const _getmodulebuildinfo = require("../get-module-build-info");
const _stringifyrequest = require("../../stringify-request");
const _constants = require("../../../../lib/constants");
const _loadentrypoint = require("../../../load-entrypoint");
const _ismetadataroute = require("../../../../lib/metadata/is-metadata-route");
function getCacheHandlersSetup(cacheHandlersStringified, contextifyImportPath) {
const cacheHandlers = JSON.parse(cacheHandlersStringified || '{}');
const definedCacheHandlers = Object.entries(cacheHandlers).filter((entry)=>Boolean(entry[1]));
const cacheHandlerImports = [];
const edgeCacheHandlersRegistration = [];
for (const [index, [kind, handlerPath]] of definedCacheHandlers.entries()){
const cacheHandlerVarName = `edgeCacheHandler_${index}`;
const cacheHandlerImportPath = contextifyImportPath(handlerPath);
cacheHandlerImports.push(`import ${cacheHandlerVarName} from ${JSON.stringify(cacheHandlerImportPath)}`);
edgeCacheHandlersRegistration.push(`edgeCacheHandlers[${JSON.stringify(kind)}] = ${cacheHandlerVarName}`);
}
return {
cacheHandlerImports: cacheHandlerImports.join('\n') || '\n',
edgeCacheHandlersRegistration: edgeCacheHandlersRegistration.join('\n') || '\n'
};
}
const EdgeAppRouteLoader = async function() {
const { page, absolutePagePath, preferredRegion, appDirLoader: appDirLoaderBase64 = '', middlewareConfig: middlewareConfigBase64 = '', cacheHandler, cacheHandlers: cacheHandlersStringified } = this.getOptions();
const appDirLoader = Buffer.from(appDirLoaderBase64, 'base64').toString();
const middlewareConfig = JSON.parse(Buffer.from(middlewareConfigBase64, 'base64').toString());
const cacheHandlersSetup = getCacheHandlersSetup(cacheHandlersStringified, (handlerPath)=>this.utils.contextify(this.context || this.rootContext, handlerPath));
const incrementalCacheHandler = cacheHandler ? this.utils.contextify(this.context || this.rootContext, cacheHandler) : null;
// Ensure we only run this loader for as a module.
if (!this._module) throw Object.defineProperty(new Error('This loader is only usable as a module'), "__NEXT_ERROR_CODE", {
value: "E433",
enumerable: false,
configurable: true
});
const buildInfo = (0, _getmodulebuildinfo.getModuleBuildInfo)(this._module);
buildInfo.nextEdgeSSR = {
isServerComponent: !(0, _ismetadataroute.isMetadataRoute)(page),
page: page,
isAppDir: true
};
buildInfo.route = {
page,
absolutePagePath,
preferredRegion,
middlewareConfig
};
const stringifiedPagePath = (0, _stringifyrequest.stringifyRequest)(this, absolutePagePath);
const modulePath = `${appDirLoader}${stringifiedPagePath.substring(1, stringifiedPagePath.length - 1)}?${_constants.WEBPACK_RESOURCE_QUERIES.edgeSSREntry}`;
return await (0, _loadentrypoint.loadEntrypoint)('edge-app-route', {
VAR_USERLAND: modulePath,
VAR_PAGE: page
}, cacheHandlersSetup, {
incrementalCacheHandler
});
};
const _default = EdgeAppRouteLoader;
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long