Skip to content

Commit

Permalink
fix: make ssr-plugin compatible with wp4/5(vuejs#11718)
Browse files Browse the repository at this point in the history
  • Loading branch information
lduoduo committed Dec 9, 2020
1 parent 4f81b5d commit b641e1b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/server/webpack-plugin/client.js
Expand Up @@ -19,6 +19,20 @@ export default class VueSSRClientPlugin {
const initialFiles = uniq(Object.keys(stats.entrypoints)
.map(name => stats.entrypoints[name].assets)
.reduce((assets, all) => all.concat(assets), [])
.map(function (file) {
if (typeof file === "string") {
return file;
}

if (
Object.prototype.toString.call(file) === "[object Object]" &&
file.name
) {
return file.name;
}

throw new Error(`file structure is not correct: ${file}`);
})
.filter((file) => isJS(file) || isCSS(file)))

const asyncFiles = allFiles
Expand Down
16 changes: 15 additions & 1 deletion src/server/webpack-plugin/server.js
Expand Up @@ -20,7 +20,21 @@ export default class VueSSRServerPlugin {
return cb()
}

const entryAssets = entryInfo.assets.filter(isJS)
const entryAssets = entryInfo.assets
.map(function (file) {
if (typeof file === "string") {
return file;
}

if (
Object.prototype.toString.call(file) === "[object Object]" &&
file.name
) {
return file.name;
}

throw new Error(`file structure is not correct: ${file}`);
}).filter(isJS)

if (entryAssets.length > 1) {
throw new Error(
Expand Down

0 comments on commit b641e1b

Please sign in to comment.