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

Optimize client entry creation #51849

Merged
merged 6 commits into from
Jun 27, 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
4 changes: 2 additions & 2 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { WellKnownErrorsPlugin } from './webpack/plugins/wellknown-errors-plugin
import { regexLikeCss } from './webpack/config/blocks/css'
import { CopyFilePlugin } from './webpack/plugins/copy-file-plugin'
import { ClientReferenceManifestPlugin } from './webpack/plugins/flight-manifest-plugin'
import { ClientReferenceEntryPlugin } from './webpack/plugins/flight-client-entry-plugin'
import { FlightClientEntryPlugin } from './webpack/plugins/flight-client-entry-plugin'
import { NextTypesPlugin } from './webpack/plugins/next-types-plugin'
import type {
Feature,
Expand Down Expand Up @@ -2420,7 +2420,7 @@ export default async function getBaseWebpackConfig(
dev,
appDir,
})
: new ClientReferenceEntryPlugin({
: new FlightClientEntryPlugin({
appDir,
dev,
isEdgeServer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getModuleBuildInfo } from '../get-module-build-info'

const noopHeadPath = require.resolve('next/dist/client/components/noop-head')

export default async function transformSource(
export default function transformSource(
this: any,
source: string,
sourceMap: any
Expand All @@ -21,8 +21,6 @@ export default async function transformSource(
? 'next/dist/esm/build/webpack/loaders/next-flight-loader/module-proxy'
: 'next/dist/build/webpack/loaders/next-flight-loader/module-proxy'

const callback = this.async()

// Assign the RSC meta information to buildInfo.
// Exclude next internal files which are not marked as client files
const buildInfo = getModuleBuildInfo(this._module)
Expand Down Expand Up @@ -55,11 +53,12 @@ export default async function transformSource(

if (assumedSourceType === 'module') {
if (clientRefs.includes('*')) {
return callback(
this.callback(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not adding this.async() you can also return [code, map] and throw for errors.

new Error(
`It's currently unsupported to use "export *" in a client boundary. Please use named exports instead.`
)
)
return
}

let esmSource = `\
Expand Down Expand Up @@ -88,7 +87,8 @@ export { e${cnt++} as ${ref} };`
}
}

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

Expand All @@ -100,7 +100,7 @@ export { e${cnt++} as ${ref} };`
}
}

return callback(
this.callback(
null,
source.replace(RSC_MOD_REF_PROXY_ALIAS, moduleProxy),
sourceMap
Expand Down