vike 0.4.159 → 0.4.160-commit-30d535e
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/dist/cjs/node/plugin/index.js +20 -1
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +9 -0
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/config/stemUtils.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +18 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +28 -46
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +129 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +33 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +139 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{replaceImportStatements.js → getVikeConfig/transformFileImports.js} +44 -13
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{transpileAndExecuteFile.js → getVikeConfig/transpileAndExecuteFile.js} +105 -78
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +201 -382
- package/dist/cjs/node/plugin/plugins/previewConfig.js +1 -1
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +3 -3
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -2
- package/dist/cjs/node/prerender/runPrerender.js +12 -5
- package/dist/cjs/node/runtime/globalContext.js +7 -3
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/html/renderHtml.js +1 -1
- package/dist/cjs/node/runtime/html/stream.js +2 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +1 -1
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/{logHintForCjsEsmError.js → logErrorHint.js} +81 -43
- package/dist/cjs/node/runtime/renderPage/loggerProd.js +3 -3
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +44 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +54 -27
- package/dist/cjs/shared/route/abort.js +1 -1
- package/dist/cjs/shared/route/executeGuardHook.js +3 -2
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/assert.js +5 -6
- package/dist/cjs/utils/assertIsNotProductionRuntime.js +35 -17
- package/dist/cjs/utils/{findUserPackageJsonPath.js → findFile.js} +11 -8
- package/dist/cjs/utils/nodeEnv.js +33 -1
- package/dist/cjs/utils/objectKeys.js +19 -3
- package/dist/cjs/utils/projectInfo.js +2 -4
- package/dist/cjs/utils/sorter.js +62 -1
- package/dist/esm/node/plugin/index.js +21 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +2 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +10 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/config/stemUtils.js +2 -2
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.d.ts +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +12 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +8 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +39 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +29 -47
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +21 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +123 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +27 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +12 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +133 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{replaceImportStatements.d.ts → getVikeConfig/transformFileImports.d.ts} +5 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{replaceImportStatements.js → getVikeConfig/transformFileImports.js} +43 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{transpileAndExecuteFile.d.ts → getVikeConfig/transpileAndExecuteFile.d.ts} +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{transpileAndExecuteFile.js → getVikeConfig/transpileAndExecuteFile.js} +105 -78
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +16 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +199 -380
- package/dist/esm/node/plugin/plugins/previewConfig.js +2 -2
- package/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js +1 -1
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +3 -3
- package/dist/esm/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -2
- package/dist/esm/node/plugin/utils.js +1 -2
- package/dist/esm/node/prerender/runPrerender.js +13 -6
- package/dist/esm/node/runtime/globalContext.js +8 -4
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/esm/node/runtime/html/renderHtml.js +1 -1
- package/dist/esm/node/runtime/html/stream.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/esm/node/runtime/renderPage/logErrorHint.d.ts +8 -0
- package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError.js → logErrorHint.js} +80 -42
- package/dist/esm/node/runtime/renderPage/loggerProd.js +3 -3
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/shared/page-configs/Config.d.ts +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +6 -0
- package/dist/esm/shared/page-configs/assertPlusFileExport.d.ts +2 -0
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +38 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +54 -27
- package/dist/esm/shared/route/abort.js +2 -2
- package/dist/esm/shared/route/executeGuardHook.js +3 -2
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -1
- package/dist/esm/utils/assert.js +5 -6
- package/dist/esm/utils/assertIsNotProductionRuntime.d.ts +8 -6
- package/dist/esm/utils/assertIsNotProductionRuntime.js +35 -17
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/findFile.d.ts +3 -0
- package/dist/esm/utils/findFile.js +21 -0
- package/dist/esm/utils/nodeEnv.d.ts +6 -0
- package/dist/esm/utils/nodeEnv.js +29 -0
- package/dist/esm/utils/objectKeys.d.ts +10 -1
- package/dist/esm/utils/objectKeys.js +20 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -8
- package/dist/esm/utils/projectInfo.js +2 -4
- package/dist/esm/utils/sorter.d.ts +59 -0
- package/dist/esm/utils/sorter.js +61 -0
- package/package.json +1 -1
- package/dist/cjs/shared/page-configs/assertExports.js +0 -67
- package/dist/cjs/utils/objectEntries.js +0 -8
- package/dist/esm/node/runtime/renderPage/logHintForCjsEsmError.d.ts +0 -13
- package/dist/esm/shared/page-configs/assertExports.d.ts +0 -6
- package/dist/esm/shared/page-configs/assertExports.js +0 -61
- package/dist/esm/utils/findUserPackageJsonPath.d.ts +0 -2
- package/dist/esm/utils/findUserPackageJsonPath.js +0 -18
- package/dist/esm/utils/objectEntries.d.ts +0 -4
- package/dist/esm/utils/objectEntries.js +0 -5
- /package/dist/cjs/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.js +0 -0
- /package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.d.ts +0 -0
- /package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.js +0 -0
|
@@ -33,7 +33,7 @@ function previewConfig() {
|
|
|
33
33
|
- This ugly hack to set appType for preview won't be need once https://github.com/vitejs/vite/pull/14855 is merged.
|
|
34
34
|
config.appType = 'mpa'
|
|
35
35
|
*/
|
|
36
|
-
(0, utils_js_1.
|
|
36
|
+
(0, utils_js_1.markEnvAsVitePreview)();
|
|
37
37
|
return () => {
|
|
38
38
|
assertDist();
|
|
39
39
|
/* We don't use this condition (we wrongfully always use the SSR middleware) because of the regression introduced by https://github.com/vitejs/vite/pull/14756 which stops servering .html files when `appType: 'custom'`.
|
|
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.installHttpRequestAsyncStore = exports.getHttpRequestAsyncStore = void 0;
|
|
30
30
|
const renderPage_js_1 = require("../../runtime/renderPage.js");
|
|
31
31
|
const utils_js_1 = require("../utils.js");
|
|
32
|
-
const transpileAndExecuteFile_js_1 = require("../plugins/importUserCode/v1-design/transpileAndExecuteFile.js");
|
|
32
|
+
const transpileAndExecuteFile_js_1 = require("../plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js");
|
|
33
33
|
const loggerNotProd_js_1 = require("./loggerNotProd.js");
|
|
34
34
|
const errorWithCodeSnippet_js_1 = require("./loggerNotProd/errorWithCodeSnippet.js");
|
|
35
35
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
@@ -22,10 +22,10 @@ exports.logWithVikeTag = logWithVikeTag;
|
|
|
22
22
|
function getProjectTag(showVikeVersion) {
|
|
23
23
|
let projectTag;
|
|
24
24
|
if (showVikeVersion) {
|
|
25
|
-
projectTag = `[
|
|
25
|
+
projectTag = `[vike@${utils_js_1.projectInfo.projectVersion}]`;
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
|
-
projectTag = `[
|
|
28
|
+
projectTag = `[vike]`;
|
|
29
29
|
}
|
|
30
30
|
return projectTag;
|
|
31
31
|
}
|
|
@@ -89,7 +89,7 @@ function prependTags(msg, projectTag, category, logType) {
|
|
|
89
89
|
return picocolors_1.default.yellow(s);
|
|
90
90
|
if (projectTag === '[vite]')
|
|
91
91
|
return picocolors_1.default.bold(picocolors_1.default.cyan(s));
|
|
92
|
-
if (projectTag.startsWith(`[
|
|
92
|
+
if (projectTag.startsWith(`[vike`))
|
|
93
93
|
return picocolors_1.default.bold(picocolors_1.default.cyan(s));
|
|
94
94
|
(0, utils_js_1.assert)(false);
|
|
95
95
|
};
|
|
@@ -17,7 +17,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
17
17
|
const getHttpRequestAsyncStore_js_1 = require("./getHttpRequestAsyncStore.js");
|
|
18
18
|
const isErrorDebug_js_1 = require("./isErrorDebug.js");
|
|
19
19
|
const errorWithCodeSnippet_js_1 = require("./loggerNotProd/errorWithCodeSnippet.js");
|
|
20
|
-
const transpileAndExecuteFile_js_1 = require("../plugins/importUserCode/v1-design/transpileAndExecuteFile.js");
|
|
20
|
+
const transpileAndExecuteFile_js_1 = require("../plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js");
|
|
21
21
|
const log_js_1 = require("./loggerNotProd/log.js");
|
|
22
22
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
23
23
|
const isNewError_js_1 = require("../../runtime/renderPage/isNewError.js");
|
|
@@ -27,7 +27,6 @@ __exportStar(require("../../utils/getDependencyPackageJson.js"), exports);
|
|
|
27
27
|
__exportStar(require("../../utils/requireResolve.js"), exports);
|
|
28
28
|
__exportStar(require("../../utils/arrayIncludes.js"), exports);
|
|
29
29
|
__exportStar(require("../../utils/isDev.js"), exports);
|
|
30
|
-
__exportStar(require("../../utils/objectKeys.js"), exports);
|
|
31
30
|
__exportStar(require("../../utils/getMostSimilar.js"), exports);
|
|
32
31
|
__exportStar(require("../../utils/getRandomId.js"), exports);
|
|
33
32
|
__exportStar(require("../../utils/joinEnglish.js"), exports);
|
|
@@ -35,7 +34,7 @@ __exportStar(require("../../utils/escapeRegex.js"), exports);
|
|
|
35
34
|
__exportStar(require("../../utils/stripAnsi.js"), exports);
|
|
36
35
|
__exportStar(require("../../utils/trimWithAnsi.js"), exports);
|
|
37
36
|
__exportStar(require("../../utils/removeEmptyLines.js"), exports);
|
|
38
|
-
__exportStar(require("../../utils/
|
|
37
|
+
__exportStar(require("../../utils/findFile.js"), exports);
|
|
39
38
|
__exportStar(require("../../utils/getPropAccessNotation.js"), exports);
|
|
40
39
|
__exportStar(require("../../utils/mergeCumulativeValues.js"), exports);
|
|
41
40
|
__exportStar(require("../../utils/deepEqual.js"), exports);
|
|
@@ -51,11 +51,11 @@ const loadUserFilesServerSide_js_1 = require("../runtime/renderPage/loadUserFile
|
|
|
51
51
|
const getHook_js_1 = require("../../shared/hooks/getHook.js");
|
|
52
52
|
const noRouteMatch_js_1 = require("../../shared/route/noRouteMatch.js");
|
|
53
53
|
const getVikeConfig_js_1 = require("../plugin/plugins/importUserCode/v1-design/getVikeConfig.js");
|
|
54
|
-
const
|
|
54
|
+
const logErrorHint_js_1 = require("../runtime/renderPage/logErrorHint.js");
|
|
55
55
|
async function runPrerenderFromAPI(options = {}) {
|
|
56
56
|
await runPrerender(options, 'prerender()');
|
|
57
57
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
58
|
-
// - We don't use
|
|
58
|
+
// - We don't use logErrorHint() because we don't have control over what happens with the error. For example, if the user land purposely swallows the error then the hint shouldn't be logged. Also, it's best if the hint is shown to the user *after* the error, but we cannot do/guarentee that.
|
|
59
59
|
}
|
|
60
60
|
exports.runPrerenderFromAPI = runPrerenderFromAPI;
|
|
61
61
|
async function runPrerenderFromCLI(options) {
|
|
@@ -64,7 +64,7 @@ async function runPrerenderFromCLI(options) {
|
|
|
64
64
|
}
|
|
65
65
|
catch (err) {
|
|
66
66
|
console.error(err);
|
|
67
|
-
(0,
|
|
67
|
+
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
68
68
|
process.exit(1);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -75,7 +75,7 @@ async function runPrerenderFromAutoFullBuild(options) {
|
|
|
75
75
|
}
|
|
76
76
|
catch (err) {
|
|
77
77
|
console.error(err);
|
|
78
|
-
(0,
|
|
78
|
+
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
79
79
|
process.exit(1);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -87,7 +87,7 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
87
87
|
if (logLevel === 'info') {
|
|
88
88
|
console.log(`${picocolors_1.default.cyan(`vike v${utils_js_1.projectInfo.projectVersion}`)} ${picocolors_1.default.green('pre-rendering HTML...')}`);
|
|
89
89
|
}
|
|
90
|
-
(
|
|
90
|
+
handleNodeEnv();
|
|
91
91
|
await disableReactStreaming();
|
|
92
92
|
const viteConfig = await (0, vite_1.resolveConfig)(options.viteConfig || {}, 'vike pre-rendering', 'production');
|
|
93
93
|
assertLoadedConfig(viteConfig, options);
|
|
@@ -742,3 +742,10 @@ function assertIsNotAbort(err, urlOr404) {
|
|
|
742
742
|
(0, utils_js_1.assert)(abortCall);
|
|
743
743
|
(0, utils_js_1.assertUsage)(false, `${picocolors_1.default.cyan(abortCall)} thrown${thrownBy} while pre-rendering ${urlOr404} but ${picocolors_1.default.cyan(abortCaller)} isn't supported for pre-rendered pages`);
|
|
744
744
|
}
|
|
745
|
+
function handleNodeEnv() {
|
|
746
|
+
const assertNodeEnv = () => (0, utils_js_1.assertNodeEnvIsNotDev)('pre-rendering');
|
|
747
|
+
if ((0, utils_js_1.getNodeEnv)())
|
|
748
|
+
assertNodeEnv();
|
|
749
|
+
(0, utils_js_1.setNodeEnvToProduction)();
|
|
750
|
+
assertNodeEnv();
|
|
751
|
+
}
|
|
@@ -157,7 +157,11 @@ function assertNodeEnv(hasViteDevServer) {
|
|
|
157
157
|
const nodeEnv = (0, utils_js_1.getNodeEnv)();
|
|
158
158
|
if (nodeEnv === null || nodeEnv === 'test')
|
|
159
159
|
return;
|
|
160
|
-
const
|
|
161
|
-
//
|
|
162
|
-
|
|
160
|
+
const isDev = (0, utils_js_1.isNodeEnvDev)();
|
|
161
|
+
// Calling Vite's createServer() is enough for hasViteDevServer to be true, even without actually adding Vite's development middleware to the server: https://github.com/vikejs/vike/issues/792#issuecomment-1516830759
|
|
162
|
+
if (hasViteDevServer === isDev)
|
|
163
|
+
return;
|
|
164
|
+
const nodeEnvDesc = (0, utils_js_1.getNodeEnvDesc)();
|
|
165
|
+
// We should change this to be a warning if it blocks users (e.g. if a bad-citizen tool sets a wrong process.env.NODE_ENV value)
|
|
166
|
+
(0, utils_js_1.assertUsage)(false, `Vite's development server was${hasViteDevServer ? '' : "n't"} instantiated while the ${nodeEnvDesc} which is contradictory, see https://vike.dev/NODE_ENV`);
|
|
163
167
|
}
|
|
@@ -90,8 +90,8 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
|
|
|
90
90
|
// See https://github.com/vikejs/vike/pull/1271
|
|
91
91
|
const positionJavaScriptEntry = (() => {
|
|
92
92
|
if (pageContext._pageContextPromise) {
|
|
93
|
-
(0, utils_js_1.assertWarning)(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time
|
|
94
|
-
// If there is a pageContext._pageContextPromise (which is resolved after the stream has ended) then the pageContext JSON data needs to await for it: https://vike.dev/
|
|
93
|
+
(0, utils_js_1.assertWarning)(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time, because progressive hydration won't work.", { onlyOnce: true });
|
|
94
|
+
// If there is a pageContext._pageContextPromise (which is resolved after the stream has ended) then the pageContext JSON data needs to await for it: https://vike.dev/streaming#initial-data-after-stream-end
|
|
95
95
|
return 'HTML_END';
|
|
96
96
|
}
|
|
97
97
|
if (injectToStream) {
|
|
@@ -186,7 +186,7 @@ async function renderTemplate(templateContent, pageContext) {
|
|
|
186
186
|
const varType = typeof templateVar;
|
|
187
187
|
const streamNote = ['boolean', 'number', 'bigint', 'symbol'].includes(varType)
|
|
188
188
|
? null
|
|
189
|
-
: '(See https://vike.dev/
|
|
189
|
+
: '(See https://vike.dev/streaming for HTML streaming.)';
|
|
190
190
|
(0, utils_js_1.assertUsage)(varType === 'string', getErrMsg(picocolors_1.default.cyan(`typeof htmlVar === "${varType}"`), streamNote));
|
|
191
191
|
}
|
|
192
192
|
{
|
|
@@ -631,7 +631,7 @@ exports.isStream = isStream;
|
|
|
631
631
|
const __streamPipeWeb = '__streamPipeWeb';
|
|
632
632
|
/** @deprecated */
|
|
633
633
|
function pipeWebStream(pipe) {
|
|
634
|
-
(0, utils_js_1.assertWarning)(false, 'pipeWebStream() is outdated, use stampPipe() instead. See https://vike.dev/
|
|
634
|
+
(0, utils_js_1.assertWarning)(false, 'pipeWebStream() is outdated, use stampPipe() instead. See https://vike.dev/streaming', {
|
|
635
635
|
onlyOnce: true,
|
|
636
636
|
showStackTrace: true
|
|
637
637
|
});
|
|
@@ -668,7 +668,7 @@ exports.isStreamPipeWeb = isStreamPipeWeb;
|
|
|
668
668
|
const __streamPipeNode = '__streamPipeNode';
|
|
669
669
|
/** @deprecated */
|
|
670
670
|
function pipeNodeStream(pipe) {
|
|
671
|
-
(0, utils_js_1.assertWarning)(false, 'pipeNodeStream() is outdated, use stampPipe() instead. See https://vike.dev/
|
|
671
|
+
(0, utils_js_1.assertWarning)(false, 'pipeNodeStream() is outdated, use stampPipe() instead. See https://vike.dev/streaming', {
|
|
672
672
|
onlyOnce: true,
|
|
673
673
|
showStackTrace: true
|
|
674
674
|
});
|
|
@@ -125,11 +125,11 @@ function processHookReturnValue(hookReturnValue, renderHook) {
|
|
|
125
125
|
const val = hookReturnValue.pageContext;
|
|
126
126
|
const errBegin = `${errPrefix} returned ${picocolors_1.default.cyan('{ pageContext }')}, but ${picocolors_1.default.cyan('pageContext')}`;
|
|
127
127
|
if ((0, utils_js_1.isPromise)(val) || (0, utils_js_1.isCallable)(val)) {
|
|
128
|
-
(0, utils_js_1.assertWarning)(!(0, utils_js_1.isPromise)(val), `${errBegin} is a promise which is deprecated in favor of async functions, see https://vike.dev/
|
|
128
|
+
(0, utils_js_1.assertWarning)(!(0, utils_js_1.isPromise)(val), `${errBegin} is a promise which is deprecated in favor of async functions, see https://vike.dev/streaming#initial-data-after-stream-end`, { onlyOnce: true });
|
|
129
129
|
pageContextPromise = val;
|
|
130
130
|
}
|
|
131
131
|
else {
|
|
132
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(val), `${errBegin} should be an object or an async function, see https://vike.dev/
|
|
132
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(val), `${errBegin} should be an object or an async function, see https://vike.dev/streaming#initial-data-after-stream-end`);
|
|
133
133
|
(0, assertPageContextProvidedByUser_js_1.assertPageContextProvidedByUser)(val, renderHook);
|
|
134
134
|
pageContextProvidedByRenderHook = val;
|
|
135
135
|
}
|
|
@@ -8,7 +8,7 @@ const stream_js_1 = require("../html/stream.js");
|
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
9
|
const renderHtml_js_1 = require("../html/renderHtml.js");
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
|
-
const streamDocs = 'See https://vike.dev/
|
|
11
|
+
const streamDocs = 'See https://vike.dev/streaming for more information.';
|
|
12
12
|
function getHttpResponseBody(htmlRender, renderHook) {
|
|
13
13
|
if (typeof htmlRender !== 'string') {
|
|
14
14
|
(0, utils_js_1.assertUsage)(false, getErrMsg(htmlRender, renderHook, 'body', `Use ${picocolors_1.default.cyan('pageContext.httpResponse.pipe()')} instead`));
|
|
@@ -44,7 +44,7 @@ async function loadUserFilesServerSide(pageContext) {
|
|
|
44
44
|
// TODO/v1-release: remove
|
|
45
45
|
Object.assign(pageContextAddendum, {
|
|
46
46
|
_getPageAssets: async () => {
|
|
47
|
-
(0, utils_js_1.assertWarning)(false, 'pageContext._getPageAssets() deprecated, see https://vike.dev/
|
|
47
|
+
(0, utils_js_1.assertWarning)(false, 'pageContext._getPageAssets() deprecated, see https://vike.dev/preloading', {
|
|
48
48
|
onlyOnce: true,
|
|
49
49
|
showStackTrace: true
|
|
50
50
|
});
|
|
@@ -3,22 +3,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getHint = exports.
|
|
6
|
+
exports.getHint = exports.isKnownError = exports.isCjsEsmError = exports.logErrorHint = void 0;
|
|
7
7
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const knownErrors = [
|
|
10
|
+
{
|
|
11
|
+
errMsg: 'jsxDEV is not a function',
|
|
12
|
+
link: 'https://github.com/vikejs/vike/issues/1469#issuecomment-1919518096'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
errMsg: 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)',
|
|
16
|
+
link: 'https://vike.dev/broken-npm-package#react-invalid-component'
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
function logErrorHint(error) {
|
|
20
|
+
/* Collect errors for ./logErrorHint.spec.ts
|
|
11
21
|
collectError(error)
|
|
12
22
|
//*/
|
|
13
23
|
const hint = getHint(error);
|
|
14
24
|
if (hint)
|
|
15
25
|
logHint(hint);
|
|
16
26
|
}
|
|
17
|
-
exports.
|
|
27
|
+
exports.logErrorHint = logErrorHint;
|
|
18
28
|
function getHint(error) {
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
29
|
+
{
|
|
30
|
+
const link = isKnownError(error);
|
|
31
|
+
if (link)
|
|
32
|
+
return `To fix this error, see ${link}`;
|
|
22
33
|
}
|
|
23
34
|
const res = isCjsEsmError(error);
|
|
24
35
|
if (res) {
|
|
@@ -40,44 +51,73 @@ function logHint(hint) {
|
|
|
40
51
|
hint = (0, utils_js_1.formatHintLog)(hint);
|
|
41
52
|
console.error(hint);
|
|
42
53
|
}
|
|
43
|
-
function
|
|
54
|
+
function isKnownError(error) {
|
|
44
55
|
const anywhere = getAnywhere(error);
|
|
45
|
-
|
|
56
|
+
const knownErr = knownErrors.find((knownErorr) => {
|
|
57
|
+
return includes(anywhere, knownErorr.errMsg);
|
|
58
|
+
});
|
|
59
|
+
if (!knownErr)
|
|
60
|
+
return false;
|
|
61
|
+
return knownErr.link;
|
|
46
62
|
}
|
|
47
|
-
exports.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* `'some-npm-package'` -> add some-npm-package to `ssr.noExternal`
|
|
52
|
-
*/
|
|
63
|
+
exports.isKnownError = isKnownError;
|
|
64
|
+
// `false` -> noop
|
|
65
|
+
// `true` -> generic message
|
|
66
|
+
// `'some-npm-package'` -> add some-npm-package to `ssr.noExternal`
|
|
53
67
|
function isCjsEsmError(error) {
|
|
68
|
+
const res = check(error);
|
|
69
|
+
if (res === true || res === false)
|
|
70
|
+
return res;
|
|
71
|
+
const packageNames = normalizeRes(res);
|
|
72
|
+
if (packageNames === false)
|
|
73
|
+
return packageNames;
|
|
74
|
+
packageNames.forEach((packageName) => {
|
|
75
|
+
(0, utils_js_1.assert)(!['vite', 'vike'].includes(packageName));
|
|
76
|
+
});
|
|
77
|
+
return packageNames;
|
|
78
|
+
}
|
|
79
|
+
exports.isCjsEsmError = isCjsEsmError;
|
|
80
|
+
function normalizeRes(res) {
|
|
81
|
+
let packageNames = Array.isArray(res) ? res : [res];
|
|
82
|
+
packageNames = (0, utils_js_1.unique)(packageNames.filter(utils_js_1.isNotNullish).filter((packageName) => packageName !== '@brillout/import'));
|
|
83
|
+
if (packageNames.length === 0)
|
|
84
|
+
return false;
|
|
85
|
+
return packageNames;
|
|
86
|
+
}
|
|
87
|
+
function check(error) {
|
|
54
88
|
const message = getErrMessage(error);
|
|
55
89
|
const anywhere = getAnywhere(error);
|
|
56
90
|
const packageName_stack1 = getPackageName_stack1(error);
|
|
57
91
|
const packageName_stack2 = getPackageName_stack2(error);
|
|
58
92
|
const isRelatedToNodeModules = !!packageName_stack1 || !!packageName_stack2 || includesNodeModules(message);
|
|
59
|
-
|
|
93
|
+
/*
|
|
94
|
+
const relatedNpmPackages = normalizeArray([
|
|
95
|
+
packageName_stack1 || null,
|
|
96
|
+
packageName_stack2 || null,
|
|
97
|
+
(message && extractFromNodeModulesPath(message)) || null
|
|
98
|
+
])
|
|
99
|
+
*/
|
|
60
100
|
// ERR_UNSUPPORTED_DIR_IMPORT
|
|
61
101
|
{
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
102
|
+
const packageName = parseNodeModulesPathMessage('ERR_UNSUPPORTED_DIR_IMPORT', anywhere);
|
|
103
|
+
if (packageName)
|
|
104
|
+
return packageName;
|
|
65
105
|
}
|
|
66
106
|
// ERR_UNKNOWN_FILE_EXTENSION
|
|
67
107
|
{
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
return
|
|
108
|
+
const packageName = parseUnkownFileExtensionMessage(anywhere);
|
|
109
|
+
if (packageName)
|
|
110
|
+
return packageName;
|
|
71
111
|
}
|
|
72
112
|
{
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
return
|
|
113
|
+
const packageName = parseNodeModulesPathMessage('ERR_UNKNOWN_FILE_EXTENSION', anywhere);
|
|
114
|
+
if (packageName)
|
|
115
|
+
return packageName;
|
|
76
116
|
}
|
|
77
117
|
{
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
118
|
+
const packageName = parseNodeModulesPathMessage('is not exported', anywhere);
|
|
119
|
+
if (packageName)
|
|
120
|
+
return packageName;
|
|
81
121
|
}
|
|
82
122
|
// Using CJS inside ESM modules.
|
|
83
123
|
if (includes(anywhere, 'require is not a function') ||
|
|
@@ -98,7 +138,7 @@ function isCjsEsmError(error) {
|
|
|
98
138
|
if (includes(anywhere, 'ERR_REQUIRE_ESM')) {
|
|
99
139
|
/* The issue is the importer, not the importee.
|
|
100
140
|
if (relatedNpmPackages) return relatedNpmPackages
|
|
101
|
-
|
|
141
|
+
*/
|
|
102
142
|
{
|
|
103
143
|
if (packageName_stack1)
|
|
104
144
|
return packageName_stack1;
|
|
@@ -118,9 +158,9 @@ function isCjsEsmError(error) {
|
|
|
118
158
|
*/
|
|
119
159
|
// `SyntaxError: Named export '${exportName}' not found. The requested module '${packageName}' is a CommonJS module, which may not support all module.exports as named exports.`
|
|
120
160
|
{
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
return
|
|
161
|
+
const packageName = parseImportFrom(anywhere);
|
|
162
|
+
if (packageName)
|
|
163
|
+
return packageName;
|
|
124
164
|
}
|
|
125
165
|
if (includes(anywhere, 'Cannot read properties of undefined')) {
|
|
126
166
|
if (isRelatedToNodeModules) {
|
|
@@ -150,14 +190,13 @@ function isCjsEsmError(error) {
|
|
|
150
190
|
}
|
|
151
191
|
return false;
|
|
152
192
|
}
|
|
153
|
-
exports.isCjsEsmError = isCjsEsmError;
|
|
154
193
|
function parseCannotFindMessage(str) {
|
|
155
194
|
const match = /Cannot find \S+ '(\S+)' imported from (\S+)/.exec(str);
|
|
156
195
|
if (!match)
|
|
157
196
|
return false;
|
|
158
197
|
// const packageNameCannotFind = extractFromPath(match[1]!)
|
|
159
198
|
const packageNameFrom = extractFromPath(match[2]);
|
|
160
|
-
return
|
|
199
|
+
return normalizeArray([
|
|
161
200
|
// packageNameCannotFind,
|
|
162
201
|
packageNameFrom
|
|
163
202
|
]);
|
|
@@ -168,7 +207,7 @@ function parseUnkownFileExtensionMessage(str) {
|
|
|
168
207
|
return false;
|
|
169
208
|
const filePath = match[1];
|
|
170
209
|
const packageName = extractFromPath(filePath);
|
|
171
|
-
return
|
|
210
|
+
return packageName;
|
|
172
211
|
}
|
|
173
212
|
function parseImportFrom(str) {
|
|
174
213
|
const match = /\bimport\b.*?\bfrom\b\s*?"(.+?)"/.exec(str);
|
|
@@ -176,7 +215,7 @@ function parseImportFrom(str) {
|
|
|
176
215
|
return false;
|
|
177
216
|
const importPath = match[1];
|
|
178
217
|
const packageName = extractFromPath(importPath);
|
|
179
|
-
return
|
|
218
|
+
return packageName;
|
|
180
219
|
}
|
|
181
220
|
function parseNodeModulesPathMessage(begin, str) {
|
|
182
221
|
str = str.replaceAll('\\', '/');
|
|
@@ -230,7 +269,6 @@ function extractFromPath(filePath) {
|
|
|
230
269
|
packageName = packageName.split('/')[0];
|
|
231
270
|
}
|
|
232
271
|
packageName = clean(packageName);
|
|
233
|
-
(0, utils_js_1.assert)(!['vite', 'vike'].includes(packageName));
|
|
234
272
|
return packageName;
|
|
235
273
|
}
|
|
236
274
|
function clean(packageName) {
|
|
@@ -248,7 +286,7 @@ function extractFromNodeModulesPath(str) {
|
|
|
248
286
|
return false;
|
|
249
287
|
const packageName = extractFromPath(str);
|
|
250
288
|
(0, utils_js_1.assert)(packageName);
|
|
251
|
-
return
|
|
289
|
+
return packageName;
|
|
252
290
|
}
|
|
253
291
|
function includes(str1, str2) {
|
|
254
292
|
return !!str1 && str1.toLowerCase().includes(str2.toLowerCase());
|
|
@@ -263,11 +301,11 @@ function includesNodeModules(str) {
|
|
|
263
301
|
return false;
|
|
264
302
|
return true;
|
|
265
303
|
}
|
|
266
|
-
function
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
return
|
|
270
|
-
return
|
|
304
|
+
function normalizeArray(arr) {
|
|
305
|
+
const arrNormalized = arr.filter(utils_js_1.isNotNullish);
|
|
306
|
+
if (arrNormalized.length === 0)
|
|
307
|
+
return null;
|
|
308
|
+
return arrNormalized;
|
|
271
309
|
}
|
|
272
310
|
function getErrMessage(err) {
|
|
273
311
|
if (!(0, utils_js_1.isObject)(err))
|
|
@@ -10,7 +10,7 @@ const abort_js_1 = require("../../../shared/route/abort.js");
|
|
|
10
10
|
const isNewError_js_1 = require("./isNewError.js");
|
|
11
11
|
const utils_js_1 = require("../utils.js");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
|
-
const
|
|
13
|
+
const logErrorHint_js_1 = require("./logErrorHint.js");
|
|
14
14
|
function logErrorProd(err, _httpRquestId) {
|
|
15
15
|
(0, utils_js_1.warnIfErrorIsNotObject)(err);
|
|
16
16
|
(0, isNewError_js_1.setAlreadyLogged)(err);
|
|
@@ -25,7 +25,7 @@ function logErrorProd(err, _httpRquestId) {
|
|
|
25
25
|
exports.logErrorProd = logErrorProd;
|
|
26
26
|
// Every server-side runtime error is expected to go through onRuntimeError(). (In principle, any runtime error is (or at least should) be catched by Vike, otherwise Vike couldn't render the error page.)
|
|
27
27
|
function onRuntimeError(err) {
|
|
28
|
-
// The more runtime errors we pass to
|
|
29
|
-
(0,
|
|
28
|
+
// The more runtime errors we pass to logErrorHint() the better.
|
|
29
|
+
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
30
30
|
}
|
|
31
31
|
exports.onRuntimeError = onRuntimeError;
|
|
@@ -55,7 +55,7 @@ __exportStar(require("../../utils/isNpmPackage.js"), exports);
|
|
|
55
55
|
__exportStar(require("../../utils/isNotNullish.js"), exports);
|
|
56
56
|
__exportStar(require("../../utils/isScriptFile.js"), exports);
|
|
57
57
|
__exportStar(require("../../utils/removeFileExtention.js"), exports);
|
|
58
|
-
__exportStar(require("../../utils/
|
|
58
|
+
__exportStar(require("../../utils/objectKeys.js"), exports);
|
|
59
59
|
__exportStar(require("../../utils/isStringRecord.js"), exports);
|
|
60
60
|
__exportStar(require("../../utils/getFileExtension.js"), exports);
|
|
61
61
|
__exportStar(require("../../utils/assertIsNotProductionRuntime.js"), exports);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.assertPlusFileExport = void 0;
|
|
7
|
+
const utils_js_1 = require("../utils.js");
|
|
8
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
+
const EXPORTS_IGNORE = [
|
|
10
|
+
// vite-plugin-solid adds `export { $$registrations }`
|
|
11
|
+
'$$registrations',
|
|
12
|
+
// @vitejs/plugin-vue adds `export { _rerender_only }`
|
|
13
|
+
'_rerender_only'
|
|
14
|
+
];
|
|
15
|
+
// Tolerate `export { frontmatter }` in .mdx files
|
|
16
|
+
const TOLERATE_SIDE_EXPORTS = ['.md', '.mdx'];
|
|
17
|
+
function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
18
|
+
const exportsAll = Object.keys(fileExports).filter((exportName) => !EXPORTS_IGNORE.includes(exportName));
|
|
19
|
+
const exportsInvalid = exportsAll.filter((e) => e !== 'default' && e !== configName);
|
|
20
|
+
if (exportsInvalid.length === 0) {
|
|
21
|
+
if (exportsAll.length === 1) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const exportDefault = picocolors_1.default.cyan('export default');
|
|
25
|
+
const exportNamed = picocolors_1.default.cyan(`export { ${configName} }`);
|
|
26
|
+
if (exportsAll.length === 0) {
|
|
27
|
+
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} doesn't export any value, but it should have a ${exportNamed} or ${exportDefault}`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
(0, utils_js_1.assert)(exportsAll.length === 2); // because `exportsInvalid.length === 0`
|
|
31
|
+
(0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} remove ${exportNamed} or ${exportDefault}`, {
|
|
32
|
+
onlyOnce: true
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (TOLERATE_SIDE_EXPORTS.some((ext) => filePathToShowToUser.endsWith(ext)))
|
|
38
|
+
return;
|
|
39
|
+
exportsInvalid.forEach((exportInvalid) => {
|
|
40
|
+
(0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} should have only one export: move ${picocolors_1.default.cyan(`export { ${exportInvalid} }`)} to its own +${exportsInvalid}.js file`, { onlyOnce: true });
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.assertPlusFileExport = assertPlusFileExport;
|
|
@@ -2,43 +2,70 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseConfigValuesImported = void 0;
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
const
|
|
5
|
+
const assertPlusFileExport_js_1 = require("../assertPlusFileExport.js");
|
|
6
6
|
function parseConfigValuesImported(configValuesImported) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
definedAt: {
|
|
12
|
-
// importPath cannot be relative to the current file, since the current file is a virtual file
|
|
13
|
-
filePathToShowToUser: importPath,
|
|
14
|
-
fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
|
|
15
|
-
? []
|
|
16
|
-
: // Side-effect config
|
|
17
|
-
[exportName]
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
assertIsNotNull(value, configName, importPath);
|
|
21
|
-
};
|
|
22
|
-
configValuesImported.forEach((configValueLoaded) => {
|
|
7
|
+
const configValuesUnmerged = {};
|
|
8
|
+
configValuesImported
|
|
9
|
+
.filter((c) => c.configName !== 'client')
|
|
10
|
+
.forEach((configValueLoaded) => {
|
|
23
11
|
if (configValueLoaded.isValueFile) {
|
|
24
12
|
const { exportValues, importPath, configName } = configValueLoaded;
|
|
25
|
-
|
|
26
|
-
(0, assertExports_js_1.assertExportsOfValueFile)(exportValues, importPath, configName);
|
|
27
|
-
}
|
|
13
|
+
(0, assertPlusFileExport_js_1.assertPlusFileExport)(exportValues, importPath, configName);
|
|
28
14
|
Object.entries(exportValues).forEach(([exportName, exportValue]) => {
|
|
29
15
|
const isSideExport = exportName !== 'default'; // .md files may have "side-exports" such as `export { frontmatter }`
|
|
30
16
|
const configName = isSideExport ? exportName : configValueLoaded.configName;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
|
|
18
|
+
configValuesUnmerged[configName].push({
|
|
19
|
+
value: exportValue,
|
|
20
|
+
importPath,
|
|
21
|
+
exportName,
|
|
22
|
+
isSideExport
|
|
23
|
+
});
|
|
37
24
|
});
|
|
38
25
|
}
|
|
39
26
|
else {
|
|
40
27
|
const { configName, importPath, exportValue, exportName } = configValueLoaded;
|
|
41
|
-
|
|
28
|
+
configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
|
|
29
|
+
configValuesUnmerged[configName].push({
|
|
30
|
+
value: exportValue,
|
|
31
|
+
importPath,
|
|
32
|
+
exportName,
|
|
33
|
+
isSideExport: false
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const configValues = {};
|
|
38
|
+
Object.entries(configValuesUnmerged).forEach(([configName, values]) => {
|
|
39
|
+
const valuesWithoutSideExports = values.filter((v) => !v.isSideExport);
|
|
40
|
+
const isCumulative = valuesWithoutSideExports.length > 1;
|
|
41
|
+
const noSideExports = valuesWithoutSideExports.length === values.length;
|
|
42
|
+
if (isCumulative) {
|
|
43
|
+
// Vike currently doesn't support side exports for cumulative configs
|
|
44
|
+
(0, utils_js_1.assert)(noSideExports);
|
|
45
|
+
// TODO: implement
|
|
46
|
+
(0, utils_js_1.assert)(false);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const val = valuesWithoutSideExports[0] ??
|
|
50
|
+
// We can't avoid side-export conflicts upstream. (We cannot know about side-exports at build-time.)
|
|
51
|
+
// Side-exports have lower precedence.
|
|
52
|
+
values[0];
|
|
53
|
+
(0, utils_js_1.assert)(val);
|
|
54
|
+
const { value, importPath, exportName } = val;
|
|
55
|
+
configValues[configName] = {
|
|
56
|
+
value,
|
|
57
|
+
definedAt: {
|
|
58
|
+
// importPath cannot be relative to the current file, since the current file is a virtual file
|
|
59
|
+
filePathToShowToUser: importPath,
|
|
60
|
+
fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
|
|
61
|
+
? []
|
|
62
|
+
: [
|
|
63
|
+
// Side-export
|
|
64
|
+
exportName
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
assertIsNotNull(value, configName, importPath);
|
|
42
69
|
}
|
|
43
70
|
});
|
|
44
71
|
return configValues;
|
|
@@ -136,7 +136,7 @@ function logAbortErrorHandled(err, isProduction, pageContext) {
|
|
|
136
136
|
exports.logAbortErrorHandled = logAbortErrorHandled;
|
|
137
137
|
function assertStatusCode(statusCode, expected, caller) {
|
|
138
138
|
const expectedEnglish = (0, utils_js_1.joinEnglish)(expected.map((s) => s.toString()), 'or');
|
|
139
|
-
(0, utils_js_1.assertWarning)(expected.includes(statusCode), `Unepexected status code ${statusCode} passed to ${caller}(), we recommend ${expectedEnglish} instead. (Or reach out at
|
|
139
|
+
(0, utils_js_1.assertWarning)(expected.includes(statusCode), `Unepexected status code ${statusCode} passed to ${caller}(), we recommend ${expectedEnglish} instead. (Or reach out at https://github.com/vikejs/vike/issues/1008 if you believe ${statusCode} should be added.)`, { onlyOnce: true });
|
|
140
140
|
}
|
|
141
141
|
function getPageContextFromAllRewrites(pageContextsFromRewrite) {
|
|
142
142
|
assertNoInfiniteLoop(pageContextsFromRewrite);
|