@openuiai/next 16.0.5 → 16.0.7

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 (55) 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/css-loader/src/utils.js +2 -1
  5. package/dist/build/webpack/loaders/css-loader/src/utils.js.map +1 -1
  6. package/dist/build/webpack/loaders/next-flight-client-entry-loader.js +2 -2
  7. package/dist/build/webpack/loaders/next-flight-client-entry-loader.js.map +1 -1
  8. package/dist/build/webpack/plugins/flight-client-entry-plugin.js +4 -0
  9. package/dist/build/webpack/plugins/flight-client-entry-plugin.js.map +1 -1
  10. package/dist/build/webpack/plugins/jsconfig-paths-plugin.js +4 -0
  11. package/dist/build/webpack/plugins/jsconfig-paths-plugin.js.map +1 -1
  12. package/dist/build/webpack/plugins/profiling-plugin.js +4 -1
  13. package/dist/build/webpack/plugins/profiling-plugin.js.map +1 -1
  14. package/dist/build/webpack/plugins/react-loadable-plugin.js +2 -0
  15. package/dist/build/webpack/plugins/react-loadable-plugin.js.map +1 -1
  16. package/dist/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.js +8 -0
  17. package/dist/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.js.map +1 -1
  18. package/dist/build/webpack-config.js +2 -2
  19. package/dist/client/app-bootstrap.js +1 -1
  20. package/dist/client/index.js +1 -1
  21. package/dist/esm/build/index.js +3 -3
  22. package/dist/esm/build/swc/index.js +1 -1
  23. package/dist/esm/build/webpack/loaders/css-loader/src/utils.js +2 -1
  24. package/dist/esm/build/webpack/loaders/css-loader/src/utils.js.map +1 -1
  25. package/dist/esm/build/webpack/loaders/next-flight-client-entry-loader.js +2 -2
  26. package/dist/esm/build/webpack/loaders/next-flight-client-entry-loader.js.map +1 -1
  27. package/dist/esm/build/webpack/plugins/flight-client-entry-plugin.js +4 -0
  28. package/dist/esm/build/webpack/plugins/flight-client-entry-plugin.js.map +1 -1
  29. package/dist/esm/build/webpack/plugins/jsconfig-paths-plugin.js +4 -0
  30. package/dist/esm/build/webpack/plugins/jsconfig-paths-plugin.js.map +1 -1
  31. package/dist/esm/build/webpack/plugins/profiling-plugin.js +4 -1
  32. package/dist/esm/build/webpack/plugins/profiling-plugin.js.map +1 -1
  33. package/dist/esm/build/webpack/plugins/react-loadable-plugin.js +2 -0
  34. package/dist/esm/build/webpack/plugins/react-loadable-plugin.js.map +1 -1
  35. package/dist/esm/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.js +8 -0
  36. package/dist/esm/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.js.map +1 -1
  37. package/dist/esm/build/webpack-config.js +2 -2
  38. package/dist/esm/client/app-bootstrap.js +1 -1
  39. package/dist/esm/client/index.js +1 -1
  40. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  41. package/dist/esm/server/dev/on-demand-entry-handler.js +2 -1
  42. package/dist/esm/server/dev/on-demand-entry-handler.js.map +1 -1
  43. package/dist/esm/server/lib/app-info-log.js +1 -1
  44. package/dist/esm/server/lib/start-server.js +1 -1
  45. package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
  46. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  47. package/dist/server/dev/on-demand-entry-handler.js +2 -1
  48. package/dist/server/dev/on-demand-entry-handler.js.map +1 -1
  49. package/dist/server/lib/app-info-log.js +1 -1
  50. package/dist/server/lib/start-server.js +1 -1
  51. package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  52. package/dist/telemetry/anonymous-meta.js +1 -1
  53. package/dist/telemetry/events/session-stopped.js +2 -2
  54. package/dist/telemetry/events/version.js +2 -2
  55. package/package.json +1 -1
