295f9da393
## Feature Change server components convention from using `.server.js` / `.client.js` file extension to determine it's a server or client component to using `'client'` js literal as a directive for determine client components boundary. React RFC: https://github.com/reactjs/rfcs/pull/189 New behavior doesn't consume `.server.js` as server components any more, if you're enabling `serverComponents` flag, every `page.js` in app dir will become server components by default. If you adding a `'client'` directive to the page, then that page will become a client component. This rule also applies to the normal js components, client components will require a `'client'` directive to indicate its identity, instead of having a `.client.js` extension. - [x] 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` - [x] 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` Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import type {
|
|
MiddlewareMatcher,
|
|
RSCModuleType,
|
|
} 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
|
|
rsc?: RSCMeta
|
|
}
|
|
}
|
|
|
|
export interface RSCMeta {
|
|
type?: RSCModuleType
|
|
requests?: string[] // client requests in flight client entry
|
|
}
|
|
|
|
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
|
|
}
|