@openuiai/next 16.0.5 → 16.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +3 -3
  3. package/dist/build/swc/index.js +1 -1
  4. package/dist/build/webpack/loaders/next-flight-client-entry-loader.js +2 -2
  5. package/dist/build/webpack/loaders/next-flight-client-entry-loader.js.map +1 -1
  6. package/dist/build/webpack/plugins/flight-client-entry-plugin.js +4 -0
  7. package/dist/build/webpack/plugins/flight-client-entry-plugin.js.map +1 -1
  8. package/dist/build/webpack-config.js +2 -2
  9. package/dist/client/app-bootstrap.js +1 -1
  10. package/dist/client/index.js +1 -1
  11. package/dist/esm/build/index.js +3 -3
  12. package/dist/esm/build/swc/index.js +1 -1
  13. package/dist/esm/build/webpack/loaders/next-flight-client-entry-loader.js +2 -2
  14. package/dist/esm/build/webpack/loaders/next-flight-client-entry-loader.js.map +1 -1
  15. package/dist/esm/build/webpack/plugins/flight-client-entry-plugin.js +4 -0
  16. package/dist/esm/build/webpack/plugins/flight-client-entry-plugin.js.map +1 -1
  17. package/dist/esm/build/webpack-config.js +2 -2
  18. package/dist/esm/client/app-bootstrap.js +1 -1
  19. package/dist/esm/client/index.js +1 -1
  20. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  21. package/dist/esm/server/dev/on-demand-entry-handler.js +2 -1
  22. package/dist/esm/server/dev/on-demand-entry-handler.js.map +1 -1
  23. package/dist/esm/server/lib/app-info-log.js +1 -1
  24. package/dist/esm/server/lib/start-server.js +1 -1
  25. package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
  26. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  27. package/dist/server/dev/on-demand-entry-handler.js +2 -1
  28. package/dist/server/dev/on-demand-entry-handler.js.map +1 -1
  29. package/dist/server/lib/app-info-log.js +1 -1
  30. package/dist/server/lib/start-server.js +1 -1
  31. package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  32. package/dist/telemetry/anonymous-meta.js +1 -1
  33. package/dist/telemetry/events/session-stopped.js +2 -2
  34. package/dist/telemetry/events/version.js +2 -2
  35. package/package.json +1 -1
