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

Assign layer to app client entries #43197

Merged
merged 12 commits into from Dec 7, 2022
19 changes: 16 additions & 3 deletions packages/next/build/entries.ts
Expand Up @@ -19,7 +19,7 @@ import {
SERVER_RUNTIME,
WEBPACK_LAYERS,
} from '../lib/constants'
import { RSC_MODULE_TYPES } from '../shared/lib/constants'
import { APP_CLIENT_INTERNALS, RSC_MODULE_TYPES } from '../shared/lib/constants'
import {
CLIENT_STATIC_FILES_RUNTIME_AMP,
CLIENT_STATIC_FILES_RUNTIME_MAIN,
Expand Down Expand Up @@ -517,6 +517,12 @@ export function finalizeEntrypoint({
}
}

const isAppLayer =
hasAppDir &&
(name === CLIENT_STATIC_FILES_RUNTIME_MAIN_APP ||
name === APP_CLIENT_INTERNALS ||
name.startsWith('app/'))

if (
// Client special cases
name !== CLIENT_STATIC_FILES_RUNTIME_POLYFILLS &&
Expand All @@ -525,10 +531,10 @@ export function finalizeEntrypoint({
name !== CLIENT_STATIC_FILES_RUNTIME_AMP &&
name !== CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH
) {
// TODO-APP: this is a temporary fix. @shuding is going to change the handling of server components
if (hasAppDir && entry.import.includes('next-flight-client-entry-loader')) {
if (isAppLayer) {
return {
dependOn: CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,
layer: WEBPACK_LAYERS.appClient,
...entry,
}
}
Expand All @@ -542,5 +548,12 @@ export function finalizeEntrypoint({
}
}

if (isAppLayer) {
return {
layer: WEBPACK_LAYERS.appClient,
...entry,
}
}

return entry
}
Expand Up @@ -65,6 +65,7 @@ export async function getNotFoundError(
column: loc.start.column,
source: originalSource,
rootDirectory: compilation.options.context!,
modulePath: fileName,
frame: {},
})

Expand Down
1 change: 1 addition & 0 deletions packages/next/lib/constants.ts
Expand Up @@ -76,4 +76,5 @@ export const WEBPACK_LAYERS = {
api: 'api',
middleware: 'middleware',
edgeAsset: 'edge-asset',
appClient: 'app-client',
}