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 client entry plugin to separate methods. #39162

Merged
merged 42 commits into from Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6f56156
Refactor client entry plugin to separate methods.
timneutkens Jul 29, 2022
aea276b
Remove runtime and ssr options on flight-client-entry-plugin
timneutkens Jul 29, 2022
4395c74
Change name to entryName
timneutkens Jul 29, 2022
4ee4b92
Port changes from https://github.com/vercel/next.js/pull/39166
timneutkens Jul 29, 2022
72e7a57
Make layers constants
timneutkens Jul 30, 2022
9bc1b4b
Add modules into existing server compilation entry
timneutkens Jul 31, 2022
9bdc6f2
Remove extra condition
timneutkens Jul 31, 2022
11a266c
Update comment
timneutkens Jul 31, 2022
4d867ff
Add types for getCssInlinedLinkTags
timneutkens Jul 31, 2022
b83c332
Remove NEXT_CLIENT_SSR_ENTRY_SUFFIX / require for the separate bundle
timneutkens Jul 31, 2022
6a593ce
Update handling of clientLoader
timneutkens Aug 1, 2022
218369d
Add ChildEntry type
timneutkens Aug 1, 2022
cb34665
Use same request between dev/prod
timneutkens Aug 1, 2022
f2d1e6f
Rename request to relativeRequest
timneutkens Aug 1, 2022
3f208af
Rename type -> compilerType
timneutkens Aug 1, 2022
2666a3f
Move bundlePath type
timneutkens Aug 1, 2022
cc6a153
Rename clientLoader to request
timneutkens Aug 1, 2022
0d7bebb
Update comment
timneutkens Aug 1, 2022
24b5295
Use request for entry
timneutkens Aug 1, 2022
aeae993
generate server css manifest
shuding Aug 2, 2022
3398960
use server css manifest
shuding Aug 2, 2022
9485448
inject css into the correct level
shuding Aug 4, 2022
683eab8
Fix type for id
timneutkens Aug 5, 2022
79a293b
Add check for invalidation and overriding of existing loader
timneutkens Aug 5, 2022
47e0062
Use FlightCSSManifest type and rename variable
timneutkens Aug 5, 2022
9e6f167
Only invalidate client compiler when adding client compiler entries
timneutkens Aug 5, 2022
1ecde5c
Refactor handling of on-demand-entries invalidation
timneutkens Aug 8, 2022
998d600
Update more cases to COMPILER_NAMES
timneutkens Aug 8, 2022
7f988dc
Ensure rebuildAgain is correctly checked
timneutkens Aug 8, 2022
2349cc0
comment out new style injection
shuding Aug 8, 2022
b525238
merge canary
shuding Aug 9, 2022
21954f5
fix test
shuding Aug 10, 2022
e851052
fix bad conflict resolution
shuding Aug 10, 2022
6c2e455
fix lint error
shuding Aug 10, 2022
4e4641d
merge canary
shuding Aug 10, 2022
b2dadce
merge canary
shuding Aug 11, 2022
f3b793b
fix invalidator
shuding Aug 11, 2022
ed05b1d
fix entrypoint sets
shuding Aug 11, 2022
b4ae9e9
merge canary
shuding Aug 11, 2022
17ad000
fix entrypoint sets
shuding Aug 12, 2022
66d3513
fix linter and use set for BuildingTracker and RebuildTracker
shuding Aug 12, 2022
523a6ec
Merge branch 'canary' into add/css-handling-flight-entry
shuding Aug 12, 2022
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
@@ -1,33 +1,40 @@
import { SERVER_RUNTIME } from '../../../lib/constants'
export type ClientComponentImports = string[]
export type CssImports = Record<string, string[]>

export type NextFlightClientEntryLoaderOptions = {
modules: ClientComponentImports
/**
* Stringified version of CssImports
*/
css: string
/** This is transmitted as a string to `getOptions` */
server: boolean | 'true' | 'false'
}

export default async function transformSource(this: any): Promise<string> {
let { modules, runtime, ssr, server } = this.getOptions()
let { modules, css, server }: NextFlightClientEntryLoaderOptions =
this.getOptions()
const isServer = server === 'true'

if (!Array.isArray(modules)) {
modules = modules ? [modules] : []
}

const requests = modules as string[]
const code =
requests
.filter((request) => (server ? !request.endsWith('.css') : true))
// Filter out css files on the server
.filter((request) => (isServer ? !request.endsWith('.css') : true))
.map((request) => `import(/* webpackMode: "eager" */ '${request}')`)
.join(';\n') +
`
export const __next_rsc_css__ = ${JSON.stringify(
requests.filter((request) => request.endsWith('.css'))
)};
export const __next_rsc_css__ = ${server ? css : 'null'};
export const __next_rsc__ = {
server: false,
__webpack_require__
};
export default function RSC() {};
` +
// Currently for the Edge runtime, we treat all RSC pages as SSR pages.
(runtime === SERVER_RUNTIME.edge
? 'export const __N_SSP = true;'
: ssr
? `export const __N_SSP = true;`
: `export const __N_SSG = true;`)
`

return code
}