@@ -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":["webpack","parse","stringify","path","sources","getInvalidator","getEntries","EntryTypes","getEntryKey","WEBPACK_LAYERS","WEBPACK_RESOURCE_QUERIES","APP_CLIENT_INTERNALS","BARREL_OPTIMIZATION_PREFIX","COMPILER_NAMES","DEFAULT_RUNTIME_WEBPACK","EDGE_RUNTIME_WEBPACK","SERVER_REFERENCE_MANIFEST","UNDERSCORE_NOT_FOUND_ROUTE_ENTRY","UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY","isClientComponentEntryModule","isCSSMod","regexCSS","traverseModules","forEachEntryModule","formatBarrelOptimizedResource","getModuleReferencesInOrder","normalizePathSep","getProxiedPluginState","PAGE_TYPES","getModuleBuildInfo","getAssumedSourceType","isAppRouteRoute","DEFAULT_METADATA_ROUTE_EXTENSIONS","isMetadataRouteFile","getWebpackBundler","isAppBuiltinPage","PLUGIN_NAME","pluginState","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","name","bName","indexA","indexOf","indexB","dedupedCSSImports","trackedCSSImports","Set","entryFilePath","cssImports","entryConventionName","cssImport","has","includes","add","push","FlightClientEntryPlugin","constructor","options","dev","appDir","projectDir","join","isEdgeServer","assetPrefix","encryptionKey","webpackRuntime","apply","compiler","hooks","finishMake","tapPromise","compilation","createClientEntries","afterCompile","tap","recordModule","modId","mod","modPath","matchResource","resourceResolveData","modQuery","query","modResource","startsWith","resource","layer","reactServerComponents","key","relative","context","replace","moduleInfo","moduleId","async","moduleGraph","isAsync","serverSideRendering","ssrNamedModuleId","_chunk","_chunkGroup","make","processAssets","stage","Compilation","PROCESS_ASSETS_STAGE_OPTIMIZE_HASH","createActionAssets","addClientEntryAndSSRModulesList","createdSSRDependenciesForEntry","addActionEntryList","actionMapsPerEntry","createdActionIds","entryModule","internalClientComponentEntryImports","actionEntryImports","Map","clientEntriesToInject","moduleReferences","connection","entryRequest","dependency","request","endsWith","metadataRoute","filePath","isDynamicRouteExtension","getMetadataRouteResource","clientComponentImports","actionImports","collectComponentInfoFromServerEntryDependency","resolvedModule","forEach","dep","actions","set","isAbsoluteRequest","isAbsolute","isAppRouterBuiltinPage","keys","value","relativeRequest","bundlePath","appDirRelativeRequest","isMetadataEntryFile","assign","entryName","absolutePagePath","clientEntryToInject","injected","injectClientEntryAndSSRModules","clientImports","reduce","res","curr","size","injectActionEntry","invalidator","outputPath","some","shouldInvalidate","invalidate","client","Promise","all","flatMap","addClientEntryAndSSRModules","addedClientActionEntryList","actionMapsPerClientEntry","ssrEntryDependencies","collectClientActionsFromDependencies","dependencies","remainingClientImportedActions","remainingActionEntryImports","remainingActionNames","action","id","fromClient","collectedActions","visitedModule","visitedEntry","collectActions","collectActionsInDep","getModuleResource","actionIds","rsc","map","exportedName","filename","posix","entryDependency","ssrEntryModule","getResolvedModule","depModule","visitedOfClientComponentsTraverse","CSSImports","filterClientComponents","importedIdentifiers","addClientImport","sideEffectFree","factoryMeta","unused","getExportsInfo","isModuleUsed","dependencyIds","ids","Array","from","bundler","modules","test","localeCompare","clientImportPath","clientBrowserLoader","sep","x","JSON","server","clientServerLoader","pageKey","APP","type","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","RawSource","modRequest","isFirstVisitModule","clientEntryType","isCjsModule","assumedSourceType","clientImportsSet","isAutoModuleSourceType","isCjsDefaultImport","identifier","rawRequest"],"mappings":"AAKA,SAASA,OAAO,QAAQ,qCAAoC;AAC5D,SAASC,KAAK,EAAEC,SAAS,QAAQ,cAAa;AAC9C,OAAOC,UAAU,OAAM;AACvB,SAASC,OAAO,QAAQ,q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","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":["webpack","parse","stringify","path","sources","getInvalidator","getEntries","EntryTypes","getEntryKey","WEBPACK_LAYERS","WEBPACK_RESOURCE_QUERIES","APP_CLIENT_INTERNALS","BARREL_OPTIMIZATION_PREFIX","COMPILER_NAMES","DEFAULT_RUNTIME_WEBPACK","EDGE_RUNTIME_WEBPACK","SERVER_REFERENCE_MANIFEST","UNDERSCORE_NOT_FOUND_ROUTE_ENTRY","UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY","isClientComponentEntryModule","isCSSMod","regexCSS","traverseModules","forEachEntryModule","formatBarrelOptimizedResource","getModuleReferencesInOrder","normalizePathSep","getProxiedPluginState","PAGE_TYPES","getModuleBuildInfo","getAssumedSourceType","isAppRouteRoute","DEFAULT_METADATA_ROUTE_EXTENSIONS","isMetadataRouteFile","getWebpackBundler","isAppBuiltinPage","PLUGIN_NAME","pluginState","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","name","bName","indexA","indexOf","indexB","dedupedCSSImports","trackedCSSImports","Set","entryFilePath","cssImports","entryConventionName","cssImport","has","includes","add","push","FlightClientEntryPlugin","constructor","options","dev","appDir","projectDir","join","isEdgeServer","assetPrefix","encryptionKey","webpackRuntime","apply","compiler","hooks","finishMake","tapPromise","compilation","createClientEntries","afterCompile","tap","recordModule","modId","mod","modPath","matchResource","resourceResolveData","modQuery","query","modResource","startsWith","resource","layer","reactServerComponents","key","relative","context","replace","moduleInfo","moduleId","async","moduleGraph","isAsync","serverSideRendering","ssrNamedModuleId","_chunk","_chunkGroup","make","processAssets","stage","Compilation","PROCESS_ASSETS_STAGE_OPTIMIZE_HASH","createActionAssets","addClientEntryAndSSRModulesList","createdSSRDependenciesForEntry","addActionEntryList","actionMapsPerEntry","createdActionIds","entryModule","internalClientComponentEntryImports","actionEntryImports","Map","clientEntriesToInject","moduleReferences","connection","entryRequest","dependency","request","endsWith","metadataRoute","filePath","isDynamicRouteExtension","getMetadataRouteResource","clientComponentImports","actionImports","collectComponentInfoFromServerEntryDependency","resolvedModule","forEach","dep","actions","set","isAbsoluteRequest","isAbsolute","isAppRouterBuiltinPage","keys","value","relativeRequest","bundlePath","appDirRelativeRequest","isMetadataEntryFile","assign","entryName","absolutePagePath","clientEntryToInject","injected","injectClientEntryAndSSRModules","clientImports","reduce","res","curr","size","injectActionEntry","invalidator","outputPath","some","shouldInvalidate","invalidate","client","Promise","all","flatMap","addClientEntryAndSSRModules","addedClientActionEntryList","actionMapsPerClientEntry","ssrEntryDependencies","collectClientActionsFromDependencies","dependencies","remainingClientImportedActions","remainingActionEntryImports","remainingActionNames","action","id","fromClient","collectedActions","visitedModule","visitedEntry","collectActions","collectActionsInDep","getModuleResource","actionIds","rsc","map","exportedName","filename","posix","entryDependency","ssrEntryModule","getResolvedModule","depModule","visitedOfClientComponentsTraverse","CSSImports","filterClientComponents","importedIdentifiers","addClientImport","sideEffectFree","factoryMeta","unused","getExportsInfo","isModuleUsed","dependencyIds","ids","Array","from","bundler","modules","test","localeCompare","clientImportPath","clientBrowserLoader","sep","x","JSON","server","clientServerLoader","pageKey","APP","type","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","RawSource","modRequest","isFirstVisitModule","clientEntryType","isCjsModule","assumedSourceType","clientImportsSet","isAutoModuleSourceType","isCjsDefaultImport","identifier","rawRequest"],"mappings":"AAKA,SAASA,OAAO,QAAQ,qCAAoC;AAC5D,SAASC,KAAK,EAAEC,SAAS,QAAQ,cAAa;AAC9C,OAAOC,UAAU,OAAM;AACvB,SAASC,OAAO,QAAQ,qCAAoC;AAC5D,SACEC,cAAc,EACdC,UAAU,EACVC,UAAU,EACVC,WAAW,QACN,8CAA6C;AACpD,SACEC,cAAc,EACdC,wBAAwB,QACnB,yBAAwB;AAC/B,SACEC,oBAAoB,EACpBC,0BAA0B,EAC1BC,cAAc,EACdC,uBAAuB,EACvBC,oBAAoB,EACpBC,yBAAyB,QACpB,gCAA+B;AACtC,SACEC,gCAAgC,EAChCC,mCAAmC,QAC9B,sCAAqC;AAC5C,SACEC,4BAA4B,EAC5BC,QAAQ,EACRC,QAAQ,QACH,mBAAkB;AACzB,SACEC,eAAe,EACfC,kBAAkB,EAClBC,6BAA6B,EAC7BC,0BAA0B,QACrB,WAAU;AACjB,SAASC,gBAAgB,QAAQ,mDAAkD;AACnF,SAASC,qBAAqB,QAAQ,sBAAqB;AAC3D,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,oBAAoB,QAAQ,gCAA+B;AACpE,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SACEC,iCAAiC,EACjCC,mBAAmB,QACd,0CAAyC;AAGhD,OAAOC,uBAAuB,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,cAAa;AAS9C,MAAMC,cAAc;AAiCpB,MAAMC,cAAcV,sBAAsB;IACxC,gDAAgD;IAChDW,eAAe,CAAC;IAChBC,mBAAmB,CAAC;IAEpBC,qBAAqB,CAAC;IAOtBC,yBAAyB,CAAC;IAO1BC,YAAY,CAAC;IACbC,gBAAgB,CAAC;IAEjBC,YAAY,CAAC;I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;QAC7DgG,cAAcN,IAAIE,aAAa,GAAG,MAAMI;IAC1C;IAEA,IAAIN,IAAIQ,QAAQ,KAAK,CAAC,CAAC,EAAEpG,yBAAyB0I,aAAa,EAAE,EAAE;QACjE,OAAOG,yBAAyBjD,IAAIwM,UAAU,EAAEzJ,QAAQ;IAC1D;IAEA,OAAOzC;AACT;AAEA,SAAS2C,yBAAyBL,OAAe;IAC/C,sHAAsH;IACtH,MAAMvC,QAAQuC,QAAQtF,KAAK,CAAC,IAAI,CAAC,EAAE,CAACA,KAAK,CAAC,8BAA8B,CAAC,EAAE;IAE3E,OAAO3D,MAAM0G;AACf","ignoreList":[0]}
@@ -125,6 +125,10 @@ export class JsConfigPathsPlugin {
125
125
  return callback();
126
126
  }
127
127
  const moduleName = request.request;
128
+ // Skip if moduleName is undefined (Bun compatibility)
129
+ if (!moduleName || typeof moduleName !== 'string') {
130
+ return callback();
131
+ }
128
132
  // Exclude node_modules from paths support (speeds up resolving)
129
133
  if (request.path.match(NODE_MODULES_REGEX)) {
130
134
  log('skipping request as it is inside node_modules %s', moduleName);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/build/webpack/plugins/jsconfig-paths-plugin.ts"],"sourcesContent":["/**\n * This webpack resolver is largely based on TypeScript's \"paths\" handling\n * The TypeScript license can be found here:\n * https://github.com/microsoft/TypeScript/blob/214df64e287804577afa1fea0184c18c40f7d1ca/LICENSE.txt\n */\nimport path from 'path'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { debug } from 'next/dist/compiled/debug'\nimport type { ResolvedBaseUrl } from '../../load-jsconfig'\n\nconst log = debug('next:jsconfig-paths-plugin')\n\nexport interface Pattern {\n prefix: string\n suffix: string\n}\n\nconst asterisk = 0x2a\n\nexport function hasZeroOrOneAsteriskCharacter(str: string): boolean {\n let seenAsterisk = false\n for (let i = 0; i < str.length; i++) {\n if (str.charCodeAt(i) === asterisk) {\n if (!seenAsterisk) {\n seenAsterisk = true\n } else {\n // have already seen asterisk\n return false\n }\n }\n }\n return true\n}\n\n/**\n * Determines whether a path starts with a relative path component (i.e. `.` or `..`).\n */\nexport function pathIsRelative(testPath: string): boolean {\n return /^\\.\\.?($|[\\\\/])/.test(testPath)\n}\n\nexport function tryParsePattern(pattern: string): Pattern | undefined {\n // This should be verified outside of here and a proper error thrown.\n const indexOfStar = pattern.indexOf('*')\n return indexOfStar === -1\n ? undefined\n : {\n prefix: pattern.slice(0, indexOfStar),\n suffix: pattern.slice(indexOfStar + 1),\n }\n}\n\nfunction isPatternMatch({ prefix, suffix }: Pattern, candidate: string) {\n return (\n candidate.length >= prefix.length + suffix.length &&\n candidate.startsWith(prefix) &&\n candidate.endsWith(suffix)\n )\n}\n\n/** Return the object corresponding to the best pattern to match `candidate`. */\nexport function findBestPatternMatch<T>(\n values: readonly T[],\n getPattern: (value: T) => Pattern,\n candidate: string\n): T | undefined {\n let matchedValue: T | undefined\n // use length of prefix as betterness criteria\n let longestMatchPrefixLength = -1\n\n for (const v of values) {\n const pattern = getPattern(v)\n if (\n isPatternMatch(pattern, candidate) &&\n pattern.prefix.length > longestMatchPrefixLength\n ) {\n longestMatchPrefixLength = pattern.prefix.length\n matchedValue = v\n }\n }\n\n return matchedValue\n}\n\n/**\n * patternStrings contains both pattern strings (containing \"*\") and regular strings.\n * Return an exact match if possible, or a pattern match, or undefined.\n * (These are verified by verifyCompilerOptions to have 0 or 1 \"*\" characters.)\n */\nexport function matchPatternOrExact(\n patternStrings: readonly string[],\n candidate: string\n): string | Pattern | undefined {\n const patterns: Pattern[] = []\n for (const patternString of patternStrings) {\n if (!hasZeroOrOneAsteriskCharacter(patternString)) continue\n const pattern = tryParsePattern(patternString)\n if (pattern) {\n patterns.push(pattern)\n } else if (patternString === candidate) {\n // pattern was matched as is - no need to search further\n return patternString\n }\n }\n\n return findBestPatternMatch(patterns, (_) => _, candidate)\n}\n\n/**\n * Tests whether a value is string\n */\nexport function isString(text: unknown): text is string {\n return typeof text === 'string'\n}\n\n/**\n * Given that candidate matches pattern, returns the text matching the '*'.\n * E.g.: matchedText(tryParsePattern(\"foo*baz\"), \"foobarbaz\") === \"bar\"\n */\nexport function matchedText(pattern: Pattern, candidate: string): string {\n return candidate.substring(\n pattern.prefix.length,\n candidate.length - pattern.suffix.length\n )\n}\n\nexport function patternText({ prefix, suffix }: Pattern): string {\n return `${prefix}*${suffix}`\n}\n\n/**\n * Calls the iterator function for each entry of the array\n * until the first result or error is reached\n */\nfunction forEachBail<TEntry>(\n array: TEntry[],\n iterator: (\n entry: TEntry,\n entryCallback: (err?: any, result?: any) => void\n ) => void,\n callback: (err?: any, result?: any) => void\n): void {\n if (array.length === 0) return callback()\n\n let i = 0\n const next = () => {\n let loop: boolean | undefined = undefined\n iterator(array[i++], (err, result) => {\n if (err || result !== undefined || i >= array.length) {\n return callback(err, result)\n }\n if (loop === false) while (next());\n loop = true\n })\n if (!loop) loop = false\n return loop\n }\n while (next());\n}\n\nconst NODE_MODULES_REGEX = /node_modules/\n\ntype Paths = { [match: string]: string[] }\n\n/**\n * Handles tsconfig.json or jsconfig.js \"paths\" option for webpack\n * Largely based on how the TypeScript compiler handles it:\n * https://github.com/microsoft/TypeScript/blob/1a9c8197fffe3dace5f8dca6633d450a88cba66d/src/compiler/moduleNameResolver.ts#L1362\n */\n\ntype NonFunction<T> = T extends Function ? never : T\n\n// Pick the object type of ResolvePluginInstance\ntype ResolvePluginPlugin = NonFunction<webpack.ResolvePluginInstance>\nexport class JsConfigPathsPlugin implements ResolvePluginPlugin {\n paths: Paths\n resolvedBaseUrl: ResolvedBaseUrl\n jsConfigPlugin: true\n\n constructor(paths: Paths, resolvedBaseUrl: ResolvedBaseUrl) {\n this.paths = paths\n this.resolvedBaseUrl = resolvedBaseUrl\n this.jsConfigPlugin = true\n log('tsconfig.json or jsconfig.json paths: %O', paths)\n log('resolved baseUrl: %s', resolvedBaseUrl)\n }\n apply(resolver: webpack.Resolver) {\n const target = resolver.ensureHook('resolve')\n resolver\n .getHook('described-resolve')\n .tapAsync(\n 'JsConfigPathsPlugin',\n (\n request: any,\n resolveContext: any,\n callback: (err?: any, result?: any) => void\n ) => {\n const resolvedBaseUrl = this.resolvedBaseUrl\n if (resolvedBaseUrl === undefined) {\n return callback()\n }\n const paths = this.paths\n const pathsKeys = Object.keys(paths)\n\n // If no aliases are added bail out\n if (pathsKeys.length === 0) {\n log('paths are empty, bailing out')\n return callback()\n }\n\n const moduleName = request.request\n\n // Exclude node_modules from paths support (speeds up resolving)\n if (request.path.match(NODE_MODULES_REGEX)) {\n log('skipping request as it is inside node_modules %s', moduleName)\n return callback()\n }\n\n if (\n path.posix.isAbsolute(moduleName) ||\n (process.platform === 'win32' && path.win32.isAbsolute(moduleName))\n ) {\n log('skipping request as it is an absolute path %s', moduleName)\n return callback()\n }\n\n if (pathIsRelative(moduleName)) {\n log('skipping request as it is a relative path %s', moduleName)\n return callback()\n }\n\n // log('starting to resolve request %s', moduleName)\n\n // If the module name does not match any of the patterns in `paths` we hand off resolving to webpack\n const matchedPattern = matchPatternOrExact(pathsKeys, moduleName)\n if (!matchedPattern) {\n log('moduleName did not match any paths pattern %s', moduleName)\n return callback()\n }\n\n const matchedStar = isString(matchedPattern)\n ? undefined\n : matchedText(matchedPattern, moduleName)\n const matchedPatternText = isString(matchedPattern)\n ? matchedPattern\n : patternText(matchedPattern)\n\n let triedPaths = []\n\n forEachBail(\n paths[matchedPatternText],\n (subst, pathCallback) => {\n const curPath = matchedStar\n ? subst.replace('*', matchedStar)\n : subst\n // Ensure .d.ts is not matched\n if (curPath.endsWith('.d.ts')) {\n // try next path candidate\n return pathCallback()\n }\n const candidate = path.join(resolvedBaseUrl.baseUrl, curPath)\n const obj = Object.assign({}, request, {\n request: candidate,\n })\n resolver.doResolve(\n target,\n obj,\n `Aliased with tsconfig.json or jsconfig.json ${matchedPatternText} to ${candidate}`,\n resolveContext,\n (resolverErr: any, resolverResult: any) => {\n if (resolverErr || resolverResult === undefined) {\n triedPaths.push(candidate)\n // try next path candidate\n return pathCallback()\n }\n return pathCallback(resolverErr, resolverResult)\n }\n )\n },\n callback\n )\n }\n )\n }\n}\n"],"names":["path","debug","log","asterisk","hasZeroOrOneAsteriskCharacter","str","seenAsterisk","i","length","charCodeAt","pathIsRelative","testPath","test","tryParsePattern","pattern","indexOfStar","indexOf","undefined","prefix","slice","suffix","isPatternMatch","candidate","startsWith","endsWith","findBestPatternMatch","values","getPattern","matchedValue","longestMatchPrefixLength","v","matchPatternOrExact","patternStrings","patterns","patternString","push","_","isString","text","matchedText","substring","patternText","forEachBail","array","iterator","callback","next","loop","err","result","NODE_MODULES_REGEX","JsConfigPathsPlugin","constructor","paths","resolvedBaseUrl","jsConfigPlugin","apply","resolver","target","ensureHook","getHook","tapAsync","request","resolveContext","pathsKeys","Object","keys","moduleName","match","posix","isAbsolute","process","platform","win32","matchedPattern","matchedStar","matchedPatternText","triedPaths","subst","pathCallback","curPath","replace","join","baseUrl","obj","assign","doResolve","resolverErr","resolverResult"],"mappings":"AAAA;;;;CAIC,GACD,OAAOA,UAAU,OAAM;AAEvB,SAASC,KAAK,QAAQ,2BAA0B;AAGhD,MAAMC,MAAMD,MAAM;AAOlB,MAAME,WAAW;AAEjB,OAAO,SAASC,8BAA8BC,GAAW;IACvD,IAAIC,eAAe;IACnB,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIG,MAAM,EAAED,IAAK;QACnC,IAAIF,IAAII,UAAU,CAACF,OAAOJ,UAAU;YAClC,IAAI,CAACG,cAAc;gBACjBA,eAAe;YACjB,OAAO;gBACL,6BAA6B;gBAC7B,OAAO;YACT;QACF;IACF;IACA,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,eAAeC,QAAgB;IAC7C,OAAO,kBAAkBC,IAAI,CAACD;AAChC;AAEA,OAAO,SAASE,gBAAgBC,OAAe;IAC7C,qEAAqE;IACrE,MAAMC,cAAcD,QAAQE,OAAO,CAAC;IACpC,OAAOD,gBAAgB,CAAC,IACpBE,YACA;QACEC,QAAQJ,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IAAI,CAACb;wBAChB,0BAA0B;wBAC1B,OAAOyD;oBACT;oBACA,OAAOA,aAAaQ,aAAaC;gBACnC;YAEJ,GACA3C;QAEJ;IAEN;AACF","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../../src/build/webpack/plugins/jsconfig-paths-plugin.ts"],"sourcesContent":["/**\n * This webpack resolver is largely based on TypeScript's \"paths\" handling\n * The TypeScript license can be found here:\n * https://github.com/microsoft/TypeScript/blob/214df64e287804577afa1fea0184c18c40f7d1ca/LICENSE.txt\n */\nimport path from 'path'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { debug } from 'next/dist/compiled/debug'\nimport type { ResolvedBaseUrl } from '../../load-jsconfig'\n\nconst log = debug('next:jsconfig-paths-plugin')\n\nexport interface Pattern {\n prefix: string\n suffix: string\n}\n\nconst asterisk = 0x2a\n\nexport function hasZeroOrOneAsteriskCharacter(str: string): boolean {\n let seenAsterisk = false\n for (let i = 0; i < str.length; i++) {\n if (str.charCodeAt(i) === asterisk) {\n if (!seenAsterisk) {\n seenAsterisk = true\n } else {\n // have already seen asterisk\n return false\n }\n }\n }\n return true\n}\n\n/**\n * Determines whether a path starts with a relative path component (i.e. `.` or `..`).\n */\nexport function pathIsRelative(testPath: string): boolean {\n return /^\\.\\.?($|[\\\\/])/.test(testPath)\n}\n\nexport function tryParsePattern(pattern: string): Pattern | undefined {\n // This should be verified outside of here and a proper error thrown.\n const indexOfStar = pattern.indexOf('*')\n return indexOfStar === -1\n ? undefined\n : {\n prefix: pattern.slice(0, indexOfStar),\n suffix: pattern.slice(indexOfStar + 1),\n }\n}\n\nfunction isPatternMatch({ prefix, suffix }: Pattern, candidate: string) {\n return (\n candidate.length >= prefix.length + suffix.length &&\n candidate.startsWith(prefix) &&\n candidate.endsWith(suffix)\n )\n}\n\n/** Return the object corresponding to the best pattern to match `candidate`. */\nexport function findBestPatternMatch<T>(\n values: readonly T[],\n getPattern: (value: T) => Pattern,\n candidate: string\n): T | undefined {\n let matchedValue: T | undefined\n // use length of prefix as betterness criteria\n let longestMatchPrefixLength = -1\n\n for (const v of values) {\n const pattern = getPattern(v)\n if (\n isPatternMatch(pattern, candidate) &&\n pattern.prefix.length > longestMatchPrefixLength\n ) {\n longestMatchPrefixLength = pattern.prefix.length\n matchedValue = v\n }\n }\n\n return matchedValue\n}\n\n/**\n * patternStrings contains both pattern strings (containing \"*\") and regular strings.\n * Return an exact match if possible, or a pattern match, or undefined.\n * (These are verified by verifyCompilerOptions to have 0 or 1 \"*\" characters.)\n */\nexport function matchPatternOrExact(\n patternStrings: readonly string[],\n candidate: string\n): string | Pattern | undefined {\n const patterns: Pattern[] = []\n for (const patternString of patternStrings) {\n if (!hasZeroOrOneAsteriskCharacter(patternString)) continue\n const pattern = tryParsePattern(patternString)\n if (pattern) {\n patterns.push(pattern)\n } else if (patternString === candidate) {\n // pattern was matched as is - no need to search further\n return patternString\n }\n }\n\n return findBestPatternMatch(patterns, (_) => _, candidate)\n}\n\n/**\n * Tests whether a value is string\n */\nexport function isString(text: unknown): text is string {\n return typeof text === 'string'\n}\n\n/**\n * Given that candidate matches pattern, returns the text matching the '*'.\n * E.g.: matchedText(tryParsePattern(\"foo*baz\"), \"foobarbaz\") === \"bar\"\n */\nexport function matchedText(pattern: Pattern, candidate: string): string {\n return candidate.substring(\n pattern.prefix.length,\n candidate.length - pattern.suffix.length\n )\n}\n\nexport function patternText({ prefix, suffix }: Pattern): string {\n return `${prefix}*${suffix}`\n}\n\n/**\n * Calls the iterator function for each entry of the array\n * until the first result or error is reached\n */\nfunction forEachBail<TEntry>(\n array: TEntry[],\n iterator: (\n entry: TEntry,\n entryCallback: (err?: any, result?: any) => void\n ) => void,\n callback: (err?: any, result?: any) => void\n): void {\n if (array.length === 0) return callback()\n\n let i = 0\n const next = () => {\n let loop: boolean | undefined = undefined\n iterator(array[i++], (err, result) => {\n if (err || result !== undefined || i >= array.length) {\n return callback(err, result)\n }\n if (loop === false) while (next());\n loop = true\n })\n if (!loop) loop = false\n return loop\n }\n while (next());\n}\n\nconst NODE_MODULES_REGEX = /node_modules/\n\ntype Paths = { [match: string]: string[] }\n\n/**\n * Handles tsconfig.json or jsconfig.js \"paths\" option for webpack\n * Largely based on how the TypeScript compiler handles it:\n * https://github.com/microsoft/TypeScript/blob/1a9c8197fffe3dace5f8dca6633d450a88cba66d/src/compiler/moduleNameResolver.ts#L1362\n */\n\ntype NonFunction<T> = T extends Function ? never : T\n\n// Pick the object type of ResolvePluginInstance\ntype ResolvePluginPlugin = NonFunction<webpack.ResolvePluginInstance>\nexport class JsConfigPathsPlugin implements ResolvePluginPlugin {\n paths: Paths\n resolvedBaseUrl: ResolvedBaseUrl\n jsConfigPlugin: true\n\n constructor(paths: Paths, resolvedBaseUrl: ResolvedBaseUrl) {\n this.paths = paths\n this.resolvedBaseUrl = resolvedBaseUrl\n this.jsConfigPlugin = true\n log('tsconfig.json or jsconfig.json paths: %O', paths)\n log('resolved baseUrl: %s', resolvedBaseUrl)\n }\n apply(resolver: webpack.Resolver) {\n const target = resolver.ensureHook('resolve')\n resolver\n .getHook('described-resolve')\n .tapAsync(\n 'JsConfigPathsPlugin',\n (\n request: any,\n resolveContext: any,\n callback: (err?: any, result?: any) => void\n ) => {\n const resolvedBaseUrl = this.resolvedBaseUrl\n if (resolvedBaseUrl === undefined) {\n return callback()\n }\n const paths = this.paths\n const pathsKeys = Object.keys(paths)\n\n // If no aliases are added bail out\n if (pathsKeys.length === 0) {\n log('paths are empty, bailing out')\n return callback()\n }\n\n const moduleName = request.request\n\n // Skip if moduleName is undefined (Bun compatibility)\n if (!moduleName || typeof moduleName !== 'string') {\n return callback()\n }\n\n // Exclude node_modules from paths support (speeds up resolving)\n if (request.path.match(NODE_MODULES_REGEX)) {\n log('skipping request as it is inside node_modules %s', moduleName)\n return callback()\n }\n\n if (\n path.posix.isAbsolute(moduleName) ||\n (process.platform === 'win32' && path.win32.isAbsolute(moduleName))\n ) {\n log('skipping request as it is an absolute path %s', moduleName)\n return callback()\n }\n\n if (pathIsRelative(moduleName)) {\n log('skipping request as it is a relative path %s', moduleName)\n return callback()\n }\n\n // log('starting to resolve request %s', moduleName)\n\n // If the module name does not match any of the patterns in `paths` we hand off resolving to webpack\n const matchedPattern = matchPatternOrExact(pathsKeys, moduleName)\n if (!matchedPattern) {\n log('moduleName did not match any paths pattern %s', moduleName)\n return callback()\n }\n\n const matchedStar = isString(matchedPattern)\n ? undefined\n : matchedText(matchedPattern, moduleName)\n const matchedPatternText = isString(matchedPattern)\n ? matchedPattern\n : patternText(matchedPattern)\n\n let triedPaths = []\n\n forEachBail(\n paths[matchedPatternText],\n (subst, pathCallback) => {\n const curPath = matchedStar\n ? subst.replace('*', matchedStar)\n : subst\n // Ensure .d.ts is not matched\n if (curPath.endsWith('.d.ts')) {\n // try next path candidate\n return pathCallback()\n }\n const candidate = path.join(resolvedBaseUrl.baseUrl, curPath)\n const obj = Object.assign({}, request, {\n request: candidate,\n })\n resolver.doResolve(\n target,\n obj,\n `Aliased with tsconfig.json or jsconfig.json ${matchedPatternText} to ${candidate}`,\n resolveContext,\n (resolverErr: any, resolverResult: any) => {\n if (resolverErr || resolverResult === undefined) {\n triedPaths.push(candidate)\n // try next path candidate\n return pathCallback()\n }\n return pathCallback(resolverErr, resolverResult)\n }\n )\n },\n callback\n )\n }\n )\n }\n}\n"],"names":["path","debug","log","asterisk","hasZeroOrOneAsteriskCharacter","str","seenAsterisk","i","length","charCodeAt","pathIsRelative","testPath","test","tryParsePattern","pattern","indexOfStar","indexOf","undefined","prefix","slice","suffix","isPatternMatch","candidate","startsWith","endsWith","findBestPatternMatch","values","getPattern","matchedValue","longestMatchPrefixLength","v","matchPatternOrExact","patternStrings","patterns","patternString","push","_","isString","text","matchedText","substring","patternText","forEachBail","array","iterator","callback","next","loop","err","result","NODE_MODULES_REGEX","JsConfigPathsPlugin","constructor","paths","resolvedBaseUrl","jsConfigPlugin","apply","resolver","target","ensureHook","getHook","tapAsync","request","resolveContext","pathsKeys","Object","keys","moduleName","match","posix","isAbsolute","process","platform","win32","matchedPattern","matchedStar","matchedPatternText","triedPaths","subst","pathCallback","curPath","replace","join","baseUrl","obj","assign","doResolve","resolverErr","resolverResult"],"mappings":"AAAA;;;;CAIC,GACD,OAAOA,UAAU,OAAM;AAEvB,SAASC,KAAK,QAAQ,2BAA0B;AAGhD,MAAMC,MAAMD,MAAM;AAOlB,MAAME,WAAW;AAEjB,OAAO,SAASC,8BAA8BC,GAAW;IACvD,IAAIC,eAAe;IACnB,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIG,MAAM,EAAED,IAAK;QACnC,IAAIF,IAAII,UAAU,CAACF,OAAOJ,UAAU;YAClC,IAAI,CAACG,cAAc;gBACjBA,eAAe;YACjB,OAAO;gBACL,6BAA6B;gBAC7B,OAAO;YACT;QACF;IACF;IACA,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,eAAeC,QAAgB;IAC7C,OAAO,kBAAkBC,IAAI,CAACD;AAChC;AAEA,OAAO,SAASE,gBAAgBC,OAAe;IAC7C,qEAAqE;IACrE,MAAMC,cAAcD,QAAQE,OAAO,CAAC;IACpC,OAAOD,gBAAgB,CAAC,IACpBE,YACA;QACEC,QAAQJ,QAAQK,KAAK,CAAC,GAAGJ;QACzBK,QAAQN,QAAQK,KAAK,CAACJ,cAAc;IACtC;AACN;AAEA,SAASM,eAAe,EAAEH,MAAM,EAAEE,MAAM,EAAW,EAAEE,SAAiB;IACpE,OACEA,UAAUd,MAAM,IAAIU,OAAOV,MAAM,GAAGY,OAAOZ,MAAM,IACjDc,UAAUC,UAAU,CAACL,WACrBI,UAAUE,QAAQ,CAACJ;AAEvB;AAEA,8EAA8E,GAC9E,OAAO,SAASK,qBACdC,MAAoB,EACpBC,UAAiC,EACjCL,SAAiB;IAEjB,IAAIM;IACJ,8CAA8C;IAC9C,IAAIC,2BAA2B,CAAC;IAEhC,KAAK,MAAMC,KAAKJ,OAAQ;QACtB,MAAMZ,UAAUa,WAAWG;QAC3B,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D;YAEpD,oGAAoG;YACpG,MAAM6B,iBAAiB3C,oBAAoBiC,WAAWG;YACtD,IAAI,CAACO,gBAAgB;gBACnBxE,IAAI,iDAAiDiE;gBACrD,OAAOtB;YACT;YAEA,MAAM8B,cAActC,SAASqC,kBACzBzD,YACAsB,YAAYmC,gBAAgBP;YAChC,MAAMS,qBAAqBvC,SAASqC,kBAChCA,iBACAjC,YAAYiC;YAEhB,IAAIG,aAAa,EAAE;YAEnBnC,YACEW,KAAK,CAACuB,mBAAmB,EACzB,CAACE,OAAOC;gBACN,MAAMC,UAAUL,cACZG,MAAMG,OAAO,CAAC,KAAKN,eACnBG;gBACJ,8BAA8B;gBAC9B,IAAIE,QAAQxD,QAAQ,CAAC,UAAU;oBAC7B,0BAA0B;oBAC1B,OAAOuD;gBACT;gBACA,MAAMzD,YAAYtB,KAAKkF,IAAI,CAAC5B,gBAAgB6B,OAAO,EAAEH;gBACrD,MAAMI,MAAMnB,OAAOoB,MAAM,CAAC,CAAC,GAAGvB,SAAS;oBACrCA,SAASxC;gBACX;gBACAmC,SAAS6B,SAAS,CAChB5B,QACA0B,KACA,CAAC,4CAA4C,EAAER,mBAAmB,IAAI,EAAEtD,WAAW,EACnFyC,gBACA,CAACwB,aAAkBC;oBACjB,IAAID,eAAeC,mBAAmBvE,WAAW;wBAC/C4D,WAAW1C,IAAI,CAACb;wBAChB,0BAA0B;wBAC1B,OAAOyD;oBACT;oBACA,OAAOA,aAAaQ,aAAaC;gBACnC;YAEJ,GACA3C;QAEJ;IAEN;AACF","ignoreList":[0]}
@@ -177,7 +177,10 @@ export class ProfilingPlugin {
177
177
  return;
178
178
  }
179
179
  const addEntrySpan = parentSpan.traceChild('add-entry');
180
- addEntrySpan.setAttribute('request', entry.request);
180
+ // Only set request attribute if it's defined (Bun compatibility)
181
+ if (entry.request) {
182
+ addEntrySpan.setAttribute('request', entry.request);
183
+ }
181
184
  spans.set(entry, addEntrySpan);
182
185
  });
183
186
  compilation.hooks.succeedEntry.tap(pluginName, (entry)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/build/webpack/plugins/profiling-plugin.ts"],"sourcesContent":["import { NormalModule } from 'next/dist/compiled/webpack/webpack'\nimport type { Span } from '../../../trace'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport path from 'path'\n\nconst pluginName = 'ProfilingPlugin'\nexport const spans = new WeakMap<webpack.Compilation | webpack.Compiler, Span>()\nconst moduleSpansByCompilation = new WeakMap<\n webpack.Compilation,\n WeakMap<webpack.Module, Span>\n>()\nconst makeSpanByCompilation = new WeakMap<webpack.Compilation, Span>()\nconst sealSpanByCompilation = new WeakMap<webpack.Compilation, Span>()\nexport const webpackInvalidSpans = new WeakMap<any, Span>()\n\nconst TRACE_LABELS_SEAL = [\n 'module assets',\n 'create chunk assets',\n 'asset render',\n 'asset emit',\n 'store asset',\n]\n\nfunction inTraceLabelsSeal(label: string) {\n return TRACE_LABELS_SEAL.some((l) => label.startsWith(l))\n}\n\nexport class ProfilingPlugin {\n compiler: any\n runWebpackSpan: Span\n rootDir: string\n\n constructor({\n runWebpackSpan,\n rootDir,\n }: {\n runWebpackSpan: Span\n rootDir: string\n }) {\n this.runWebpackSpan = runWebpackSpan\n this.rootDir = rootDir\n }\n apply(compiler: any) {\n this.traceTopLevelHooks(compiler)\n this.traceCompilationHooks(compiler)\n this.compiler = compiler\n }\n\n traceHookPair(\n spanName: string | (() => string),\n startHook: any,\n stopHook: any,\n {\n parentSpan,\n attrs,\n onStart,\n onStop,\n }: {\n parentSpan?: (...params: any[]) => Span\n attrs?: any\n onStart?: (span: Span, ...params: any[]) => void\n onStop?: (span: Span, ...params: any[]) => void\n } = {}\n ) {\n let span: Span | undefined\n startHook.tap(\n { name: pluginName, stage: -Infinity },\n (...params: any[]) => {\n const name = typeof spanName === 'function' ? spanName() : spanName\n const attributes = attrs ? attrs(...params) : attrs\n span = parentSpan\n ? parentSpan(...params).traceChild(name, attributes)\n : this.runWebpackSpan.traceChild(name, attributes)\n\n if (onStart) onStart(span, ...params)\n }\n )\n stopHook.tap({ name: pluginName, stage: Infinity }, (...params: any[]) => {\n // `stopHook` may be triggered when `startHook` has not in cases\n // where `stopHook` is used as the terminating event for more\n // than one pair of hooks.\n if (!span) {\n return\n }\n\n if (onStop) onStop(span, ...params)\n span.stop()\n })\n }\n\n traceTopLevelHooks(compiler: any) {\n this.traceHookPair(\n 'webpack-compilation',\n compiler.hooks.compilation,\n compiler.hooks.afterCompile,\n {\n parentSpan: () =>\n webpackInvalidSpans.get(compiler) || this.runWebpackSpan,\n attrs: () => ({ name: compiler.name }),\n onStart: (span, compilation) => {\n spans.set(compilation, span)\n spans.set(compiler, span)\n moduleSpansByCompilation.set(compilation, new WeakMap())\n },\n }\n )\n\n if (compiler.options.mode === 'development') {\n this.traceHookPair(\n () => `webpack-invalidated-${compiler.name}`,\n compiler.hooks.invalid,\n compiler.hooks.done,\n {\n onStart: (span) => webpackInvalidSpans.set(compiler, span),\n onStop: () => webpackInvalidSpans.delete(compiler),\n attrs: (fileName: any) => ({\n trigger: fileName\n ? path.relative(this.rootDir, fileName).replaceAll(path.sep, '/')\n : 'manual',\n }),\n }\n )\n }\n }\n\n traceCompilationHooks(compiler: any) {\n this.traceHookPair('emit', compiler.hooks.emit, compiler.hooks.afterEmit, {\n parentSpan: () =>\n webpackInvalidSpans.get(compiler) || this.runWebpackSpan,\n })\n\n this.traceHookPair('make', compiler.hooks.make, compiler.hooks.finishMake, {\n parentSpan: (compilation) => {\n const compilationSpan = spans.get(compilation)\n if (!compilationSpan) {\n return webpackInvalidSpans.get(compiler) || this.runWebpackSpan\n }\n\n return compilationSpan\n },\n onStart: (span, compilation) => {\n makeSpanByCompilation.set(compilation, span)\n },\n onStop: (_span, compilation) => {\n makeSpanByCompilation.delete(compilation)\n },\n })\n\n compiler.hooks.compilation.tap(\n { name: pluginName, stage: -Infinity },\n (compilation: any) => {\n compilation.hooks.buildModule.tap(pluginName, (module: any) => {\n const moduleType = (() => {\n const r = module.userRequest\n if (!r || r.endsWith('!')) {\n return ''\n } else {\n const resource = r.split('!').pop()\n const match = /^[^?]+\\.([^?]+)$/.exec(resource)\n return match ? match[1] : ''\n }\n })()\n\n const issuerModule = compilation?.moduleGraph?.getIssuer(module)\n\n let span: Span\n\n const moduleSpans = moduleSpansByCompilation.get(compilation)\n const spanName = `build-module${moduleType ? `-${moduleType}` : ''}`\n const issuerSpan: Span | undefined =\n issuerModule && moduleSpans?.get(issuerModule)\n if (issuerSpan) {\n span = issuerSpan.traceChild(spanName)\n } else {\n let parentSpan: Span | undefined\n for (const incomingConnection of compilation.moduleGraph.getIncomingConnections(\n module\n )) {\n const entrySpan = spans.get(incomingConnection.dependency)\n if (entrySpan) {\n parentSpan = entrySpan\n break\n }\n }\n\n if (!parentSpan) {\n const compilationSpan = spans.get(compilation)\n if (!compilationSpan) {\n return\n }\n\n parentSpan = compilationSpan\n }\n span = parentSpan.traceChild(spanName)\n }\n span.setAttribute('name', module.userRequest)\n span.setAttribute('layer', module.layer)\n moduleSpans!.set(module, span)\n })\n\n const moduleHooks = NormalModule.getCompilationHooks(compilation)\n moduleHooks.readResource.for(undefined).intercept({\n register(tapInfo: any) {\n const fn = tapInfo.fn\n tapInfo.fn = (loaderContext: any, callback: any) => {\n fn(loaderContext, (err: any, result: any) => {\n callback(err, result)\n })\n }\n return tapInfo\n },\n })\n\n moduleHooks.loader.tap(\n pluginName,\n (loaderContext: any, module: any) => {\n const moduleSpan = moduleSpansByCompilation\n .get(compilation)\n ?.get(module)\n loaderContext.currentTraceSpan = moduleSpan\n }\n )\n\n compilation.hooks.succeedModule.tap(pluginName, (module: any) => {\n moduleSpansByCompilation?.get(compilation)?.get(module)?.stop()\n })\n compilation.hooks.failedModule.tap(pluginName, (module: any) => {\n moduleSpansByCompilation?.get(compilation)?.get(module)?.stop()\n })\n\n this.traceHookPair(\n 'seal',\n compilation.hooks.seal,\n compilation.hooks.afterSeal,\n {\n parentSpan: () => spans.get(compilation)!,\n onStart(span) {\n sealSpanByCompilation.set(compilation, span)\n },\n onStop() {\n sealSpanByCompilation.delete(compilation)\n },\n }\n )\n\n compilation.hooks.addEntry.tap(pluginName, (entry: any) => {\n const parentSpan =\n makeSpanByCompilation.get(compilation) || spans.get(compilation)\n if (!parentSpan) {\n return\n }\n const addEntrySpan = parentSpan.traceChild('add-entry')\n addEntrySpan.setAttribute('request', entry.request)\n spans.set(entry, addEntrySpan)\n })\n\n compilation.hooks.succeedEntry.tap(pluginName, (entry: any) => {\n spans.get(entry)?.stop()\n spans.delete(entry)\n })\n compilation.hooks.failedEntry.tap(pluginName, (entry: any) => {\n spans.get(entry)?.stop()\n spans.delete(entry)\n })\n\n this.traceHookPair(\n 'chunk-graph',\n compilation.hooks.beforeChunks,\n compilation.hooks.afterChunks,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize',\n compilation.hooks.optimize,\n compilation.hooks.reviveModules,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize-modules',\n compilation.hooks.optimizeModules,\n compilation.hooks.afterOptimizeModules,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize-chunks',\n compilation.hooks.optimizeChunks,\n compilation.hooks.afterOptimizeChunks,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize-tree',\n compilation.hooks.optimizeTree,\n compilation.hooks.afterOptimizeTree,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize-chunk-modules',\n compilation.hooks.optimizeChunkModules,\n compilation.hooks.afterOptimizeChunkModules,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'module-hash',\n compilation.hooks.beforeModuleHash,\n compilation.hooks.afterModuleHash,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'code-generation',\n compilation.hooks.beforeCodeGeneration,\n compilation.hooks.afterCodeGeneration,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'hash',\n compilation.hooks.beforeHash,\n compilation.hooks.afterHash,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'code-generation-jobs',\n compilation.hooks.afterHash,\n compilation.hooks.beforeModuleAssets,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n\n const logs = new Map()\n const originalTime = compilation.logger.time\n const originalTimeEnd = compilation.logger.timeEnd\n\n compilation.logger.time = (label: string) => {\n if (!inTraceLabelsSeal(label)) {\n return originalTime.call(compilation.logger, label)\n }\n const span = sealSpanByCompilation.get(compilation)\n if (span) {\n logs.set(label, span.traceChild(label.replace(/ /g, '-')))\n }\n return originalTime.call(compilation.logger, label)\n }\n compilation.logger.timeEnd = (label: string) => {\n if (!inTraceLabelsSeal(label)) {\n return originalTimeEnd.call(compilation.logger, label)\n }\n\n const span = logs.get(label)\n if (span) {\n span.stop()\n logs.delete(label)\n }\n return originalTimeEnd.call(compilation.logger, label)\n }\n }\n )\n }\n}\n"],"names":["NormalModule","path","pluginName","spans","WeakMap","moduleSpansByCompilation","makeSpanByCompilation","sealSpanByCompilation","webpackInvalidSpans","TRACE_LABELS_SEAL","inTraceLabelsSeal","label","some","l","startsWith","ProfilingPlugin","constructor","runWebpackSpan","rootDir","apply","compiler","traceTopLevelHooks","traceCompilationHooks","traceHookPair","spanName","startHook","stopHook","parentSpan","attrs","onStart","onStop","span","tap","name","stage","Infinity","params","attributes","traceChild","stop","hooks","compilation","afterCompile","get","set","options","mode","invalid","done","delete","fileName","trigger","relative","replaceAll","sep","emit","afterEmit","make","finishMake","compilationSpan","_span","buildModule","module","moduleType","r","userRequest","endsWith","resource","split","pop","match","exec","issuerModule","moduleGraph","getIssuer","moduleSpans","issuerSpan","incomingConnection","getIncomingConnections","entrySpan","dependency","setAttribute","layer","moduleHooks","getCompilationHooks","readResource","for","undefined","intercept","register","tapInfo","fn","loaderContext","callback","err","result","loader","moduleSpan","currentTraceSpan","succeedModule","failedModule","seal","afterSeal","addEntry","entry","addEntrySpan","request","succeedEntry","failedEntry","beforeChunks","afterChunks","optimize","reviveModules","optimizeModules","afterOptimizeModules","optimizeChunks","afterOptimizeChunks","optimizeTree","afterOptimizeTree","optimizeChunkModules","afterOptimizeChunkModules","beforeModuleHash","afterModuleHash","beforeCodeGeneration","afterCodeGeneration","beforeHash","afterHash","beforeModuleAssets","logs","Map","originalTime","logger","time","originalTimeEnd","timeEnd","call","replace"],"mappings":"AAAA,SAASA,YAAY,QAAQ,qCAAoC;AAGjE,OAAOC,UAAU,OAAM;AAEvB,MAAMC,aAAa;AACnB,OAAO,MAAMC,QAAQ,IAAIC,UAAuD;AAChF,MAAMC,2BAA2B,IAAID;AAIrC,MAAME,wBAAwB,IAAIF;AAClC,MAAMG,wBAAwB,IAAIH;AAClC,OAAO,MAAMI,sBAAsB,IAAIJ,UAAoB;AAE3D,MAAMK,oBAAoB;IACxB;IACA;IACA;IACA;IACA;CACD;AAED,SAASC,kBAAkBC,KAAa;IACtC,OAAOF,kBAAkBG,IAAI,CAAC,CAACC,IAAMF,MAAMG,UAAU,CAACD;AACxD;AAEA,OAAO,MAAME;IAKXC,YAAY,EACVC,cAAc,EACdC,OAAO,EAIR,CAAE;QACD,IAAI,CAACD,cAAc,GAAGA;QACtB,IAAI,CAACC,OAAO,GAAGA;IACjB;IACAC,MAAMC,QAAa,EAAE;QACnB,IAAI,CAACC,kBAAkB,CAACD;QACxB,IAAI,CAACE,qBAAqB,CAACF;QAC3B,IAAI,CAACA,QAAQ,G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BAAkB,EACpC;gBACEpG,YAAY,IACVpB,sBAAsBoC,GAAG,CAACF,gBAAgBtC,MAAMwC,GAAG,CAACF;YACxD;YAGF,MAAMuF,OAAO,IAAIC;YACjB,MAAMC,eAAezF,YAAY0F,MAAM,CAACC,IAAI;YAC5C,MAAMC,kBAAkB5F,YAAY0F,MAAM,CAACG,OAAO;YAElD7F,YAAY0F,MAAM,CAACC,IAAI,GAAG,CAACzH;gBACzB,IAAI,CAACD,kBAAkBC,QAAQ;oBAC7B,OAAOuH,aAAaK,IAAI,CAAC9F,YAAY0F,MAAM,EAAExH;gBAC/C;gBACA,MAAMoB,OAAOxB,sBAAsBoC,GAAG,CAACF;gBACvC,IAAIV,MAAM;oBACRiG,KAAKpF,GAAG,CAACjC,OAAOoB,KAAKO,UAAU,CAAC3B,MAAM6H,OAAO,CAAC,MAAM;gBACtD;gBACA,OAAON,aAAaK,IAAI,CAAC9F,YAAY0F,MAAM,EAAExH;YAC/C;YACA8B,YAAY0F,MAAM,CAACG,OAAO,GAAG,CAAC3H;gBAC5B,IAAI,CAACD,kBAAkBC,QAAQ;oBAC7B,OAAO0H,gBAAgBE,IAAI,CAAC9F,YAAY0F,MAAM,EAAExH;gBAClD;gBAEA,MAAMoB,OAAOiG,KAAKrF,GAAG,CAAChC;gBACtB,IAAIoB,MAAM;oBACRA,KAAKQ,IAAI;oBACTyF,KAAK/E,MAAM,CAACtC;gBACd;gBACA,OAAO0H,gBAAgBE,IAAI,CAAC9F,YAAY0F,MAAM,EAAExH;YAClD;QACF;IAEJ;AACF","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../../src/build/webpack/plugins/profiling-plugin.ts"],"sourcesContent":["import { NormalModule } from 'next/dist/compiled/webpack/webpack'\nimport type { Span } from '../../../trace'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport path from 'path'\n\nconst pluginName = 'ProfilingPlugin'\nexport const spans = new WeakMap<webpack.Compilation | webpack.Compiler, Span>()\nconst moduleSpansByCompilation = new WeakMap<\n webpack.Compilation,\n WeakMap<webpack.Module, Span>\n>()\nconst makeSpanByCompilation = new WeakMap<webpack.Compilation, Span>()\nconst sealSpanByCompilation = new WeakMap<webpack.Compilation, Span>()\nexport const webpackInvalidSpans = new WeakMap<any, Span>()\n\nconst TRACE_LABELS_SEAL = [\n 'module assets',\n 'create chunk assets',\n 'asset render',\n 'asset emit',\n 'store asset',\n]\n\nfunction inTraceLabelsSeal(label: string) {\n return TRACE_LABELS_SEAL.some((l) => label.startsWith(l))\n}\n\nexport class ProfilingPlugin {\n compiler: any\n runWebpackSpan: Span\n rootDir: string\n\n constructor({\n runWebpackSpan,\n rootDir,\n }: {\n runWebpackSpan: Span\n rootDir: string\n }) {\n this.runWebpackSpan = runWebpackSpan\n this.rootDir = rootDir\n }\n apply(compiler: any) {\n this.traceTopLevelHooks(compiler)\n this.traceCompilationHooks(compiler)\n this.compiler = compiler\n }\n\n traceHookPair(\n spanName: string | (() => string),\n startHook: any,\n stopHook: any,\n {\n parentSpan,\n attrs,\n onStart,\n onStop,\n }: {\n parentSpan?: (...params: any[]) => Span\n attrs?: any\n onStart?: (span: Span, ...params: any[]) => void\n onStop?: (span: Span, ...params: any[]) => void\n } = {}\n ) {\n let span: Span | undefined\n startHook.tap(\n { name: pluginName, stage: -Infinity },\n (...params: any[]) => {\n const name = typeof spanName === 'function' ? spanName() : spanName\n const attributes = attrs ? attrs(...params) : attrs\n span = parentSpan\n ? parentSpan(...params).traceChild(name, attributes)\n : this.runWebpackSpan.traceChild(name, attributes)\n\n if (onStart) onStart(span, ...params)\n }\n )\n stopHook.tap({ name: pluginName, stage: Infinity }, (...params: any[]) => {\n // `stopHook` may be triggered when `startHook` has not in cases\n // where `stopHook` is used as the terminating event for more\n // than one pair of hooks.\n if (!span) {\n return\n }\n\n if (onStop) onStop(span, ...params)\n span.stop()\n })\n }\n\n traceTopLevelHooks(compiler: any) {\n this.traceHookPair(\n 'webpack-compilation',\n compiler.hooks.compilation,\n compiler.hooks.afterCompile,\n {\n parentSpan: () =>\n webpackInvalidSpans.get(compiler) || this.runWebpackSpan,\n attrs: () => ({ name: compiler.name }),\n onStart: (span, compilation) => {\n spans.set(compilation, span)\n spans.set(compiler, span)\n moduleSpansByCompilation.set(compilation, new WeakMap())\n },\n }\n )\n\n if (compiler.options.mode === 'development') {\n this.traceHookPair(\n () => `webpack-invalidated-${compiler.name}`,\n compiler.hooks.invalid,\n compiler.hooks.done,\n {\n onStart: (span) => webpackInvalidSpans.set(compiler, span),\n onStop: () => webpackInvalidSpans.delete(compiler),\n attrs: (fileName: any) => ({\n trigger: fileName\n ? path.relative(this.rootDir, fileName).replaceAll(path.sep, '/')\n : 'manual',\n }),\n }\n )\n }\n }\n\n traceCompilationHooks(compiler: any) {\n this.traceHookPair('emit', compiler.hooks.emit, compiler.hooks.afterEmit, {\n parentSpan: () =>\n webpackInvalidSpans.get(compiler) || this.runWebpackSpan,\n })\n\n this.traceHookPair('make', compiler.hooks.make, compiler.hooks.finishMake, {\n parentSpan: (compilation) => {\n const compilationSpan = spans.get(compilation)\n if (!compilationSpan) {\n return webpackInvalidSpans.get(compiler) || this.runWebpackSpan\n }\n\n return compilationSpan\n },\n onStart: (span, compilation) => {\n makeSpanByCompilation.set(compilation, span)\n },\n onStop: (_span, compilation) => {\n makeSpanByCompilation.delete(compilation)\n },\n })\n\n compiler.hooks.compilation.tap(\n { name: pluginName, stage: -Infinity },\n (compilation: any) => {\n compilation.hooks.buildModule.tap(pluginName, (module: any) => {\n const moduleType = (() => {\n const r = module.userRequest\n if (!r || r.endsWith('!')) {\n return ''\n } else {\n const resource = r.split('!').pop()\n const match = /^[^?]+\\.([^?]+)$/.exec(resource)\n return match ? match[1] : ''\n }\n })()\n\n const issuerModule = compilation?.moduleGraph?.getIssuer(module)\n\n let span: Span\n\n const moduleSpans = moduleSpansByCompilation.get(compilation)\n const spanName = `build-module${moduleType ? `-${moduleType}` : ''}`\n const issuerSpan: Span | undefined =\n issuerModule && moduleSpans?.get(issuerModule)\n if (issuerSpan) {\n span = issuerSpan.traceChild(spanName)\n } else {\n let parentSpan: Span | undefined\n for (const incomingConnection of compilation.moduleGraph.getIncomingConnections(\n module\n )) {\n const entrySpan = spans.get(incomingConnection.dependency)\n if (entrySpan) {\n parentSpan = entrySpan\n break\n }\n }\n\n if (!parentSpan) {\n const compilationSpan = spans.get(compilation)\n if (!compilationSpan) {\n return\n }\n\n parentSpan = compilationSpan\n }\n span = parentSpan.traceChild(spanName)\n }\n span.setAttribute('name', module.userRequest)\n span.setAttribute('layer', module.layer)\n moduleSpans!.set(module, span)\n })\n\n const moduleHooks = NormalModule.getCompilationHooks(compilation)\n moduleHooks.readResource.for(undefined).intercept({\n register(tapInfo: any) {\n const fn = tapInfo.fn\n tapInfo.fn = (loaderContext: any, callback: any) => {\n fn(loaderContext, (err: any, result: any) => {\n callback(err, result)\n })\n }\n return tapInfo\n },\n })\n\n moduleHooks.loader.tap(\n pluginName,\n (loaderContext: any, module: any) => {\n const moduleSpan = moduleSpansByCompilation\n .get(compilation)\n ?.get(module)\n loaderContext.currentTraceSpan = moduleSpan\n }\n )\n\n compilation.hooks.succeedModule.tap(pluginName, (module: any) => {\n moduleSpansByCompilation?.get(compilation)?.get(module)?.stop()\n })\n compilation.hooks.failedModule.tap(pluginName, (module: any) => {\n moduleSpansByCompilation?.get(compilation)?.get(module)?.stop()\n })\n\n this.traceHookPair(\n 'seal',\n compilation.hooks.seal,\n compilation.hooks.afterSeal,\n {\n parentSpan: () => spans.get(compilation)!,\n onStart(span) {\n sealSpanByCompilation.set(compilation, span)\n },\n onStop() {\n sealSpanByCompilation.delete(compilation)\n },\n }\n )\n\n compilation.hooks.addEntry.tap(pluginName, (entry: any) => {\n const parentSpan =\n makeSpanByCompilation.get(compilation) || spans.get(compilation)\n if (!parentSpan) {\n return\n }\n const addEntrySpan = parentSpan.traceChild('add-entry')\n // Only set request attribute if it's defined (Bun compatibility)\n if (entry.request) {\n addEntrySpan.setAttribute('request', entry.request)\n }\n spans.set(entry, addEntrySpan)\n })\n\n compilation.hooks.succeedEntry.tap(pluginName, (entry: any) => {\n spans.get(entry)?.stop()\n spans.delete(entry)\n })\n compilation.hooks.failedEntry.tap(pluginName, (entry: any) => {\n spans.get(entry)?.stop()\n spans.delete(entry)\n })\n\n this.traceHookPair(\n 'chunk-graph',\n compilation.hooks.beforeChunks,\n compilation.hooks.afterChunks,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize',\n compilation.hooks.optimize,\n compilation.hooks.reviveModules,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize-modules',\n compilation.hooks.optimizeModules,\n compilation.hooks.afterOptimizeModules,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize-chunks',\n compilation.hooks.optimizeChunks,\n compilation.hooks.afterOptimizeChunks,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize-tree',\n compilation.hooks.optimizeTree,\n compilation.hooks.afterOptimizeTree,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'optimize-chunk-modules',\n compilation.hooks.optimizeChunkModules,\n compilation.hooks.afterOptimizeChunkModules,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'module-hash',\n compilation.hooks.beforeModuleHash,\n compilation.hooks.afterModuleHash,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'code-generation',\n compilation.hooks.beforeCodeGeneration,\n compilation.hooks.afterCodeGeneration,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'hash',\n compilation.hooks.beforeHash,\n compilation.hooks.afterHash,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n this.traceHookPair(\n 'code-generation-jobs',\n compilation.hooks.afterHash,\n compilation.hooks.beforeModuleAssets,\n {\n parentSpan: () =>\n sealSpanByCompilation.get(compilation) || spans.get(compilation)!,\n }\n )\n\n const logs = new Map()\n const originalTime = compilation.logger.time\n const originalTimeEnd = compilation.logger.timeEnd\n\n compilation.logger.time = (label: string) => {\n if (!inTraceLabelsSeal(label)) {\n return originalTime.call(compilation.logger, label)\n }\n const span = sealSpanByCompilation.get(compilation)\n if (span) {\n logs.set(label, span.traceChild(label.replace(/ /g, '-')))\n }\n return originalTime.call(compilation.logger, label)\n }\n compilation.logger.timeEnd = (label: string) => {\n if (!inTraceLabelsSeal(label)) {\n return originalTimeEnd.call(compilation.logger, label)\n }\n\n const span = logs.get(label)\n if (span) {\n span.stop()\n logs.delete(label)\n }\n return originalTimeEnd.call(compilation.logger, label)\n }\n }\n )\n }\n}\n"],"names":["NormalModule","path","pluginName","spans","WeakMap","moduleSpansByCompilation","makeSpanByCompilation","sealSpanByCompilation","webpackInvalidSpans","TRACE_LABELS_SEAL","inTraceLabelsSeal","label","some","l","startsWith","ProfilingPlugin","constructor","runWebpackSpan","rootDir","apply","compiler","traceTopLevelHooks","traceCompilationHooks","traceHookPair","spanName","startHook","stopHook","parentSpan","attrs","onStart","onStop","span","tap","name","stage","Infinity","params","attributes","traceChild","stop","hooks","compilation","afterCompile","get","set","options","mode","invalid","done","delete","fileName","trigger","relative","replaceAll","sep","emit","afterEmit","make","finishMake","compilationSpan","_span","buildModule","module","moduleType","r","userRequest","endsWith","resource","split","pop","match","exec","issuerModule","moduleGraph","getIssuer","moduleSpans","issuerSpan","incomingConnection","getIncomingConnections","entrySpan","dependency","setAttribute","layer","moduleHooks","getCompilationHooks","readResource","for","undefined","intercept","register","tapInfo","fn","loaderContext","callback","err","result","loader","moduleSpan","currentTraceSpan","succeedModule","failedModule","seal","afterSeal","addEntry","entry","addEntrySpan","request","succeedEntry","failedEntry","beforeChunks","afterChunks","optimize","reviveModules","optimizeModules","afterOptimizeModules","optimizeChunks","afterOptimizeChunks","optimizeTree","afterOptimizeTree","optimizeChunkModules","afterOptimizeChunkModules","beforeModuleHash","afterModuleHash","beforeCodeGeneration","afterCodeGeneration","beforeHash","afterHash","beforeModuleAssets","logs","Map","originalTime","logger","time","originalTimeEnd","timeEnd","call","replace"],"mappings":"AAAA,SAASA,YAAY,QAAQ,qCAAoC;AAGjE,OAAOC,UAAU,OAAM;AAEvB,MAAMC,aAAa;AACnB,OAAO,MAAMC,QAAQ,IAAIC,UAAuD;AAChF,MAAMC,2BAA2B,IAAID;AAIrC,MAAME,wBAAwB,IAAIF;AAClC,MAAMG,wBAAwB,IAAIH;AAClC,OAAO,MAAMI,sBAAsB,IAAIJ,UAAoB;AAE3D,MAAMK,oBAAoB;IACxB;IACA;IACA;IACA;IACA;CACD;AAED,SAASC,kBAAkBC,KAAa;IACtC,OAAOF,kBAAkBG,IAAI,CAAC,CAACC,IAAMF,MAAMG,UAAU,CAACD;AACxD;AAEA,OAAO,MAAME;IAKXC,YAAY,EACVC,cAAc,EACdC,OAAO,EAIR,CAAE;QACD,IAAI,CAACD,cAAc,GAAGA;QACtB,IAAI,CAACC,OAAO,GAAGA;IACjB;IACAC,MAAMC,QAAa,EAAE;QACnB,IAAI,CAACC,kBAAkB,CAACD;QACxB,IAAI,CAACE,qBAAqB,CAACF;QAC3B,IAAI,CAACA,QAAQ,GAAGA;IAClB;IAEAG,cACEC,QAAiC,EACjCC,SAAc,EACdC,QAAa,EACb,EACEC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,MAAM,EAMP,GAAG,CAAC,CAAC,EACN;QACA,IAAIC;QACJN,UAAUO,GAAG,CACX;YAAEC,MAAM/B;YAAYgC,OAAO,CAACC;QAAS,GACrC,CAAC,GAAGC;YACF,M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kB5F,YAAY0F,MAAM,CAACG,OAAO;YAElD7F,YAAY0F,MAAM,CAACC,IAAI,GAAG,CAACzH;gBACzB,IAAI,CAACD,kBAAkBC,QAAQ;oBAC7B,OAAOuH,aAAaK,IAAI,CAAC9F,YAAY0F,MAAM,EAAExH;gBAC/C;gBACA,MAAMoB,OAAOxB,sBAAsBoC,GAAG,CAACF;gBACvC,IAAIV,MAAM;oBACRiG,KAAKpF,GAAG,CAACjC,OAAOoB,KAAKO,UAAU,CAAC3B,MAAM6H,OAAO,CAAC,MAAM;gBACtD;gBACA,OAAON,aAAaK,IAAI,CAAC9F,YAAY0F,MAAM,EAAExH;YAC/C;YACA8B,YAAY0F,MAAM,CAACG,OAAO,GAAG,CAAC3H;gBAC5B,IAAI,CAACD,kBAAkBC,QAAQ;oBAC7B,OAAO0H,gBAAgBE,IAAI,CAAC9F,YAAY0F,MAAM,EAAExH;gBAClD;gBAEA,MAAMoB,OAAOiG,KAAKrF,GAAG,CAAChC;gBACtB,IAAIoB,MAAM;oBACRA,KAAKQ,IAAI;oBACTyF,KAAK/E,MAAM,CAACtC;gBACd;gBACA,OAAO0H,gBAAgBE,IAAI,CAAC9F,YAAY0F,MAAM,EAAExH;YAClD;QACF;IAEJ;AACF","ignoreList":[0]}
@@ -64,6 +64,8 @@ function buildManifest(_compiler, compilation, projectSrcDir, dev, shouldCreateD
64
64
  // We construct a "unique" key from origin module and request
65
65
  // It's not perfect unique, but that will be fine for us.
66
66
  // We also need to construct the same in the babel plugin.
67
+ // Skip if dependency.request is undefined (Bun compatibility)
68
+ if (!dependency.request) return;
67
69
  const key = `${path.relative(projectSrcDir, originRequest)} -> ${dependency.request}`;
68
70
  // Capture all files that need to be loaded.
69
71
  const files = new Set();