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

Fix missing cleanup process in flight plugin globals #43297

Merged
merged 8 commits into from Nov 29, 2022
Merged
Changes from 2 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 @@ -3,6 +3,8 @@ import type {
ClientComponentImports,
NextFlightClientEntryLoaderOptions,
} from '../loaders/next-flight-client-entry-loader'
import type { FlightCSSManifest } from './flight-manifest-plugin'

import { webpack } from 'next/dist/compiled/webpack/webpack'
import { stringify } from 'querystring'
import path from 'path'
Expand All @@ -19,7 +21,6 @@ import {
EDGE_RUNTIME_WEBPACK,
FLIGHT_SERVER_CSS_MANIFEST,
} from '../../../shared/lib/constants'
import { FlightCSSManifest } from './flight-manifest-plugin'
import { ASYNC_CLIENT_MODULES } from './flight-manifest-plugin'
import { isClientComponentModule, regexCSS } from '../loaders/utils'
import { traverseModules } from '../utils'
Expand All @@ -37,9 +38,6 @@ export const injectedClientEntries = new Map()
export const serverModuleIds = new Map<string, string | number>()
export const edgeServerModuleIds = new Map<string, string | number>()

// TODO-APP: move CSS manifest generation to the flight manifest plugin.
Copy link
Member Author

Choose a reason for hiding this comment

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

No longer valid.

const flightCSSManifest: FlightCSSManifest = {}

export class FlightClientEntryPlugin {
dev: boolean
appDir: string
Expand Down Expand Up @@ -111,6 +109,12 @@ export class FlightClientEntryPlugin {
}
}

if (this.isEdgeServer) {
edgeServerModuleIds.clear()
} else {
serverModuleIds.clear()
}

traverseModules(compilation, (mod, _chunk, _chunkGroup, modId) => {
recordModule(modId + '', mod)
})
Expand All @@ -121,6 +125,7 @@ export class FlightClientEntryPlugin {
const promises: Array<
ReturnType<typeof this.injectClientEntryAndSSRModules>
> = []
let flightCSSManifest: FlightCSSManifest = {}

// Loop over all the entry modules.
function forEachEntryModule(
Expand Down Expand Up @@ -234,6 +239,7 @@ export class FlightClientEntryPlugin {
// by the certain chunk.
compilation.hooks.afterOptimizeModules.tap(PLUGIN_NAME, () => {
const cssImportsForChunk: Record<string, string[]> = {}
flightCSSManifest = {}

function collectModule(entryName: string, mod: any) {
const resource = mod.resource
Expand Down