{"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  UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n} from '../../../shared/lib/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'\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      for (const connection of getModuleReferencesInOrder(\n        entryModule,\n        compilation.moduleGraph\n      )) {\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\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          continue\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 = isAbsoluteRequest\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        // TODO-APP: This could be better handled, however Turbopack does not have the same problem as we resolve client components in a single graph.\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\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","connection","getModuleReferencesInOrder","entryRequest","dependency","request","endsWith","WEBPACK_RESOURCE_QUERIES","metadataRoute","filePath","isDynamicRouteExtension","getMetadataRouteResource","clientComponentImports","actionImports","collectComponentInfoFromServerEntryDependency","resolvedModule","forEach","dep","actions","set","isAbsoluteRequest","isAbsolute","keys","value","relativeRequest","bundlePath","appDirRelativeRequest","isMetadataEntryFile","isMetadataRouteFile","DEFAULT_METADATA_ROUTE_EXTENSIONS","assign","entryName","absolutePagePath","UNDERSCORE_NOT_FOUND_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":";;;;+BAiMaA;;;eAAAA;;;yBA5LW;6BACS;6DAChB;sCAOV;2BAIA;4BASA;uBAKA;wBAMA;kCAC0B;8BACK;2BACX;oCACQ;kCACE;iCACL;iCAIzB;0EAGuB;;;;;;AAS9B,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,8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