Unverified Commit 2a230397 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Assign layer to app client entries (#43197)

This is one of the required changes to refactor bundling strategy for
pages and app.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent dbc83344
...@@ -19,7 +19,7 @@ import { ...@@ -19,7 +19,7 @@ import {
SERVER_RUNTIME, SERVER_RUNTIME,
WEBPACK_LAYERS, WEBPACK_LAYERS,
} from '../lib/constants' } from '../lib/constants'
import { RSC_MODULE_TYPES } from '../shared/lib/constants' import { APP_CLIENT_INTERNALS, RSC_MODULE_TYPES } from '../shared/lib/constants'
import { import {
CLIENT_STATIC_FILES_RUNTIME_AMP, CLIENT_STATIC_FILES_RUNTIME_AMP,
CLIENT_STATIC_FILES_RUNTIME_MAIN, CLIENT_STATIC_FILES_RUNTIME_MAIN,
...@@ -517,6 +517,12 @@ export function finalizeEntrypoint({ ...@@ -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 ( if (
// Client special cases // Client special cases
name !== CLIENT_STATIC_FILES_RUNTIME_POLYFILLS && name !== CLIENT_STATIC_FILES_RUNTIME_POLYFILLS &&
...@@ -525,10 +531,10 @@ export function finalizeEntrypoint({ ...@@ -525,10 +531,10 @@ export function finalizeEntrypoint({
name !== CLIENT_STATIC_FILES_RUNTIME_AMP && name !== CLIENT_STATIC_FILES_RUNTIME_AMP &&
name !== CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH 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 (isAppLayer) {
if (hasAppDir && entry.import.includes('next-flight-client-entry-loader')) {
return { return {
dependOn: CLIENT_STATIC_FILES_RUNTIME_MAIN_APP, dependOn: CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,
layer: WEBPACK_LAYERS.appClient,
...entry, ...entry,
} }
} }
...@@ -542,5 +548,12 @@ export function finalizeEntrypoint({ ...@@ -542,5 +548,12 @@ export function finalizeEntrypoint({
} }
} }
if (isAppLayer) {
return {
layer: WEBPACK_LAYERS.appClient,
...entry,
}
}
return entry return entry
} }
...@@ -65,6 +65,7 @@ export async function getNotFoundError( ...@@ -65,6 +65,7 @@ export async function getNotFoundError(
column: loc.start.column, column: loc.start.column,
source: originalSource, source: originalSource,
rootDirectory: compilation.options.context!, rootDirectory: compilation.options.context!,
modulePath: fileName,
frame: {}, frame: {},
}) })
......
...@@ -76,4 +76,5 @@ export const WEBPACK_LAYERS = { ...@@ -76,4 +76,5 @@ export const WEBPACK_LAYERS = {
api: 'api', api: 'api',
middleware: 'middleware', middleware: 'middleware',
edgeAsset: 'edge-asset', edgeAsset: 'edge-asset',
appClient: 'app-client',
} }
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