Skip to content

Commit 397aed8

Browse files
committed
Use emitAsset
1 parent 26a3b4c commit 397aed8

File tree

2 files changed

+47
-39
lines changed

2 files changed

+47
-39
lines changed

packages/next/src/build/webpack/plugins/build-manifest-plugin.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export default class BuildManifestPlugin {
201201
this.rewrites.fallback = options.rewrites.fallback.map(processRoute)
202202
}
203203

204-
createAssets(compiler: any, compilation: any, assets: any) {
204+
createAssets(compiler: any, compilation: any) {
205205
const compilationSpan = spans.get(compilation) || spans.get(compiler)
206206
const createAssetsSpan = (
207207
compilationSpan || new Span({ name: '' })
@@ -299,7 +299,10 @@ export default class BuildManifestPlugin {
299299
this.buildId
300300
)
301301
assetMap.lowPriorityFiles.push(buildManifestPath, ssgManifestPath)
302-
assets[ssgManifestPath] = new sources.RawSource(srcEmptySsgManifest)
302+
compilation.emitAsset(
303+
ssgManifestPath,
304+
new sources.RawSource(srcEmptySsgManifest)
305+
)
303306
}
304307

305308
assetMap.pages = Object.keys(assetMap.pages)
@@ -316,29 +319,30 @@ export default class BuildManifestPlugin {
316319
buildManifestName = `fallback-${BUILD_MANIFEST}`
317320
}
318321

319-
assets[buildManifestName] = new sources.RawSource(
320-
JSON.stringify(assetMap, null, 2)
322+
compilation.emitAsset(
323+
buildManifestName,
324+
new sources.RawSource(JSON.stringify(assetMap, null, 2))
321325
)
322326

323-
assets[`server/${MIDDLEWARE_BUILD_MANIFEST}.js`] = new sources.RawSource(
324-
`${createEdgeRuntimeManifest(assetMap)}`
327+
compilation.emitAsset(
328+
`server/${MIDDLEWARE_BUILD_MANIFEST}.js`,
329+
new sources.RawSource(`${createEdgeRuntimeManifest(assetMap)}`)
325330
)
326331

327332
if (!this.isDevFallback) {
328-
const clientManifestPath = `${CLIENT_STATIC_FILES_PATH}/${this.buildId}/_buildManifest.js`
329-
330-
assets[clientManifestPath] = new sources.RawSource(
331-
`self.__BUILD_MANIFEST = ${generateClientManifest(
332-
assetMap,
333-
this.rewrites,
334-
this.clientRouterFilters,
335-
compiler,
336-
compilation
337-
)};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()`
333+
compilation.emitAsset(
334+
`${CLIENT_STATIC_FILES_PATH}/${this.buildId}/_buildManifest.js`,
335+
new sources.RawSource(
336+
`self.__BUILD_MANIFEST = ${generateClientManifest(
337+
assetMap,
338+
this.rewrites,
339+
this.clientRouterFilters,
340+
compiler,
341+
compilation
342+
)};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()`
343+
)
338344
)
339345
}
340-
341-
return assets
342346
})
343347
}
344348

@@ -349,8 +353,8 @@ export default class BuildManifestPlugin {
349353
name: 'NextJsBuildManifest',
350354
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
351355
},
352-
(assets: any) => {
353-
this.createAssets(compiler, compilation, assets)
356+
() => {
357+
this.createAssets(compiler, compilation)
354358
}
355359
)
356360
})

packages/next/src/build/webpack/plugins/pages-manifest-plugin.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ export default class PagesManifestPlugin
134134
} else {
135135
const pagesManifestPath =
136136
(!this.dev && !this.isEdgeRuntime ? '../' : '') + PAGES_MANIFEST
137-
assets[pagesManifestPath] = new sources.RawSource(
138-
JSON.stringify(
139-
{
140-
...edgeServerPages,
141-
...nodeServerPages,
142-
},
143-
null,
144-
2
137+
compilation.emitAsset(
138+
pagesManifestPath,
139+
new sources.RawSource(
140+
JSON.stringify(
141+
{
142+
...edgeServerPages,
143+
...nodeServerPages,
144+
},
145+
null,
146+
2
147+
)
145148
)
146149
)
147150
}
@@ -158,16 +161,17 @@ export default class PagesManifestPlugin
158161
...nodeServerAppPaths,
159162
})
160163
} else {
161-
assets[
162-
(!this.dev && !this.isEdgeRuntime ? '../' : '') + APP_PATHS_MANIFEST
163-
] = new sources.RawSource(
164-
JSON.stringify(
165-
{
166-
...edgeServerAppPaths,
167-
...nodeServerAppPaths,
168-
},
169-
null,
170-
2
164+
compilation.emitAsset(
165+
(!this.dev && !this.isEdgeRuntime ? '../' : '') + APP_PATHS_MANIFEST,
166+
new sources.RawSource(
167+
JSON.stringify(
168+
{
169+
...edgeServerAppPaths,
170+
...nodeServerAppPaths,
171+
},
172+
null,
173+
2
174+
)
171175
)
172176
)
173177
}
@@ -181,7 +185,7 @@ export default class PagesManifestPlugin
181185
name: 'NextJsPagesManifest',
182186
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
183187
},
184-
(assets) => this.createAssets(compilation, assets)
188+
() => this.createAssets(compilation)
185189
)
186190
})
187191
}

0 commit comments

Comments
 (0)