Skip to content

Commit

Permalink
update serverless plugin to use webpack 5 apis (#31058)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
shuding and kodiakhq[bot] committed Nov 6, 2021
1 parent fab345d commit d2c1888
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/next/build/webpack/plugins/serverless-plugin.ts
Expand Up @@ -14,7 +14,8 @@ export class ServerlessPlugin {
hook.tap('ServerlessPlugin', (chunks) => {
for (const chunk of chunks) {
// If chunk is not an entry point skip them
if (!chunk.hasEntryModule()) {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
if (compilation.chunkGraph.getNumberOfEntryModules(chunk) === 0) {
continue
}

Expand All @@ -26,7 +27,11 @@ export class ServerlessPlugin {
dynamicChunk
)) {
// Add module back into the entry chunk
chunk.addModule(module)
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) {
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
compilation.chunkGraph.connectChunkAndModule(chunk, module)
}
}
}
}
Expand Down

0 comments on commit d2c1888

Please sign in to comment.