未验证 提交 7c30bf97 编写于 作者: J JJ Kasper 提交者: GitHub

Re-add require cache clearing (#7674)

上级 e7110a03
......@@ -7,6 +7,18 @@ export default function worker(
try {
const { serverBundle, runtimeEnvConfig } = options || ({} as any)
const isStatic = isPageStatic(serverBundle, runtimeEnvConfig)
// clear require.cache to prevent running out of memory
// since the cache is persisted by default
Object.keys(require.cache).map(modId => {
const mod = require.cache[modId]
delete require.cache[modId]
if (mod.parent) {
const idx = mod.parent.children.indexOf(mod)
mod.parent.children.splice(idx, 1)
}
})
callback(null, { isStatic })
} catch (error) {
callback(error)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册