File size: 1,597 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type {
  MiddlewareConfig,
  MiddlewareMatcher,
  RSCModuleType,
} from '../../analysis/get-page-static-info'
import type { webpack } from 'next/dist/compiled/webpack/webpack'

export type ModuleBuildInfo = {
  nextEdgeMiddleware?: EdgeMiddlewareMeta
  nextEdgeApiFunction?: EdgeMiddlewareMeta
  nextEdgeSSR?: EdgeSSRMeta
  nextWasmMiddlewareBinding?: AssetBinding
  nextAssetMiddlewareBinding?: AssetBinding
  usingIndirectEval?: boolean | Set<string>
  route?: RouteMeta
  importLocByPath?: Map<string, any>
  rootDir?: string
  rsc?: RSCMeta
}

/**
 * A getter for module build info that casts to the type it should have.
 * We also expose here types to make easier to use it.
 */
export function getModuleBuildInfo(webpackModule: webpack.Module) {
  return webpackModule.buildInfo as ModuleBuildInfo
}

export interface RSCMeta {
  type: RSCModuleType
  actionIds?: Record<string, string>
  clientRefs?: string[]
  clientEntryType?: 'cjs' | 'auto'
  isClientRef?: boolean
  requests?: string[] // client requests in flight client entry
}

export interface RouteMeta {
  page: string
  absolutePagePath: string
  preferredRegion: string | string[] | undefined
  middlewareConfig: MiddlewareConfig
  // references to other modules that this route needs
  // e.g. related routes, not-found routes, etc
  relatedModules?: string[]
}

export interface EdgeMiddlewareMeta {
  page: string
  matchers?: MiddlewareMatcher[]
}

export interface EdgeSSRMeta {
  isServerComponent: boolean
  isAppDir?: boolean
  page: string
}

export interface AssetBinding {
  filePath: string
  name: string
}