From 64ca193ac9b636607f2fb16f37a8b78a14627922 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 17 Feb 2021 20:39:02 +0100 Subject: [PATCH] fix(webpack): remove hmr chunks from client manifest --- packages/nuxt3/src/builder/webpack/plugins/vue/client.ts | 8 ++++++-- packages/nuxt3/src/builder/webpack/plugins/vue/util.ts | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/nuxt3/src/builder/webpack/plugins/vue/client.ts b/packages/nuxt3/src/builder/webpack/plugins/vue/client.ts index 74be040311..ac2f1588a1 100644 --- a/packages/nuxt3/src/builder/webpack/plugins/vue/client.ts +++ b/packages/nuxt3/src/builder/webpack/plugins/vue/client.ts @@ -8,7 +8,7 @@ import hash from 'hash-sum' import uniq from 'lodash/uniq' import { writeFile, mkdirp } from 'fs-extra' -import { isJS, isCSS } from './util' +import { isJS, isCSS, isHotUpdate } from './util' export default class VueSSRClientPlugin { options: { @@ -27,19 +27,23 @@ export default class VueSSRClientPlugin { const allFiles = uniq(stats.assets .map(a => a.name)) + .filter(file => !isHotUpdate(file)) const initialFiles = uniq(Object.keys(stats.entrypoints) .map(name => stats.entrypoints[name].assets) .reduce((files, entryAssets) => files.concat(entryAssets.map(entryAsset => entryAsset.name)), []) .filter(file => isJS(file) || isCSS(file))) + .filter(file => !isHotUpdate(file)) const asyncFiles = allFiles .filter(file => isJS(file) || isCSS(file)) .filter(file => !initialFiles.includes(file)) + .filter(file => !isHotUpdate(file)) const assetsMapping = {} stats.assets .filter(({ name }) => isJS(name)) + .filter(({ name }) => !isHotUpdate(name)) .forEach(({ name, chunkNames }) => { const componentHash = hash(chunkNames.join('|')) if (!assetsMapping[componentHash]) { @@ -69,7 +73,7 @@ export default class VueSSRClientPlugin { return } const id = m.identifier.replace(/\s\w+$/, '') // remove appended hash - const filesSet = new Set(chunk.files.map(fileToIndex)) + const filesSet = new Set(chunk.files.map(fileToIndex).filter(i => i !== -1)) for (const chunkName of chunk.names) { if (!entrypoints[chunkName]) { diff --git a/packages/nuxt3/src/builder/webpack/plugins/vue/util.ts b/packages/nuxt3/src/builder/webpack/plugins/vue/util.ts index e874c29bc5..6ce85fc9c6 100644 --- a/packages/nuxt3/src/builder/webpack/plugins/vue/util.ts +++ b/packages/nuxt3/src/builder/webpack/plugins/vue/util.ts @@ -30,3 +30,5 @@ export const isJS = file => isJSRegExp.test(file) export const extractQueryPartJS = file => isJSRegExp.exec(file)[1] export const isCSS = file => /\.css(\?[^.]+)?$/.test(file) + +export const isHotUpdate = file => file.includes('hot-update')