package/dist/bin/next CHANGED
@@ -79,7 +79,7 @@ const program = new NextRootCommand();
79
79
  program.name('next').description('The Next.js CLI allows you to develop, build, start your application, and more.').configureHelp({
80
80
  formatHelp: (cmd, helper)=>(0, _formatclihelpoutput.formatCliHelpOutput)(cmd, helper),
81
81
  subcommandTerm: (cmd)=>`${cmd.name()} ${cmd.usage()}`
82
- }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"16.0.5"}`, '-v, --version', 'Outputs the Next.js version.');
82
+ }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"16.0.6"}`, '-v, --version', 'Outputs the Next.js version.');
83
83
  program.command('build').description('Creates an optimized production build of your application. The output displays information about each route.').argument('[directory]', `A directory on which to build the application. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).option('-d, --debug', 'Enables a more verbose build output.').option('--debug-prerender', 'Enables debug mode for prerendering. Not for production use!').option('--no-mangling', 'Disables mangling.').option('--profile', 'Enables production profiling for React.').option('--experimental-app-only', 'Builds only App Router routes.').option('--webpack', 'Builds using webpack.').addOption(new _commander.Option('--experimental-build-mode [mode]', 'Uses an experimental build mode.').choices([
84
84
  'compile',
85
85
  'generate',
@@ -373,7 +373,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
373
373
  try {
374
374
  const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
375
375
  buildMode: experimentalBuildMode,
376
- version: "16.0.5"
376
+ version: "16.0.6"
377
377
  });
378
378
  _buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
379
379
  _buildcontext.NextBuildContext.dir = dir;
@@ -886,7 +886,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
886
886
  // Files outside of the distDir can be "type": "module"
887
887
  await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
888
888
  // These are written to distDir, so they need to come after creating and cleaning distDr.
889
- await (0, _builddiagnostics.recordFrameworkVersion)("16.0.5");
889
+ await (0, _builddiagnostics.recordFrameworkVersion)("16.0.6");
890
890
  await (0, _builddiagnostics.updateBuildDiagnostics)({
891
891
  buildStage: 'start'
892
892
  });
@@ -2535,7 +2535,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
2535
2535
  configOutDir: _path.default.join(dir, configOutDir),
2536
2536
  staticPages,
2537
2537
  serverPropsPages,
2538
- nextVersion: "16.0.5",
2538
+ nextVersion: "16.0.6",
2539
2539
  tracingRoot: outputFileTracingRoot,
2540
2540
  hasNodeMiddleware,
2541
2541
  hasInstrumentationHook,
@@ -128,7 +128,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
128
128
  }
129
129
  return newObj;
130
130
  }
131
- const nextVersion = "16.0.5";
131
+ const nextVersion = "16.0.6";
132
132
  const ArchName = (0, _os.arch)();
133
133
  const PlatformName = (0, _os.platform)();
134
134
  function infoLog(...args) {
@@ -19,8 +19,8 @@ function transformSource() {
19
19
  modules
20
20
  ] : [];
21
21
  }
22
- const code = modules.map((x)=>JSON.parse(x))// Filter out CSS files in the SSR compilation
23
- .filter(({ request })=>isServer ? !_utils.regexCSS.test(request) : true).map(({ request, ids })=>{
22
+ const code = modules.map((x)=>JSON.parse(x))// Filter out undefined requests (Bun compatibility) and CSS files in the SSR compilation
23
+ .filter(({ request })=>request && (isServer ? !_utils.regexCSS.test(request) : true)).map(({ request, ids })=>{
24
24
  const importPath = JSON.stringify(request.startsWith(_constants.BARREL_OPTIMIZATION_PREFIX) ? request.replace(':', '!=!') : request);
25
25
  // When we cannot determine the export names, we use eager mode to include the whole module.
26
26
  // Otherwise, we use eager mode with webpackExports to only include the necessary exports.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/loaders/next-flight-client-entry-loader.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport {\n BARREL_OPTIMIZATION_PREFIX,\n RSC_MODULE_TYPES,\n} from '../../../shared/lib/constants'\nimport { getModuleBuildInfo } from './get-module-build-info'\nimport { regexCSS } from './utils'\n\n/**\n * { [client import path]: [exported names] }\n */\nexport type ClientComponentImports = Record<string, Set<string>>\nexport type CssImports = Record<string, string[]>\n\nexport type NextFlightClientEntryLoaderOptions = {\n modules: string[] | string\n /** This is transmitted as a string to `getOptions` */\n server: boolean | 'true' | 'false'\n}\n\nexport type FlightClientEntryModuleItem = {\n // module path\n request: string\n // imported identifiers\n ids: string[]\n}\n\nexport default function transformSource(\n this: webpack.LoaderContext<NextFlightClientEntryLoaderOptions>\n) {\n let { modules, server } = this.getOptions()\n const isServer = server === 'true'\n\n if (!Array.isArray(modules)) {\n modules = modules ? [modules] : []\n }\n\n const code = modules\n .map((x) => JSON.parse(x) as FlightClientEntryModuleItem)\n // Filter out CSS files in the SSR compilation\n .filter(({ request }) => (isServer ? !regexCSS.test(request) : true))\n .map(({ request, ids }: FlightClientEntryModuleItem) => {\n const importPath = JSON.stringify(\n request.startsWith(BARREL_OPTIMIZATION_PREFIX)\n ? request.replace(':', '!=!')\n : request\n )\n\n // When we cannot determine the export names, we use eager mode to include the whole module.\n // Otherwise, we use eager mode with webpackExports to only include the necessary exports.\n // If we have '*' in the ids, we include all the imports\n if (ids.length === 0 || ids.includes('*')) {\n return `import(/* webpackMode: \"eager\" */ ${importPath});\\n`\n } else {\n return `import(/* webpackMode: \"eager\", webpackExports: ${JSON.stringify(\n ids\n )} */ ${importPath});\\n`\n }\n })\n .join(';\\n')\n\n const buildInfo = getModuleBuildInfo(this._module!)\n\n buildInfo.rsc = {\n type: RSC_MODULE_TYPES.client,\n }\n if (process.env.BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN) {\n const rscModuleInformationJson = JSON.stringify(buildInfo.rsc)\n return (\n `/* __rspack_internal_rsc_module_information_do_not_use__ ${rscModuleInformationJson} */\\n` +\n code\n )\n }\n\n return code\n}\n"],"names":["transformSource","modules","server","getOptions","isServer","Array","isArray","code","map","x","JSON","parse","filter","request","regexCSS","test","ids","importPath","stringify","startsWith","BARREL_OPTIMIZATION_PREFIX","replace","length","includes","join","buildInfo","getModuleBuildInfo","_module","rsc","type","RSC_MODULE_TYPES","client","process","env","BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN","rscModuleInformationJson"],"mappings":";;;;+BA2BA;;;eAAwBA;;;2BAvBjB;oCAC4B;uBACV;AAqBV,SAASA;IAGtB,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAG,IAAI,CAACC,UAAU;IACzC,MAAMC,WAAWF,WAAW;IAE5B,IAAI,CAACG,MAAMC,OAAO,CAACL,UAAU;QAC3BA,UAAUA,UAAU;YAACA;SAAQ,GAAG,EAAE;IACpC;IAEA,MAAMM,OAAON,QACVO,GAAG,CAAC,CAACC,IAAMC,KAAKC,KAAK,CAACF,GACvB,8CAA8C;KAC7CG,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAE,GAAMT,WAAW,CAACU,eAAQ,CAACC,IAAI,CAACF,WAAW,MAC9DL,GAAG,CAAC,CAAC,EAAEK,OAAO,EAAEG,GAAG,EAA+B;QACjD,MAAMC,aAAaP,KAAKQ,SAAS,CAC/BL,QAAQM,UAAU,CAACC,qCAA0B,IACzCP,QAAQQ,OAAO,CAAC,KAAK,SACrBR;QAGN,4FAA4F;QAC5F,0FAA0F;QAC1F,wDAAwD;QACxD,IAAIG,IAAIM,MAAM,KAAK,KAAKN,IAAIO,QAAQ,CAAC,MAAM;YACzC,OAAO,CAAC,kCAAkC,EAAEN,WAAW,IAAI,CAAC;QAC9D,OAAO;YACL,OAAO,CAAC,gDAAgD,EAAEP,KAAKQ,SAAS,CACtEF,KACA,IAAI,EAAEC,WAAW,IAAI,CAAC;QAC1B;IACF,GACCO,IAAI,CAAC;IAER,MAAMC,YAAYC,IAAAA,sCAAkB,EAAC,IAAI,CAACC,OAAO;IAEjDF,UAAUG,GAAG,GAAG;QACdC,MAAMC,2BAAgB,CAACC,MAAM;IAC/B;IACA,IAAIC,QAAQC,GAAG,CAACC,kCAAkC,EAAE;QAClD,MAAMC,2BAA2BzB,KAAKQ,SAAS,CAACO,UAAUG,GAAG;QAC7D,OACE,CAAC,yDAAyD,EAAEO,yBAAyB,KAAK,CAAC,GAC3F5B;IAEJ;IAEA,OAAOA;AACT","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/build/webpack/loaders/next-flight-client-entry-loader.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport {\n BARREL_OPTIMIZATION_PREFIX,\n RSC_MODULE_TYPES,\n} from '../../../shared/lib/constants'\nimport { getModuleBuildInfo } from './get-module-build-info'\nimport { regexCSS } from './utils'\n\n/**\n * { [client import path]: [exported names] }\n */\nexport type ClientComponentImports = Record<string, Set<string>>\nexport type CssImports = Record<string, string[]>\n\nexport type NextFlightClientEntryLoaderOptions = {\n modules: string[] | string\n /** This is transmitted as a string to `getOptions` */\n server: boolean | 'true' | 'false'\n}\n\nexport type FlightClientEntryModuleItem = {\n // module path\n request: string\n // imported identifiers\n ids: string[]\n}\n\nexport default function transformSource(\n this: webpack.LoaderContext<NextFlightClientEntryLoaderOptions>\n) {\n let { modules, server } = this.getOptions()\n const isServer = server === 'true'\n\n if (!Array.isArray(modules)) {\n modules = modules ? [modules] : []\n }\n\n const code = modules\n .map((x) => JSON.parse(x) as FlightClientEntryModuleItem)\n // Filter out undefined requests (Bun compatibility) and CSS files in the SSR compilation\n .filter(({ request }) => request && (isServer ? !regexCSS.test(request) : true))\n .map(({ request, ids }: FlightClientEntryModuleItem) => {\n const importPath = JSON.stringify(\n request.startsWith(BARREL_OPTIMIZATION_PREFIX)\n ? request.replace(':', '!=!')\n : request\n )\n\n // When we cannot determine the export names, we use eager mode to include the whole module.\n // Otherwise, we use eager mode with webpackExports to only include the necessary exports.\n // If we have '*' in the ids, we include all the imports\n if (ids.length === 0 || ids.includes('*')) {\n return `import(/* webpackMode: \"eager\" */ ${importPath});\\n`\n } else {\n return `import(/* webpackMode: \"eager\", webpackExports: ${JSON.stringify(\n ids\n )} */ ${importPath});\\n`\n }\n })\n .join(';\\n')\n\n const buildInfo = getModuleBuildInfo(this._module!)\n\n buildInfo.rsc = {\n type: RSC_MODULE_TYPES.client,\n }\n if (process.env.BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN) {\n const rscModuleInformationJson = JSON.stringify(buildInfo.rsc)\n return (\n `/* __rspack_internal_rsc_module_information_do_not_use__ ${rscModuleInformationJson} */\\n` +\n code\n )\n }\n\n return code\n}\n"],"names":["transformSource","modules","server","getOptions","isServer","Array","isArray","code","map","x","JSON","parse","filter","request","regexCSS","test","ids","importPath","stringify","startsWith","BARREL_OPTIMIZATION_PREFIX","replace","length","includes","join","buildInfo","getModuleBuildInfo","_module","rsc","type","RSC_MODULE_TYPES","client","process","env","BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN","rscModuleInformationJson"],"mappings":";;;;+BA2BA;;;eAAwBA;;;2BAvBjB;oCAC4B;uBACV;AAqBV,SAASA;IAGtB,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAG,IAAI,CAACC,UAAU;IACzC,MAAMC,WAAWF,WAAW;IAE5B,IAAI,CAACG,MAAMC,OAAO,CAACL,UAAU;QAC3BA,UAAUA,UAAU;YAACA;SAAQ,GAAG,EAAE;IACpC;IAEA,MAAMM,OAAON,QACVO,GAAG,CAAC,CAACC,IAAMC,KAAKC,KAAK,CAACF,GACvB,yFAAyF;KACxFG,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAE,GAAKA,WAAYT,CAAAA,WAAW,CAACU,eAAQ,CAACC,IAAI,CAACF,WAAW,IAAG,GAC5EL,GAAG,CAAC,CAAC,EAAEK,OAAO,EAAEG,GAAG,EAA+B;QACjD,MAAMC,aAAaP,KAAKQ,SAAS,CAC/BL,QAAQM,UAAU,CAACC,qCAA0B,IACzCP,QAAQQ,OAAO,CAAC,KAAK,SACrBR;QAGN,4FAA4F;QAC5F,0FAA0F;QAC1F,wDAAwD;QACxD,IAAIG,IAAIM,MAAM,KAAK,KAAKN,IAAIO,QAAQ,CAAC,MAAM;YACzC,OAAO,CAAC,kCAAkC,EAAEN,WAAW,IAAI,CAAC;QAC9D,OAAO;YACL,OAAO,CAAC,gDAAgD,EAAEP,KAAKQ,SAAS,CACtEF,KACA,IAAI,EAAEC,WAAW,IAAI,CAAC;QAC1B;IACF,GACCO,IAAI,CAAC;IAER,MAAMC,YAAYC,IAAAA,sCAAkB,EAAC,IAAI,CAACC,OAAO;IAEjDF,UAAUG,GAAG,GAAG;QACdC,MAAMC,2BAAgB,CAACC,MAAM;IAC/B;IACA,IAAIC,QAAQC,GAAG,CAACC,kCAAkC,EAAE;QAClD,MAAMC,2BAA2BzB,KAAKQ,SAAS,CAACO,UAAUG,GAAG;QAC7D,OACE,CAAC,yDAAyD,EAAEO,yBAAyB,KAAK,CAAC,GAC3F5B;IAEJ;IAEA,OAAOA;AACT","ignoreList":[0]}
@@ -190,6 +190,8 @@ class FlightClientEntryPlugin {
190
190
  for (const connection of moduleReferences){
191
191
  // Entry can be any user defined entry files such as layout, page, error, loading, etc.
192
192
  let entryRequest = connection.dependency.request;
193
+ // Skip if entryRequest is undefined (can happen with Bun's module resolution)
194
+ if (!entryRequest || typeof entryRequest !== 'string') continue;
193
195
  if (entryRequest.endsWith(_constants.WEBPACK_RESOURCE_QUERIES.metadataRoute)) {
194
196
  const { filePath, isDynamicRouteExtension } = getMetadataRouteResource(entryRequest);
195
197
  if (isDynamicRouteExtension === '1') {
@@ -437,6 +439,8 @@ class FlightClientEntryPlugin {
437
439
  for (const connection of (0, _utils1.getModuleReferencesInOrder)(ssrEntryModule, compilation.moduleGraph)){
438
440
  const depModule = connection.dependency;
439
441
  const request = depModule.request;
442
+ // Skip if request is undefined (can happen with Bun's module resolution)
443
+ if (!request || typeof request !== 'string') continue;
440
444
  // It is possible that the same entry is added multiple times in the
441
445
  // connection graph. We can just skip these to speed up the process.
442
446
  if (visitedEntry.has(request)) continue;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/plugins/flight-client-entry-plugin.ts"],"sourcesContent":["import type {\n CssImports,\n ClientComponentImports,\n} from '../loaders/next-flight-client-entry-loader'\n\nimport { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { parse, stringify } from 'querystring'\nimport path from 'path'\nimport { sources } from 'next/dist/compiled/webpack/webpack'\nimport {\n getInvalidator,\n getEntries,\n EntryTypes,\n getEntryKey,\n} from '../../../server/dev/on-demand-entry-handler'\nimport {\n WEBPACK_LAYERS,\n WEBPACK_RESOURCE_QUERIES,\n} from '../../../lib/constants'\nimport {\n APP_CLIENT_INTERNALS,\n BARREL_OPTIMIZATION_PREFIX,\n COMPILER_NAMES,\n DEFAULT_RUNTIME_WEBPACK,\n EDGE_RUNTIME_WEBPACK,\n SERVER_REFERENCE_MANIFEST,\n} from '../../../shared/lib/constants'\nimport {\n UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY,\n} from '../../../shared/lib/entry-constants'\nimport {\n isClientComponentEntryModule,\n isCSSMod,\n regexCSS,\n} from '../loaders/utils'\nimport {\n traverseModules,\n forEachEntryModule,\n formatBarrelOptimizedResource,\n getModuleReferencesInOrder,\n} from '../utils'\nimport { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'\nimport { getProxiedPluginState } from '../../build-context'\nimport { PAGE_TYPES } from '../../../lib/page-types'\nimport { getModuleBuildInfo } from '../loaders/get-module-build-info'\nimport { getAssumedSourceType } from '../loaders/next-flight-loader'\nimport { isAppRouteRoute } from '../../../lib/is-app-route-route'\nimport {\n DEFAULT_METADATA_ROUTE_EXTENSIONS,\n isMetadataRouteFile,\n} from '../../../lib/metadata/is-metadata-route'\nimport type { MetadataRouteLoaderOptions } from '../loaders/next-metadata-route-loader'\nimport type { FlightActionEntryLoaderActions } from '../loaders/next-flight-action-entry-loader'\nimport getWebpackBundler from '../../../shared/lib/get-webpack-bundler'\nimport { isAppBuiltinPage } from '../../utils'\n\ninterface Options {\n dev: boolean\n appDir: string\n isEdgeServer: boolean\n encryptionKey: string\n}\n\nconst PLUGIN_NAME = 'FlightClientEntryPlugin'\n\ntype Actions = {\n [actionId: string]: {\n exportedName?: string\n filename?: string\n workers: {\n [name: string]: {\n moduleId: string | number\n async: boolean\n }\n }\n // Record which layer the action is in (rsc or sc_action), in the specific entry.\n layer: {\n [name: string]: string\n }\n }\n}\n\ntype ActionIdNamePair = { id: string; exportedName?: string; filename?: string }\n\nexport type ActionManifest = {\n // Assign a unique encryption key during production build.\n encryptionKey: string\n node: Actions\n edge: Actions\n}\n\nexport interface ModuleInfo {\n moduleId: string | number\n async: boolean\n}\n\nconst pluginState = getProxiedPluginState({\n // A map to track \"action\" -> \"list of bundles\".\n serverActions: {} as ActionManifest['node'],\n edgeServerActions: {} as ActionManifest['edge'],\n\n serverActionModules: {} as {\n [workerName: string]: {\n server?: ModuleInfo\n client?: ModuleInfo\n }\n },\n\n edgeServerActionModules: {} as {\n [workerName: string]: {\n server?: ModuleInfo\n client?: ModuleInfo\n }\n },\n\n ssrModules: {} as { [ssrModuleId: string]: ModuleInfo },\n edgeSsrModules: {} as { [ssrModuleId: string]: ModuleInfo },\n\n rscModules: {} as { [rscModuleId: string]: ModuleInfo },\n edgeRscModules: {} as { [rscModuleId: string]: ModuleInfo },\n\n injectedClientEntries: {} as Record<string, string>,\n})\n\nconst POSSIBLE_SHARED_CONVENTIONS = ['template', 'layout']\nconst STANDALONE_BUNDLE_CONVENTION = 'global-not-found'\n\nfunction deduplicateCSSImportsForEntry(mergedCSSimports: CssImports) {\n // If multiple entry module connections are having the same CSS import,\n // we only need to have one module to keep track of that CSS import.\n // It is based on the fact that if a page or a layout is rendered in the\n // given entry, all its parent layouts are always rendered too.\n // This can avoid duplicate CSS imports in the generated CSS manifest,\n // for example, if a page and its parent layout are both using the same\n // CSS import, we only need to have the layout to keep track of that CSS\n // import.\n // To achieve this, we need to first collect all the CSS imports from\n // every connection, and deduplicate them in the order of layers from\n // top to bottom. The implementation can be generally described as:\n // - Sort by number of `/` in the request path (the more `/`, the deeper)\n // - When in the same depth, sort by the filename (template < layout < page and others)\n\n // Sort the connections as described above.\n const sortedCSSImports = Object.entries(mergedCSSimports).sort((a, b) => {\n const [aPath] = a\n const [bPath] = b\n\n const aDepth = aPath.split('/').length\n const bDepth = bPath.split('/').length\n\n if (aDepth !== bDepth) {\n return aDepth - bDepth\n }\n\n const aName = path.parse(aPath).name\n const bName = path.parse(bPath).name\n\n const indexA = POSSIBLE_SHARED_CONVENTIONS.indexOf(aName)\n const indexB = POSSIBLE_SHARED_CONVENTIONS.indexOf(bName)\n\n if (indexA === -1) return 1\n if (indexB === -1) return -1\n return indexA - indexB\n })\n\n const dedupedCSSImports: CssImports = {}\n const trackedCSSImports = new Set<string>()\n\n for (const [entryFilePath, cssImports] of sortedCSSImports) {\n const entryConventionName = path.parse(entryFilePath).name\n\n for (const cssImport of cssImports) {\n // If the CSS import is already tracked, we can skip it.\n // Or if it's any standalone entry such as `global-not-found`, it won't share any resources with other entry, skip it.\n if (\n trackedCSSImports.has(cssImport) &&\n STANDALONE_BUNDLE_CONVENTION !== entryConventionName\n ) {\n continue\n }\n\n // Only track CSS imports that are in files that can inherit CSS.\n if (POSSIBLE_SHARED_CONVENTIONS.includes(entryConventionName)) {\n trackedCSSImports.add(cssImport)\n }\n\n if (!dedupedCSSImports[entryFilePath]) {\n dedupedCSSImports[entryFilePath] = []\n }\n dedupedCSSImports[entryFilePath].push(cssImport)\n }\n }\n\n return dedupedCSSImports\n}\n\nexport class FlightClientEntryPlugin {\n dev: boolean\n appDir: string\n projectDir: string\n encryptionKey: string\n isEdgeServer: boolean\n assetPrefix: string\n webpackRuntime: string\n\n constructor(options: Options) {\n this.dev = options.dev\n this.appDir = options.appDir\n this.projectDir = path.join(options.appDir, '..')\n this.isEdgeServer = options.isEdgeServer\n this.assetPrefix = !this.dev && !this.isEdgeServer ? '../' : ''\n this.encryptionKey = options.encryptionKey\n this.webpackRuntime = this.isEdgeServer\n ? EDGE_RUNTIME_WEBPACK\n : DEFAULT_RUNTIME_WEBPACK\n }\n\n apply(compiler: webpack.Compiler) {\n compiler.hooks.finishMake.tapPromise(PLUGIN_NAME, (compilation) =>\n this.createClientEntries(compiler, compilation)\n )\n\n compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation) => {\n const recordModule = (modId: string, mod: any) => {\n // Match Resource is undefined unless an import is using the inline match resource syntax\n // https://webpack.js.org/api/loaders/#inline-matchresource\n const modPath = mod.matchResource || mod.resourceResolveData?.path\n const modQuery = mod.resourceResolveData?.query || ''\n // query is already part of mod.resource\n // so it's only necessary to add it for matchResource or mod.resourceResolveData\n const modResource = modPath\n ? modPath.startsWith(BARREL_OPTIMIZATION_PREFIX)\n ? formatBarrelOptimizedResource(mod.resource, modPath)\n : modPath + modQuery\n : mod.resource\n\n if (typeof modId !== 'undefined' && modResource) {\n if (mod.layer === WEBPACK_LAYERS.reactServerComponents) {\n const key = path\n .relative(compiler.context, modResource)\n .replace(/\\/next\\/dist\\/esm\\//, '/next/dist/')\n\n const moduleInfo: ModuleInfo = {\n moduleId: modId,\n async: compilation.moduleGraph.isAsync(mod),\n }\n\n if (this.isEdgeServer) {\n pluginState.edgeRscModules[key] = moduleInfo\n } else {\n pluginState.rscModules[key] = moduleInfo\n }\n }\n }\n\n if (mod.layer !== WEBPACK_LAYERS.serverSideRendering) {\n return\n }\n\n // Check mod resource to exclude the empty resource module like virtual module created by next-flight-client-entry-loader\n if (typeof modId !== 'undefined' && modResource) {\n // Note that this isn't that reliable as webpack is still possible to assign\n // additional queries to make sure there's no conflict even using the `named`\n // module ID strategy.\n let ssrNamedModuleId = path.relative(compiler.context, modResource)\n\n if (!ssrNamedModuleId.startsWith('.')) {\n // TODO use getModuleId instead\n ssrNamedModuleId = `./${normalizePathSep(ssrNamedModuleId)}`\n }\n\n const moduleInfo: ModuleInfo = {\n moduleId: modId,\n async: compilation.moduleGraph.isAsync(mod),\n }\n\n if (this.isEdgeServer) {\n pluginState.edgeSsrModules[\n ssrNamedModuleId.replace(/\\/next\\/dist\\/esm\\//, '/next/dist/')\n ] = moduleInfo\n } else {\n pluginState.ssrModules[ssrNamedModuleId] = moduleInfo\n }\n }\n }\n\n traverseModules(compilation, (mod, _chunk, _chunkGroup, modId) => {\n if (modId) recordModule(modId, mod)\n })\n })\n\n compiler.hooks.make.tap(PLUGIN_NAME, (compilation) => {\n compilation.hooks.processAssets.tapPromise(\n {\n name: PLUGIN_NAME,\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH,\n },\n () => this.createActionAssets(compilation)\n )\n })\n }\n\n async createClientEntries(\n compiler: webpack.Compiler,\n compilation: webpack.Compilation\n ) {\n const addClientEntryAndSSRModulesList: Array<\n ReturnType<typeof this.injectClientEntryAndSSRModules>\n > = []\n const createdSSRDependenciesForEntry: Record<\n string,\n ReturnType<typeof this.injectClientEntryAndSSRModules>[3][]\n > = {}\n\n const addActionEntryList: Array<ReturnType<typeof this.injectActionEntry>> =\n []\n const actionMapsPerEntry: Record<\n string,\n Map<string, ActionIdNamePair[]>\n > = {}\n const createdActionIds = new Set<string>()\n\n // For each SC server compilation entry, we need to create its corresponding\n // client component entry.\n forEachEntryModule(compilation, ({ name, entryModule }) => {\n const internalClientComponentEntryImports: ClientComponentImports = {}\n const actionEntryImports = new Map<string, ActionIdNamePair[]>()\n const clientEntriesToInject = []\n const mergedCSSimports: CssImports = {}\n\n const moduleReferences = getModuleReferencesInOrder(\n entryModule,\n compilation.moduleGraph\n )\n for (const connection of moduleReferences) {\n // Entry can be any user defined entry files such as layout, page, error, loading, etc.\n let entryRequest = (\n connection.dependency as unknown as webpack.NormalModule\n ).request\n\n if (entryRequest.endsWith(WEBPACK_RESOURCE_QUERIES.metadataRoute)) {\n const { filePath, isDynamicRouteExtension } =\n getMetadataRouteResource(entryRequest)\n\n if (isDynamicRouteExtension === '1') {\n entryRequest = filePath\n }\n }\n\n const { clientComponentImports, actionImports, cssImports } =\n this.collectComponentInfoFromServerEntryDependency({\n entryRequest,\n compilation,\n resolvedModule: connection.resolvedModule,\n })\n\n actionImports.forEach(([dep, actions]) =>\n actionEntryImports.set(dep, actions)\n )\n\n const isAbsoluteRequest = path.isAbsolute(entryRequest)\n const isAppRouterBuiltinPage = isAppBuiltinPage(entryRequest)\n\n // Next.js internals are put into a separate entry.\n if (!isAbsoluteRequest) {\n Object.keys(clientComponentImports).forEach(\n (value) => (internalClientComponentEntryImports[value] = new Set())\n )\n if (!isAppRouterBuiltinPage) {\n continue\n }\n }\n\n // TODO-APP: Enable these lines. This ensures no entrypoint is created for layout/page when there are no client components.\n // Currently disabled because it causes test failures in CI.\n // if (clientImports.length === 0 && actionImports.length === 0) {\n // continue\n // }\n\n const relativeRequest =\n isAbsoluteRequest && !isAppRouterBuiltinPage\n ? path.relative(compilation.options.context!, entryRequest)\n : entryRequest\n\n // Replace file suffix as `.js` will be added.\n // bundlePath will have app/ prefix but not src/.\n // e.g. src/app/foo/page.js -> app/foo/page\n let bundlePath = normalizePathSep(\n relativeRequest.replace(/\\.[^.\\\\/]+$/, '').replace(/^src[\\\\/]/, '')\n )\n\n // For metadata routes, the entry name can be used as the bundle path,\n // as it has been normalized already.\n // e.g.\n // When `relativeRequest` is 'src/app/sitemap.js',\n // `appDirRelativeRequest` will be '/sitemap.js'\n // then `isMetadataEntryFile` will be `true`\n const appDirRelativeRequest = relativeRequest\n .replace(/^src[\\\\/]/, '')\n .replace(/^app[\\\\/]/, '/')\n const isMetadataEntryFile = isMetadataRouteFile(\n appDirRelativeRequest,\n DEFAULT_METADATA_ROUTE_EXTENSIONS,\n true\n )\n if (isMetadataEntryFile) {\n bundlePath = name\n }\n\n Object.assign(mergedCSSimports, cssImports)\n clientEntriesToInject.push({\n compiler,\n compilation,\n entryName: name,\n clientComponentImports,\n bundlePath,\n absolutePagePath: entryRequest,\n })\n\n // The webpack implementation of writing the client reference manifest relies on all entrypoints writing a page.js even when there is no client components in the page.\n // It needs the file in order to write the reference manifest for the path in the `.next/server` folder.\n if (\n name === `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}` &&\n bundlePath === 'app/not-found'\n ) {\n clientEntriesToInject.push({\n compiler,\n compilation,\n entryName: name,\n clientComponentImports: {},\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n absolutePagePath: entryRequest,\n })\n }\n\n if (\n name === `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}` &&\n bundlePath === 'app/global-not-found'\n ) {\n clientEntriesToInject.push({\n compiler,\n compilation,\n entryName: name,\n clientComponentImports,\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n absolutePagePath: entryRequest,\n })\n }\n\n if (name === `app${UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY}`) {\n clientEntriesToInject.push({\n compiler,\n compilation,\n entryName: name,\n clientComponentImports,\n bundlePath: `app${UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY}`,\n absolutePagePath: entryRequest,\n })\n }\n }\n\n // Make sure CSS imports are deduplicated before injecting the client entry\n // and SSR modules.\n const dedupedCSSImports = deduplicateCSSImportsForEntry(mergedCSSimports)\n for (const clientEntryToInject of clientEntriesToInject) {\n const injected = this.injectClientEntryAndSSRModules({\n ...clientEntryToInject,\n clientImports: {\n ...clientEntryToInject.clientComponentImports,\n ...(\n dedupedCSSImports[clientEntryToInject.absolutePagePath] || []\n ).reduce<ClientComponentImports>((res, curr) => {\n res[curr] = new Set()\n return res\n }, {}),\n },\n })\n\n // Track all created SSR dependencies for each entry from the server layer.\n if (!createdSSRDependenciesForEntry[clientEntryToInject.entryName]) {\n createdSSRDependenciesForEntry[clientEntryToInject.entryName] = []\n }\n createdSSRDependenciesForEntry[clientEntryToInject.entryName].push(\n injected[3]\n )\n\n addClientEntryAndSSRModulesList.push(injected)\n }\n\n if (!isAppRouteRoute(name)) {\n // Create internal app\n addClientEntryAndSSRModulesList.push(\n this.injectClientEntryAndSSRModules({\n compiler,\n compilation,\n entryName: name,\n clientImports: { ...internalClientComponentEntryImports },\n bundlePath: APP_CLIENT_INTERNALS,\n })\n )\n }\n\n if (actionEntryImports.size > 0) {\n if (!actionMapsPerEntry[name]) {\n actionMapsPerEntry[name] = new Map()\n }\n actionMapsPerEntry[name] = new Map([\n ...actionMapsPerEntry[name],\n ...actionEntryImports,\n ])\n }\n })\n\n for (const [name, actionEntryImports] of Object.entries(\n actionMapsPerEntry\n )) {\n addActionEntryList.push(\n this.injectActionEntry({\n compiler,\n compilation,\n actions: actionEntryImports,\n entryName: name,\n bundlePath: name,\n createdActionIds,\n })\n )\n }\n\n // Invalidate in development to trigger recompilation\n const invalidator = getInvalidator(compiler.outputPath)\n // Check if any of the entry injections need an invalidation\n if (\n invalidator &&\n addClientEntryAndSSRModulesList.some(\n ([shouldInvalidate]) => shouldInvalidate === true\n )\n ) {\n invalidator.invalidate([COMPILER_NAMES.client])\n }\n\n // Client compiler is invalidated before awaiting the compilation of the SSR\n // and RSC client component entries so that the client compiler is running\n // in parallel to the server compiler.\n await Promise.all(\n addClientEntryAndSSRModulesList.flatMap((addClientEntryAndSSRModules) => [\n addClientEntryAndSSRModules[1],\n addClientEntryAndSSRModules[2],\n ])\n )\n\n // Wait for action entries to be added.\n await Promise.all(addActionEntryList)\n\n const addedClientActionEntryList: Promise<any>[] = []\n const actionMapsPerClientEntry: Record<\n string,\n Map<string, ActionIdNamePair[]>\n > = {}\n\n // We need to create extra action entries that are created from the\n // client layer.\n // Start from each entry's created SSR dependency from our previous step.\n for (const [name, ssrEntryDependencies] of Object.entries(\n createdSSRDependenciesForEntry\n )) {\n // Collect from all entries, e.g. layout.js, page.js, loading.js, ...\n // add aggregate them.\n const actionEntryImports = this.collectClientActionsFromDependencies({\n compilation,\n dependencies: ssrEntryDependencies,\n })\n\n if (actionEntryImports.size > 0) {\n if (!actionMapsPerClientEntry[name]) {\n actionMapsPerClientEntry[name] = new Map()\n }\n actionMapsPerClientEntry[name] = new Map([\n ...actionMapsPerClientEntry[name],\n ...actionEntryImports,\n ])\n }\n }\n\n for (const [entryName, actionEntryImports] of Object.entries(\n actionMapsPerClientEntry\n )) {\n // If an action method is already created in the server layer, we don't\n // need to create it again in the action layer.\n // This is to avoid duplicate action instances and make sure the module\n // state is shared.\n let remainingClientImportedActions = false\n const remainingActionEntryImports = new Map<string, ActionIdNamePair[]>()\n for (const [dep, actions] of actionEntryImports) {\n const remainingActionNames = []\n for (const action of actions) {\n if (!createdActionIds.has(entryName + '@' + action.id)) {\n remainingActionNames.push(action)\n }\n }\n if (remainingActionNames.length > 0) {\n remainingActionEntryImports.set(dep, remainingActionNames)\n remainingClientImportedActions = true\n }\n }\n\n if (remainingClientImportedActions) {\n addedClientActionEntryList.push(\n this.injectActionEntry({\n compiler,\n compilation,\n actions: remainingActionEntryImports,\n entryName,\n bundlePath: entryName,\n fromClient: true,\n createdActionIds,\n })\n )\n }\n }\n\n await Promise.all(addedClientActionEntryList)\n }\n\n collectClientActionsFromDependencies({\n compilation,\n dependencies,\n }: {\n compilation: webpack.Compilation\n dependencies: ReturnType<typeof webpack.EntryPlugin.createDependency>[]\n }) {\n // action file path -> action names\n const collectedActions = new Map<string, ActionIdNamePair[]>()\n\n // Keep track of checked modules to avoid infinite loops with recursive imports.\n const visitedModule = new Set<string>()\n const visitedEntry = new Set<string>()\n\n const collectActions = ({\n entryRequest,\n resolvedModule,\n }: {\n entryRequest: string\n resolvedModule: any\n }) => {\n const collectActionsInDep = (mod: webpack.NormalModule): void => {\n if (!mod) return\n\n const modResource = getModuleResource(mod)\n\n if (!modResource) return\n\n if (visitedModule.has(modResource)) return\n visitedModule.add(modResource)\n\n const actionIds = getModuleBuildInfo(mod).rsc?.actionIds\n if (actionIds) {\n collectedActions.set(\n modResource,\n Object.entries(actionIds).map(([id, exportedName]) => ({\n id,\n exportedName,\n filename: path.posix.relative(this.projectDir, modResource),\n }))\n )\n }\n\n // Collect used exported actions transversely.\n getModuleReferencesInOrder(mod, compilation.moduleGraph).forEach(\n (connection: any) => {\n collectActionsInDep(\n connection.resolvedModule as webpack.NormalModule\n )\n }\n )\n }\n\n // Don't traverse the module graph anymore once hitting the action layer.\n if (\n entryRequest &&\n !entryRequest.includes('next-flight-action-entry-loader')\n ) {\n // Traverse the module graph to find all client components.\n collectActionsInDep(resolvedModule)\n }\n }\n\n for (const entryDependency of dependencies) {\n const ssrEntryModule =\n compilation.moduleGraph.getResolvedModule(entryDependency)!\n for (const connection of getModuleReferencesInOrder(\n ssrEntryModule,\n compilation.moduleGraph\n )) {\n const depModule = connection.dependency\n const request = (depModule as unknown as webpack.NormalModule).request\n\n // It is possible that the same entry is added multiple times in the\n // connection graph. We can just skip these to speed up the process.\n if (visitedEntry.has(request)) continue\n visitedEntry.add(request)\n\n collectActions({\n entryRequest: request,\n resolvedModule: connection.resolvedModule,\n })\n }\n }\n\n return collectedActions\n }\n\n collectComponentInfoFromServerEntryDependency({\n entryRequest,\n compilation,\n resolvedModule,\n }: {\n entryRequest: string\n compilation: webpack.Compilation\n resolvedModule: any /* Dependency */\n }): {\n cssImports: CssImports\n clientComponentImports: ClientComponentImports\n actionImports: [string, ActionIdNamePair[]][]\n } {\n // Keep track of checked modules to avoid infinite loops with recursive imports.\n const visitedOfClientComponentsTraverse = new Set()\n\n // Info to collect.\n const clientComponentImports: ClientComponentImports = {}\n const actionImports: [string, ActionIdNamePair[]][] = []\n const CSSImports = new Set<string>()\n\n const filterClientComponents = (\n mod: webpack.NormalModule,\n importedIdentifiers: string[]\n ): void => {\n if (!mod) return\n\n const modResource = getModuleResource(mod)\n\n if (!modResource) return\n if (visitedOfClientComponentsTraverse.has(modResource)) {\n if (clientComponentImports[modResource]) {\n addClientImport(\n mod,\n modResource,\n clientComponentImports,\n importedIdentifiers,\n false\n )\n }\n return\n }\n visitedOfClientComponentsTraverse.add(modResource)\n\n const actionIds = getModuleBuildInfo(mod).rsc?.actionIds\n if (actionIds) {\n actionImports.push([\n modResource,\n Object.entries(actionIds).map(([id, exportedName]) => ({\n id,\n exportedName,\n filename: path.posix.relative(this.projectDir, modResource),\n })),\n ])\n }\n\n if (isCSSMod(mod)) {\n const sideEffectFree =\n mod.factoryMeta && (mod.factoryMeta as any).sideEffectFree\n\n if (sideEffectFree) {\n const unused = !compilation.moduleGraph\n .getExportsInfo(mod)\n .isModuleUsed(this.webpackRuntime)\n\n if (unused) return\n }\n\n CSSImports.add(modResource)\n } else if (isClientComponentEntryModule(mod)) {\n if (!clientComponentImports[modResource]) {\n clientComponentImports[modResource] = new Set()\n }\n addClientImport(\n mod,\n modResource,\n clientComponentImports,\n importedIdentifiers,\n true\n )\n\n return\n }\n\n getModuleReferencesInOrder(mod, compilation.moduleGraph).forEach(\n (connection: any) => {\n let dependencyIds: string[] = []\n\n // `ids` are the identifiers that are imported from the dependency,\n // if it's present, it's an array of strings.\n if (connection.dependency?.ids) {\n dependencyIds.push(...connection.dependency.ids)\n } else {\n dependencyIds = ['*']\n }\n\n filterClientComponents(connection.resolvedModule, dependencyIds)\n }\n )\n }\n\n // Traverse the module graph to find all client components.\n filterClientComponents(resolvedModule, [])\n\n return {\n clientComponentImports,\n cssImports: CSSImports.size\n ? {\n [entryRequest]: Array.from(CSSImports),\n }\n : {},\n actionImports,\n }\n }\n\n injectClientEntryAndSSRModules({\n compiler,\n compilation,\n entryName,\n clientImports,\n bundlePath,\n absolutePagePath,\n }: {\n compiler: webpack.Compiler\n compilation: webpack.Compilation\n entryName: string\n clientImports: ClientComponentImports\n bundlePath: string\n absolutePagePath?: string\n }): [\n shouldInvalidate: boolean,\n addSSREntryPromise: Promise<void>,\n addRSCEntryPromise: Promise<void>,\n ssrDep: ReturnType<typeof webpack.EntryPlugin.createDependency>,\n ] {\n const bundler = getWebpackBundler()\n let shouldInvalidate = false\n\n const modules = Object.keys(clientImports)\n .sort((a, b) => (regexCSS.test(b) ? 1 : a.localeCompare(b)))\n .map((clientImportPath) => ({\n request: clientImportPath,\n ids: [...clientImports[clientImportPath]],\n }))\n\n // For the client entry, we always use the CJS build of Next.js. If the\n // server is using the ESM build (when using the Edge runtime), we need to\n // replace them.\n const clientBrowserLoader = `next-flight-client-entry-loader?${stringify({\n modules: (this.isEdgeServer\n ? modules.map(({ request, ids }) => ({\n request: request.replace(\n /[\\\\/]next[\\\\/]dist[\\\\/]esm[\\\\/]/,\n '/next/dist/'.replace(/\\//g, path.sep)\n ),\n ids,\n }))\n : modules\n ).map((x) => JSON.stringify(x)),\n server: false,\n })}!`\n\n const clientServerLoader = `next-flight-client-entry-loader?${stringify({\n modules: modules.map((x) => JSON.stringify(x)),\n server: true,\n })}!`\n\n // Add for the client compilation\n // Inject the entry to the client compiler.\n if (this.dev) {\n const entries = getEntries(compiler.outputPath)\n const pageKey = getEntryKey(\n COMPILER_NAMES.client,\n PAGE_TYPES.APP,\n bundlePath\n )\n\n if (!entries[pageKey]) {\n entries[pageKey] = {\n type: EntryTypes.CHILD_ENTRY,\n parentEntries: new Set([entryName]),\n absoluteEntryFilePath: absolutePagePath,\n bundlePath,\n request: clientBrowserLoader,\n dispose: false,\n lastActiveTime: Date.now(),\n }\n shouldInvalidate = true\n } else {\n const entryData = entries[pageKey]\n // New version of the client loader\n if (entryData.request !== clientBrowserLoader) {\n entryData.request = clientBrowserLoader\n shouldInvalidate = true\n }\n if (entryData.type === EntryTypes.CHILD_ENTRY) {\n entryData.parentEntries.add(entryName)\n }\n entryData.dispose = false\n entryData.lastActiveTime = Date.now()\n }\n } else {\n pluginState.injectedClientEntries[bundlePath] = clientBrowserLoader\n }\n\n const clientComponentSSREntryDep = bundler.EntryPlugin.createDependency(\n clientServerLoader,\n { name: bundlePath }\n )\n\n const clientComponentRSCEntryDep = bundler.EntryPlugin.createDependency(\n clientServerLoader,\n { name: bundlePath }\n )\n\n return [\n shouldInvalidate,\n // Add the entries to the server compiler for the SSR and RSC layers. The\n // promises are awaited later using `Promise.all` in order to parallelize\n // adding the entries.\n this.addEntry(compilation, compiler.context, clientComponentSSREntryDep, {\n name: entryName,\n layer: WEBPACK_LAYERS.serverSideRendering,\n }),\n this.addEntry(compilation, compiler.context, clientComponentRSCEntryDep, {\n name: entryName,\n layer: WEBPACK_LAYERS.reactServerComponents,\n }),\n clientComponentSSREntryDep,\n ]\n }\n\n injectActionEntry({\n compiler,\n compilation,\n actions,\n entryName,\n bundlePath,\n fromClient,\n createdActionIds,\n }: {\n compiler: webpack.Compiler\n compilation: webpack.Compilation\n actions: Map<string, ActionIdNamePair[]>\n entryName: string\n bundlePath: string\n createdActionIds: Set<string>\n fromClient?: boolean\n }) {\n const bundler = getWebpackBundler()\n const actionsArray = Array.from(actions.entries())\n for (const [, actionsFromModule] of actions) {\n for (const { id } of actionsFromModule) {\n createdActionIds.add(entryName + '@' + id)\n }\n }\n\n if (actionsArray.length === 0) {\n return Promise.resolve()\n }\n\n const actionLoader = `next-flight-action-entry-loader?${stringify({\n actions: JSON.stringify(\n actionsArray satisfies FlightActionEntryLoaderActions\n ),\n __client_imported__: fromClient,\n })}!`\n\n const currentCompilerServerActions = this.isEdgeServer\n ? pluginState.edgeServerActions\n : pluginState.serverActions\n\n for (const [, actionsFromModule] of actionsArray) {\n for (const { id, exportedName, filename } of actionsFromModule) {\n if (typeof currentCompilerServerActions[id] === 'undefined') {\n currentCompilerServerActions[id] = {\n workers: {},\n layer: {},\n filename,\n exportedName,\n }\n }\n currentCompilerServerActions[id].workers[bundlePath] = {\n moduleId: '', // TODO: What's the meaning of this?\n async: false,\n }\n\n currentCompilerServerActions[id].layer[bundlePath] = fromClient\n ? WEBPACK_LAYERS.actionBrowser\n : WEBPACK_LAYERS.reactServerComponents\n }\n }\n\n // Inject the entry to the server compiler\n const actionEntryDep = bundler.EntryPlugin.createDependency(actionLoader, {\n name: bundlePath,\n })\n\n return this.addEntry(\n compilation,\n // Reuse compilation context.\n compiler.context,\n actionEntryDep,\n {\n name: entryName,\n layer: fromClient\n ? WEBPACK_LAYERS.actionBrowser\n : WEBPACK_LAYERS.reactServerComponents,\n }\n )\n }\n\n addEntry(\n compilation: webpack.Compilation,\n context: string,\n dependency: webpack.Dependency,\n options: webpack.EntryOptions\n ): Promise<any> /* Promise<module> */ {\n return new Promise((resolve, reject) => {\n if ('rspack' in compilation.compiler) {\n compilation.addInclude(context, dependency, options, (err, module) => {\n if (err) {\n return reject(err)\n }\n\n compilation.moduleGraph\n .getExportsInfo(module!)\n .setUsedInUnknownWay(\n this.isEdgeServer ? EDGE_RUNTIME_WEBPACK : DEFAULT_RUNTIME_WEBPACK\n )\n return resolve(module)\n })\n } else {\n const entry = compilation.entries.get(options.name!)!\n entry.includeDependencies.push(dependency)\n compilation.hooks.addEntry.call(entry as any, options)\n compilation.addModuleTree(\n {\n context,\n dependency,\n contextInfo: { issuerLayer: options.layer },\n },\n (err: any, module: any) => {\n if (err) {\n compilation.hooks.failedEntry.call(dependency, options, err)\n return reject(err)\n }\n\n compilation.hooks.succeedEntry.call(dependency, options, module)\n\n compilation.moduleGraph\n .getExportsInfo(module)\n .setUsedInUnknownWay(\n this.isEdgeServer\n ? EDGE_RUNTIME_WEBPACK\n : DEFAULT_RUNTIME_WEBPACK\n )\n\n return resolve(module)\n }\n )\n }\n })\n }\n\n async createActionAssets(compilation: webpack.Compilation) {\n const serverActions: ActionManifest['node'] = {}\n const edgeServerActions: ActionManifest['edge'] = {}\n\n traverseModules(compilation, (mod, _chunk, chunkGroup, modId) => {\n // Go through all action entries and record the module ID for each entry.\n if (\n chunkGroup.name &&\n mod.request &&\n modId &&\n /next-flight-action-entry-loader/.test(mod.request)\n ) {\n const fromClient = /&__client_imported__=true/.test(mod.request)\n\n const mapping = this.isEdgeServer\n ? pluginState.edgeServerActionModules\n : pluginState.serverActionModules\n\n if (!mapping[chunkGroup.name]) {\n mapping[chunkGroup.name] = {}\n }\n\n mapping[chunkGroup.name][fromClient ? 'client' : 'server'] = {\n moduleId: modId,\n async: compilation.moduleGraph.isAsync(mod),\n }\n }\n })\n\n for (let id in pluginState.serverActions) {\n const action = pluginState.serverActions[id]\n for (let name in action.workers) {\n const modId =\n pluginState.serverActionModules[name][\n action.layer[name] === WEBPACK_LAYERS.actionBrowser\n ? 'client'\n : 'server'\n ]\n action.workers[name] = modId!\n }\n serverActions[id] = action\n }\n\n for (let id in pluginState.edgeServerActions) {\n const action = pluginState.edgeServerActions[id]\n for (let name in action.workers) {\n const modId =\n pluginState.edgeServerActionModules[name][\n action.layer[name] === WEBPACK_LAYERS.actionBrowser\n ? 'client'\n : 'server'\n ]\n action.workers[name] = modId!\n }\n edgeServerActions[id] = action\n }\n\n const serverManifest = {\n node: serverActions,\n edge: edgeServerActions,\n encryptionKey: this.encryptionKey,\n }\n const edgeServerManifest = {\n ...serverManifest,\n encryptionKey: 'process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY',\n }\n\n const json = JSON.stringify(serverManifest, null, this.dev ? 2 : undefined)\n const edgeJson = JSON.stringify(\n edgeServerManifest,\n null,\n this.dev ? 2 : undefined\n )\n\n compilation.emitAsset(\n `${this.assetPrefix}${SERVER_REFERENCE_MANIFEST}.js`,\n new sources.RawSource(\n `self.__RSC_SERVER_MANIFEST=${JSON.stringify(edgeJson)}`\n ) as unknown as webpack.sources.RawSource\n )\n compilation.emitAsset(\n `${this.assetPrefix}${SERVER_REFERENCE_MANIFEST}.json`,\n new sources.RawSource(json) as unknown as webpack.sources.RawSource\n )\n }\n}\n\nfunction addClientImport(\n mod: webpack.NormalModule,\n modRequest: string,\n clientComponentImports: ClientComponentImports,\n importedIdentifiers: string[],\n isFirstVisitModule: boolean\n) {\n const clientEntryType = getModuleBuildInfo(mod).rsc?.clientEntryType\n const isCjsModule = clientEntryType === 'cjs'\n const assumedSourceType = getAssumedSourceType(\n mod,\n isCjsModule ? 'commonjs' : 'auto'\n )\n\n const clientImportsSet = clientComponentImports[modRequest]\n\n if (importedIdentifiers[0] === '*') {\n // If there's collected import path with named import identifiers,\n // or there's nothing in collected imports are empty.\n // we should include the whole module.\n if (!isFirstVisitModule && [...clientImportsSet][0] !== '*') {\n clientComponentImports[modRequest] = new Set(['*'])\n }\n } else {\n const isAutoModuleSourceType = assumedSourceType === 'auto'\n if (isAutoModuleSourceType) {\n clientComponentImports[modRequest] = new Set(['*'])\n } else {\n // If it's not analyzed as named ESM exports, e.g. if it's mixing `export *` with named exports,\n // We'll include all modules since it's not able to do tree-shaking.\n for (const name of importedIdentifiers) {\n // For cjs module default import, we include the whole module since\n const isCjsDefaultImport = isCjsModule && name === 'default'\n\n // Always include __esModule along with cjs module default export,\n // to make sure it work with client module proxy from React.\n if (isCjsDefaultImport) {\n clientComponentImports[modRequest].add('__esModule')\n }\n\n clientComponentImports[modRequest].add(name)\n }\n }\n }\n}\n\nfunction getModuleResource(mod: webpack.NormalModule): string {\n const modPath: string = mod.resourceResolveData?.path || ''\n const modQuery = mod.resourceResolveData?.query || ''\n // We have to always use the resolved request here to make sure the\n // server and client are using the same module path (required by RSC), as\n // the server compiler and client compiler have different resolve configs.\n let modResource: string = modPath + modQuery\n\n // Context modules don't have a resource path, we use the identifier instead.\n if (mod.constructor.name === 'ContextModule') {\n modResource = mod.identifier()\n }\n\n // For the barrel optimization, we need to use the match resource instead\n // because there will be 2 modules for the same file (same resource path)\n // but they're different modules and can't be deduped via `visitedModule`.\n // The first module is a virtual re-export module created by the loader.\n if (mod.matchResource?.startsWith(BARREL_OPTIMIZATION_PREFIX)) {\n modResource = mod.matchResource + ':' + modResource\n }\n\n if (mod.resource === `?${WEBPACK_RESOURCE_QUERIES.metadataRoute}`) {\n return getMetadataRouteResource(mod.rawRequest).filePath\n }\n\n return modResource\n}\n\nfunction getMetadataRouteResource(request: string): MetadataRouteLoaderOptions {\n // e.g. next-metadata-route-loader?filePath=<some-url-encoded-path>&isDynamicRouteExtension=1!?__next_metadata_route__\n const query = request.split('!')[0].split('next-metadata-route-loader?')[1]\n\n return parse(query) as MetadataRouteLoaderOptions\n}\n"],"names":["FlightClientEntryPlugin","PLUGIN_NAME","pluginState","getProxiedPluginState","serverActions","edgeServerActions","serverActionModules","edgeServerActionModules","ssrModules","edgeSsrModules","rscModules","edgeRscModules","injectedClientEntries","POSSIBLE_SHARED_CONVENTIONS","STANDALONE_BUNDLE_CONVENTION","deduplicateCSSImportsForEntry","mergedCSSimports","sortedCSSImports","Object","entries","sort","a","b","aPath","bPath","aDepth","split","length","bDepth","aName","path","parse","name","bName","indexA","indexOf","indexB","dedupedCSSImports","trackedCSSImports","Set","entryFilePath","cssImports","entryConventionName","cssImport","has","includes","add","push","constructor","options","dev","appDir","projectDir","join","isEdgeServer","assetPrefix","encryptionKey","webpackRuntime","EDGE_RUNTIME_WEBPACK","DEFAULT_RUNTIME_WEBPACK","apply","compiler","hooks","finishMake","tapPromise","compilation","createClientEntries","afterCompile","tap","recordModule","modId","mod","modPath","matchResource","resourceResolveData","modQuery","query","modResource","startsWith","BARREL_OPTIMIZATION_PREFIX","formatBarrelOptimizedResource","resource","layer","WEBPACK_LAYERS","reactServerComponents","key","relative","context","replace","moduleInfo","moduleId","async","moduleGraph","isAsync","serverSideRendering","ssrNamedModuleId","normalizePathSep","traverseModules","_chunk","_chunkGroup","make","processAssets","stage","webpack","Compilation","PROCESS_ASSETS_STAGE_OPTIMIZE_HASH","createActionAssets","addClientEntryAndSSRModulesList","createdSSRDependenciesForEntry","addActionEntryList","actionMapsPerEntry","createdActionIds","forEachEntryModule","entryModule","internalClientComponentEntryImports","actionEntryImports","Map","clientEntriesToInject","moduleReferences","getModuleReferencesInOrder","connection","entryRequest","dependency","request","endsWith","WEBPACK_RESOURCE_QUERIES","metadataRoute","filePath","isDynamicRouteExtension","getMetadataRouteResource","clientComponentImports","actionImports","collectComponentInfoFromServerEntryDependency","resolvedModule","forEach","dep","actions","set","isAbsoluteRequest","isAbsolute","isAppRouterBuiltinPage","isAppBuiltinPage","keys","value","relativeRequest","bundlePath","appDirRelativeRequest","isMetadataEntryFile","isMetadataRouteFile","DEFAULT_METADATA_ROUTE_EXTENSIONS","assign","entryName","absolutePagePath","UNDERSCORE_NOT_FOUND_ROUTE_ENTRY","UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY","clientEntryToInject","injected","injectClientEntryAndSSRModules","clientImports","reduce","res","curr","isAppRouteRoute","APP_CLIENT_INTERNALS","size","injectActionEntry","invalidator","getInvalidator","outputPath","some","shouldInvalidate","invalidate","COMPILER_NAMES","client","Promise","all","flatMap","addClientEntryAndSSRModules","addedClientActionEntryList","actionMapsPerClientEntry","ssrEntryDependencies","collectClientActionsFromDependencies","dependencies","remainingClientImportedActions","remainingActionEntryImports","remainingActionNames","action","id","fromClient","collectedActions","visitedModule","visitedEntry","collectActions","collectActionsInDep","getModuleBuildInfo","getModuleResource","actionIds","rsc","map","exportedName","filename","posix","entryDependency","ssrEntryModule","getResolvedModule","depModule","visitedOfClientComponentsTraverse","CSSImports","filterClientComponents","importedIdentifiers","addClientImport","isCSSMod","sideEffectFree","factoryMeta","unused","getExportsInfo","isModuleUsed","isClientComponentEntryModule","dependencyIds","ids","Array","from","bundler","getWebpackBundler","modules","regexCSS","test","localeCompare","clientImportPath","clientBrowserLoader","stringify","sep","x","JSON","server","clientServerLoader","getEntries","pageKey","getEntryKey","PAGE_TYPES","APP","type","EntryTypes","CHILD_ENTRY","parentEntries","absoluteEntryFilePath","dispose","lastActiveTime","Date","now","entryData","clientComponentSSREntryDep","EntryPlugin","createDependency","clientComponentRSCEntryDep","addEntry","actionsArray","actionsFromModule","resolve","actionLoader","__client_imported__","currentCompilerServerActions","workers","actionBrowser","actionEntryDep","reject","addInclude","err","module","setUsedInUnknownWay","entry","get","includeDependencies","call","addModuleTree","contextInfo","issuerLayer","failedEntry","succeedEntry","chunkGroup","mapping","serverManifest","node","edge","edgeServerManifest","json","undefined","edgeJson","emitAsset","SERVER_REFERENCE_MANIFEST","sources","RawSource","modRequest","isFirstVisitModule","clientEntryType","isCjsModule","assumedSourceType","getAssumedSourceType","clientImportsSet","isAutoModuleSourceType","isCjsDefaultImport","identifier","rawRequest"],"mappings":";;;;+BAqMaA;;;eAAAA;;;yBAhMW;6BACS;6DAChB;sCAOV;2BAIA;4BAQA;gCAIA;uBAKA;wBAMA;kCAC0B;8BACK;2BACX;oCACQ;kCACE;iCACL;iCAIzB;0EAGuB;wBACG;;;;;;AASjC,MAAMC,cAAc;AAiCpB,MAAMC,cAAcC,IAAAA,mCAAqB,EAAC;IACxC,gDAAgD;IAChDC,eAAe,CAAC;IAChBC,mBAAmB,CAAC;IAEpBC,qBAAqB,CAAC;IAOtBC,yBAAyB,CAAC;IAO1BC,YAAY,CAAC;IACbC,gBAAgB,CAAC;IAEjBC,YAAY,CAAC;IACbC,gBAAgB,CAAC;IAEjBC,uBAAuB,CAAC;AAC1B;AAEA,MAAMC,8BAA8B;IAAC;IAAY;CAAS;AAC1D,MAAMC,+BAA+B;AAErC,SAASC,8BAA8BC,gBAA4B;IACjE,uEAAuE;IACvE,oEAAoE;IACpE,wEAAwE;IACxE,+DAA+D;IAC/D,sEAAsE;IACtE,uEAAuE;IACvE,wEAAwE;IACxE,UAAU;IACV,qEAAqE;IACrE,qEAAqE;IACrE,mEAAmE;IACnE,yEAAyE;IACzE,uFAAuF;IAEvF,2CAA2C;IAC3C,MAAMC,mBAAmBC,OAAOC,OAAO,CAACH,kBAAkBI,IAAI,CAAC,CAACC,GAAGC;QACjE,MAAM,CAACC,MAAM,GAAGF;QAChB,MAAM,CAACG,MAAM,GAAGF;QAEhB,MAAMG,SAASF,MAAMG,KAAK,CAAC,KAAKC,MAAM;QACtC,MAAMC,SAASJ,MAAME,KAAK,CAAC,KAAKC,MAAM;QAEtC,IAAIF,WAAWG,QAAQ;YACrB,OAAOH,SAASG;QAClB;QAEA,MAAMC,QAAQC,aAAI,CAACC,KAAK,CAACR,OAAOS,IAAI;QACpC,MAAMC,QAAQH,aAAI,CAACC,KAAK,CAACP,OAAOQ,IAAI;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K,CAAC,IAAI,CAAC,EAAE,CAACA,KAAK,CAAC,8BAA8B,CAAC,EAAE;IAE3E,OAAOK,IAAAA,kBAAK,EAAC6C;AACf","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/build/webpack/plugins/flight-client-entry-plugin.ts"],"sourcesContent":["import type {\n CssImports,\n ClientComponentImports,\n} from '../loaders/next-flight-client-entry-loader'\n\nimport { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { parse, stringify } from 'querystring'\nimport path from 'path'\nimport { sources } from 'next/dist/compiled/webpack/webpack'\nimport {\n getInvalidator,\n getEntries,\n EntryTypes,\n getEntryKey,\n} from '../../../server/dev/on-demand-entry-handler'\nimport {\n WEBPACK_LAYERS,\n WEBPACK_RESOURCE_QUERIES,\n} from '../../../lib/constants'\nimport {\n APP_CLIENT_INTERNALS,\n BARREL_OPTIMIZATION_PREFIX,\n COMPILER_NAMES,\n DEFAULT_RUNTIME_WEBPACK,\n EDGE_RUNTIME_WEBPACK,\n SERVER_REFERENCE_MANIFEST,\n} from '../../../shared/lib/constants'\nimport {\n UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY,\n} from '../../../shared/lib/entry-constants'\nimport {\n isClientComponentEntryModule,\n isCSSMod,\n regexCSS,\n} from '../loaders/utils'\nimport {\n traverseModules,\n forEachEntryModule,\n formatBarrelOptimizedResource,\n getModuleReferencesInOrder,\n} from '../utils'\nimport { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'\nimport { getProxiedPluginState } from '../../build-context'\nimport { PAGE_TYPES } from '../../../lib/page-types'\nimport { getModuleBuildInfo } from '../loaders/get-module-build-info'\nimport { getAssumedSourceType } from '../loaders/next-flight-loader'\nimport { isAppRouteRoute } from '../../../lib/is-app-route-route'\nimport {\n DEFAULT_METADATA_ROUTE_EXTENSIONS,\n isMetadataRouteFile,\n} from '../../../lib/metadata/is-metadata-route'\nimport type { MetadataRouteLoaderOptions } from '../loaders/next-metadata-route-loader'\nimport type { FlightActionEntryLoaderActions } from '../loaders/next-flight-action-entry-loader'\nimport getWebpackBundler from '../../../shared/lib/get-webpack-bundler'\nimport { isAppBuiltinPage } from '../../utils'\n\ninterface Options {\n dev: boolean\n appDir: string\n isEdgeServer: boolean\n encryptionKey: string\n}\n\nconst PLUGIN_NAME = 'FlightClientEntryPlugin'\n\ntype Actions = {\n [actionId: string]: {\n exportedName?: string\n filename?: string\n workers: {\n [name: string]: {\n moduleId: string | number\n async: boolean\n }\n }\n // Record which layer the action is in (rsc or sc_action), in the specific entry.\n layer: {\n [name: string]: string\n }\n }\n}\n\ntype ActionIdNamePair = { id: string; exportedName?: string; filename?: string }\n\nexport type ActionManifest = {\n // Assign a unique encryption key during production build.\n encryptionKey: string\n node: Actions\n edge: Actions\n}\n\nexport interface ModuleInfo {\n moduleId: string | number\n async: boolean\n}\n\nconst pluginState = getProxiedPluginState({\n // A map to track \"action\" -> \"list of bundles\".\n serverActions: {} as ActionManifest['node'],\n edgeServerActions: {} as ActionManifest['edge'],\n\n serverActionModules: {} as {\n [workerName: string]: {\n server?: ModuleInfo\n client?: ModuleInfo\n }\n },\n\n edgeServerActionModules: {} as {\n [workerName: string]: {\n server?: ModuleInfo\n client?: ModuleInfo\n }\n },\n\n ssrModules: {} as { [ssrModuleId: string]: ModuleInfo },\n edgeSsrModules: {} as { [ssrModuleId: string]: ModuleInfo },\n\n rscModules: {} as { [rscModuleId: string]: ModuleInfo },\n edgeRscModules: {} as { [rscModuleId: string]: ModuleInfo },\n\n injectedClientEntries: {} as Record<string, string>,\n})\n\nconst POSSIBLE_SHARED_CONVENTIONS = ['template', 'layout']\nconst STANDALONE_BUNDLE_CONVENTION = 'global-not-found'\n\nfunction deduplicateCSSImportsForEntry(mergedCSSimports: CssImports) {\n // If multiple entry module connections are having the same CSS import,\n // we only need to have one module to keep track of that CSS import.\n // It is based on the fact that if a page or a layout is rendered in the\n // given entry, all its parent layouts are always rendered too.\n // This can avoid duplicate CSS imports in the generated CSS manifest,\n // for example, if a page and its parent layout are both using the same\n // CSS import, we only need to have the layout to keep track of that CSS\n // import.\n // To achieve this, we need to first collect all the CSS imports from\n // every connection, and deduplicate them in the order of layers from\n // top to bottom. The implementation can be generally described as:\n // - Sort by number of `/` in the request path (the more `/`, the deeper)\n // - When in the same depth, sort by the filename (template < layout < page and others)\n\n // Sort the connections as described above.\n const sortedCSSImports = Object.entries(mergedCSSimports).sort((a, b) => {\n const [aPath] = a\n const [bPath] = b\n\n const aDepth = aPath.split('/').length\n const bDepth = bPath.split('/').length\n\n if (aDepth !== bDepth) {\n return aDepth - bDepth\n }\n\n const aName = path.parse(aPath).name\n const bName = path.parse(bPath).name\n\n const indexA = POSSIBLE_SHARED_CONVENTIONS.indexOf(aName)\n const indexB = POSSIBLE_SHARED_CONVENTIONS.indexOf(bName)\n\n if (indexA === -1) return 1\n if (indexB === -1) return -1\n return indexA - indexB\n })\n\n const dedupedCSSImports: CssImports = {}\n const trackedCSSImports = new Set<string>()\n\n for (const [entryFilePath, cssImports] of sortedCSSImports) {\n const entryConventionName = path.parse(entryFilePath).name\n\n for (const cssImport of cssImports) {\n // If the CSS import is already tracked, we can skip it.\n // Or if it's any standalone entry such as `global-not-found`, it won't share any resources with other entry, skip it.\n if (\n trackedCSSImports.has(cssImport) &&\n STANDALONE_BUNDLE_CONVENTION !== entryConventionName\n ) {\n continue\n }\n\n // Only track CSS imports that are in files that can inherit CSS.\n if (POSSIBLE_SHARED_CONVENTIONS.includes(entryConventionName)) {\n trackedCSSImports.add(cssImport)\n }\n\n if (!dedupedCSSImports[entryFilePath]) {\n dedupedCSSImports[entryFilePath] = []\n }\n dedupedCSSImports[entryFilePath].push(cssImport)\n }\n }\n\n return dedupedCSSImports\n}\n\nexport class FlightClientEntryPlugin {\n dev: boolean\n appDir: string\n projectDir: string\n encryptionKey: string\n isEdgeServer: boolean\n assetPrefix: string\n webpackRuntime: string\n\n constructor(options: Options) {\n this.dev = options.dev\n this.appDir = options.appDir\n this.projectDir = path.join(options.appDir, '..')\n this.isEdgeServer = options.isEdgeServer\n this.assetPrefix = !this.dev && !this.isEdgeServer ? '../' : ''\n this.encryptionKey = options.encryptionKey\n this.webpackRuntime = this.isEdgeServer\n ? EDGE_RUNTIME_WEBPACK\n : DEFAULT_RUNTIME_WEBPACK\n }\n\n apply(compiler: webpack.Compiler) {\n compiler.hooks.finishMake.tapPromise(PLUGIN_NAME, (compilation) =>\n this.createClientEntries(compiler, compilation)\n )\n\n compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation) => {\n const recordModule = (modId: string, mod: any) => {\n // Match Resource is undefined unless an import is using the inline match resource syntax\n // https://webpack.js.org/api/loaders/#inline-matchresource\n const modPath = mod.matchResource || mod.resourceResolveData?.path\n const modQuery = mod.resourceResolveData?.query || ''\n // query is already part of mod.resource\n // so it's only necessary to add it for matchResource or mod.resourceResolveData\n const modResource = modPath\n ? modPath.startsWith(BARREL_OPTIMIZATION_PREFIX)\n ? formatBarrelOptimizedResource(mod.resource, modPath)\n : modPath + modQuery\n : mod.resource\n\n if (typeof modId !== 'undefined' && modResource) {\n if (mod.layer === WEBPACK_LAYERS.reactServerComponents) {\n const key = path\n .relative(compiler.context, modResource)\n .replace(/\\/next\\/dist\\/esm\\//, '/next/dist/')\n\n const moduleInfo: ModuleInfo = {\n moduleId: modId,\n async: compilation.moduleGraph.isAsync(mod),\n }\n\n if (this.isEdgeServer) {\n pluginState.edgeRscModules[key] = moduleInfo\n } else {\n pluginState.rscModules[key] = moduleInfo\n }\n }\n }\n\n if (mod.layer !== WEBPACK_LAYERS.serverSideRendering) {\n return\n }\n\n // Check mod resource to exclude the empty resource module like virtual module created by next-flight-client-entry-loader\n if (typeof modId !== 'undefined' && modResource) {\n // Note that this isn't that reliable as webpack is still possible to assign\n // additional queries to make sure there's no conflict even using the `named`\n // module ID strategy.\n let ssrNamedModuleId = path.relative(compiler.context, modResource)\n\n if (!ssrNamedModuleId.startsWith('.')) {\n // TODO use getModuleId instead\n ssrNamedModuleId = `./${normalizePathSep(ssrNamedModuleId)}`\n }\n\n const moduleInfo: ModuleInfo = {\n moduleId: modId,\n async: compilation.moduleGraph.isAsync(mod),\n }\n\n if (this.isEdgeServer) {\n pluginState.edgeSsrModules[\n ssrNamedModuleId.replace(/\\/next\\/dist\\/esm\\//, '/next/dist/')\n ] = moduleInfo\n } else {\n pluginState.ssrModules[ssrNamedModuleId] = moduleInfo\n }\n }\n }\n\n traverseModules(compilation, (mod, _chunk, _chunkGroup, modId) => {\n if (modId) recordModule(modId, mod)\n })\n })\n\n compiler.hooks.make.tap(PLUGIN_NAME, (compilation) => {\n compilation.hooks.processAssets.tapPromise(\n {\n name: PLUGIN_NAME,\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH,\n },\n () => this.createActionAssets(compilation)\n )\n })\n }\n\n async createClientEntries(\n compiler: webpack.Compiler,\n compilation: webpack.Compilation\n ) {\n const addClientEntryAndSSRModulesList: Array<\n ReturnType<typeof this.injectClientEntryAndSSRModules>\n > = []\n const createdSSRDependenciesForEntry: Record<\n string,\n ReturnType<typeof this.injectClientEntryAndSSRModules>[3][]\n > = {}\n\n const addActionEntryList: Array<ReturnType<typeof this.injectActionEntry>> =\n []\n const actionMapsPerEntry: Record<\n string,\n Map<string, ActionIdNamePair[]>\n > = {}\n const createdActionIds = new Set<string>()\n\n // For each SC server compilation entry, we need to create its corresponding\n // client component entry.\n forEachEntryModule(compilation, ({ name, entryModule }) => {\n const internalClientComponentEntryImports: ClientComponentImports = {}\n const actionEntryImports = new Map<string, ActionIdNamePair[]>()\n const clientEntriesToInject = []\n const mergedCSSimports: CssImports = {}\n\n const moduleReferences = getModuleReferencesInOrder(\n entryModule,\n compilation.moduleGraph\n )\n for (const connection of moduleReferences) {\n // Entry can be any user defined entry files such as layout, page, error, loading, etc.\n let entryRequest = (\n connection.dependency as unknown as webpack.NormalModule\n ).request\n\n // Skip if entryRequest is undefined (can happen with Bun's module resolution)\n if (!entryRequest || typeof entryRequest !== 'string') continue\n\n if (entryRequest.endsWith(WEBPACK_RESOURCE_QUERIES.metadataRoute)) {\n const { filePath, isDynamicRouteExtension } =\n getMetadataRouteResource(entryRequest)\n\n if (isDynamicRouteExtension === '1') {\n entryRequest = filePath\n }\n }\n\n const { clientComponentImports, actionImports, cssImports } =\n this.collectComponentInfoFromServerEntryDependency({\n entryRequest,\n compilation,\n resolvedModule: connection.resolvedModule,\n })\n\n actionImports.forEach(([dep, actions]) =>\n actionEntryImports.set(dep, actions)\n )\n\n const isAbsoluteRequest = path.isAbsolute(entryRequest)\n const isAppRouterBuiltinPage = isAppBuiltinPage(entryRequest)\n\n // Next.js internals are put into a separate entry.\n if (!isAbsoluteRequest) {\n Object.keys(clientComponentImports).forEach(\n (value) => (internalClientComponentEntryImports[value] = new Set())\n )\n if (!isAppRouterBuiltinPage) {\n continue\n }\n }\n\n // TODO-APP: Enable these lines. This ensures no entrypoint is created for layout/page when there are no client components.\n // Currently disabled because it causes test failures in CI.\n // if (clientImports.length === 0 && actionImports.length === 0) {\n // continue\n // }\n\n const relativeRequest =\n isAbsoluteRequest && !isAppRouterBuiltinPage\n ? path.relative(compilation.options.context!, entryRequest)\n : entryRequest\n\n // Replace file suffix as `.js` will be added.\n // bundlePath will have app/ prefix but not src/.\n // e.g. src/app/foo/page.js -> app/foo/page\n let bundlePath = normalizePathSep(\n relativeRequest.replace(/\\.[^.\\\\/]+$/, '').replace(/^src[\\\\/]/, '')\n )\n\n // For metadata routes, the entry name can be used as the bundle path,\n // as it has been normalized already.\n // e.g.\n // When `relativeRequest` is 'src/app/sitemap.js',\n // `appDirRelativeRequest` will be '/sitemap.js'\n // then `isMetadataEntryFile` will be `true`\n const appDirRelativeRequest = relativeRequest\n .replace(/^src[\\\\/]/, '')\n .replace(/^app[\\\\/]/, '/')\n const isMetadataEntryFile = isMetadataRouteFile(\n appDirRelativeRequest,\n DEFAULT_METADATA_ROUTE_EXTENSIONS,\n true\n )\n if (isMetadataEntryFile) {\n bundlePath = name\n }\n\n Object.assign(mergedCSSimports, cssImports)\n clientEntriesToInject.push({\n compiler,\n compilation,\n entryName: name,\n clientComponentImports,\n bundlePath,\n absolutePagePath: entryRequest,\n })\n\n // The webpack implementation of writing the client reference manifest relies on all entrypoints writing a page.js even when there is no client components in the page.\n // It needs the file in order to write the reference manifest for the path in the `.next/server` folder.\n if (\n name === `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}` &&\n bundlePath === 'app/not-found'\n ) {\n clientEntriesToInject.push({\n compiler,\n compilation,\n entryName: name,\n clientComponentImports: {},\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n absolutePagePath: entryRequest,\n })\n }\n\n if (\n name === `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}` &&\n bundlePath === 'app/global-not-found'\n ) {\n clientEntriesToInject.push({\n compiler,\n compilation,\n entryName: name,\n clientComponentImports,\n bundlePath: `app${UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,\n absolutePagePath: entryRequest,\n })\n }\n\n if (name === `app${UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY}`) {\n clientEntriesToInject.push({\n compiler,\n compilation,\n entryName: name,\n clientComponentImports,\n bundlePath: `app${UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY}`,\n absolutePagePath: entryRequest,\n })\n }\n }\n\n // Make sure CSS imports are deduplicated before injecting the client entry\n // and SSR modules.\n const dedupedCSSImports = deduplicateCSSImportsForEntry(mergedCSSimports)\n for (const clientEntryToInject of clientEntriesToInject) {\n const injected = this.injectClientEntryAndSSRModules({\n ...clientEntryToInject,\n clientImports: {\n ...clientEntryToInject.clientComponentImports,\n ...(\n dedupedCSSImports[clientEntryToInject.absolutePagePath] || []\n ).reduce<ClientComponentImports>((res, curr) => {\n res[curr] = new Set()\n return res\n }, {}),\n },\n })\n\n // Track all created SSR dependencies for each entry from the server layer.\n if (!createdSSRDependenciesForEntry[clientEntryToInject.entryName]) {\n createdSSRDependenciesForEntry[clientEntryToInject.entryName] = []\n }\n createdSSRDependenciesForEntry[clientEntryToInject.entryName].push(\n injected[3]\n )\n\n addClientEntryAndSSRModulesList.push(injected)\n }\n\n if (!isAppRouteRoute(name)) {\n // Create internal app\n addClientEntryAndSSRModulesList.push(\n this.injectClientEntryAndSSRModules({\n compiler,\n compilation,\n entryName: name,\n clientImports: { ...internalClientComponentEntryImports },\n bundlePath: APP_CLIENT_INTERNALS,\n })\n )\n }\n\n if (actionEntryImports.size > 0) {\n if (!actionMapsPerEntry[name]) {\n actionMapsPerEntry[name] = new Map()\n }\n actionMapsPerEntry[name] = new Map([\n ...actionMapsPerEntry[name],\n ...actionEntryImports,\n ])\n }\n })\n\n for (const [name, actionEntryImports] of Object.entries(\n actionMapsPerEntry\n )) {\n addActionEntryList.push(\n this.injectActionEntry({\n compiler,\n compilation,\n actions: actionEntryImports,\n entryName: name,\n bundlePath: name,\n createdActionIds,\n })\n )\n }\n\n // Invalidate in development to trigger recompilation\n const invalidator = getInvalidator(compiler.outputPath)\n // Check if any of the entry injections need an invalidation\n if (\n invalidator &&\n addClientEntryAndSSRModulesList.some(\n ([shouldInvalidate]) => shouldInvalidate === true\n )\n ) {\n invalidator.invalidate([COMPILER_NAMES.client])\n }\n\n // Client compiler is invalidated before awaiting the compilation of the SSR\n // and RSC client component entries so that the client compiler is running\n // in parallel to the server compiler.\n await Promise.all(\n addClientEntryAndSSRModulesList.flatMap((addClientEntryAndSSRModules) => [\n addClientEntryAndSSRModules[1],\n addClientEntryAndSSRModules[2],\n ])\n )\n\n // Wait for action entries to be added.\n await Promise.all(addActionEntryList)\n\n const addedClientActionEntryList: Promise<any>[] = []\n const actionMapsPerClientEntry: Record<\n string,\n Map<string, ActionIdNamePair[]>\n > = {}\n\n // We need to create extra action entries that are created from the\n // client layer.\n // Start from each entry's created SSR dependency from our previous step.\n for (const [name, ssrEntryDependencies] of Object.entries(\n createdSSRDependenciesForEntry\n )) {\n // Collect from all entries, e.g. layout.js, page.js, loading.js, ...\n // add aggregate them.\n const actionEntryImports = this.collectClientActionsFromDependencies({\n compilation,\n dependencies: ssrEntryDependencies,\n })\n\n if (actionEntryImports.size > 0) {\n if (!actionMapsPerClientEntry[name]) {\n actionMapsPerClientEntry[name] = new Map()\n }\n actionMapsPerClientEntry[name] = new Map([\n ...actionMapsPerClientEntry[name],\n ...actionEntryImports,\n ])\n }\n }\n\n for (const [entryName, actionEntryImports] of Object.entries(\n actionMapsPerClientEntry\n )) {\n // If an action method is already created in the server layer, we don't\n // need to create it again in the action layer.\n // This is to avoid duplicate action instances and make sure the module\n // state is shared.\n let remainingClientImportedActions = false\n const remainingActionEntryImports = new Map<string, ActionIdNamePair[]>()\n for (const [dep, actions] of actionEntryImports) {\n const remainingActionNames = []\n for (const action of actions) {\n if (!createdActionIds.has(entryName + '@' + action.id)) {\n remainingActionNames.push(action)\n }\n }\n if (remainingActionNames.length > 0) {\n remainingActionEntryImports.set(dep, remainingActionNames)\n remainingClientImportedActions = true\n }\n }\n\n if (remainingClientImportedActions) {\n addedClientActionEntryList.push(\n this.injectActionEntry({\n compiler,\n compilation,\n actions: remainingActionEntryImports,\n entryName,\n bundlePath: entryName,\n fromClient: true,\n createdActionIds,\n })\n )\n }\n }\n\n await Promise.all(addedClientActionEntryList)\n }\n\n collectClientActionsFromDependencies({\n compilation,\n dependencies,\n }: {\n compilation: webpack.Compilation\n dependencies: ReturnType<typeof webpack.EntryPlugin.createDependency>[]\n }) {\n // action file path -> action names\n const collectedActions = new Map<string, ActionIdNamePair[]>()\n\n // Keep track of checked modules to avoid infinite loops with recursive imports.\n const visitedModule = new Set<string>()\n const visitedEntry = new Set<string>()\n\n const collectActions = ({\n entryRequest,\n resolvedModule,\n }: {\n entryRequest: string\n resolvedModule: any\n }) => {\n const collectActionsInDep = (mod: webpack.NormalModule): void => {\n if (!mod) return\n\n const modResource = getModuleResource(mod)\n\n if (!modResource) return\n\n if (visitedModule.has(modResource)) return\n visitedModule.add(modResource)\n\n const actionIds = getModuleBuildInfo(mod).rsc?.actionIds\n if (actionIds) {\n collectedActions.set(\n modResource,\n Object.entries(actionIds).map(([id, exportedName]) => ({\n id,\n exportedName,\n filename: path.posix.relative(this.projectDir, modResource),\n }))\n )\n }\n\n // Collect used exported actions transversely.\n getModuleReferencesInOrder(mod, compilation.moduleGraph).forEach(\n (connection: any) => {\n collectActionsInDep(\n connection.resolvedModule as webpack.NormalModule\n )\n }\n )\n }\n\n // Don't traverse the module graph anymore once hitting the action layer.\n if (\n entryRequest &&\n !entryRequest.includes('next-flight-action-entry-loader')\n ) {\n // Traverse the module graph to find all client components.\n collectActionsInDep(resolvedModule)\n }\n }\n\n for (const entryDependency of dependencies) {\n const ssrEntryModule =\n compilation.moduleGraph.getResolvedModule(entryDependency)!\n for (const connection of getModuleReferencesInOrder(\n ssrEntryModule,\n compilation.moduleGraph\n )) {\n const depModule = connection.dependency\n const request = (depModule as unknown as webpack.NormalModule).request\n\n // Skip if request is undefined (can happen with Bun's module resolution)\n if (!request || typeof request !== 'string') continue\n\n // It is possible that the same entry is added multiple times in the\n // connection graph. We can just skip these to speed up the process.\n if (visitedEntry.has(request)) continue\n visitedEntry.add(request)\n\n collectActions({\n entryRequest: request,\n resolvedModule: connection.resolvedModule,\n })\n }\n }\n\n return collectedActions\n }\n\n collectComponentInfoFromServerEntryDependency({\n entryRequest,\n compilation,\n resolvedModule,\n }: {\n entryRequest: string\n compilation: webpack.Compilation\n resolvedModule: any /* Dependency */\n }): {\n cssImports: CssImports\n clientComponentImports: ClientComponentImports\n actionImports: [string, ActionIdNamePair[]][]\n } {\n // Keep track of checked modules to avoid infinite loops with recursive imports.\n const visitedOfClientComponentsTraverse = new Set()\n\n // Info to collect.\n const clientComponentImports: ClientComponentImports = {}\n const actionImports: [string, ActionIdNamePair[]][] = []\n const CSSImports = new Set<string>()\n\n const filterClientComponents = (\n mod: webpack.NormalModule,\n importedIdentifiers: string[]\n ): void => {\n if (!mod) return\n\n const modResource = getModuleResource(mod)\n\n if (!modResource) return\n if (visitedOfClientComponentsTraverse.has(modResource)) {\n if (clientComponentImports[modResource]) {\n addClientImport(\n mod,\n modResource,\n clientComponentImports,\n importedIdentifiers,\n false\n )\n }\n return\n }\n visitedOfClientComponentsTraverse.add(modResource)\n\n const actionIds = getModuleBuildInfo(mod).rsc?.actionIds\n if (actionIds) {\n actionImports.push([\n modResource,\n Object.entries(actionIds).map(([id, exportedName]) => ({\n id,\n exportedName,\n filename: path.posix.relative(this.projectDir, modResource),\n })),\n ])\n }\n\n if (isCSSMod(mod)) {\n const sideEffectFree =\n mod.factoryMeta && (mod.factoryMeta as any).sideEffectFree\n\n if (sideEffectFree) {\n const unused = !compilation.moduleGraph\n .getExportsInfo(mod)\n .isModuleUsed(this.webpackRuntime)\n\n if (unused) return\n }\n\n CSSImports.add(modResource)\n } else if (isClientComponentEntryModule(mod)) {\n if (!clientComponentImports[modResource]) {\n clientComponentImports[modResource] = new Set()\n }\n addClientImport(\n mod,\n modResource,\n clientComponentImports,\n importedIdentifiers,\n true\n )\n\n return\n }\n\n getModuleReferencesInOrder(mod, compilation.moduleGraph).forEach(\n (connection: any) => {\n let dependencyIds: string[] = []\n\n // `ids` are the identifiers that are imported from the dependency,\n // if it's present, it's an array of strings.\n if (connection.dependency?.ids) {\n dependencyIds.push(...connection.dependency.ids)\n } else {\n dependencyIds = ['*']\n }\n\n filterClientComponents(connection.resolvedModule, dependencyIds)\n }\n )\n }\n\n // Traverse the module graph to find all client components.\n filterClientComponents(resolvedModule, [])\n\n return {\n clientComponentImports,\n cssImports: CSSImports.size\n ? {\n [entryRequest]: Array.from(CSSImports),\n }\n : {},\n actionImports,\n }\n }\n\n injectClientEntryAndSSRModules({\n compiler,\n compilation,\n entryName,\n clientImports,\n bundlePath,\n absolutePagePath,\n }: {\n compiler: webpack.Compiler\n compilation: webpack.Compilation\n entryName: string\n clientImports: ClientComponentImports\n bundlePath: string\n absolutePagePath?: string\n }): [\n shouldInvalidate: boolean,\n addSSREntryPromise: Promise<void>,\n addRSCEntryPromise: Promise<void>,\n ssrDep: ReturnType<typeof webpack.EntryPlugin.createDependency>,\n ] {\n const bundler = getWebpackBundler()\n let shouldInvalidate = false\n\n const modules = Object.keys(clientImports)\n .sort((a, b) => (regexCSS.test(b) ? 1 : a.localeCompare(b)))\n .map((clientImportPath) => ({\n request: clientImportPath,\n ids: [...clientImports[clientImportPath]],\n }))\n\n // For the client entry, we always use the CJS build of Next.js. If the\n // server is using the ESM build (when using the Edge runtime), we need to\n // replace them.\n const clientBrowserLoader = `next-flight-client-entry-loader?${stringify({\n modules: (this.isEdgeServer\n ? modules.map(({ request, ids }) => ({\n request: request.replace(\n /[\\\\/]next[\\\\/]dist[\\\\/]esm[\\\\/]/,\n '/next/dist/'.replace(/\\//g, path.sep)\n ),\n ids,\n }))\n : modules\n ).map((x) => JSON.stringify(x)),\n server: false,\n })}!`\n\n const clientServerLoader = `next-flight-client-entry-loader?${stringify({\n modules: modules.map((x) => JSON.stringify(x)),\n server: true,\n })}!`\n\n // Add for the client compilation\n // Inject the entry to the client compiler.\n if (this.dev) {\n const entries = getEntries(compiler.outputPath)\n const pageKey = getEntryKey(\n COMPILER_NAMES.client,\n PAGE_TYPES.APP,\n bundlePath\n )\n\n if (!entries[pageKey]) {\n entries[pageKey] = {\n type: EntryTypes.CHILD_ENTRY,\n parentEntries: new Set([entryName]),\n absoluteEntryFilePath: absolutePagePath,\n bundlePath,\n request: clientBrowserLoader,\n dispose: false,\n lastActiveTime: Date.now(),\n }\n shouldInvalidate = true\n } else {\n const entryData = entries[pageKey]\n // New version of the client loader\n if (entryData.request !== clientBrowserLoader) {\n entryData.request = clientBrowserLoader\n shouldInvalidate = true\n }\n if (entryData.type === EntryTypes.CHILD_ENTRY) {\n entryData.parentEntries.add(entryName)\n }\n entryData.dispose = false\n entryData.lastActiveTime = Date.now()\n }\n } else {\n pluginState.injectedClientEntries[bundlePath] = clientBrowserLoader\n }\n\n const clientComponentSSREntryDep = bundler.EntryPlugin.createDependency(\n clientServerLoader,\n { name: bundlePath }\n )\n\n const clientComponentRSCEntryDep = bundler.EntryPlugin.createDependency(\n clientServerLoader,\n { name: bundlePath }\n )\n\n return [\n shouldInvalidate,\n // Add the entries to the server compiler for the SSR and RSC layers. The\n // promises are awaited later using `Promise.all` in order to parallelize\n // adding the entries.\n this.addEntry(compilation, compiler.context, clientComponentSSREntryDep, {\n name: entryName,\n layer: WEBPACK_LAYERS.serverSideRendering,\n }),\n this.addEntry(compilation, compiler.context, clientComponentRSCEntryDep, {\n name: entryName,\n layer: WEBPACK_LAYERS.reactServerComponents,\n }),\n clientComponentSSREntryDep,\n ]\n }\n\n injectActionEntry({\n compiler,\n compilation,\n actions,\n entryName,\n bundlePath,\n fromClient,\n createdActionIds,\n }: {\n compiler: webpack.Compiler\n compilation: webpack.Compilation\n actions: Map<string, ActionIdNamePair[]>\n entryName: string\n bundlePath: string\n createdActionIds: Set<string>\n fromClient?: boolean\n }) {\n const bundler = getWebpackBundler()\n const actionsArray = Array.from(actions.entries())\n for (const [, actionsFromModule] of actions) {\n for (const { id } of actionsFromModule) {\n createdActionIds.add(entryName + '@' + id)\n }\n }\n\n if (actionsArray.length === 0) {\n return Promise.resolve()\n }\n\n const actionLoader = `next-flight-action-entry-loader?${stringify({\n actions: JSON.stringify(\n actionsArray satisfies FlightActionEntryLoaderActions\n ),\n __client_imported__: fromClient,\n })}!`\n\n const currentCompilerServerActions = this.isEdgeServer\n ? pluginState.edgeServerActions\n : pluginState.serverActions\n\n for (const [, actionsFromModule] of actionsArray) {\n for (const { id, exportedName, filename } of actionsFromModule) {\n if (typeof currentCompilerServerActions[id] === 'undefined') {\n currentCompilerServerActions[id] = {\n workers: {},\n layer: {},\n filename,\n exportedName,\n }\n }\n currentCompilerServerActions[id].workers[bundlePath] = {\n moduleId: '', // TODO: What's the meaning of this?\n async: false,\n }\n\n currentCompilerServerActions[id].layer[bundlePath] = fromClient\n ? WEBPACK_LAYERS.actionBrowser\n : WEBPACK_LAYERS.reactServerComponents\n }\n }\n\n // Inject the entry to the server compiler\n const actionEntryDep = bundler.EntryPlugin.createDependency(actionLoader, {\n name: bundlePath,\n })\n\n return this.addEntry(\n compilation,\n // Reuse compilation context.\n compiler.context,\n actionEntryDep,\n {\n name: entryName,\n layer: fromClient\n ? WEBPACK_LAYERS.actionBrowser\n : WEBPACK_LAYERS.reactServerComponents,\n }\n )\n }\n\n addEntry(\n compilation: webpack.Compilation,\n context: string,\n dependency: webpack.Dependency,\n options: webpack.EntryOptions\n ): Promise<any> /* Promise<module> */ {\n return new Promise((resolve, reject) => {\n if ('rspack' in compilation.compiler) {\n compilation.addInclude(context, dependency, options, (err, module) => {\n if (err) {\n return reject(err)\n }\n\n compilation.moduleGraph\n .getExportsInfo(module!)\n .setUsedInUnknownWay(\n this.isEdgeServer ? EDGE_RUNTIME_WEBPACK : DEFAULT_RUNTIME_WEBPACK\n )\n return resolve(module)\n })\n } else {\n const entry = compilation.entries.get(options.name!)!\n entry.includeDependencies.push(dependency)\n compilation.hooks.addEntry.call(entry as any, options)\n compilation.addModuleTree(\n {\n context,\n dependency,\n contextInfo: { issuerLayer: options.layer },\n },\n (err: any, module: any) => {\n if (err) {\n compilation.hooks.failedEntry.call(dependency, options, err)\n return reject(err)\n }\n\n compilation.hooks.succeedEntry.call(dependency, options, module)\n\n compilation.moduleGraph\n .getExportsInfo(module)\n .setUsedInUnknownWay(\n this.isEdgeServer\n ? EDGE_RUNTIME_WEBPACK\n : DEFAULT_RUNTIME_WEBPACK\n )\n\n return resolve(module)\n }\n )\n }\n })\n }\n\n async createActionAssets(compilation: webpack.Compilation) {\n const serverActions: ActionManifest['node'] = {}\n const edgeServerActions: ActionManifest['edge'] = {}\n\n traverseModules(compilation, (mod, _chunk, chunkGroup, modId) => {\n // Go through all action entries and record the module ID for each entry.\n if (\n chunkGroup.name &&\n mod.request &&\n modId &&\n /next-flight-action-entry-loader/.test(mod.request)\n ) {\n const fromClient = /&__client_imported__=true/.test(mod.request)\n\n const mapping = this.isEdgeServer\n ? pluginState.edgeServerActionModules\n : pluginState.serverActionModules\n\n if (!mapping[chunkGroup.name]) {\n mapping[chunkGroup.name] = {}\n }\n\n mapping[chunkGroup.name][fromClient ? 'client' : 'server'] = {\n moduleId: modId,\n async: compilation.moduleGraph.isAsync(mod),\n }\n }\n })\n\n for (let id in pluginState.serverActions) {\n const action = pluginState.serverActions[id]\n for (let name in action.workers) {\n const modId =\n pluginState.serverActionModules[name][\n action.layer[name] === WEBPACK_LAYERS.actionBrowser\n ? 'client'\n : 'server'\n ]\n action.workers[name] = modId!\n }\n serverActions[id] = action\n }\n\n for (let id in pluginState.edgeServerActions) {\n const action = pluginState.edgeServerActions[id]\n for (let name in action.workers) {\n const modId =\n pluginState.edgeServerActionModules[name][\n action.layer[name] === WEBPACK_LAYERS.actionBrowser\n ? 'client'\n : 'server'\n ]\n action.workers[name] = modId!\n }\n edgeServerActions[id] = action\n }\n\n const serverManifest = {\n node: serverActions,\n edge: edgeServerActions,\n encryptionKey: this.encryptionKey,\n }\n const edgeServerManifest = {\n ...serverManifest,\n encryptionKey: 'process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY',\n }\n\n const json = JSON.stringify(serverManifest, null, this.dev ? 2 : undefined)\n const edgeJson = JSON.stringify(\n edgeServerManifest,\n null,\n this.dev ? 2 : undefined\n )\n\n compilation.emitAsset(\n `${this.assetPrefix}${SERVER_REFERENCE_MANIFEST}.js`,\n new sources.RawSource(\n `self.__RSC_SERVER_MANIFEST=${JSON.stringify(edgeJson)}`\n ) as unknown as webpack.sources.RawSource\n )\n compilation.emitAsset(\n `${this.assetPrefix}${SERVER_REFERENCE_MANIFEST}.json`,\n new sources.RawSource(json) as unknown as webpack.sources.RawSource\n )\n }\n}\n\nfunction addClientImport(\n mod: webpack.NormalModule,\n modRequest: string,\n clientComponentImports: ClientComponentImports,\n importedIdentifiers: string[],\n isFirstVisitModule: boolean\n) {\n const clientEntryType = getModuleBuildInfo(mod).rsc?.clientEntryType\n const isCjsModule = clientEntryType === 'cjs'\n const assumedSourceType = getAssumedSourceType(\n mod,\n isCjsModule ? 'commonjs' : 'auto'\n )\n\n const clientImportsSet = clientComponentImports[modRequest]\n\n if (importedIdentifiers[0] === '*') {\n // If there's collected import path with named import identifiers,\n // or there's nothing in collected imports are empty.\n // we should include the whole module.\n if (!isFirstVisitModule && [...clientImportsSet][0] !== '*') {\n clientComponentImports[modRequest] = new Set(['*'])\n }\n } else {\n const isAutoModuleSourceType = assumedSourceType === 'auto'\n if (isAutoModuleSourceType) {\n clientComponentImports[modRequest] = new Set(['*'])\n } else {\n // If it's not analyzed as named ESM exports, e.g. if it's mixing `export *` with named exports,\n // We'll include all modules since it's not able to do tree-shaking.\n for (const name of importedIdentifiers) {\n // For cjs module default import, we include the whole module since\n const isCjsDefaultImport = isCjsModule && name === 'default'\n\n // Always include __esModule along with cjs module default export,\n // to make sure it work with client module proxy from React.\n if (isCjsDefaultImport) {\n clientComponentImports[modRequest].add('__esModule')\n }\n\n clientComponentImports[modRequest].add(name)\n }\n }\n }\n}\n\nfunction getModuleResource(mod: webpack.NormalModule): string {\n const modPath: string = mod.resourceResolveData?.path || ''\n const modQuery = mod.resourceResolveData?.query || ''\n // We have to always use the resolved request here to make sure the\n // server and client are using the same module path (required by RSC), as\n // the server compiler and client compiler have different resolve configs.\n let modResource: string = modPath + modQuery\n\n // Context modules don't have a resource path, we use the identifier instead.\n if (mod.constructor.name === 'ContextModule') {\n modResource = mod.identifier()\n }\n\n // For the barrel optimization, we need to use the match resource instead\n // because there will be 2 modules for the same file (same resource path)\n // but they're different modules and can't be deduped via `visitedModule`.\n // The first module is a virtual re-export module created by the loader.\n if (mod.matchResource?.startsWith(BARREL_OPTIMIZATION_PREFIX)) {\n modResource = mod.matchResource + ':' + modResource\n }\n\n if (mod.resource === `?${WEBPACK_RESOURCE_QUERIES.metadataRoute}`) {\n return getMetadataRouteResource(mod.rawRequest).filePath\n }\n\n return modResource\n}\n\nfunction getMetadataRouteResource(request: string): MetadataRouteLoaderOptions {\n // e.g. next-metadata-route-loader?filePath=<some-url-encoded-path>&isDynamicRouteExtension=1!?__next_metadata_route__\n const query = request.split('!')[0].split('next-metadata-route-loader?')[1]\n\n return parse(query) as MetadataRouteLoaderOptions\n}\n"],"names":["FlightClientEntryPlugin","PLUGIN_NAME","pluginState","getProxiedPluginState","serverActions","edgeServerActions","serverActionModules","edgeServerActionModules","ssrModules","edgeSsrModules","rscModules","edgeRscModules","injectedClientEntries","POSSIBLE_SHARED_CONVENTIONS","STANDALONE_BUNDLE_CONVENTION","deduplicateCSSImportsForEntry","mergedCSSimports","sortedCSSImports","Object","entries","sort","a","b","aPath","bPath","aDepth","split","length","bDepth","aName","path","parse","name","bName","indexA","indexOf","indexB","dedupedCSSImports","trackedCSSImports","Set","entryFilePath","cssImports","entryConventionName","cssImport","has","includes","add","push","constructor","options","dev","appDir","projectDir","join","isEdgeServer","assetPrefix","encryptionKey","webpackRuntime","EDGE_RUNTIME_WEBPACK","DEFAULT_RUNTIME_WEBPACK","apply","compiler","hooks","finishMake","tapPromise","compilation","createClientEntries","afterCompile","tap","recordModule","modId","mod","modPath","matchResource","resourceResolveData","modQuery","query","modResource","startsWith","BARREL_OPTIMIZATION_PREFIX","formatBarrelOptimizedResource","resource","layer","WEBPACK_LAYERS","reactServerComponents","key","relative","context","replace","moduleInfo","moduleId","async","moduleGraph","isAsync","serverSideRendering","ssrNamedModuleId","normalizePathSep","traverseModules","_chunk","_chunkGroup","make","processAssets","stage","webpack","Compilation","PROCESS_ASSETS_STAGE_OPTIMIZE_HASH","createActionAssets","addClientEntryAndSSRModulesList","createdSSRDependenciesForEntry","addActionEntryList","actionMapsPerEntry","createdActionIds","forEachEntryModule","entryModule","internalClientComponentEntryImports","actionEntryImports","Map","clientEntriesToInject","moduleReferences","getModuleReferencesInOrder","connection","entryRequest","dependency","request","endsWith","WEBPACK_RESOURCE_QUERIES","metadataRoute","filePath","isDynamicRouteExtension","getMetadataRouteResource","clientComponentImports","actionImports","collectComponentInfoFromServerEntryDependency","resolvedModule","forEach","dep","actions","set","isAbsoluteRequest","isAbsolute","isAppRouterBuiltinPage","isAppBuiltinPage","keys","value","relativeRequest","bundlePath","appDirRelativeRequest","isMetadataEntryFile","isMetadataRouteFile","DEFAULT_METADATA_ROUTE_EXTENSIONS","assign","entryName","absolutePagePath","UNDERSCORE_NOT_FOUND_ROUTE_ENTRY","UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY","clientEntryToInject","injected","injectClientEntryAndSSRModules","clientImports","reduce","res","curr","isAppRouteRoute","APP_CLIENT_INTERNALS","size","injectActionEntry","invalidator","getInvalidator","outputPath","some","shouldInvalidate","invalidate","COMPILER_NAMES","client","Promise","all","flatMap","addClientEntryAndSSRModules","addedClientActionEntryList","actionMapsPerClientEntry","ssrEntryDependencies","collectClientActionsFromDependencies","dependencies","remainingClientImportedActions","remainingActionEntryImports","remainingActionNames","action","id","fromClient","collectedActions","visitedModule","visitedEntry","collectActions","collectActionsInDep","getModuleBuildInfo","getModuleResource","actionIds","rsc","map","exportedName","filename","posix","entryDependency","ssrEntryModule","getResolvedModule","depModule","visitedOfClientComponentsTraverse","CSSImports","filterClientComponents","importedIdentifiers","addClientImport","isCSSMod","sideEffectFree","factoryMeta","unused","getExportsInfo","isModuleUsed","isClientComponentEntryModule","dependencyIds","ids","Array","from","bundler","getWebpackBundler","modules","regexCSS","test","localeCompare","clientImportPath","clientBrowserLoader","stringify","sep","x","JSON","server","clientServerLoader","getEntries","pageKey","getEntryKey","PAGE_TYPES","APP","type","EntryTypes","CHILD_ENTRY","parentEntries","absoluteEntryFilePath","dispose","lastActiveTime","Date","now","entryData","clientComponentSSREntryDep","EntryPlugin","createDependency","clientComponentRSCEntryDep","addEntry","actionsArray","actionsFromModule","resolve","actionLoader","__client_imported__","currentCompilerServerActions","workers","actionBrowser","actionEntryDep","reject","addInclude","err","module","setUsedInUnknownWay","entry","get","includeDependencies","call","addModuleTree","contextInfo","issuerLayer","failedEntry","succeedEntry","chunkGroup","mapping","serverManifest","node","edge","edgeServerManifest","json","undefined","edgeJson","emitAsset","SERVER_REFERENCE_MANIFEST","sources","RawSource","modRequest","isFirstVisitModule","clientEntryType","isCjsModule","assumedSourceType","getAssumedSourceType","clientImportsSet","isAutoModuleSourceType","isCjsDefaultImport","identifier","rawRequest"],"mappings":";;;;+BAqMaA;;;eAAAA;;;yBAhMW;6BACS;6DAChB;sCAOV;2BAIA;4BAQA;gCAIA;uBAKA;wBAMA;kCAC0B;8BACK;2BACX;oCACQ;kCACE;iCACL;iCAIzB;0EAGuB;wBACG;;;;;;AASjC,MAAMC,cAAc;AAiCpB,MAAMC,cAAcC,IAAAA,mCAAqB,EAAC;IACxC,gDAAgD;IAChDC,eAAe,CAAC;IAChBC,mBAAmB,CAAC;IAEpBC,qBAAqB,CAAC;IAOtBC,yBAAyB,CAAC;IAO1BC,YAAY,CAAC;IACbC,gBAAgB,CAAC;IAEjBC,YAAY,CAAC;IACbC,gBAAgB,CAAC;IAEjBC,uBAAuB,CAAC;AAC1B;AAEA,MAAMC,8BAA8B;IAAC;IAAY;CAAS;AAC1D,MAAMC,+BAA+B;AAErC,SAASC,8BAA8BC,gBAA4B;IACjE,uEAAuE;IACvE,oEAAoE;IACpE,wEAAwE;IACxE,+DAA+D;IAC/D,sEAAsE;IACtE,uEAAuE;IACvE,wEAAwE;IACxE,UAAU;IACV,qEAAqE;IACrE,qEAAqE;IACrE,mEAAmE;IACnE,yEAAyE;IACzE,uFAAuF;IAEvF,2CAA2C;IAC3C,MAAMC,mBAAmBC,OAAOC,OAAO,CAACH,kBAAkBI,IAAI,CAAC,CAACC,GAAGC;QACjE,MAAM,CAACC,MAAM,GAAGF;QAChB,MAAM,CAACG,MAAM,GAAGF;QAEhB,MAAMG,SAASF,MAAMG,KAAK,CAAC,KAAKC,MAAM;QACtC,MAAMC,SAASJ,MAAME,KAAK,CAAC,KAAKC,MAAM;QAEtC,IAAIF,WAAWG,Q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E,aAAa,GAAG,MAAMI;IAC1C;IAEA,IAAIN,IAAIU,QAAQ,KAAK,CAAC,CAAC,EAAE4C,mCAAwB,CAACC,aAAa,EAAE,EAAE;QACjE,OAAOG,yBAAyB1D,IAAIuO,UAAU,EAAE/K,QAAQ;IAC1D;IAEA,OAAOlD;AACT;AAEA,SAASoD,yBAAyBN,OAAe;IAC/C,sHAAsH;IACtH,MAAM/C,QAAQ+C,QAAQjG,KAAK,CAAC,IAAI,CAAC,EAAE,CAACA,KAAK,CAAC,8BAA8B,CAAC,EAAE;IAE3E,OAAOK,IAAAA,kBAAK,EAAC6C;AACf","ignoreList":[0]}
@@ -1713,7 +1713,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
1713
1713
  isClient && new _copyfileplugin.CopyFilePlugin({
1714
1714
  // file path to build output of `@next/polyfill-nomodule`
1715
1715
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1716
- cacheKey: "16.0.5",
1716
+ cacheKey: "16.0.6",
1717
1717
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1718
1718
  minimize: false,
1719
1719
  info: {
@@ -1904,7 +1904,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
1904
1904
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1905
1905
  // - Next.js version
1906
1906
  // - next.config.js keys that affect compilation
1907
- version: `${__dirname}|${"16.0.5"}|${configVars}`,
1907
+ version: `${__dirname}|${"16.0.6"}|${configVars}`,
1908
1908
  cacheDirectory: _path.default.join(distDir, 'cache', 'webpack'),
1909
1909
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1910
1910
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "appBootstrap", {
15
15
  });
16
16
  const _assetprefix = require("./asset-prefix");
17
17
  const _setattributesfromprops = require("./set-attributes-from-props");
18
- const version = "16.0.5";
18
+ const version = "16.0.6";
19
19
  window.next = {
20
20
  version,
21
21
  appDir: true
@@ -60,7 +60,7 @@ const _hooksclientcontextsharedruntime = require("../shared/lib/hooks-client-con
60
60
  const _onrecoverableerror = require("./react-client-callbacks/on-recoverable-error");
61
61
  const _tracer = /*#__PURE__*/ _interop_require_default._(require("./tracing/tracer"));
62
62
  const _isnextroutererror = require("./components/is-next-router-error");
63
- const version = "16.0.5";
63
+ const version = "16.0.6";
64
64
  let router;
65
65
  const emitter = (0, _mitt.default)();
66
66
  const looseToArray = (input)=>[].slice.call(input);
@@ -305,7 +305,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
305
305
  try {
306
306
  const nextBuildSpan = trace('next-build', undefined, {
307
307
  buildMode: experimentalBuildMode,
308
- version: "16.0.5"
308
+ version: "16.0.6"
309
309
  });
310
310
  NextBuildContext.nextBuildSpan = nextBuildSpan;
311
311
  NextBuildContext.dir = dir;
@@ -818,7 +818,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
818
818
  // Files outside of the distDir can be "type": "module"
819
819
  await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
820
820
  // These are written to distDir, so they need to come after creating and cleaning distDr.
821
- await recordFrameworkVersion("16.0.5");
821
+ await recordFrameworkVersion("16.0.6");
822
822
  await updateBuildDiagnostics({
823
823
  buildStage: 'start'
824
824
  });
@@ -2467,7 +2467,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
2467
2467
  configOutDir: path.join(dir, configOutDir),
2468
2468
  staticPages,
2469
2469
  serverPropsPages,
2470
- nextVersion: "16.0.5",
2470
+ nextVersion: "16.0.6",
2471
2471
  tracingRoot: outputFileTracingRoot,
2472
2472
  hasNodeMiddleware,
2473
2473
  hasInstrumentationHook,
@@ -8,7 +8,7 @@ import { eventSwcLoadFailure } from '../../telemetry/events/swc-load-failure';
8
8
  import { patchIncorrectLockfile } from '../../lib/patch-incorrect-lockfile';
9
9
  import { downloadNativeNextSwc, downloadWasmSwc } from '../../lib/download-swc';
10
10
  import { getDefineEnv } from '../define-env';
11
- const nextVersion = "16.0.5";
11
+ const nextVersion = "16.0.6";
12
12
  const ArchName = arch();
13
13
  const PlatformName = platform();
14
14
  function infoLog(...args) {
@@ -9,8 +9,8 @@ export default function transformSource() {
9
9
  modules
10
10
  ] : [];
11
11
  }
12
- const code = modules.map((x)=>JSON.parse(x))// Filter out CSS files in the SSR compilation
13
- .filter(({ request })=>isServer ? !regexCSS.test(request) : true).map(({ request, ids })=>{
12
+ const code = modules.map((x)=>JSON.parse(x))// Filter out undefined requests (Bun compatibility) and CSS files in the SSR compilation
13
+ .filter(({ request })=>request && (isServer ? !regexCSS.test(request) : true)).map(({ request, ids })=>{
14
14
  const importPath = JSON.stringify(request.startsWith(BARREL_OPTIMIZATION_PREFIX) ? request.replace(':', '!=!') : request);
15
15
  // When we cannot determine the export names, we use eager mode to include the whole module.
16
16
  // Otherwise, we use eager mode with webpackExports to only include the necessary exports.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/build/webpack/loaders/next-flight-client-entry-loader.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport {\n BARREL_OPTIMIZATION_PREFIX,\n RSC_MODULE_TYPES,\n} from '../../../shared/lib/constants'\nimport { getModuleBuildInfo } from './get-module-build-info'\nimport { regexCSS } from './utils'\n\n/**\n * { [client import path]: [exported names] }\n */\nexport type ClientComponentImports = Record<string, Set<string>>\nexport type CssImports = Record<string, string[]>\n\nexport type NextFlightClientEntryLoaderOptions = {\n modules: string[] | string\n /** This is transmitted as a string to `getOptions` */\n server: boolean | 'true' | 'false'\n}\n\nexport type FlightClientEntryModuleItem = {\n // module path\n request: string\n // imported identifiers\n ids: string[]\n}\n\nexport default function transformSource(\n this: webpack.LoaderContext<NextFlightClientEntryLoaderOptions>\n) {\n let { modules, server } = this.getOptions()\n const isServer = server === 'true'\n\n if (!Array.isArray(modules)) {\n modules = modules ? [modules] : []\n }\n\n const code = modules\n .map((x) => JSON.parse(x) as FlightClientEntryModuleItem)\n // Filter out CSS files in the SSR compilation\n .filter(({ request }) => (isServer ? !regexCSS.test(request) : true))\n .map(({ request, ids }: FlightClientEntryModuleItem) => {\n const importPath = JSON.stringify(\n request.startsWith(BARREL_OPTIMIZATION_PREFIX)\n ? request.replace(':', '!=!')\n : request\n )\n\n // When we cannot determine the export names, we use eager mode to include the whole module.\n // Otherwise, we use eager mode with webpackExports to only include the necessary exports.\n // If we have '*' in the ids, we include all the imports\n if (ids.length === 0 || ids.includes('*')) {\n return `import(/* webpackMode: \"eager\" */ ${importPath});\\n`\n } else {\n return `import(/* webpackMode: \"eager\", webpackExports: ${JSON.stringify(\n ids\n )} */ ${importPath});\\n`\n }\n })\n .join(';\\n')\n\n const buildInfo = getModuleBuildInfo(this._module!)\n\n buildInfo.rsc = {\n type: RSC_MODULE_TYPES.client,\n }\n if (process.env.BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN) {\n const rscModuleInformationJson = JSON.stringify(buildInfo.rsc)\n return (\n `/* __rspack_internal_rsc_module_information_do_not_use__ ${rscModuleInformationJson} */\\n` +\n code\n )\n }\n\n return code\n}\n"],"names":["BARREL_OPTIMIZATION_PREFIX","RSC_MODULE_TYPES","getModuleBuildInfo","regexCSS","transformSource","modules","server","getOptions","isServer","Array","isArray","code","map","x","JSON","parse","filter","request","test","ids","importPath","stringify","startsWith","replace","length","includes","join","buildInfo","_module","rsc","type","client","process","env","BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN","rscModuleInformationJson"],"mappings":"AACA,SACEA,0BAA0B,EAC1BC,gBAAgB,QACX,gCAA+B;AACtC,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,QAAQ,QAAQ,UAAS;AAqBlC,eAAe,SAASC;IAGtB,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAG,IAAI,CAACC,UAAU;IACzC,MAAMC,WAAWF,WAAW;IAE5B,IAAI,CAACG,MAAMC,OAAO,CAACL,UAAU;QAC3BA,UAAUA,UAAU;YAACA;SAAQ,GAAG,EAAE;IACpC;IAEA,MAAMM,OAAON,QACVO,GAAG,CAAC,CAACC,IAAMC,KAAKC,KAAK,CAACF,GACvB,8CAA8C;KAC7CG,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAE,GAAMT,WAAW,CAACL,SAASe,IAAI,CAACD,WAAW,MAC9DL,GAAG,CAAC,CAAC,EAAEK,OAAO,EAAEE,GAAG,EAA+B;QACjD,MAAMC,aAAaN,KAAKO,SAAS,CAC/BJ,QAAQK,UAAU,CAACtB,8BACfiB,QAAQM,OAAO,CAAC,KAAK,SACrBN;QAGN,4FAA4F;QAC5F,0FAA0F;QAC1F,wDAAwD;QACxD,IAAIE,IAAIK,MAAM,KAAK,KAAKL,IAAIM,QAAQ,CAAC,MAAM;YACzC,OAAO,CAAC,kCAAkC,EAAEL,WAAW,IAAI,CAAC;QAC9D,OAAO;YACL,OAAO,CAAC,gDAAgD,EAAEN,KAAKO,SAAS,CACtEF,KACA,IAAI,EAAEC,WAAW,IAAI,CAAC;QAC1B;IACF,GACCM,IAAI,CAAC;IAER,MAAMC,YAAYzB,mBAAmB,IAAI,CAAC0B,OAAO;IAEjDD,UAAUE,GAAG,GAAG;QACdC,MAAM7B,iBAAiB8B,MAAM;IAC/B;IACA,IAAIC,QAAQC,GAAG,CAACC,kCAAkC,EAAE;QAClD,MAAMC,2BAA2BrB,KAAKO,SAAS,CAACM,UAAUE,GAAG;QAC7D,OACE,CAAC,yDAAyD,EAAEM,yBAAyB,KAAK,CAAC,GAC3FxB;IAEJ;IAEA,OAAOA;AACT","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../../src/build/webpack/loaders/next-flight-client-entry-loader.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport {\n BARREL_OPTIMIZATION_PREFIX,\n RSC_MODULE_TYPES,\n} from '../../../shared/lib/constants'\nimport { getModuleBuildInfo } from './get-module-build-info'\nimport { regexCSS } from './utils'\n\n/**\n * { [client import path]: [exported names] }\n */\nexport type ClientComponentImports = Record<string, Set<string>>\nexport type CssImports = Record<string, string[]>\n\nexport type NextFlightClientEntryLoaderOptions = {\n modules: string[] | string\n /** This is transmitted as a string to `getOptions` */\n server: boolean | 'true' | 'false'\n}\n\nexport type FlightClientEntryModuleItem = {\n // module path\n request: string\n // imported identifiers\n ids: string[]\n}\n\nexport default function transformSource(\n this: webpack.LoaderContext<NextFlightClientEntryLoaderOptions>\n) {\n let { modules, server } = this.getOptions()\n const isServer = server === 'true'\n\n if (!Array.isArray(modules)) {\n modules = modules ? [modules] : []\n }\n\n const code = modules\n .map((x) => JSON.parse(x) as FlightClientEntryModuleItem)\n // Filter out undefined requests (Bun compatibility) and CSS files in the SSR compilation\n .filter(({ request }) => request && (isServer ? !regexCSS.test(request) : true))\n .map(({ request, ids }: FlightClientEntryModuleItem) => {\n const importPath = JSON.stringify(\n request.startsWith(BARREL_OPTIMIZATION_PREFIX)\n ? request.replace(':', '!=!')\n : request\n )\n\n // When we cannot determine the export names, we use eager mode to include the whole module.\n // Otherwise, we use eager mode with webpackExports to only include the necessary exports.\n // If we have '*' in the ids, we include all the imports\n if (ids.length === 0 || ids.includes('*')) {\n return `import(/* webpackMode: \"eager\" */ ${importPath});\\n`\n } else {\n return `import(/* webpackMode: \"eager\", webpackExports: ${JSON.stringify(\n ids\n )} */ ${importPath});\\n`\n }\n })\n .join(';\\n')\n\n const buildInfo = getModuleBuildInfo(this._module!)\n\n buildInfo.rsc = {\n type: RSC_MODULE_TYPES.client,\n }\n if (process.env.BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN) {\n const rscModuleInformationJson = JSON.stringify(buildInfo.rsc)\n return (\n `/* __rspack_internal_rsc_module_information_do_not_use__ ${rscModuleInformationJson} */\\n` +\n code\n )\n }\n\n return code\n}\n"],"names":["BARREL_OPTIMIZATION_PREFIX","RSC_MODULE_TYPES","getModuleBuildInfo","regexCSS","transformSource","modules","server","getOptions","isServer","Array","isArray","code","map","x","JSON","parse","filter","request","test","ids","importPath","stringify","startsWith","replace","length","includes","join","buildInfo","_module","rsc","type","client","process","env","BUILTIN_FLIGHT_CLIENT_ENTRY_PLUGIN","rscModuleInformationJson"],"mappings":"AACA,SACEA,0BAA0B,EAC1BC,gBAAgB,QACX,gCAA+B;AACtC,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,QAAQ,QAAQ,UAAS;AAqBlC,eAAe,SAASC;IAGtB,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAG,IAAI,CAACC,UAAU;IACzC,MAAMC,WAAWF,WAAW;IAE5B,IAAI,CAACG,MAAMC,OAAO,CAACL,UAAU;QAC3BA,UAAUA,UAAU;YAACA;SAAQ,GAAG,EAAE;IACpC;IAEA,MAAMM,OAAON,QACVO,GAAG,CAAC,CAACC,IAAMC,KAAKC,KAAK,CAACF,GACvB,yFAAyF;KACxFG,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAE,GAAKA,WAAYT,CAAAA,WAAW,CAACL,SAASe,IAAI,CAACD,WAAW,IAAG,GAC5EL,GAAG,CAAC,CAAC,EAAEK,OAAO,EAAEE,GAAG,EAA+B;QACjD,MAAMC,aAAaN,KAAKO,SAAS,CAC/BJ,QAAQK,UAAU,CAACtB,8BACfiB,QAAQM,OAAO,CAAC,KAAK,SACrBN;QAGN,4FAA4F;QAC5F,0FAA0F;QAC1F,wDAAwD;QACxD,IAAIE,IAAIK,MAAM,KAAK,KAAKL,IAAIM,QAAQ,CAAC,MAAM;YACzC,OAAO,CAAC,kCAAkC,EAAEL,WAAW,IAAI,CAAC;QAC9D,OAAO;YACL,OAAO,CAAC,gDAAgD,EAAEN,KAAKO,SAAS,CACtEF,KACA,IAAI,EAAEC,WAAW,IAAI,CAAC;QAC1B;IACF,GACCM,IAAI,CAAC;IAER,MAAMC,YAAYzB,mBAAmB,IAAI,CAAC0B,OAAO;IAEjDD,UAAUE,GAAG,GAAG;QACdC,MAAM7B,iBAAiB8B,MAAM;IAC/B;IACA,IAAIC,QAAQC,GAAG,CAACC,kCAAkC,EAAE;QAClD,MAAMC,2BAA2BrB,KAAKO,SAAS,CAACM,UAAUE,GAAG;QAC7D,OACE,CAAC,yDAAyD,EAAEM,yBAAyB,KAAK,CAAC,GAC3FxB;IAEJ;IAEA,OAAOA;AACT","ignoreList":[0]}
@@ -176,6 +176,8 @@ export class FlightClientEntryPlugin {
176
176
  for (const connection of moduleReferences){
177
177
  // Entry can be any user defined entry files such as layout, page, error, loading, etc.
178
178
  let entryRequest = connection.dependency.request;
179
+ // Skip if entryRequest is undefined (can happen with Bun's module resolution)
180
+ if (!entryRequest || typeof entryRequest !== 'string') continue;
179
181
  if (entryRequest.endsWith(WEBPACK_RESOURCE_QUERIES.metadataRoute)) {
180
182
  const { filePath, isDynamicRouteExtension } = getMetadataRouteResource(entryRequest);
181
183
  if (isDynamicRouteExtension === '1') {
@@ -423,6 +425,8 @@ export class FlightClientEntryPlugin {
423
425
  for (const connection of getModuleReferencesInOrder(ssrEntryModule, compilation.moduleGraph)){
424
426
  const depModule = connection.dependency;
425
427
  const request = depModule.request;
428
+ // Skip if request is undefined (can happen with Bun's module resolution)
429
+ if (!request || typeof request !== 'string') continue;
426
430
  // It is possible that the same entry is added multiple times in the
427
431
  // connection graph. We can just skip these to speed up the process.
428
432
  if (visitedEntry.has(request)) continue;