b122178ead
* (wip) * dev mode * build mode * update comment * fix tests * fix _N_SSP and _N_SSG exports * fix missing variables * fix api route bug * fix compiler stats * fix lint errors * add extra cache group for edge server * fix test * fix test * fix views route meta and entries * fix linter error Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
31 lines
562 B
TypeScript
31 lines
562 B
TypeScript
import { parse } from '../../swc'
|
|
|
|
export default async function transformSource(
|
|
this: any,
|
|
source: string
|
|
): Promise<string> {
|
|
const { resourcePath } = this
|
|
|
|
const ast = await parse(source, {
|
|
filename: resourcePath,
|
|
isModule: 'unknown',
|
|
})
|
|
const isModule = ast.type === 'Module'
|
|
|
|
return (
|
|
source +
|
|
(isModule
|
|
? `
|
|
export const __next_rsc__ = {
|
|
__webpack_require__,
|
|
server: true
|
|
}
|
|
`
|
|
: `
|
|
exports.__next_rsc__ = {
|
|
__webpack_require__,
|
|
server: true
|
|
}
|
|
`)
|
|
)
|
|
}
|