/
get-module-build-info.ts
42 lines (37 loc) · 1.06 KB
/
get-module-build-info.ts
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
import type { MiddlewareMatcher } from '../../analysis/get-page-static-info'
import { webpack } from 'next/dist/compiled/webpack/webpack'
/**
* 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 {
nextEdgeMiddleware?: EdgeMiddlewareMeta
nextEdgeApiFunction?: EdgeMiddlewareMeta
nextEdgeSSR?: EdgeSSRMeta
nextUsedEnvVars?: Set<string>
nextWasmMiddlewareBinding?: AssetBinding
nextAssetMiddlewareBinding?: AssetBinding
usingIndirectEval?: boolean | Set<string>
route?: RouteMeta
importLocByPath?: Map<string, any>
rootDir?: string
}
}
export interface RouteMeta {
page: string
absolutePagePath: string
}
export interface EdgeMiddlewareMeta {
page: string
matchers?: MiddlewareMatcher[]
}
export interface EdgeSSRMeta {
isServerComponent: boolean
isAppDir?: boolean
page: string
}
export interface AssetBinding {
filePath: string
name: string
}