Skip to content

Commit bfdc77b

Browse files
pi0pooya parsa
authored andcommitted
fix(vue-app): sanitize layouts after resolve for splitChunks.layout (nuxt#7139)
1 parent 487c13e commit bfdc77b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/vue-app/template/App.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ import '<%= relativeToBuild(resolvePath(c.src || c, { isStyle: true })) %>'
1818
<% if (features.layouts) { %>
1919
<%= Object.keys(layouts).map((key) => {
2020
if (splitChunks.layouts) {
21-
return `const _${hash(key)} = () => import('${layouts[key]}' /* webpackChunkName: "${wChunk('layouts/' + key)}" */).then(m => m.default || m)`
21+
return `const _${hash(key)} = () => import('${layouts[key]}' /* webpackChunkName: "${wChunk('layouts/' + key)}" */).then(m => sanitizeComponent(m.default || m))`
2222
} else {
2323
return `import _${hash(key)} from '${layouts[key]}'`
2424
}
2525
}).join('\n') %>
2626

27+
<% if (splitChunks.layouts) { %>
28+
let resolvedLayouts = {}
29+
const layouts = { <%= Object.keys(layouts).map(key => `"_${key}": _${hash(key)}`).join(',') %> }<%= isTest ? '// eslint-disable-line' : '' %>
30+
<% } else { %>
2731
const layouts = { <%= Object.keys(layouts).map(key => `"_${key}": sanitizeComponent(_${hash(key)})`).join(',') %> }<%= isTest ? '// eslint-disable-line' : '' %>
32+
<% } %>
2833

29-
<% if (splitChunks.layouts) { %>let resolvedLayouts = {}<% } %>
3034
<% } %>
3135

3236
export default {

test/fixtures/basic/nuxt.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default {
8181
scopeHoisting: true,
8282
publicPath: '',
8383
followSymlinks: true,
84+
splitChunks: {
85+
layouts: true
86+
},
8487
postcss: {
8588
preset: {
8689
features: {

0 commit comments

Comments
 (0)