Skip to content

Commit 358cfb3

Browse files
committed
Make dynamic import support to work with HMR.
1 parent 93da57e commit 358cfb3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

server/build/plugins/dynamic-chunks-plugin.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ export default class PagesPlugin {
2626
source: () => newContent,
2727
size: () => newContent.length
2828
}
29+
30+
// This is to support, webpack dynamic import support with HMR
31+
compilation.assets[`chunks/${chunk.id}`] = {
32+
source: () => newContent,
33+
size: () => newContent.length
34+
}
2935
})
3036
callback()
3137
})

server/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ export default class Server {
106106
await this.serveStatic(req, res, p)
107107
},
108108

109+
// This is to support, webpack dynamic import support with HMR
110+
'/_next/webpack/:id': async (req, res, params) => {
111+
const p = join(this.dir, '.next', 'chunks', params.id)
112+
await this.serveStatic(req, res, p)
113+
},
114+
109115
'/_next/:hash/manifest.js': async (req, res, params) => {
110116
this.handleBuildHash('manifest.js', params.hash, res)
111117
const p = join(this.dir, `${this.dist}/manifest.js`)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy