Skip to content

Commit 58f8b2f

Browse files
committedSep 7, 2023
fix: improve error message about non-default exports
1 parent d294ca3 commit 58f8b2f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed
 

‎vite-plugin-ssr/utils/assertDefaultExport.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ function assertSingleDefaultExport(
5656
)
5757
}
5858
} else if (!FILES_WITH_SIDE_EXPORTS.some((ext) => filePath.endsWith(ext))) {
59-
const exportsInvalidStr = exportsInvalid.join(', ')
6059
if (defaultExportValueIsUnknown) {
61-
assertWarning(
62-
exportsInvalid.length === 0,
63-
`${filePath} should only have a default export: remove ${pc.cyan(`export { ${exportsInvalidStr} }`)}`,
64-
{ onlyOnce: true }
65-
)
60+
exportsInvalid.forEach((exportInvalid) => {
61+
assertWarning(
62+
exportsInvalid.length === 0,
63+
`${filePath} should only have a default export: move ${pc.cyan(
64+
`export { ${exportInvalid} }`
65+
)} to +config.h.js or its own +${exportsInvalid}.js`,
66+
{ onlyOnce: true }
67+
)
68+
})
6669
} else {
70+
const exportsInvalidStr = exportsInvalid.join(', ')
6771
assertWarning(
6872
exportsInvalid.length === 0,
6973
`${filePath} replace ${pc.cyan(`export { ${exportsInvalidStr} }`)} with ${pc.cyan(

0 commit comments

Comments
 (0)
Please sign in to comment.