Unverified Commit 61ac9299 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Refactor some loaders to be synchronous (#51997)

This PR changes some Webpack loaders to be synchronous as they don't have async code inside. Some of them will scale quiet a lot such as `next-flight-client-module-loader` and we don't want to waste some extra ticks there, as well as got potentially queued after some other events like file I/O.
parent 54a963b6
......@@ -15,7 +15,7 @@ export type EdgeAppRouteLoaderQuery = {
}
const EdgeAppRouteLoader: webpack.LoaderDefinitionFunction<EdgeAppRouteLoaderQuery> =
async function (this) {
function (this) {
const {
page,
absolutePagePath,
......
......@@ -39,7 +39,7 @@ function swapDistFolderWithEsmDistFolder(path: string) {
}
const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
async function edgeSSRLoader(this) {
function edgeSSRLoader(this) {
const {
dev,
page,
......
......@@ -11,7 +11,7 @@ export type NextFlightClientEntryLoaderOptions = {
server: boolean | 'true' | 'false'
}
export default async function transformSource(this: any): Promise<string> {
export default function transformSource(this: any) {
let { modules, server }: NextFlightClientEntryLoaderOptions =
this.getOptions()
const isServer = server === 'true'
......
import { getRSCModuleInformation } from '../../analysis/get-page-static-info'
import { getModuleBuildInfo } from './get-module-build-info'
export default async function transformSource(
export default function transformSource(
this: any,
source: string,
sourceMap: any
......@@ -11,8 +11,6 @@ export default async function transformSource(
throw new Error('Expected source to have been transformed to a string.')
}
const callback = this.async()
// Assign the RSC meta information to buildInfo.
const buildInfo = getModuleBuildInfo(this._module)
buildInfo.rsc = getRSCModuleInformation(source, false)
......@@ -31,5 +29,5 @@ ${source}
`
}
return callback(null, source, sourceMap)
return this.callback(null, source, sourceMap)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment