.
This commit is contained in:
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export { callServer } from 'next/dist/client/app-call-server';
|
||||
export { findSourceMapURL } from 'next/dist/client/app-find-source-map-url';
|
||||
export { createServerReference } from 'react-server-dom-webpack/client';
|
||||
Generated
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// This file must be bundled in the app's client layer, it shouldn't be directly
|
||||
// imported by the server.
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
callServer: null,
|
||||
createServerReference: null,
|
||||
findSourceMapURL: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
callServer: function() {
|
||||
return _appcallserver.callServer;
|
||||
},
|
||||
createServerReference: function() {
|
||||
return _client.createServerReference;
|
||||
},
|
||||
findSourceMapURL: function() {
|
||||
return _appfindsourcemapurl.findSourceMapURL;
|
||||
}
|
||||
});
|
||||
const _appcallserver = require("next/dist/client/app-call-server");
|
||||
const _appfindsourcemapurl = require("next/dist/client/app-find-source-map-url");
|
||||
const _client = require("react-server-dom-webpack/client");
|
||||
|
||||
//# sourceMappingURL=action-client-wrapper.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/build/webpack/loaders/next-flight-loader/action-client-wrapper.ts"],"sourcesContent":["// This file must be bundled in the app's client layer, it shouldn't be directly\n// imported by the server.\n\nexport { callServer } from 'next/dist/client/app-call-server'\nexport { findSourceMapURL } from 'next/dist/client/app-find-source-map-url'\n\n// A noop wrapper to let the Flight client create the server reference.\n// See also: https://github.com/facebook/react/pull/26632\n// eslint-disable-next-line import/no-extraneous-dependencies\nexport { createServerReference } from 'react-server-dom-webpack/client'\n"],"names":["callServer","createServerReference","findSourceMapURL"],"mappings":"AAAA,gFAAgF;AAChF,0BAA0B;;;;;;;;;;;;;;;;;IAEjBA,UAAU;eAAVA,yBAAU;;IAMVC,qBAAqB;eAArBA,6BAAqB;;IALrBC,gBAAgB;eAAhBA,qCAAgB;;;+BADE;qCACM;wBAKK","ignoreList":[0]}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function ensureServerEntryExports(actions: any[]): void;
|
||||
Generated
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// This function ensures that all the exported values are valid server actions,
|
||||
// during the runtime. By definition all actions are required to be async
|
||||
// functions, but here we can only check that they are functions.
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "ensureServerEntryExports", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ensureServerEntryExports;
|
||||
}
|
||||
});
|
||||
function ensureServerEntryExports(actions) {
|
||||
for(let i = 0; i < actions.length; i++){
|
||||
const action = actions[i];
|
||||
if (typeof action !== 'function') {
|
||||
throw Object.defineProperty(new Error(`A "use server" file can only export async functions, found ${typeof action}.\nRead more: https://nextjs.org/docs/messages/invalid-use-server-value`), "__NEXT_ERROR_CODE", {
|
||||
value: "E352",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=action-validate.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/build/webpack/loaders/next-flight-loader/action-validate.ts"],"sourcesContent":["// This function ensures that all the exported values are valid server actions,\n// during the runtime. By definition all actions are required to be async\n// functions, but here we can only check that they are functions.\nexport function ensureServerEntryExports(actions: any[]) {\n for (let i = 0; i < actions.length; i++) {\n const action = actions[i]\n if (typeof action !== 'function') {\n throw new Error(\n `A \"use server\" file can only export async functions, found ${typeof action}.\\nRead more: https://nextjs.org/docs/messages/invalid-use-server-value`\n )\n }\n }\n}\n"],"names":["ensureServerEntryExports","actions","i","length","action","Error"],"mappings":"AAAA,+EAA+E;AAC/E,yEAAyE;AACzE,iEAAiE;;;;;+BACjDA;;;eAAAA;;;AAAT,SAASA,yBAAyBC,OAAc;IACrD,IAAK,IAAIC,IAAI,GAAGA,IAAID,QAAQE,MAAM,EAAED,IAAK;QACvC,MAAME,SAASH,OAAO,CAACC,EAAE;QACzB,IAAI,OAAOE,WAAW,YAAY;YAChC,MAAM,qBAEL,CAFK,IAAIC,MACR,CAAC,2DAA2D,EAAE,OAAOD,OAAO,uEAAuE,CAAC,GADhJ,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF;IACF;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { cache } from '../../../../server/use-cache/use-cache-wrapper';
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "cache", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _usecachewrapper.cache;
|
||||
}
|
||||
});
|
||||
const _usecachewrapper = require("../../../../server/use-cache/use-cache-wrapper");
|
||||
|
||||
//# sourceMappingURL=cache-wrapper.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/build/webpack/loaders/next-flight-loader/cache-wrapper.ts"],"sourcesContent":["export { cache } from '../../../../server/use-cache/use-cache-wrapper'\n"],"names":["cache"],"mappings":";;;;+BAASA;;;eAAAA,sBAAK;;;iCAAQ","ignoreList":[0]}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { type javascript, type LoaderContext, type webpack } from 'next/dist/compiled/webpack/webpack';
|
||||
type SourceType = javascript.JavascriptParser['sourceType'] | 'commonjs';
|
||||
export declare function getAssumedSourceType(mod: webpack.Module, sourceType: SourceType): SourceType;
|
||||
export default function transformSource(this: LoaderContext<undefined>, source: string, sourceMap: any): void;
|
||||
export {};
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
default: null,
|
||||
getAssumedSourceType: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
default: function() {
|
||||
return transformSource;
|
||||
},
|
||||
getAssumedSourceType: function() {
|
||||
return getAssumedSourceType;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _constants = require("../../../../lib/constants");
|
||||
const _constants1 = require("../../../../shared/lib/constants");
|
||||
const _warnonce = require("../../../../shared/lib/utils/warn-once");
|
||||
const _getpagestaticinfo = require("../../../analysis/get-page-static-info");
|
||||
const _utils = require("../../utils");
|
||||
const _getmodulebuildinfo = require("../get-module-build-info");
|
||||
const noopHeadPath = require.resolve('next/dist/client/components/noop-head');
|
||||
// For edge runtime it will be aliased to esm version by webpack
|
||||
const MODULE_PROXY_PATH = 'next/dist/build/webpack/loaders/next-flight-loader/module-proxy';
|
||||
function getAssumedSourceType(mod, sourceType) {
|
||||
var _buildInfo_rsc, _buildInfo_rsc1;
|
||||
const buildInfo = (0, _getmodulebuildinfo.getModuleBuildInfo)(mod);
|
||||
const detectedClientEntryType = buildInfo == null ? void 0 : (_buildInfo_rsc = buildInfo.rsc) == null ? void 0 : _buildInfo_rsc.clientEntryType;
|
||||
const clientRefs = (buildInfo == null ? void 0 : (_buildInfo_rsc1 = buildInfo.rsc) == null ? void 0 : _buildInfo_rsc1.clientRefs) || [];
|
||||
// It's tricky to detect the type of a client boundary, but we should always
|
||||
// use the `module` type when we can, to support `export *` and `export from`
|
||||
// syntax in other modules that import this client boundary.
|
||||
if (sourceType === 'auto') {
|
||||
if (detectedClientEntryType === 'auto') {
|
||||
if (clientRefs.length === 0) {
|
||||
// If there's zero export detected in the client boundary, and it's the
|
||||
// `auto` type, we can safely assume it's a CJS module because it doesn't
|
||||
// have ESM exports.
|
||||
return 'commonjs';
|
||||
} else if (!clientRefs.includes('*')) {
|
||||
// Otherwise, we assume it's an ESM module.
|
||||
return 'module';
|
||||
}
|
||||
} else if (detectedClientEntryType === 'cjs') {
|
||||
return 'commonjs';
|
||||
}
|
||||
}
|
||||
return sourceType;
|
||||
}
|
||||
function transformSource(source, sourceMap) {
|
||||
var _module_matchResource, _buildInfo_rsc, _buildInfo_rsc1;
|
||||
// Avoid buffer to be consumed
|
||||
if (typeof source !== 'string') {
|
||||
throw Object.defineProperty(new Error('Expected source to have been transformed to a string.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E429",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const module1 = this._module;
|
||||
// Assign the RSC meta information to buildInfo.
|
||||
// Exclude next internal files which are not marked as client files
|
||||
const buildInfo = (0, _getmodulebuildinfo.getModuleBuildInfo)(module1);
|
||||
buildInfo.rsc = (0, _getpagestaticinfo.getRSCModuleInformation)(source, true);
|
||||
let prefix = '';
|
||||
if (process.env.BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN) {
|
||||
const rscModuleInformationJson = JSON.stringify(buildInfo.rsc);
|
||||
prefix = `/* __rspack_internal_rsc_module_information_do_not_use__ ${rscModuleInformationJson} */\n`;
|
||||
source = prefix + source;
|
||||
}
|
||||
prefix += `// This file is generated by the Webpack next-flight-loader.\n`;
|
||||
// Resource key is the unique identifier for the resource. When RSC renders
|
||||
// a client module, that key is used to identify that module across all compiler
|
||||
// layers.
|
||||
//
|
||||
// Usually it's the module's file path + the export name (e.g. `foo.js#bar`).
|
||||
// But with Barrel Optimizations, one file can be splitted into multiple modules,
|
||||
// so when you import `foo.js#bar` and `foo.js#baz`, they are actually different
|
||||
// "foo.js" being created by the Barrel Loader (one only exports `bar`, the other
|
||||
// only exports `baz`).
|
||||
//
|
||||
// Because of that, we must add another query param to the resource key to
|
||||
// differentiate them.
|
||||
let resourceKey = this.resourcePath;
|
||||
if ((_module_matchResource = module1.matchResource) == null ? void 0 : _module_matchResource.startsWith(_constants1.BARREL_OPTIMIZATION_PREFIX)) {
|
||||
resourceKey = (0, _utils.formatBarrelOptimizedResource)(resourceKey, module1.matchResource);
|
||||
}
|
||||
// A client boundary.
|
||||
if (((_buildInfo_rsc = buildInfo.rsc) == null ? void 0 : _buildInfo_rsc.type) === _constants1.RSC_MODULE_TYPES.client) {
|
||||
const assumedSourceType = getAssumedSourceType(module1, sourceTypeFromModule(module1));
|
||||
const clientRefs = buildInfo.rsc.clientRefs;
|
||||
const stringifiedResourceKey = JSON.stringify(resourceKey);
|
||||
if (assumedSourceType === 'module') {
|
||||
if (clientRefs.length === 0) {
|
||||
return this.callback(null, 'export {}');
|
||||
}
|
||||
if (clientRefs.includes('*')) {
|
||||
this.callback(Object.defineProperty(new Error(`It's currently unsupported to use "export *" in a client boundary. Please use named exports instead.`), "__NEXT_ERROR_CODE", {
|
||||
value: "E46",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
}));
|
||||
return;
|
||||
}
|
||||
let esmSource = prefix + `\
|
||||
import { registerClientReference } from "react-server-dom-webpack/server";
|
||||
`;
|
||||
for (const ref of clientRefs){
|
||||
if (ref === 'default') {
|
||||
esmSource += `export default registerClientReference(
|
||||
function() { throw new Error(${JSON.stringify(`Attempted to call the default \
|
||||
export of ${stringifiedResourceKey} from the server, but it's on the client. \
|
||||
It's not possible to invoke a client function from the server, it can only be \
|
||||
rendered as a Component or passed to props of a Client Component.`)}); },
|
||||
${stringifiedResourceKey},
|
||||
"default",
|
||||
);\n`;
|
||||
} else {
|
||||
esmSource += `export const ${ref} = registerClientReference(
|
||||
function() { throw new Error(${JSON.stringify(`Attempted to call ${ref}() from \
|
||||
the server but ${ref} is on the client. It's not possible to invoke a client \
|
||||
function from the server, it can only be rendered as a Component or passed to \
|
||||
props of a Client Component.`)}); },
|
||||
${stringifiedResourceKey},
|
||||
${JSON.stringify(ref)},
|
||||
);`;
|
||||
}
|
||||
}
|
||||
const compilation = this._compilation;
|
||||
const originalSourceURL = process.env.NEXT_RSPACK ? `webpack://_N_E/${this.utils.contextify(this.context || this.rootContext, this.resourcePath)}/__nextjs-internal-proxy.mjs` : _webpack.ModuleFilenameHelpers.createFilename(module1, {
|
||||
moduleFilenameTemplate: 'webpack://[namespace]/[resource-path]/__nextjs-internal-proxy.mjs',
|
||||
namespace: '_N_E'
|
||||
}, {
|
||||
requestShortener: compilation.requestShortener,
|
||||
chunkGraph: compilation.chunkGraph,
|
||||
hashFunction: compilation.outputOptions.hashFunction
|
||||
});
|
||||
return this.callback(null, esmSource, {
|
||||
version: 3,
|
||||
sources: [
|
||||
originalSourceURL
|
||||
],
|
||||
// minimal, parseable mappings
|
||||
mappings: 'AAAA',
|
||||
sourcesContent: [
|
||||
esmSource
|
||||
]
|
||||
});
|
||||
} else if (assumedSourceType === 'commonjs') {
|
||||
let cjsSource = prefix + `\
|
||||
const { createProxy } = require("${MODULE_PROXY_PATH}")
|
||||
|
||||
module.exports = createProxy(${stringifiedResourceKey})
|
||||
`;
|
||||
const compilation = this._compilation;
|
||||
const originalSourceURL = process.env.NEXT_RSPACK ? `webpack://_N_E/${this.utils.contextify(this.context || this.rootContext, this.resourcePath)}/__nextjs-internal-proxy.cjs` : _webpack.ModuleFilenameHelpers.createFilename(module1, {
|
||||
moduleFilenameTemplate: 'webpack://[namespace]/[resource-path]/__nextjs-internal-proxy.cjs',
|
||||
namespace: '_N_E'
|
||||
}, {
|
||||
requestShortener: compilation.requestShortener,
|
||||
chunkGraph: compilation.chunkGraph,
|
||||
hashFunction: compilation.outputOptions.hashFunction
|
||||
});
|
||||
return this.callback(null, cjsSource, {
|
||||
version: 3,
|
||||
sources: [
|
||||
originalSourceURL
|
||||
],
|
||||
// minimal, parseable mappings
|
||||
mappings: 'AAAA',
|
||||
sourcesContent: [
|
||||
cjsSource
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
if (((_buildInfo_rsc1 = buildInfo.rsc) == null ? void 0 : _buildInfo_rsc1.type) !== _constants1.RSC_MODULE_TYPES.client) {
|
||||
if (noopHeadPath === this.resourcePath) {
|
||||
(0, _warnonce.warnOnce)(`Warning: You're using \`next/head\` inside the \`app\` directory, please migrate to the Metadata API. See https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#step-3-migrating-nexthead for more details.`);
|
||||
}
|
||||
}
|
||||
const replacedSource = source.replace(_constants.RSC_MOD_REF_PROXY_ALIAS, MODULE_PROXY_PATH);
|
||||
this.callback(null, replacedSource, sourceMap);
|
||||
}
|
||||
function sourceTypeFromModule(module1) {
|
||||
const moduleType = module1.type;
|
||||
switch(moduleType){
|
||||
case 'javascript/auto':
|
||||
return 'auto';
|
||||
case 'javascript/dynamic':
|
||||
return 'script';
|
||||
case 'javascript/esm':
|
||||
return 'module';
|
||||
default:
|
||||
throw Object.defineProperty(new Error('Unexpected module type ' + moduleType), "__NEXT_ERROR_CODE", {
|
||||
value: "E651",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare const createProxy: (moduleId: string) => any;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */ "use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "createProxy", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return createProxy;
|
||||
}
|
||||
});
|
||||
const _server = require("react-server-dom-webpack/server");
|
||||
const createProxy = _server.createClientModuleProxy;
|
||||
|
||||
//# sourceMappingURL=module-proxy.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/build/webpack/loaders/next-flight-loader/module-proxy.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { createClientModuleProxy } from 'react-server-dom-webpack/server'\n\n// Re-assign to make it typed.\nexport const createProxy: (moduleId: string) => any = createClientModuleProxy\n"],"names":["createProxy","createClientModuleProxy"],"mappings":"AAAA,oDAAoD;;;;+BAIvCA;;;eAAAA;;;wBAH2B;AAGjC,MAAMA,cAAyCC,+BAAuB","ignoreList":[0]}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { registerServerReference } from 'react-server-dom-webpack/server';
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */ "use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "registerServerReference", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _server.registerServerReference;
|
||||
}
|
||||
});
|
||||
const _server = require("react-server-dom-webpack/server");
|
||||
|
||||
//# sourceMappingURL=server-reference.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/build/webpack/loaders/next-flight-loader/server-reference.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nexport { registerServerReference } from 'react-server-dom-webpack/server'\n"],"names":["registerServerReference"],"mappings":"AAAA,oDAAoD;;;;+BAC3CA;;;eAAAA,+BAAuB;;;wBAAQ","ignoreList":[0]}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { trackDynamicImport } from '../../../../server/app-render/module-loading/track-dynamic-import';
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "trackDynamicImport", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _trackdynamicimport.trackDynamicImport;
|
||||
}
|
||||
});
|
||||
const _trackdynamicimport = require("../../../../server/app-render/module-loading/track-dynamic-import");
|
||||
|
||||
//# sourceMappingURL=track-dynamic-import.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/build/webpack/loaders/next-flight-loader/track-dynamic-import.ts"],"sourcesContent":["export { trackDynamicImport } from '../../../../server/app-render/module-loading/track-dynamic-import'\n"],"names":["trackDynamicImport"],"mappings":";;;;+BAASA;;;eAAAA,sCAAkB;;;oCAAQ","ignoreList":[0]}
|
||||
Reference in New Issue
Block a user