rsnext/packages/next/build/webpack/loaders/get-module-build-info.ts
Gal Schlezinger 401a9a4479
Allow Middleware to set its matcher (#37177)
This PR will allow Middleware to set its matcher through `export const config = { matching: ... }`

## Related

* This PR is rebased off #37121 

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-06-03 16:35:44 +00:00

36 lines
833 B
TypeScript

import { webpack5 } 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: webpack5.Module) {
return webpackModule.buildInfo as {
nextEdgeMiddleware?: EdgeMiddlewareMeta
nextEdgeSSR?: EdgeSSRMeta
nextUsedEnvVars?: Set<string>
nextWasmMiddlewareBinding?: WasmBinding
usingIndirectEval?: boolean | Set<string>
route?: RouteMeta
}
}
export interface RouteMeta {
page: string
absolutePagePath: string
}
export interface EdgeMiddlewareMeta {
page: string
matcherRegexp?: string
}
export interface EdgeSSRMeta {
isServerComponent: boolean
page: string
}
export interface WasmBinding {
filePath: string
name: string
}