b5aa571c71
WIP. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## 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 `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
35 lines
992 B
TypeScript
35 lines
992 B
TypeScript
export type ClientComponentImports = string[]
|
|
export type CssImports = Record<string, string[]>
|
|
|
|
export type NextFlightClientEntryLoaderOptions = {
|
|
modules: ClientComponentImports
|
|
/** This is transmitted as a string to `getOptions` */
|
|
server: boolean | 'true' | 'false'
|
|
}
|
|
|
|
export default async function transformSource(this: any): Promise<string> {
|
|
let { modules, server }: NextFlightClientEntryLoaderOptions =
|
|
this.getOptions()
|
|
const isServer = server === 'true'
|
|
|
|
if (!Array.isArray(modules)) {
|
|
modules = modules ? [modules] : []
|
|
}
|
|
|
|
const requests = modules as string[]
|
|
const code =
|
|
requests
|
|
// Filter out css files on the server
|
|
.filter((request) => (isServer ? !request.endsWith('.css') : true))
|
|
.map((request) => `import(/* webpackMode: "eager" */ '${request}')`)
|
|
.join(';\n') +
|
|
`
|
|
export const __next_rsc__ = {
|
|
server: false,
|
|
__webpack_require__
|
|
};
|
|
export default function RSC() {};
|
|
`
|
|
|
|
return code
|
|
}
|