Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor some loaders to be synchronous #51997

Merged
merged 7 commits into from Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,7 +15,7 @@ export type EdgeAppRouteLoaderQuery = {
}

const EdgeAppRouteLoader: webpack.LoaderDefinitionFunction<EdgeAppRouteLoaderQuery> =
async function (this) {
function (this) {
const {
page,
absolutePagePath,
Expand Down
Expand Up @@ -39,7 +39,7 @@ function swapDistFolderWithEsmDistFolder(path: string) {
}

const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
async function edgeSSRLoader(this) {
function edgeSSRLoader(this) {
const {
dev,
page,
Expand Down
Expand Up @@ -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'
Expand Down
@@ -1,7 +1,7 @@
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
Expand All @@ -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)
Expand All @@ -31,5 +29,5 @@ ${source}
`
}

return callback(null, source, sourceMap)
return this.callback(null, source, sourceMap)
}