vike 0.4.193 → 0.4.195-commit-486b49a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/RenderErrorPage.js +1 -0
- package/__internal/setup.js +1 -0
- package/__internal.js +1 -0
- package/abort.js +1 -0
- package/cli.js +1 -0
- package/client/router.js +1 -0
- package/client.js +1 -0
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +2 -2
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +4 -9
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -13
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -24
- package/dist/cjs/node/plugin/shared/loggerVite.js +0 -3
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +2 -2
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +17 -12
- package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/html/injectAssets.js +2 -2
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/cjs/node/runtime/renderPage/assertArguments.js +3 -3
- package/dist/cjs/node/runtime/renderPage/{createHttpResponseObject.js → createHttpResponse.js} +34 -15
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +3 -5
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +4 -3
- package/dist/cjs/node/runtime/renderPage/inferMediaType.js +3 -0
- package/dist/cjs/node/runtime/renderPage/isConfigInvalid.js +4 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -12
- package/dist/cjs/node/runtime/renderPage.js +62 -66
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -2
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/isArray.js +1 -1
- package/dist/cjs/utils/parseUrl-extras.js +6 -1
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +2 -2
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +30 -15
- package/dist/esm/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +2 -2
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd/log.d.ts +0 -7
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +0 -12
- package/dist/esm/node/plugin/shared/loggerNotProd.d.ts +1 -7
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -24
- package/dist/esm/node/plugin/shared/loggerVite.js +1 -4
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +17 -12
- package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets.js +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/esm/node/runtime/renderPage/assertArguments.js +3 -3
- package/dist/esm/node/runtime/renderPage/{createHttpResponseObject.d.ts → createHttpResponse.d.ts} +13 -5
- package/dist/esm/node/runtime/renderPage/{createHttpResponseObject.js → createHttpResponse.js} +34 -15
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +3 -5
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +4 -3
- package/dist/esm/node/runtime/renderPage/inferMediaType.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/inferMediaType.js +3 -0
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.d.ts +6 -2
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.js +6 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +5 -11
- package/dist/esm/node/runtime/renderPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage.js +62 -66
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/page-configs/Config.d.ts +2 -2
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +1 -2
- package/dist/esm/shared/route/abort.d.ts +3 -3
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/isArray.js +1 -1
- package/dist/esm/utils/parseUrl-extras.d.ts +2 -0
- package/dist/esm/utils/parseUrl-extras.js +5 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +69 -68
- package/plugin.js +1 -0
- package/prerender.js +1 -0
- package/routing.js +1 -0
- package/server.js +1 -0
- /package/dist/cjs/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/assertNoInfiniteHttpRedirect.js +0 -0
- /package/dist/cjs/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/getCacheControl.js +0 -0
- /package/dist/esm/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/assertNoInfiniteHttpRedirect.d.ts +0 -0
- /package/dist/esm/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/assertNoInfiniteHttpRedirect.js +0 -0
- /package/dist/esm/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/getCacheControl.d.ts +0 -0
- /package/dist/esm/node/runtime/renderPage/{createHttpResponseObject → createHttpResponse}/getCacheControl.js +0 -0
|
@@ -11,7 +11,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
11
11
|
const serializePageContextClientSide_js_1 = require("../html/serializePageContextClientSide.js");
|
|
12
12
|
const getPageContextUrlComputed_js_1 = require("../../../shared/getPageContextUrlComputed.js");
|
|
13
13
|
const globalContext_js_1 = require("../globalContext.js");
|
|
14
|
-
const
|
|
14
|
+
const createHttpResponse_js_1 = require("./createHttpResponse.js");
|
|
15
15
|
const loadUserFilesServerSide_js_1 = require("./loadUserFilesServerSide.js");
|
|
16
16
|
const executeOnRenderHtmlHook_js_1 = require("./executeOnRenderHtmlHook.js");
|
|
17
17
|
const executeOnBeforeRenderAndDataHooks_js_1 = require("./executeOnBeforeRenderAndDataHooks.js");
|
|
@@ -52,21 +52,15 @@ async function renderPageAlreadyRouted(pageContext) {
|
|
|
52
52
|
(0, utils_js_1.objectAssign)(pageContext, { [isServerSideError_js_1.isServerSideError]: true });
|
|
53
53
|
}
|
|
54
54
|
const pageContextSerialized = (0, serializePageContextClientSide_js_1.serializePageContextClientSide)(pageContext);
|
|
55
|
-
const httpResponse = await (0,
|
|
55
|
+
const httpResponse = await (0, createHttpResponse_js_1.createHttpResponsePageContextJson)(pageContextSerialized);
|
|
56
56
|
(0, utils_js_1.objectAssign)(pageContext, { httpResponse });
|
|
57
57
|
return pageContext;
|
|
58
58
|
}
|
|
59
59
|
const renderHookResult = await (0, executeOnRenderHtmlHook_js_1.executeOnRenderHtmlHook)(pageContext);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
else {
|
|
65
|
-
const { htmlRender, renderHook } = renderHookResult;
|
|
66
|
-
const httpResponse = await (0, createHttpResponseObject_js_1.createHttpResponseObject)(htmlRender, renderHook, pageContext);
|
|
67
|
-
(0, utils_js_1.objectAssign)(pageContext, { httpResponse });
|
|
68
|
-
return pageContext;
|
|
69
|
-
}
|
|
60
|
+
const { htmlRender, renderHook } = renderHookResult;
|
|
61
|
+
const httpResponse = await (0, createHttpResponse_js_1.createHttpResponsePage)(htmlRender, renderHook, pageContext);
|
|
62
|
+
(0, utils_js_1.objectAssign)(pageContext, { httpResponse });
|
|
63
|
+
return pageContext;
|
|
70
64
|
}
|
|
71
65
|
exports.renderPageAlreadyRouted = renderPageAlreadyRouted;
|
|
72
66
|
async function prerenderPage(pageContext) {
|
|
@@ -10,7 +10,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
10
10
|
const abort_js_1 = require("../../shared/route/abort.js");
|
|
11
11
|
const globalContext_js_1 = require("./globalContext.js");
|
|
12
12
|
const handlePageContextRequestUrl_js_1 = require("./renderPage/handlePageContextRequestUrl.js");
|
|
13
|
-
const
|
|
13
|
+
const createHttpResponse_js_1 = require("./renderPage/createHttpResponse.js");
|
|
14
14
|
const loggerRuntime_js_1 = require("./renderPage/loggerRuntime.js");
|
|
15
15
|
const isNewError_js_1 = require("./renderPage/isNewError.js");
|
|
16
16
|
const assertArguments_js_1 = require("./renderPage/assertArguments.js");
|
|
@@ -23,8 +23,7 @@ const handleErrorWithoutErrorPage_js_1 = require("./renderPage/handleErrorWithou
|
|
|
23
23
|
const loadUserFilesServerSide_js_1 = require("./renderPage/loadUserFilesServerSide.js");
|
|
24
24
|
const resolveRedirects_js_1 = require("./renderPage/resolveRedirects.js");
|
|
25
25
|
const globalObject = (0, utils_js_1.getGlobalObject)('runtime/renderPage.ts', {
|
|
26
|
-
httpRequestsCount: 0
|
|
27
|
-
pendingRequestsCount: 0
|
|
26
|
+
httpRequestsCount: 0
|
|
28
27
|
});
|
|
29
28
|
let renderPage_wrapper = async (_httpRequestId, ret) => ({
|
|
30
29
|
pageContextReturn: await ret()
|
|
@@ -36,33 +35,35 @@ exports.renderPage_addWrapper = renderPage_addWrapper;
|
|
|
36
35
|
// `renderPage()` calls `renderPageNominal()` while ensuring that errors are `console.error(err)` instead of `throw err`, so that Vike never triggers a server shut down. (Throwing an error in an Express.js middleware shuts down the whole Express.js server.)
|
|
37
36
|
async function renderPage(pageContextInit) {
|
|
38
37
|
(0, assertArguments_js_1.assertArguments)(...arguments);
|
|
39
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContextInit, 'urlOriginal', 'string'));
|
|
38
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContextInit, 'urlOriginal', 'string')); // assertUsage() already implemented at assertArguments()
|
|
40
39
|
(0, utils_js_1.assertEnv)();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
assertIsUrl(pageContextInit.urlOriginal);
|
|
41
|
+
const urlPathnameWithBase = (0, utils_js_1.parseUrl)(pageContextInit.urlOriginal, '/').pathname;
|
|
42
|
+
assertIsNotViteRequest(urlPathnameWithBase, pageContextInit.urlOriginal);
|
|
43
|
+
if (urlPathnameWithBase.endsWith('/favicon.ico'))
|
|
44
|
+
return getPageContextHttpResponseFavicon404(pageContextInit);
|
|
46
45
|
const httpRequestId = getRequestId();
|
|
47
|
-
const
|
|
48
|
-
logHttpRequest(
|
|
49
|
-
globalObject.pendingRequestsCount++;
|
|
46
|
+
const urlOriginalPretty = (0, utils_js_1.getUrlPretty)(pageContextInit.urlOriginal);
|
|
47
|
+
logHttpRequest(urlOriginalPretty, httpRequestId);
|
|
50
48
|
const { pageContextReturn } = await renderPage_wrapper(httpRequestId, () => renderPageAndPrepare(pageContextInit, httpRequestId));
|
|
51
|
-
logHttpResponse(
|
|
52
|
-
globalObject.pendingRequestsCount--;
|
|
49
|
+
logHttpResponse(urlOriginalPretty, httpRequestId, pageContextReturn);
|
|
53
50
|
(0, utils_js_1.checkType)(pageContextReturn);
|
|
51
|
+
(0, utils_js_1.assert)(pageContextReturn.httpResponse);
|
|
54
52
|
return pageContextReturn;
|
|
55
53
|
}
|
|
56
54
|
exports.renderPage = renderPage;
|
|
57
55
|
async function renderPageAndPrepare(pageContextInit, httpRequestId) {
|
|
58
56
|
// Invalid config
|
|
59
|
-
const handleInvalidConfig = () => {
|
|
57
|
+
const handleInvalidConfig = (err) => {
|
|
60
58
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(picocolors_1.default.bold(picocolors_1.default.red('Error while loading a Vike config file, see error above.')), httpRequestId, 'error');
|
|
61
|
-
const
|
|
62
|
-
return
|
|
59
|
+
const pageContextWithError = getPageContextHttpResponseError(err, pageContextInit, null);
|
|
60
|
+
return pageContextWithError;
|
|
63
61
|
};
|
|
64
62
|
if (isConfigInvalid_js_1.isConfigInvalid) {
|
|
65
|
-
|
|
63
|
+
if (1 < 2 // Make TS happy
|
|
64
|
+
) {
|
|
65
|
+
return handleInvalidConfig(isConfigInvalid_js_1.isConfigInvalid.err);
|
|
66
|
+
}
|
|
66
67
|
}
|
|
67
68
|
// Prepare context
|
|
68
69
|
let renderContext;
|
|
@@ -75,21 +76,17 @@ async function renderPageAndPrepare(pageContextInit, httpRequestId) {
|
|
|
75
76
|
// initGlobalContext_renderPage() and getRenderContext() don't call any user hooks => err isn't thrown from user code.
|
|
76
77
|
(0, utils_js_1.assert)(!(0, abort_js_1.isAbortError)(err));
|
|
77
78
|
(0, loggerRuntime_js_1.logRuntimeError)(err, httpRequestId);
|
|
78
|
-
const
|
|
79
|
-
return
|
|
79
|
+
const pageContextWithError = getPageContextHttpResponseError(err, pageContextInit, null);
|
|
80
|
+
return pageContextWithError;
|
|
80
81
|
}
|
|
81
82
|
if (isConfigInvalid_js_1.isConfigInvalid) {
|
|
82
|
-
return handleInvalidConfig();
|
|
83
|
+
return handleInvalidConfig(isConfigInvalid_js_1.isConfigInvalid.err);
|
|
83
84
|
}
|
|
84
85
|
else {
|
|
85
86
|
// From now on, renderContext.pageConfigs contains all the configuration data; getVikeConfig() isn't called anymore for this request
|
|
86
87
|
}
|
|
87
88
|
// Check Base URL
|
|
88
|
-
|
|
89
|
-
const pageContextHttpResponse = checkBaseUrl(pageContextInit, httpRequestId);
|
|
90
|
-
if (pageContextHttpResponse)
|
|
91
|
-
return pageContextHttpResponse;
|
|
92
|
-
}
|
|
89
|
+
assertBaseUrl(pageContextInit);
|
|
93
90
|
// Normalize URL
|
|
94
91
|
{
|
|
95
92
|
const pageContextHttpResponse = normalizeUrl(pageContextInit, httpRequestId);
|
|
@@ -185,8 +182,8 @@ async function renderPageAlreadyPrepared(pageContextInit, httpRequestId, renderC
|
|
|
185
182
|
if (!handled.pageContextReturn) {
|
|
186
183
|
const pageContextAbort = errErrorPage._pageContextAbort;
|
|
187
184
|
(0, utils_js_1.assertWarning)(false, `Failed to render error page because ${picocolors_1.default.cyan(pageContextAbort._abortCall)} was called: make sure ${picocolors_1.default.cyan(pageContextAbort._abortCaller)} doesn't occur while the error page is being rendered.`, { onlyOnce: false });
|
|
188
|
-
const
|
|
189
|
-
return
|
|
185
|
+
const pageContextHttpWithError = getPageContextHttpResponseError(errNominalPage, pageContextInit, pageContextErrorPageInit);
|
|
186
|
+
return pageContextHttpWithError;
|
|
190
187
|
}
|
|
191
188
|
// `throw redirect()` / `throw render(url)`
|
|
192
189
|
return handled.pageContextReturn;
|
|
@@ -194,20 +191,19 @@ async function renderPageAlreadyPrepared(pageContextInit, httpRequestId, renderC
|
|
|
194
191
|
if ((0, isNewError_js_1.isNewError)(errErrorPage, errNominalPage)) {
|
|
195
192
|
(0, loggerRuntime_js_1.logRuntimeError)(errErrorPage, httpRequestId);
|
|
196
193
|
}
|
|
197
|
-
const
|
|
198
|
-
return
|
|
194
|
+
const pageContextWithError = getPageContextHttpResponseError(errNominalPage, pageContextInit, pageContextErrorPageInit);
|
|
195
|
+
return pageContextWithError;
|
|
199
196
|
}
|
|
200
197
|
return pageContextErrorPage;
|
|
201
198
|
}
|
|
202
199
|
}
|
|
203
200
|
function logHttpRequest(urlOriginal, httpRequestId) {
|
|
204
|
-
|
|
205
|
-
(0, loggerRuntime_js_1.logRuntimeInfo)?.(getRequestInfoMessage(urlOriginal), httpRequestId, 'info', clearErrors);
|
|
201
|
+
(0, loggerRuntime_js_1.logRuntimeInfo)?.(getRequestInfoMessage(urlOriginal), httpRequestId, 'info');
|
|
206
202
|
}
|
|
207
203
|
function getRequestInfoMessage(urlOriginal) {
|
|
208
204
|
return `HTTP request: ${prettyUrl(urlOriginal)}`;
|
|
209
205
|
}
|
|
210
|
-
function logHttpResponse(
|
|
206
|
+
function logHttpResponse(urlOriginalPretty, httpRequestId, pageContextReturn) {
|
|
211
207
|
const statusCode = pageContextReturn.httpResponse?.statusCode ?? null;
|
|
212
208
|
let msg;
|
|
213
209
|
let isNominal;
|
|
@@ -218,10 +214,10 @@ function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
|
218
214
|
// - URL doesn't include Base URL
|
|
219
215
|
// - Can we abort earlier so that `logHttpResponse()` and `logHttpRequest()` aren't even called?
|
|
220
216
|
// - Error loading a Vike config file
|
|
221
|
-
// - We should show `HTTP response ${
|
|
217
|
+
// - We should show `HTTP response ${urlOriginalPretty} ERR` instead.
|
|
222
218
|
// - Maybe we can/should make the error available at pageContext.errorWhileRendering
|
|
223
219
|
(0, utils_js_1.assert)(errorWhileRendering === null || errorWhileRendering === undefined);
|
|
224
|
-
msg = `HTTP response ${prettyUrl(
|
|
220
|
+
msg = `HTTP response ${prettyUrl(urlOriginalPretty)} ${picocolors_1.default.dim('null')}`;
|
|
225
221
|
// Erroneous value (it shoud sometimes be `false`) but it's fine as it doesn't seem to have much of an impact.
|
|
226
222
|
isNominal = true;
|
|
227
223
|
}
|
|
@@ -239,28 +235,33 @@ function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
|
239
235
|
.find((header) => header[0] === 'Location');
|
|
240
236
|
(0, utils_js_1.assert)(headerRedirect);
|
|
241
237
|
const urlRedirect = headerRedirect[1];
|
|
242
|
-
|
|
238
|
+
urlOriginalPretty = urlRedirect;
|
|
243
239
|
}
|
|
244
|
-
msg = `HTTP ${type} ${prettyUrl(
|
|
240
|
+
msg = `HTTP ${type} ${prettyUrl(urlOriginalPretty)} ${color(statusCode ?? 'ERR')}`;
|
|
245
241
|
}
|
|
246
242
|
}
|
|
247
243
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(msg, httpRequestId, isNominal ? 'info' : 'error');
|
|
248
244
|
}
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
function prettyUrl(url) {
|
|
246
|
+
return picocolors_1.default.bold(decodeURI(url));
|
|
247
|
+
}
|
|
248
|
+
function getPageContextHttpResponseError(err, pageContextInit, pageContext) {
|
|
249
|
+
const pageContextWithError = createPageContext(pageContextInit);
|
|
250
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseError)(pageContext);
|
|
251
|
+
(0, utils_js_1.objectAssign)(pageContextWithError, {
|
|
252
|
+
httpResponse,
|
|
253
253
|
errorWhileRendering: err
|
|
254
254
|
});
|
|
255
|
-
return
|
|
255
|
+
return pageContextWithError;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
258
|
-
const
|
|
259
|
-
(0,
|
|
260
|
-
|
|
261
|
-
|
|
257
|
+
function getPageContextHttpResponseFavicon404(pageContextInit) {
|
|
258
|
+
const pageContext = createPageContext(pageContextInit);
|
|
259
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseFavicon404)();
|
|
260
|
+
(0, utils_js_1.objectAssign)(pageContext, {
|
|
261
|
+
httpResponse
|
|
262
262
|
});
|
|
263
|
-
|
|
263
|
+
(0, utils_js_1.checkType)(pageContext);
|
|
264
|
+
return pageContext;
|
|
264
265
|
}
|
|
265
266
|
function createPageContext(pageContextInit) {
|
|
266
267
|
const pageContext = {
|
|
@@ -286,6 +287,7 @@ async function renderPageNominal(pageContext) {
|
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
289
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContext, '_pageId', 'string'));
|
|
290
|
+
(0, utils_js_1.assert)(pageContext.errorWhileRendering === null);
|
|
289
291
|
// Render
|
|
290
292
|
const pageContextAfterRender = await (0, renderPageAlreadyRouted_js_1.renderPageAlreadyRouted)(pageContext);
|
|
291
293
|
(0, utils_js_1.assert)(pageContext === pageContextAfterRender);
|
|
@@ -331,10 +333,12 @@ function getRequestId() {
|
|
|
331
333
|
(0, utils_js_1.assert)(httpRequestId >= 1);
|
|
332
334
|
return httpRequestId;
|
|
333
335
|
}
|
|
334
|
-
function
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
function assertIsUrl(urlOriginal) {
|
|
337
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.isUrl)(urlOriginal), `${picocolors_1.default.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage) called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which isn't a valid URL.`);
|
|
338
|
+
}
|
|
339
|
+
function assertIsNotViteRequest(urlPathname, urlOriginal) {
|
|
340
|
+
const isViteRequest = urlPathname.startsWith('/@vite/client') || urlPathname.startsWith('/@fs/') || urlPathname.startsWith('/__vite_ping');
|
|
341
|
+
(0, utils_js_1.assertUsage)(!isViteRequest, `${picocolors_1.default.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage) called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which is unexpected because this URL should have already been handled by Vite's development middleware. Make sure to 1. install Vite's development middleware and 2. add Vite's middleware *before* Vike's middleware, see https://vike.dev/renderPage`);
|
|
338
342
|
}
|
|
339
343
|
function normalizeUrl(pageContextInit, httpRequestId) {
|
|
340
344
|
const { trailingSlash, disableUrlNormalization, baseServer } = (0, globalContext_js_1.getGlobalContext)();
|
|
@@ -348,7 +352,7 @@ function normalizeUrl(pageContextInit, httpRequestId) {
|
|
|
348
352
|
if (!urlNormalized)
|
|
349
353
|
return null;
|
|
350
354
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`URL normalized from ${picocolors_1.default.cyan(urlOriginal)} to ${picocolors_1.default.cyan(urlNormalized)} (https://vike.dev/url-normalization)`, httpRequestId, 'info');
|
|
351
|
-
const httpResponse = (0,
|
|
355
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseRedirect)({ url: urlNormalized, statusCode: 301 }, pageContextInit.urlOriginal);
|
|
352
356
|
const pageContextHttpResponse = createPageContext(pageContextInit);
|
|
353
357
|
(0, utils_js_1.objectAssign)(pageContextHttpResponse, { httpResponse });
|
|
354
358
|
return pageContextHttpResponse;
|
|
@@ -384,7 +388,7 @@ function getPermanentRedirect(pageContextInit, httpRequestId) {
|
|
|
384
388
|
(0, utils_js_1.assert)(urlTarget !== pageContextInit.urlOriginal);
|
|
385
389
|
}
|
|
386
390
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`Permanent redirect defined by your config.redirects (https://vike.dev/redirects)`, httpRequestId, 'info');
|
|
387
|
-
const httpResponse = (0,
|
|
391
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseRedirect)({ url: urlTarget, statusCode: 301 }, urlWithoutBase);
|
|
388
392
|
const pageContextHttpResponse = createPageContext(pageContextInit);
|
|
389
393
|
(0, utils_js_1.objectAssign)(pageContextHttpResponse, { httpResponse });
|
|
390
394
|
return pageContextHttpResponse;
|
|
@@ -413,7 +417,7 @@ pageContextNominalPageInit, httpRequestId, renderContext, pageContextErrorPageIn
|
|
|
413
417
|
else {
|
|
414
418
|
pageContextSerialized = (0, serializePageContextClientSide_js_1.serializePageContextAbort)(pageContextAbort);
|
|
415
419
|
}
|
|
416
|
-
const httpResponse = await (0,
|
|
420
|
+
const httpResponse = await (0, createHttpResponse_js_1.createHttpResponsePageContextJson)(pageContextSerialized);
|
|
417
421
|
const pageContextReturn = { httpResponse };
|
|
418
422
|
return { pageContextReturn };
|
|
419
423
|
}
|
|
@@ -428,7 +432,7 @@ pageContextNominalPageInit, httpRequestId, renderContext, pageContextErrorPageIn
|
|
|
428
432
|
if (pageContextAbort._urlRedirect) {
|
|
429
433
|
const pageContextReturn = createPageContext(pageContextInit);
|
|
430
434
|
(0, utils_js_1.objectAssign)(pageContextReturn, pageContextAbort);
|
|
431
|
-
const httpResponse = (0,
|
|
435
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseRedirect)(pageContextAbort._urlRedirect, (() => {
|
|
432
436
|
const { pathname, searchOriginal } = pageContextNominalPageInit.urlParsed;
|
|
433
437
|
const urlLogical = (0, utils_js_1.createUrlFromComponents)(null, pathname, searchOriginal,
|
|
434
438
|
// The server-side doesn't have access to the hash
|
|
@@ -441,18 +445,10 @@ pageContextNominalPageInit, httpRequestId, renderContext, pageContextErrorPageIn
|
|
|
441
445
|
(0, utils_js_1.assert)(pageContextAbort.abortStatusCode);
|
|
442
446
|
return { pageContextAbort };
|
|
443
447
|
}
|
|
444
|
-
function
|
|
448
|
+
function assertBaseUrl(pageContextInit) {
|
|
445
449
|
const { baseServer } = (0, globalContext_js_1.getGlobalContext)();
|
|
446
450
|
const { urlOriginal } = pageContextInit;
|
|
447
451
|
const { urlWithoutPageContextRequestSuffix } = (0, handlePageContextRequestUrl_js_1.handlePageContextRequestUrl)(urlOriginal);
|
|
448
452
|
const { hasBaseServer } = (0, utils_js_1.parseUrl)(urlWithoutPageContextRequestSuffix, baseServer);
|
|
449
|
-
|
|
450
|
-
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`${getRequestInfoMessage(urlOriginal)} skipped because URL ${prettyUrl(urlOriginal)} doesn't start with Base URL ${prettyUrl(baseServer)} (https://vike.dev/base-url)`, httpRequestId, 'info');
|
|
451
|
-
const pageContextHttpResponseNull = getPageContextHttpResponseNull(pageContextInit);
|
|
452
|
-
return pageContextHttpResponseNull;
|
|
453
|
-
}
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
function prettyUrl(url) {
|
|
457
|
-
return picocolors_1.default.bold(decodeURI(url));
|
|
453
|
+
(0, utils_js_1.assertUsage)(hasBaseServer, `${picocolors_1.default.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage) called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which doesn't start with Base URL ${picocolors_1.default.code(baseServer)} (https://vike.dev/base-url)`);
|
|
458
454
|
}
|
|
@@ -7,14 +7,14 @@ function analyzeClientSide(pageConfig, pageFilesAll, pageId) {
|
|
|
7
7
|
// V1 design
|
|
8
8
|
if (pageConfig) {
|
|
9
9
|
const isClientRouting = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
10
|
-
const
|
|
11
|
-
return {
|
|
10
|
+
const isClientRuntimeLoaded = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'isClientRuntimeLoaded', 'boolean')?.value ?? false;
|
|
11
|
+
return { isClientRuntimeLoaded, isClientRouting };
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
14
|
// TODO/v1-release: remove
|
|
15
15
|
// V0.4 design
|
|
16
16
|
const { isHtmlOnly, isClientRouting } = (0, analyzePageClientSide_js_1.analyzePageClientSide)(pageFilesAll, pageId);
|
|
17
|
-
return {
|
|
17
|
+
return { isClientRuntimeLoaded: !isHtmlOnly, isClientRouting };
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.analyzeClientSide = analyzeClientSide;
|
|
@@ -24,6 +24,7 @@ function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
|
24
24
|
}
|
|
25
25
|
const exportDefault = picocolors_1.default.code('export default');
|
|
26
26
|
const exportNamed = picocolors_1.default.code(`export { ${configName} }`);
|
|
27
|
+
(0, utils_js_1.assert)(exportNamesValid.length <= 2);
|
|
27
28
|
if (exportNamesValid.length === 0) {
|
|
28
29
|
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} should have a ${exportNamed} or ${exportDefault}`);
|
|
29
30
|
}
|
|
@@ -32,8 +33,6 @@ function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
|
32
33
|
onlyOnce: true
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
|
-
(0, utils_js_1.assert)(exportNamesValid.length === 1);
|
|
36
|
-
(0, utils_js_1.assert)(exportNamesInvalid.length > 0);
|
|
37
36
|
if (!TOLERATE_SIDE_EXPORTS.some((ext) => filePathToShowToUser.endsWith(ext))) {
|
|
38
37
|
exportNamesInvalid.forEach((exportInvalid) => {
|
|
39
38
|
(0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} unexpected ${picocolors_1.default.cyan(`export { ${exportInvalid} }`)}`, {
|
|
@@ -72,7 +72,7 @@ async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
|
|
|
72
72
|
}
|
|
73
73
|
if ((0, utils_js_1.hasProp)(hookReturn.pageContext, 'urlLogical')) {
|
|
74
74
|
(0, utils_js_1.assertUsageUrlPathnameAbsolute)(
|
|
75
|
-
// We type-cast
|
|
75
|
+
// We skip validation and type-cast instead of assertUsage() in order to save client-side KBs
|
|
76
76
|
hookReturn.pageContext.urlLogical, `${errPrefix} returned ${picocolors_1.default.cyan('{ pageContext: { urlLogical } }')} but ${picocolors_1.default.cyan('urlLogical')}`);
|
|
77
77
|
}
|
|
78
78
|
(0, assertPageContextProvidedByUser_js_1.assertPageContextProvidedByUser)(hookReturn.pageContext, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isArray = void 0;
|
|
4
|
-
//
|
|
4
|
+
// Same as Array.isArray() but typesafe: asserts unknown[] instead of any[]
|
|
5
5
|
function isArray(value) {
|
|
6
6
|
return Array.isArray(value);
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addUrlOrigin = exports.removeUrlOrigin = exports.modifyUrlPathname = exports.removeBaseServer = exports.normalizeUrlPathname = exports.isBaseAssets = exports.prependBase = void 0;
|
|
3
|
+
exports.getUrlPretty = exports.addUrlOrigin = exports.removeUrlOrigin = exports.modifyUrlPathname = exports.removeBaseServer = exports.normalizeUrlPathname = exports.isBaseAssets = exports.prependBase = void 0;
|
|
4
4
|
const parseUrl_js_1 = require("./parseUrl.js");
|
|
5
5
|
const assert_js_1 = require("./assert.js");
|
|
6
6
|
const slice_js_1 = require("./slice.js");
|
|
@@ -103,3 +103,8 @@ function addUrlOrigin(url, origin) {
|
|
|
103
103
|
return urlModified;
|
|
104
104
|
}
|
|
105
105
|
exports.addUrlOrigin = addUrlOrigin;
|
|
106
|
+
function getUrlPretty(url) {
|
|
107
|
+
const { urlModified } = removeUrlOrigin(url);
|
|
108
|
+
return urlModified;
|
|
109
|
+
}
|
|
110
|
+
exports.getUrlPretty = getUrlPretty;
|
|
@@ -7,6 +7,6 @@ async function isClientSideRoutable(pageId, pageContext) {
|
|
|
7
7
|
sharedPageFilesAlreadyLoaded: false
|
|
8
8
|
});
|
|
9
9
|
const pageConfig = findPageConfig(pageContext._pageConfigs, pageId);
|
|
10
|
-
const {
|
|
11
|
-
return
|
|
10
|
+
const { isClientRuntimeLoaded, isClientRouting } = analyzeClientSide(pageConfig, pageContext._pageFilesAll, pageId);
|
|
11
|
+
return isClientRuntimeLoaded && isClientRouting;
|
|
12
12
|
}
|
|
@@ -20,6 +20,7 @@ import { getErrorPageId } from '../../shared/error-page.js';
|
|
|
20
20
|
const globalObject = getGlobalObject('renderPageClientSide.ts', { renderCounter: 0 });
|
|
21
21
|
async function renderPageClientSide(renderArgs) {
|
|
22
22
|
const { scrollTarget, urlOriginal = getCurrentUrl(), overwriteLastHistoryEntry = false, isBackwardNavigation, pageContextsFromRewrite = [], redirectCount = 0, isUserLandPushStateNavigation, isClientSideNavigation = true } = renderArgs;
|
|
23
|
+
const { previousPageContext } = globalObject;
|
|
23
24
|
const { isRenderOutdated, setHydrationCanBeAborted, isFirstRender } = getIsRenderOutdated();
|
|
24
25
|
// Note that pageContext.isHydration isn't equivalent to isFirstRender
|
|
25
26
|
// - Thus pageContext.isHydration isn't equivalent to !pageContext.isClientSideNavigation
|
|
@@ -41,7 +42,6 @@ async function renderPageClientSide(renderArgs) {
|
|
|
41
42
|
return;
|
|
42
43
|
// onPageTransitionStart()
|
|
43
44
|
if (globalObject.isFirstRenderDone) {
|
|
44
|
-
const { previousPageContext } = globalObject;
|
|
45
45
|
assert(previousPageContext);
|
|
46
46
|
// We use the hook of the previous page in order to be able to call onPageTransitionStart() before fetching the files of the next page.
|
|
47
47
|
// https://github.com/vikejs/vike/issues/1560
|
|
@@ -81,23 +81,30 @@ async function renderPageClientSide(renderArgs) {
|
|
|
81
81
|
}
|
|
82
82
|
if (isRenderOutdated())
|
|
83
83
|
return;
|
|
84
|
-
let isClientRoutable;
|
|
85
84
|
if (!pageContextFromRoute._pageId) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
/*
|
|
86
|
+
// We don't use the client router to render the 404 page:
|
|
87
|
+
// - So that the +redirects setting (https://vike.dev/redirects) can be applied.
|
|
88
|
+
// - This is the main argument.
|
|
89
|
+
// - See also failed CI: https://github.com/vikejs/vike/pull/1871
|
|
90
|
+
// - So that server-side error tracking can track 404 links?
|
|
91
|
+
// - We do use the client router for rendering the error page, so I don't think this is much of an argument.
|
|
92
|
+
await renderErrorPage({ is404: true })
|
|
93
|
+
*/
|
|
94
|
+
redirectHard(urlOriginal);
|
|
95
|
+
return;
|
|
92
96
|
}
|
|
97
|
+
assert(hasProp(pageContextFromRoute, '_pageId', 'string')); // Help TS
|
|
98
|
+
const isClientRoutable = await isClientSideRoutable(pageContextFromRoute._pageId, pageContext);
|
|
99
|
+
if (isRenderOutdated())
|
|
100
|
+
return;
|
|
93
101
|
if (!isClientRoutable) {
|
|
94
102
|
redirectHard(urlOriginal);
|
|
95
103
|
return;
|
|
96
104
|
}
|
|
97
|
-
assert(hasProp(pageContextFromRoute, '_pageId', 'string')); // Help TS
|
|
98
105
|
const isSamePage = pageContextFromRoute._pageId &&
|
|
99
|
-
|
|
100
|
-
pageContextFromRoute._pageId ===
|
|
106
|
+
previousPageContext?._pageId &&
|
|
107
|
+
pageContextFromRoute._pageId === previousPageContext._pageId;
|
|
101
108
|
if (isUserLandPushStateNavigation && isSamePage) {
|
|
102
109
|
// Skip's Vike's rendering; let the user handle the navigation
|
|
103
110
|
return;
|
|
@@ -170,7 +177,8 @@ async function renderPageClientSide(renderArgs) {
|
|
|
170
177
|
const pageContext = await createPageContext(urlOriginal);
|
|
171
178
|
objectAssign(pageContext, {
|
|
172
179
|
isBackwardNavigation,
|
|
173
|
-
isClientSideNavigation
|
|
180
|
+
isClientSideNavigation,
|
|
181
|
+
_previousPageContext: previousPageContext
|
|
174
182
|
});
|
|
175
183
|
{
|
|
176
184
|
const pageContextFromAllRewrites = getPageContextFromAllRewrites(pageContextsFromRewrite);
|
|
@@ -207,9 +215,10 @@ async function renderPageClientSide(renderArgs) {
|
|
|
207
215
|
const pageContext = await getPageContextBegin();
|
|
208
216
|
if (isRenderOutdated())
|
|
209
217
|
return;
|
|
210
|
-
if (args.
|
|
218
|
+
if (args.is404)
|
|
219
|
+
objectAssign(pageContext, { is404: true });
|
|
220
|
+
if (args.pageContextError)
|
|
211
221
|
objectAssign(pageContext, args.pageContextError);
|
|
212
|
-
}
|
|
213
222
|
if ('err' in args) {
|
|
214
223
|
const { err } = args;
|
|
215
224
|
assert(!('errorWhileRendering' in pageContext));
|
|
@@ -265,6 +274,13 @@ async function renderPageClientSide(renderArgs) {
|
|
|
265
274
|
objectAssign(pageContext, {
|
|
266
275
|
_pageId: errorPageId
|
|
267
276
|
});
|
|
277
|
+
const isClientRoutable = await isClientSideRoutable(pageContext._pageId, pageContext);
|
|
278
|
+
if (isRenderOutdated())
|
|
279
|
+
return;
|
|
280
|
+
if (!isClientRoutable) {
|
|
281
|
+
redirectHard(urlOriginal);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
268
284
|
try {
|
|
269
285
|
objectAssign(pageContext, await loadUserFilesClientSide(pageContext._pageId, pageContext._pageFilesAll, pageContext._pageConfigs));
|
|
270
286
|
}
|
|
@@ -366,7 +382,6 @@ async function renderPageClientSide(renderArgs) {
|
|
|
366
382
|
// onPageTransitionEnd()
|
|
367
383
|
if (globalObject.isTransitioning) {
|
|
368
384
|
globalObject.isTransitioning = undefined;
|
|
369
|
-
const { previousPageContext } = globalObject;
|
|
370
385
|
assert(previousPageContext);
|
|
371
386
|
assertHook(previousPageContext, 'onPageTransitionEnd');
|
|
372
387
|
const hook = getHook(previousPageContext, 'onPageTransitionEnd');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { importBuild };
|
|
2
2
|
export { set_ASSETS_MAP };
|
|
3
|
-
import { serverEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin
|
|
3
|
+
import { serverEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
4
|
import { assert, getOutDirs, toPosixPath } from '../../utils.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { createRequire } from 'module';
|
|
@@ -8,7 +8,7 @@ import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-file
|
|
|
8
8
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
9
9
|
import { vikeConfigDependencies, reloadVikeConfig, isVikeConfigFile } from './v1-design/getVikeConfig.js';
|
|
10
10
|
import pc from '@brillout/picocolors';
|
|
11
|
-
import { logConfigInfo
|
|
11
|
+
import { logConfigInfo } from '../../shared/loggerNotProd.js';
|
|
12
12
|
import { getModuleFilePathAbsolute } from '../../shared/getFilePath.js';
|
|
13
13
|
function importUserCode() {
|
|
14
14
|
let config;
|
|
@@ -93,17 +93,13 @@ function handleHotUpdate(ctx, config) {
|
|
|
93
93
|
`${msg} — ${pc.cyan('no HMR')}, see https://vike.dev/on-demand-compiler`,
|
|
94
94
|
'info',
|
|
95
95
|
null,
|
|
96
|
-
true
|
|
97
|
-
clear,
|
|
98
|
-
config
|
|
96
|
+
true
|
|
99
97
|
)
|
|
100
98
|
return
|
|
101
99
|
}
|
|
102
100
|
//*/
|
|
103
|
-
// HMR can resolve errors => we clear previously shown errors.
|
|
104
101
|
// It can hide an error it shouldn't hide (because the error isn't shown again), but it's ok since users can reload the page and the error will be shown again (Vite transpilation errors are shown again upon a page reload).
|
|
105
102
|
if (!isVikeConfig && isViteModule) {
|
|
106
|
-
clearLogs({ clearErrors: true });
|
|
107
103
|
return;
|
|
108
104
|
}
|
|
109
105
|
if (isVikeConfig) {
|
|
@@ -76,7 +76,11 @@ const configDefinitionsBuiltIn = {
|
|
|
76
76
|
meta: {
|
|
77
77
|
env: { config: true }
|
|
78
78
|
},
|
|
79
|
-
|
|
79
|
+
// Whether the page loads:
|
|
80
|
+
// - Vike's client runtime
|
|
81
|
+
// - User's client hooks
|
|
82
|
+
// In other words, whether the page is "HTML-only" (https://vike.dev/render-modes). HTML-only pages shouldn't load the client runtime nor client hooks.
|
|
83
|
+
isClientRuntimeLoaded: {
|
|
80
84
|
env: { server: true, client: true },
|
|
81
85
|
eager: true,
|
|
82
86
|
_computed: (configValueSources) => {
|
|
@@ -35,7 +35,7 @@ function reloadVikeConfig(userRootDir, outDirRoot) {
|
|
|
35
35
|
handleReloadSideEffects();
|
|
36
36
|
}
|
|
37
37
|
async function handleReloadSideEffects() {
|
|
38
|
-
wasConfigInvalid = isConfigInvalid;
|
|
38
|
+
wasConfigInvalid = !!isConfigInvalid;
|
|
39
39
|
const vikeConfigPromisePrevious = vikeConfigPromise;
|
|
40
40
|
try {
|
|
41
41
|
await vikeConfigPromise;
|
|
@@ -210,7 +210,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
210
210
|
else {
|
|
211
211
|
assert(ret === undefined);
|
|
212
212
|
assert(err);
|
|
213
|
-
isConfigInvalid_set(
|
|
213
|
+
isConfigInvalid_set({ err });
|
|
214
214
|
if (!isDev) {
|
|
215
215
|
assert(getViteDevServer() === null);
|
|
216
216
|
throw err;
|
|
@@ -43,14 +43,9 @@ function addSsrMiddleware(middlewares, config, isPreview) {
|
|
|
43
43
|
if (value)
|
|
44
44
|
res.setHeader(name, value);
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const { statusCode, headers } = pageContext.httpResponse;
|
|
51
|
-
headers.forEach(([name, value]) => res.setHeader(name, value));
|
|
52
|
-
res.statusCode = statusCode;
|
|
53
|
-
pageContext.httpResponse.pipe(res);
|
|
54
|
-
}
|
|
46
|
+
const { httpResponse } = pageContext;
|
|
47
|
+
httpResponse.headers.forEach(([name, value]) => res.setHeader(name, value));
|
|
48
|
+
res.statusCode = httpResponse.statusCode;
|
|
49
|
+
httpResponse.pipe(res);
|
|
55
50
|
});
|
|
56
51
|
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
export { logWithViteTag };
|
|
2
2
|
export { logWithVikeTag };
|
|
3
3
|
export { logDirectly };
|
|
4
|
-
export { isFirstLog };
|
|
5
|
-
export { clearScreen };
|
|
6
|
-
export { screenHasErrors };
|
|
7
4
|
export { applyViteSourceMapToStackTrace };
|
|
8
5
|
import type { LogCategory, LogType } from '../loggerNotProd.js';
|
|
9
|
-
import type { ResolvedConfig } from 'vite';
|
|
10
|
-
declare let isFirstLog: boolean;
|
|
11
|
-
declare let screenHasErrors: boolean;
|
|
12
6
|
declare function logWithVikeTag(msg: string, logType: LogType, category: LogCategory | null, showVikeVersion?: boolean): void;
|
|
13
7
|
declare function logWithViteTag(msg: string, logType: LogType, category: LogCategory | null): void;
|
|
14
8
|
declare function logDirectly(thing: unknown, logType: LogType): void;
|
|
15
|
-
declare function clearScreen(viteConfig: ResolvedConfig): void;
|
|
16
9
|
declare function applyViteSourceMapToStackTrace(thing: unknown): void;
|