You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: vite-plugin-ssr/node/prerender/runPrerender.ts
+35-15
Original file line number
Diff line number
Diff line change
@@ -180,7 +180,7 @@ async function runPrerender(
180
180
assert(manuallyTriggered)
181
181
assertWarning(
182
182
prerenderConfig,
183
-
`You're executing \`${manuallyTriggered}\` but the config \`prerender\` isn't set to true`,
183
+
`You're executing ${pc.cyan(manuallyTriggered)} but the config ${pc.cyan('prerender')} isn't set to true`,
184
184
{
185
185
onlyOnce: true
186
186
}
@@ -625,7 +625,9 @@ async function callOnPrerenderStartHook(
625
625
}
626
626
627
627
consterrPrefix=`The ${hookName}() hook exported by ${hookFilePath}`
628
-
constrightUsage=`${errPrefix} should return \`null\`, \`undefined\`, or \`{ prerenderContext: { pageContexts } }\`.`
628
+
constrightUsage=`${errPrefix} should return ${pc.cyan('null')}, ${pc.cyan('undefined')}, or ${pc.cyan(
629
+
'{ prerenderContext: { pageContexts } }'
630
+
)}`
629
631
630
632
// TODO/v1-release: remove
631
633
if(hasProp(result,'globalContext')){
@@ -637,7 +639,9 @@ async function callOnPrerenderStartHook(
637
639
)
638
640
assertWarning(
639
641
false,
640
-
`${errPrefix} returns \`{ globalContext: { prerenderPageContexts } }\` but the return value has been renamed to \`{ prerenderContext: { pageContexts } }\`, see ${docLink}`,
642
+
`${errPrefix} returns ${pc.cyan(
643
+
'{ globalContext: { prerenderPageContexts } }'
644
+
)} but the return value has been renamed to ${pc.cyan('{ prerenderContext: { pageContexts } }')}, see ${docLink}`,
641
645
{onlyOnce: true}
642
646
)
643
647
result={
@@ -809,7 +813,9 @@ function warnMissingPages(
809
813
constpageAt=getPageAt(pageId)
810
814
assertWarning(
811
815
partial,
812
-
`Cannot pre-render page ${pageAt} because it has a non-static route, and no ${hookName}() hook returned (an) URL(s) matching the page's route. Either use a ${hookName}() hook to pre-render the page, or use the option \`prerender.partial\` to suppress this warning, see https://vite-plugin-ssr.com/prerender-config`,
816
+
`Cannot pre-render page ${pageAt} because it has a non-static route, and no ${hookName}() hook returned (an) URL(s) matching the page's route. Either use a ${hookName}() hook to pre-render the page, or use the option ${pc.cyan(
817
+
'prerender.partial'
818
+
)} to suppress this warning, see https://vite-plugin-ssr.com/prerender-config`,
813
819
{onlyOnce: true}
814
820
)
815
821
})
@@ -955,31 +961,39 @@ function normalizeOnPrerenderHookResult(
955
961
956
962
consterrMsg1=`The ${hookName}() hook defined by ${prerenderHookFile} returned`asconst
957
963
consterrMsg2=`${errMsg1} an invalid value`asconst
958
-
consterrHint=
959
-
`Make sure your ${hookName}() hook returns an object \`{ url, pageContext }\` or an array of such objects.`asconst
964
+
consterrHint=`Make sure your ${hookName}() hook returns an object ${pc.cyan(
@@ -156,8 +157,11 @@ function processHookReturnValue(hookReturnValue: unknown, renderHook: RenderHook
156
157
}
157
158
158
159
consterrPrefix=`The ${renderHook.hookNameasstring}() hook defined at ${renderHook.hookFilePath}`asconst
159
-
consterrSuffix=
160
-
'a string generated with the escapeInject`<html>...</html>` template tag or a string returned by dangerouslySkipEscape(), see https://vite-plugin-ssr.com/escapeInject'asconst
160
+
consterrSuffix=`a string generated with the ${pc.cyan(
161
+
'escapeInject`<html>...</html>`'
162
+
)} template tag or a string returned by ${pc.cyan(
163
+
'dangerouslySkipEscape()'
164
+
)}, see https://vite-plugin-ssr.com/escapeInject`asconst
161
165
if(typeofhookReturnValue==='string'){
162
166
assertWarning(
163
167
false,
@@ -172,7 +176,11 @@ function processHookReturnValue(hookReturnValue: unknown, renderHook: RenderHook
172
176
isObject(hookReturnValue),
173
177
[
174
178
errPrefix,
175
-
'should return `null`, a value `documentHtml`, or an object `{ documentHtml, pageContext }` where `pageContext` is `undefined` or an object holding additional pageContext values, and where `documentHtml` is',
179
+
`should return ${pc.cyan('null')}, the value ${pc.cyan('documentHtml')}, or an object ${pc.cyan(
180
+
'{ documentHtml, pageContext }'
181
+
)} where ${pc.cyan('pageContext')} is ${pc.cyan(
182
+
'undefined'
183
+
)} or an object holding additional pageContext values, and where ${pc.cyan('documentHtml')} is`,
176
184
errSuffix
177
185
].join(' ')
178
186
)
@@ -185,11 +193,15 @@ function processHookReturnValue(hookReturnValue: unknown, renderHook: RenderHook
185
193
186
194
if(hookReturnValue.documentHtml){
187
195
letval=hookReturnValue.documentHtml
188
-
consterrBegin=`${errPrefix} returned \`{ documentHtml }\`, but documentHtml`
196
+
consterrBegin=`${errPrefix} returned ${pc.cyan('{ documentHtml }')}, but ${pc.cyan('documentHtml')}`asconst
189
197
if(typeofval==='string'){
190
198
assertWarning(
191
199
false,
192
-
[errBegin,'is a plain JavaScript string which is dangerous: documentHtml should be',errSuffix].join(' '),
200
+
[
201
+
errBegin,
202
+
`is a plain JavaScript string which is dangerous: ${pc.cyan('documentHtml')} should be`,
203
+
errSuffix
204
+
].join(' '),
193
205
{onlyOnce: true}
194
206
)
195
207
val=dangerouslySkipEscape(val)
@@ -200,7 +212,7 @@ function processHookReturnValue(hookReturnValue: unknown, renderHook: RenderHook
200
212
201
213
if(hookReturnValue.pageContext){
202
214
constval=hookReturnValue.pageContext
203
-
consterrBegin=`${errPrefix} returned \`{ pageContext }\`, but pageContext`
215
+
consterrBegin=`${errPrefix} returned ${pc.cyan('{ pageContext }')}, but ${pc.cyan('pageContext')}`
0 commit comments