vike 0.4.142 → 0.4.143-commit-dc6fea0
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 +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +4 -5
- package/dist/cjs/node/plugin/plugins/commonConfig.js +2 -7
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -2
- package/dist/cjs/node/plugin/plugins/envVars.js +3 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +6 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +122 -124
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +37 -27
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +50 -80
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +12 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +19 -16
- package/dist/cjs/node/plugin/plugins/suppressRollupWarning.js +16 -3
- package/dist/cjs/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +1 -12
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +3 -3
- package/dist/cjs/node/plugin/utils.js +1 -2
- package/dist/cjs/node/prerender/runPrerender.js +13 -16
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/html/stream.js +4 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/log404/index.js +10 -5
- package/dist/cjs/node/shared/virtual-files/virtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/shared/error-page.js +1 -1
- package/dist/cjs/shared/getPageFiles/assertPageConfigs.js +13 -13
- package/dist/cjs/shared/getPageFiles/getExports.js +3 -3
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +9 -43
- package/dist/cjs/shared/getPageFiles/parsePageConfigsSerialized.js +62 -0
- package/dist/cjs/shared/page-configs/assertExports.js +60 -0
- package/dist/cjs/shared/page-configs/loadConfigValues.js +18 -0
- package/dist/cjs/shared/page-configs/parseConfigValuesImported.js +50 -0
- package/dist/cjs/shared/page-configs/utils.js +1 -1
- package/dist/cjs/shared/route/loadPageRoutes.js +11 -13
- package/dist/cjs/shared/route/resolvePrecedence.js +32 -11
- package/dist/cjs/shared/route/resolveRedirects.js +1 -1
- package/dist/cjs/shared/route/resolveRouteFunction.js +1 -0
- package/dist/cjs/shared/route/resolveRouteString.js +99 -43
- package/dist/cjs/shared/utils.js +1 -1
- package/dist/cjs/types/defineConfig.js +7 -0
- package/dist/cjs/types/index.js +3 -0
- package/dist/cjs/utils/getFilePathAbsolute.js +16 -12
- package/dist/cjs/utils/objectAssign.js +3 -1
- package/dist/cjs/utils/parseUrl.js +6 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/requireResolve.js +60 -0
- package/dist/esm/__internal/index.d.ts +3 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageId.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +3 -1
- package/dist/esm/client/client-routing-runtime/useClientRouter.js +2 -2
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/plugin/index.js +3 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +4 -5
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -7
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -1
- package/dist/esm/node/plugin/plugins/envVars.js +4 -6
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +13 -2
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +19 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +6 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +123 -125
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +35 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +49 -79
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +10 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.d.ts +18 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +19 -16
- package/dist/esm/node/plugin/plugins/suppressRollupWarning.js +16 -3
- package/dist/esm/node/plugin/shared/{getConfigValueSource.d.ts → getConfigValueSourcesRelevant.d.ts} +0 -2
- package/dist/esm/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +0 -11
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +2 -2
- package/dist/esm/node/plugin/shared/loggerNotProd.js +4 -4
- 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 -16
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +2 -2
- package/dist/esm/node/runtime/html/stream.js +4 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.js +10 -5
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +13 -13
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +2 -2
- package/dist/esm/node/shared/virtual-files/virtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/shared/addIs404ToPageProps.d.ts +2 -2
- package/dist/esm/shared/addUrlComputedProps.d.ts +4 -2
- package/dist/esm/shared/error-page.d.ts +3 -3
- package/dist/esm/shared/error-page.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +2 -2
- package/dist/esm/shared/getPageFiles/assertPageConfigs.d.ts +5 -5
- package/dist/esm/shared/getPageFiles/assertPageConfigs.js +12 -12
- package/dist/esm/shared/getPageFiles/getExports.d.ts +2 -2
- package/dist/esm/shared/getPageFiles/getExports.js +1 -1
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +3 -3
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +9 -43
- package/dist/esm/shared/getPageFiles/parsePageConfigsSerialized.d.ts +6 -0
- package/dist/esm/shared/getPageFiles/parsePageConfigsSerialized.js +59 -0
- package/dist/esm/shared/getPageFiles/setPageFiles.d.ts +3 -3
- package/dist/esm/shared/page-configs/Config.d.ts +201 -14
- package/dist/esm/shared/page-configs/PageConfig.d.ts +60 -39
- package/dist/esm/shared/page-configs/assertExports.d.ts +6 -0
- package/dist/esm/shared/page-configs/assertExports.js +54 -0
- package/dist/esm/shared/page-configs/findPageConfig.d.ts +2 -2
- package/dist/esm/shared/page-configs/loadConfigValues.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +15 -0
- package/dist/esm/shared/page-configs/parseConfigValuesImported.d.ts +3 -0
- package/dist/esm/shared/page-configs/parseConfigValuesImported.js +44 -0
- package/dist/esm/shared/page-configs/utils.d.ts +3 -2
- package/dist/esm/shared/page-configs/utils.js +1 -1
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/loadPageRoutes.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +11 -13
- package/dist/esm/shared/route/resolvePrecedence.js +33 -12
- package/dist/esm/shared/route/resolveRedirects.js +1 -1
- package/dist/esm/shared/route/resolveRouteFunction.js +1 -0
- package/dist/esm/shared/route/resolveRouteString.d.ts +21 -4
- package/dist/esm/shared/route/resolveRouteString.js +98 -42
- package/dist/esm/shared/types.d.ts +8 -6
- package/dist/esm/shared/utils.d.ts +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/esm/types/defineConfig.d.ts +3 -0
- package/dist/esm/types/defineConfig.js +4 -0
- package/dist/esm/types/index.d.ts +3 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/utils/getFilePathAbsolute.d.ts +2 -2
- package/dist/esm/utils/getFilePathAbsolute.js +15 -11
- package/dist/esm/utils/objectAssign.js +3 -1
- package/dist/esm/utils/parseUrl.js +6 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/requireResolve.d.ts +2 -0
- package/dist/esm/utils/requireResolve.js +57 -0
- package/package.json +3 -3
- package/dist/cjs/shared/page-configs/loadPageCode.js +0 -63
- package/dist/cjs/utils/addFileExtensionsToRequireResolve.js +0 -23
- package/dist/cjs/utils/assertDefaultExport.js +0 -53
- package/dist/esm/shared/page-configs/loadPageCode.d.ts +0 -3
- package/dist/esm/shared/page-configs/loadPageCode.js +0 -57
- package/dist/esm/utils/addFileExtensionsToRequireResolve.d.ts +0 -2
- package/dist/esm/utils/addFileExtensionsToRequireResolve.js +0 -20
- package/dist/esm/utils/assertDefaultExport.d.ts +0 -8
- package/dist/esm/utils/assertDefaultExport.js +0 -47
- /package/dist/cjs/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.d.ts → assert_exports_old_design.d.ts} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
|
@@ -3,9 +3,8 @@ 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.getVirtualFilePageConfigs = void 0;
|
|
6
|
+
exports.getConfigValueSerialized = exports.getVirtualFilePageConfigs = void 0;
|
|
7
7
|
const utils_js_1 = require("../../../utils.js");
|
|
8
|
-
const generateEagerImport_js_1 = require("../generateEagerImport.js");
|
|
9
8
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
10
9
|
const debug_js_1 = require("./debug.js");
|
|
11
10
|
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
@@ -13,6 +12,7 @@ const helpers_js_1 = require("./helpers.js");
|
|
|
13
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
13
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
15
14
|
const isConfigEnvMatch_js_1 = require("./isConfigEnvMatch.js");
|
|
15
|
+
const getVirtualFilePageConfigValuesAll_js_1 = require("./getVirtualFilePageConfigValuesAll.js");
|
|
16
16
|
async function getVirtualFilePageConfigs(userRootDir, isForClientSide, isDev, id, configVike, isClientRouting) {
|
|
17
17
|
const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(userRootDir, isDev, configVike.extensions, true);
|
|
18
18
|
return getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
@@ -21,7 +21,8 @@ exports.getVirtualFilePageConfigs = getVirtualFilePageConfigs;
|
|
|
21
21
|
function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
22
22
|
const lines = [];
|
|
23
23
|
const importStatements = [];
|
|
24
|
-
|
|
24
|
+
const varCounterContainer = { varCounter: 0 };
|
|
25
|
+
lines.push('export const pageConfigsSerialized = [');
|
|
25
26
|
pageConfigs.forEach((pageConfig) => {
|
|
26
27
|
const { pageId, routeFilesystem, isErrorPage } = pageConfig;
|
|
27
28
|
const virtualFileIdPageConfigValuesAll = (0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, isForClientSide);
|
|
@@ -30,7 +31,7 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
30
31
|
lines.push(` isErrorPage: ${JSON.stringify(isErrorPage)},`);
|
|
31
32
|
lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
|
|
32
33
|
lines.push(` loadConfigValuesAll: async () => (await import(${JSON.stringify(virtualFileIdPageConfigValuesAll)})).default,`);
|
|
33
|
-
lines.push(`
|
|
34
|
+
lines.push(` configValuesSerialized: {`);
|
|
34
35
|
Object.entries(pageConfig.configValueSources).forEach(([configName, sources]) => {
|
|
35
36
|
const configValue = pageConfig.configValues[configName];
|
|
36
37
|
if (configValue) {
|
|
@@ -39,101 +40,71 @@ function getContent(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, i
|
|
|
39
40
|
if (!(0, isConfigEnvMatch_js_1.isConfigEnvMatch)(configEnv, isForClientSide, isClientRouting))
|
|
40
41
|
return;
|
|
41
42
|
const { value, definedAtInfo } = configValue;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const valueSerialized = JSON.stringify(value);
|
|
45
|
-
serializeConfigValue(lines, configName, { definedAtInfo }, valueSerialized);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const configValueSource = sources[0];
|
|
49
|
-
(0, utils_js_1.assert)(configValueSource);
|
|
50
|
-
if (configValueSource.configEnv === '_routing-eager') {
|
|
51
|
-
const { definedAtInfo } = configValueSource;
|
|
52
|
-
const configValue = { configName, definedAtInfo };
|
|
53
|
-
(0, utils_js_1.assert)(!configValueSource.isComputed);
|
|
54
|
-
const { filePath, fileExportPath } = configValueSource.definedAtInfo;
|
|
55
|
-
const [exportName] = fileExportPath;
|
|
56
|
-
(0, utils_js_1.assert)(exportName);
|
|
57
|
-
const configValueEagerImport = getConfigValueEagerImport(filePath, exportName, importStatements);
|
|
58
|
-
serializeConfigValue(lines, configName, configValue, configValueEagerImport);
|
|
59
|
-
}
|
|
43
|
+
const valueSerialized = getConfigValueSerialized(value, configName, definedAtInfo);
|
|
44
|
+
serializeConfigValue(lines, configName, { definedAtInfo, valueSerialized });
|
|
60
45
|
}
|
|
61
46
|
});
|
|
62
47
|
lines.push(` },`);
|
|
48
|
+
let whitespace = ' ';
|
|
49
|
+
lines.push(`${whitespace}configValuesImported: [`);
|
|
50
|
+
Object.entries(pageConfig.configValueSources).forEach(([configName, sources]) => {
|
|
51
|
+
const configValue = pageConfig.configValues[configName];
|
|
52
|
+
if (configValue)
|
|
53
|
+
return;
|
|
54
|
+
const configValueSource = sources[0];
|
|
55
|
+
(0, utils_js_1.assert)(configValueSource);
|
|
56
|
+
if (configValueSource.configEnv !== '_routing-eager')
|
|
57
|
+
return;
|
|
58
|
+
(0, utils_js_1.assert)(!configValueSource.isComputed);
|
|
59
|
+
lines.push(...(0, getVirtualFilePageConfigValuesAll_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, varCounterContainer, importStatements));
|
|
60
|
+
});
|
|
61
|
+
lines.push(`${whitespace}],`);
|
|
62
|
+
// pageConfig end
|
|
63
63
|
lines.push(` },`);
|
|
64
64
|
});
|
|
65
65
|
lines.push('];');
|
|
66
|
-
lines.push('export const
|
|
67
|
-
|
|
66
|
+
lines.push('export const pageConfigGlobalSerialized = {');
|
|
67
|
+
/* Nothing (yet)
|
|
68
|
+
lines.push(` configValuesSerialized: {`)
|
|
69
|
+
lines.push(` },`)
|
|
70
|
+
*/
|
|
71
|
+
lines.push(` configValuesImported: [`);
|
|
72
|
+
(0, utils_js_1.objectEntries)(pageConfigGlobal.configValueSources).forEach(([configName, sources]) => {
|
|
68
73
|
if (configName === 'onBeforeRoute') {
|
|
69
74
|
// if( isForClientSide && !isClientRouting ) return
|
|
70
75
|
}
|
|
71
76
|
else if (configName === 'onPrerenderStart') {
|
|
72
77
|
if (isDev || isForClientSide) {
|
|
73
78
|
// Only load onPrerenderStart() in server production runtime
|
|
74
|
-
|
|
79
|
+
return;
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
else {
|
|
78
83
|
(0, utils_js_1.assert)(false);
|
|
79
84
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
content = serializeConfigValueSource(configValueSource, configName, whitespace, isForClientSide, isClientRouting, importStatements, true);
|
|
87
|
-
(0, utils_js_1.assert)(content.startsWith('{') && content.endsWith('},') && content.includes('\n'));
|
|
88
|
-
}
|
|
89
|
-
content = `${whitespace}[${JSON.stringify(configName)}]: ${content}`;
|
|
90
|
-
lines.push(content);
|
|
85
|
+
const configValueSource = sources[0];
|
|
86
|
+
(0, utils_js_1.assert)(configValueSource);
|
|
87
|
+
const whitespace = ' ';
|
|
88
|
+
lines.push(...(0, getVirtualFilePageConfigValuesAll_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, varCounterContainer, importStatements));
|
|
91
89
|
});
|
|
90
|
+
lines.push(` ],`);
|
|
92
91
|
lines.push('};');
|
|
93
92
|
const code = [...importStatements, ...lines].join('\n');
|
|
94
93
|
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
95
94
|
return code;
|
|
96
95
|
}
|
|
97
|
-
function serializeConfigValue(lines, configName,
|
|
96
|
+
function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
98
97
|
let whitespace = ' ';
|
|
99
98
|
lines.push(`${whitespace}['${configName}']: {`);
|
|
100
99
|
whitespace += ' ';
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return;
|
|
105
|
-
// if (val === undefined) return
|
|
106
|
-
lines.push(`${whitespace} ${key}: ${JSON.stringify(val)},`);
|
|
100
|
+
Object.entries(configValueSerialized).forEach(([key, val]) => {
|
|
101
|
+
const valSerialized = key === 'definedAtInfo' ? JSON.stringify(val) : val;
|
|
102
|
+
lines.push(`${whitespace} ${key}: ${valSerialized},`);
|
|
107
103
|
});
|
|
108
104
|
whitespace = whitespace.slice(2);
|
|
109
105
|
lines.push(`${whitespace}},`);
|
|
110
106
|
}
|
|
111
|
-
function
|
|
112
|
-
(0, utils_js_1.assert)(!configValueSource.isComputed);
|
|
113
|
-
const { definedAtInfo, configEnv } = configValueSource;
|
|
114
|
-
const lines = [];
|
|
115
|
-
lines.push(`{`);
|
|
116
|
-
lines.push(`${whitespace} definedAtInfo: ${JSON.stringify(definedAtInfo)},`);
|
|
117
|
-
lines.push(`${whitespace} configEnv: ${JSON.stringify(configEnv)},`);
|
|
118
|
-
const eager = configValueSource.configEnv === '_routing-eager' || isGlobalConfig;
|
|
119
|
-
if ((0, isConfigEnvMatch_js_1.isConfigEnvMatch)(configEnv, isForClientSide, isClientRouting) || eager) {
|
|
120
|
-
if ('value' in configValueSource) {
|
|
121
|
-
const { value } = configValueSource;
|
|
122
|
-
const valueSerialized = getConfigValueSerialized(value, configName, definedAtInfo.filePath);
|
|
123
|
-
lines.push(`${whitespace} valueSerialized: ${valueSerialized}`);
|
|
124
|
-
}
|
|
125
|
-
else if (eager) {
|
|
126
|
-
const { filePath, fileExportPath } = configValueSource.definedAtInfo;
|
|
127
|
-
const [exportName] = fileExportPath;
|
|
128
|
-
(0, utils_js_1.assert)(exportName);
|
|
129
|
-
const configValueEagerImport = getConfigValueEagerImport(filePath, exportName, importStatements);
|
|
130
|
-
lines.push(`${whitespace} value: ${configValueEagerImport},`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
lines.push(`${whitespace}},`);
|
|
134
|
-
return lines.join('\n');
|
|
135
|
-
}
|
|
136
|
-
function getConfigValueSerialized(value, configName, configDefinedByFile) {
|
|
107
|
+
function getConfigValueSerialized(value, configName, definedAtInfo) {
|
|
137
108
|
let configValueSerialized;
|
|
138
109
|
const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
|
|
139
110
|
try {
|
|
@@ -141,20 +112,19 @@ function getConfigValueSerialized(value, configName, configDefinedByFile) {
|
|
|
141
112
|
}
|
|
142
113
|
catch (err) {
|
|
143
114
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(err, 'messageCore', 'string'));
|
|
115
|
+
// definedAtInfo is null when config value is:
|
|
116
|
+
// - computed => all computed values defined by Vike can are serializable
|
|
117
|
+
// - cumulative => the values are already ensured to be serializable
|
|
118
|
+
(0, utils_js_1.assert)(definedAtInfo);
|
|
119
|
+
const configDefinedByFile = definedAtInfo.filePath;
|
|
120
|
+
(0, utils_js_1.assert)(configDefinedByFile);
|
|
144
121
|
(0, utils_js_1.assertUsage)(false, [
|
|
145
|
-
`The value of the config ${picocolors_1.default.cyan(configName)} cannot be defined inside the file ${configDefinedByFile}
|
|
146
|
-
`
|
|
147
|
-
`Only serializable config values can be defined inside
|
|
122
|
+
`The value of the config ${picocolors_1.default.cyan(configName)} cannot be defined inside the file ${configDefinedByFile}:`,
|
|
123
|
+
`its value must be defined in an another file and then imported by ${configDefinedByFile}. (Because the value isn't serializable: ${err.messageCore}.)`,
|
|
124
|
+
`Only serializable config values can be defined inside +config.h.js files, see https://vike.dev/header-file.`
|
|
148
125
|
].join(' '));
|
|
149
126
|
}
|
|
150
127
|
configValueSerialized = JSON.stringify(configValueSerialized);
|
|
151
128
|
return configValueSerialized;
|
|
152
129
|
}
|
|
153
|
-
|
|
154
|
-
let configValueEagerImport;
|
|
155
|
-
const { importVar, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(importFilePath);
|
|
156
|
-
importStatements.push(importStatement);
|
|
157
|
-
// TODO: expose all exports so that assertDefaultExport can be applied
|
|
158
|
-
configValueEagerImport = `${importVar}[${JSON.stringify(exportName)}]`;
|
|
159
|
-
return configValueEagerImport;
|
|
160
|
-
}
|
|
130
|
+
exports.getConfigValueSerialized = getConfigValueSerialized;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isConfigSet = exports.getConfigEnv = void 0;
|
|
4
|
-
const getConfigValueSource_js_1 = require("../../../shared/getConfigValueSource.js");
|
|
5
4
|
const utils_js_1 = require("../../../utils.js");
|
|
6
5
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
7
6
|
function getConfigEnv(pageConfig, configName) {
|
|
8
|
-
const configValueSource =
|
|
7
|
+
const configValueSource = getConfigValueSource(pageConfig, configName);
|
|
9
8
|
if (!configValueSource)
|
|
10
9
|
return null;
|
|
11
10
|
if (configValueSource) {
|
|
@@ -25,10 +24,20 @@ function getConfigEnv(pageConfig, configName) {
|
|
|
25
24
|
}
|
|
26
25
|
exports.getConfigEnv = getConfigEnv;
|
|
27
26
|
function isConfigSet(pageConfig, configName) {
|
|
28
|
-
const configValueSource =
|
|
27
|
+
const configValueSource = getConfigValueSource(pageConfig, configName);
|
|
29
28
|
// Enable users to suppress global config values by overriding the config's value to null
|
|
30
29
|
if (configValueSource?.value === null)
|
|
31
30
|
return false;
|
|
32
31
|
return !!configValueSource;
|
|
33
32
|
}
|
|
34
33
|
exports.isConfigSet = isConfigSet;
|
|
34
|
+
function getConfigValueSource(pageConfig, configName) {
|
|
35
|
+
// Doesn't exist on the client-side, but we are on the server-side as attested by assertIsNotBrowser()
|
|
36
|
+
(0, utils_js_1.assert)(pageConfig.configValueSources);
|
|
37
|
+
const sources = pageConfig.configValueSources[configName];
|
|
38
|
+
if (!sources)
|
|
39
|
+
return null;
|
|
40
|
+
const configValueSource = sources[0];
|
|
41
|
+
(0, utils_js_1.assert)(configValueSource);
|
|
42
|
+
return configValueSource;
|
|
43
|
+
}
|
|
@@ -17,13 +17,13 @@ function replaceImportStatements(code, filePathToShowToUser) {
|
|
|
17
17
|
imports.forEach((node) => {
|
|
18
18
|
if (node.type !== 'ImportDeclaration')
|
|
19
19
|
return;
|
|
20
|
-
const
|
|
21
|
-
(0, utils_js_1.assert)(typeof
|
|
20
|
+
const importPath = node.source.value;
|
|
21
|
+
(0, utils_js_1.assert)(typeof importPath === 'string');
|
|
22
22
|
const { start, end } = node;
|
|
23
23
|
const importStatementCode = code.slice(start, end);
|
|
24
24
|
// No variable imported
|
|
25
25
|
if (node.specifiers.length === 0) {
|
|
26
|
-
const isWarning = !utils_js_1.styleFileRE.test(
|
|
26
|
+
const isWarning = !utils_js_1.styleFileRE.test(importPath);
|
|
27
27
|
let quote = indent(importStatementCode);
|
|
28
28
|
if (isWarning) {
|
|
29
29
|
quote = picocolors_1.default.cyan(quote);
|
|
@@ -46,7 +46,7 @@ function replaceImportStatements(code, filePathToShowToUser) {
|
|
|
46
46
|
specifier.type === 'ImportDefaultSpecifier' ||
|
|
47
47
|
specifier.type === 'ImportNamespaceSpecifier');
|
|
48
48
|
const importLocalName = specifier.local.name;
|
|
49
|
-
const
|
|
49
|
+
const exportName = (() => {
|
|
50
50
|
if (specifier.type === 'ImportDefaultSpecifier')
|
|
51
51
|
return 'default';
|
|
52
52
|
if (specifier.type === 'ImportNamespaceSpecifier')
|
|
@@ -58,11 +58,11 @@ function replaceImportStatements(code, filePathToShowToUser) {
|
|
|
58
58
|
}
|
|
59
59
|
return importLocalName;
|
|
60
60
|
})();
|
|
61
|
-
const
|
|
62
|
-
replacement += `const ${importLocalName} = '${
|
|
61
|
+
const importString = serializeImportData({ importPath, exportName, importStringWasGenerated: true });
|
|
62
|
+
replacement += `const ${importLocalName} = '${importString}';`;
|
|
63
63
|
fileImports.push({
|
|
64
64
|
importStatementCode,
|
|
65
|
-
|
|
65
|
+
importString,
|
|
66
66
|
importLocalName
|
|
67
67
|
});
|
|
68
68
|
});
|
|
@@ -92,35 +92,35 @@ function getImports(code) {
|
|
|
92
92
|
const import_ = 'import';
|
|
93
93
|
const SEP = ':';
|
|
94
94
|
const zeroWidthSpace = '\u200b';
|
|
95
|
-
function serializeImportData({
|
|
96
|
-
const tag =
|
|
97
|
-
// `import:${
|
|
98
|
-
return `${tag}${import_}${SEP}${
|
|
95
|
+
function serializeImportData({ importPath, exportName, importStringWasGenerated }) {
|
|
96
|
+
const tag = importStringWasGenerated ? zeroWidthSpace : '';
|
|
97
|
+
// `import:${importPath}:${importPath}`
|
|
98
|
+
return `${tag}${import_}${SEP}${importPath}${SEP}${exportName}`;
|
|
99
99
|
}
|
|
100
100
|
function isImportData(str) {
|
|
101
101
|
return str.startsWith(import_ + SEP) || str.startsWith(zeroWidthSpace + import_ + SEP);
|
|
102
102
|
}
|
|
103
103
|
exports.isImportData = isImportData;
|
|
104
|
-
function parseImportData(
|
|
105
|
-
if (!isImportData(
|
|
104
|
+
function parseImportData(importString) {
|
|
105
|
+
if (!isImportData(importString)) {
|
|
106
106
|
return null;
|
|
107
107
|
}
|
|
108
|
-
let
|
|
109
|
-
if (
|
|
110
|
-
|
|
108
|
+
let importStringWasGenerated = false;
|
|
109
|
+
if (importString.startsWith(zeroWidthSpace)) {
|
|
110
|
+
importStringWasGenerated = true;
|
|
111
111
|
(0, utils_js_1.assert)(zeroWidthSpace.length === 1);
|
|
112
|
-
|
|
112
|
+
importString = importString.slice(1);
|
|
113
113
|
}
|
|
114
|
-
const parts =
|
|
115
|
-
if (!
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
return {
|
|
114
|
+
const parts = importString.split(SEP).slice(1);
|
|
115
|
+
if (!importStringWasGenerated && parts.length === 1) {
|
|
116
|
+
const exportName = 'default';
|
|
117
|
+
const importPath = parts[0];
|
|
118
|
+
return { importPath, exportName, importStringWasGenerated, importString };
|
|
119
119
|
}
|
|
120
120
|
(0, utils_js_1.assert)(parts.length >= 2);
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
return {
|
|
121
|
+
const exportName = parts[parts.length - 1];
|
|
122
|
+
const importPath = parts.slice(0, -1).join(SEP);
|
|
123
|
+
return { importPath, exportName, importStringWasGenerated, importString };
|
|
124
124
|
}
|
|
125
125
|
exports.parseImportData = parseImportData;
|
|
126
126
|
function spliceMany(str, operations) {
|
|
@@ -3,7 +3,7 @@ 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.isTmpFile = exports.
|
|
6
|
+
exports.isTmpFile = exports.getConfigExecutionErrorIntroMsg = exports.getConfigBuildErrorFormatted = exports.transpileAndExecuteFile = void 0;
|
|
7
7
|
const esbuild_1 = require("esbuild");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -14,10 +14,11 @@ const replaceImportStatements_js_1 = require("./replaceImportStatements.js");
|
|
|
14
14
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
15
15
|
require("source-map-support/register.js");
|
|
16
16
|
const getFilePathToShowToUser_js_1 = require("./getFilePathToShowToUser.js");
|
|
17
|
+
const assertExports_js_1 = require("../../../../../shared/page-configs/assertExports.js");
|
|
17
18
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
18
19
|
async function transpileAndExecuteFile(filePath, isValueFile, userRootDir) {
|
|
19
20
|
const { code, fileImports } = await transpileFile(filePath, isValueFile, userRootDir);
|
|
20
|
-
const { fileExports } = await executeFile(filePath, code, fileImports);
|
|
21
|
+
const { fileExports } = await executeFile(filePath, code, fileImports, isValueFile);
|
|
21
22
|
return { fileExports };
|
|
22
23
|
}
|
|
23
24
|
exports.transpileAndExecuteFile = transpileAndExecuteFile;
|
|
@@ -55,7 +56,9 @@ function transpileImports(codeOriginal, filePath, isValueFile) {
|
|
|
55
56
|
const { code, fileImports } = res;
|
|
56
57
|
if (!isHeader) {
|
|
57
58
|
const filePathCorrect = appendHeaderFileExtension(filePathToShowToUser);
|
|
58
|
-
(0, utils_js_1.assertWarning)(false, `Rename ${filePathToShowToUser} to ${filePathCorrect}, see https://vike.dev/header-file`, {
|
|
59
|
+
(0, utils_js_1.assertWarning)(false, `Rename ${filePathToShowToUser} to ${filePathCorrect}, see https://vike.dev/header-file`, {
|
|
60
|
+
onlyOnce: true
|
|
61
|
+
});
|
|
59
62
|
}
|
|
60
63
|
return { code, fileImports };
|
|
61
64
|
}
|
|
@@ -133,7 +136,7 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
133
136
|
(0, utils_js_1.assert)(typeof code === 'string');
|
|
134
137
|
return code;
|
|
135
138
|
}
|
|
136
|
-
async function executeFile(filePath, code, fileImports) {
|
|
139
|
+
async function executeFile(filePath, code, fileImports, isValueFile) {
|
|
137
140
|
const { filePathAbsolute, filePathRelativeToUserRootDir } = filePath;
|
|
138
141
|
// Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
|
|
139
142
|
// - But seems to break source maps, so I don't think it's worth it
|
|
@@ -158,10 +161,10 @@ async function executeFile(filePath, code, fileImports) {
|
|
|
158
161
|
// - import() returns `[Module: null prototype] { default: { onRenderClient: '...' }}`
|
|
159
162
|
// - We don't need this special object
|
|
160
163
|
fileExports = { ...fileExports };
|
|
161
|
-
if (fileImports) {
|
|
164
|
+
if (fileImports && !isValueFile) {
|
|
162
165
|
(0, utils_js_1.assert)(filePathRelativeToUserRootDir !== undefined);
|
|
163
|
-
const
|
|
164
|
-
|
|
166
|
+
const filePathToShowToUser = filePathRelativeToUserRootDir ?? filePathAbsolute;
|
|
167
|
+
assertImportsAreReExported(fileImports, fileExports, filePathToShowToUser);
|
|
165
168
|
}
|
|
166
169
|
return { fileExports };
|
|
167
170
|
}
|
|
@@ -187,13 +190,13 @@ async function formatBuildErr(err, filePath) {
|
|
|
187
190
|
err[formatted] = `${msgIntro}\n${msgEsbuild}`;
|
|
188
191
|
}
|
|
189
192
|
const execErrIntroMsg = new WeakMap();
|
|
190
|
-
function
|
|
193
|
+
function getConfigExecutionErrorIntroMsg(err) {
|
|
191
194
|
if (!(0, utils_js_1.isObject)(err))
|
|
192
195
|
return null;
|
|
193
196
|
const errIntroMsg = execErrIntroMsg.get(err);
|
|
194
197
|
return errIntroMsg ?? null;
|
|
195
198
|
}
|
|
196
|
-
exports.
|
|
199
|
+
exports.getConfigExecutionErrorIntroMsg = getConfigExecutionErrorIntroMsg;
|
|
197
200
|
const tmpPrefix = `[build-`;
|
|
198
201
|
function getFilePathTmp(filePath) {
|
|
199
202
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
@@ -210,17 +213,17 @@ function isTmpFile(filePath) {
|
|
|
210
213
|
return fileName.startsWith(tmpPrefix);
|
|
211
214
|
}
|
|
212
215
|
exports.isTmpFile = isTmpFile;
|
|
213
|
-
function
|
|
214
|
-
(0,
|
|
216
|
+
function assertImportsAreReExported(fileImports, fileExports, filePathToShowToUser) {
|
|
217
|
+
(0, assertExports_js_1.assertExportsOfConfigFile)(fileExports, filePathToShowToUser);
|
|
215
218
|
const exportedStrings = getExportedStrings(fileExports.default);
|
|
216
219
|
Object.values(exportedStrings).forEach((exportVal) => {
|
|
217
220
|
if (typeof exportVal !== 'string')
|
|
218
221
|
return;
|
|
219
222
|
if (!(0, replaceImportStatements_js_1.isImportData)(exportVal))
|
|
220
223
|
return;
|
|
221
|
-
const
|
|
224
|
+
const importString = exportVal;
|
|
222
225
|
fileImports.forEach((fileImport) => {
|
|
223
|
-
if (fileImport.
|
|
226
|
+
if (fileImport.importString === importString) {
|
|
224
227
|
fileImport.isReExported = true;
|
|
225
228
|
}
|
|
226
229
|
});
|
|
@@ -231,11 +234,11 @@ function assertFileImports(fileImports, fileExports, filePath) {
|
|
|
231
234
|
const importStatements = (0, utils_js_1.unique)(fileImportsUnused.map((fi) => fi.importStatementCode));
|
|
232
235
|
const importNamesUnused = fileImportsUnused.map((fi) => picocolors_1.default.cyan(fi.importLocalName)).join(', ');
|
|
233
236
|
const singular = fileImportsUnused.length === 1;
|
|
234
|
-
(0, utils_js_1.
|
|
235
|
-
`${
|
|
237
|
+
(0, utils_js_1.assertUsage)(fileImportsUnused.length === 0, [
|
|
238
|
+
`${filePathToShowToUser} imports the following:`,
|
|
236
239
|
...importStatements.map((s) => picocolors_1.default.cyan(` ${s}`)),
|
|
237
240
|
`But the import${singular ? '' : 's'} ${importNamesUnused} ${singular ? "isn't" : "aren't"} re-exported at ${picocolors_1.default.cyan('export default { ... }')} and therefore ${singular ? 'has' : 'have'} no effect, see explanation at https://vike.dev/header-file`
|
|
238
|
-
].join('\n')
|
|
241
|
+
].join('\n'));
|
|
239
242
|
}
|
|
240
243
|
function getExportedStrings(obj) {
|
|
241
244
|
const exportedStrings = [];
|
|
@@ -42,10 +42,23 @@ function suppressUnusedImport(warning) {
|
|
|
42
42
|
if (warning.code !== 'UNUSED_EXTERNAL_IMPORT')
|
|
43
43
|
return false;
|
|
44
44
|
// I guess it's expected that JSX contains unsused `import React from 'react'`
|
|
45
|
-
if (warning.exporter === 'react' && warning.names?.includes('default'))
|
|
46
|
-
|
|
45
|
+
if (warning.exporter === 'react' && warning.names?.includes('default')) {
|
|
46
|
+
warning.names = warning.names.filter((n) => n !== 'default');
|
|
47
|
+
if (warning.names.length === 0)
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
// Suppress:
|
|
51
|
+
// ```
|
|
52
|
+
// "untrack" is imported from external module "solid-js" but never used in "pages/star-wars/index/+Page.tsx", "pages/index/Counter.tsx", "components/Link.tsx", "pages/todo/TodoList.tsx" and "pages/todo/+Page.tsx".
|
|
53
|
+
// ```
|
|
54
|
+
// I'm guessing Solid's transformer injects `import { untrack } from 'solid-js'`
|
|
55
|
+
if (warning.exporter === 'solid-js' && warning.names?.includes('untrack')) {
|
|
56
|
+
warning.names = warning.names.filter((n) => n !== 'untrack');
|
|
57
|
+
if (warning.names.length === 0)
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
47
60
|
// If some library does something unexpected, we suppress since it isn't actionable
|
|
48
|
-
if (warning.ids?.
|
|
61
|
+
if (warning.ids?.every((id) => id.includes('/node_modules/')))
|
|
49
62
|
return true;
|
|
50
63
|
return false;
|
|
51
64
|
}
|
package/dist/cjs/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js}
RENAMED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConfigValueSourcesRelevant =
|
|
3
|
+
exports.getConfigValueSourcesRelevant = void 0;
|
|
4
4
|
const utils_js_1 = require("../../shared/utils.js");
|
|
5
5
|
(0, utils_js_1.assertIsNotBrowser)();
|
|
6
|
-
function getConfigValueSource(pageConfig, configName) {
|
|
7
|
-
// Doesn't exist on the client-side, but we are on the server-side as attested by assertIsNotBrowser()
|
|
8
|
-
(0, utils_js_1.assert)(pageConfig.configValueSources);
|
|
9
|
-
const sources = pageConfig.configValueSources[configName];
|
|
10
|
-
if (!sources)
|
|
11
|
-
return null;
|
|
12
|
-
const configValueSource = sources[0];
|
|
13
|
-
(0, utils_js_1.assert)(configValueSource);
|
|
14
|
-
return configValueSource;
|
|
15
|
-
}
|
|
16
|
-
exports.getConfigValueSource = getConfigValueSource;
|
|
17
6
|
function getConfigValueSourcesRelevant(pageConfig) {
|
|
18
7
|
const configValueSourcesRelevant = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
|
|
19
8
|
const configValueSource = sources[0];
|
|
@@ -48,7 +48,7 @@ function getPrettyErrorWithCodeSnippet(err, userRootDir) {
|
|
|
48
48
|
let { id, frame } = err;
|
|
49
49
|
const msgFirstLine = [
|
|
50
50
|
picocolors_1.default.red('Failed to transpile'),
|
|
51
|
-
picocolors_1.default.bold(picocolors_1.default.red((0, utils_js_1.
|
|
51
|
+
picocolors_1.default.bold(picocolors_1.default.red((0, utils_js_1.getFilePathRelativeToUserRootDir)(normalizeId(id), userRootDir))),
|
|
52
52
|
picocolors_1.default.red('because:')
|
|
53
53
|
].join(' ');
|
|
54
54
|
const errMsg = getPrettyErrMessage(err);
|
|
@@ -111,7 +111,7 @@ function logConfigError(err) {
|
|
|
111
111
|
(0, utils_js_1.warnIfErrorIsNotObject)(err);
|
|
112
112
|
const category = getConfigCategory();
|
|
113
113
|
{
|
|
114
|
-
const errIntroMsg = (0, transpileAndExecuteFile_js_1.
|
|
114
|
+
const errIntroMsg = (0, transpileAndExecuteFile_js_1.getConfigExecutionErrorIntroMsg)(err);
|
|
115
115
|
if (errIntroMsg) {
|
|
116
116
|
(0, utils_js_1.assert)((0, utils_js_1.stripAnsi)(errIntroMsg).startsWith('Failed to execute'));
|
|
117
117
|
(0, log_js_1.logWithVikeTag)(errIntroMsg, 'error', category);
|
|
@@ -199,9 +199,9 @@ function logErrorDebugNote() {
|
|
|
199
199
|
store.errorDebugNoteAlreadyShown = true;
|
|
200
200
|
}
|
|
201
201
|
const msg = picocolors_1.default.dim([
|
|
202
|
-
'
|
|
202
|
+
'┌──────────────────────────────────────────────────────────┐',
|
|
203
203
|
"│ Error isn't helpful? See https://vike.dev/errors#verbose │",
|
|
204
|
-
'
|
|
204
|
+
'└──────────────────────────────────────────────────────────┘'
|
|
205
205
|
].join('\n'));
|
|
206
206
|
(0, log_js_1.logDirectly)(msg, 'error');
|
|
207
207
|
}
|
|
@@ -24,8 +24,7 @@ __exportStar(require("../runtime/utils.js"), exports);
|
|
|
24
24
|
__exportStar(require("../../utils/viteIsSSR.js"), exports);
|
|
25
25
|
__exportStar(require("../../utils/getFilePathAbsolute.js"), exports);
|
|
26
26
|
__exportStar(require("../../utils/getDependencyPackageJson.js"), exports);
|
|
27
|
-
__exportStar(require("../../utils/
|
|
28
|
-
__exportStar(require("../../utils/assertDefaultExport.js"), exports);
|
|
27
|
+
__exportStar(require("../../utils/requireResolve.js"), exports);
|
|
29
28
|
__exportStar(require("../../utils/arrayIncludes.js"), exports);
|
|
30
29
|
__exportStar(require("../../utils/isDev.js"), exports);
|
|
31
30
|
__exportStar(require("../../utils/objectKeys.js"), exports);
|
|
@@ -42,7 +42,7 @@ const getPageFiles_js_1 = require("../../shared/getPageFiles.js");
|
|
|
42
42
|
const getPageContextRequestUrl_js_1 = require("../../shared/getPageContextRequestUrl.js");
|
|
43
43
|
const resolveRouteString_js_1 = require("../../shared/route/resolveRouteString.js");
|
|
44
44
|
const utils_js_2 = require("../../shared/page-configs/utils.js");
|
|
45
|
-
const
|
|
45
|
+
const loadConfigValues_js_1 = require("../../shared/page-configs/loadConfigValues.js");
|
|
46
46
|
const error_page_js_1 = require("../../shared/error-page.js");
|
|
47
47
|
const addUrlComputedProps_js_1 = require("../../shared/addUrlComputedProps.js");
|
|
48
48
|
const assertPathIsFilesystemAbsolute_js_1 = require("../../utils/assertPathIsFilesystemAbsolute.js");
|
|
@@ -171,7 +171,7 @@ async function callOnBeforePrerenderStartHooks(prerenderContext, renderContext,
|
|
|
171
171
|
// V1 design
|
|
172
172
|
await Promise.all(renderContext.pageConfigs.map((pageConfig) => concurrencyLimit(async () => {
|
|
173
173
|
const hookName = 'onBeforePrerenderStart';
|
|
174
|
-
const pageConfigLoaded = await (0,
|
|
174
|
+
const pageConfigLoaded = await (0, loadConfigValues_js_1.loadConfigValues)(pageConfig, false);
|
|
175
175
|
const configValue = (0, utils_js_2.getConfigValue)(pageConfigLoaded, hookName);
|
|
176
176
|
if (!configValue)
|
|
177
177
|
return;
|
|
@@ -309,20 +309,17 @@ async function callOnPrerenderStartHook(prerenderContext, renderContext) {
|
|
|
309
309
|
let onPrerenderStartHook;
|
|
310
310
|
// V1 design
|
|
311
311
|
if (renderContext.pageConfigs.length > 0) {
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
const hookFn =
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
hookFilePath
|
|
324
|
-
};
|
|
325
|
-
}
|
|
312
|
+
const { pageConfigGlobal } = renderContext;
|
|
313
|
+
if (pageConfigGlobal.configValues.onPrerenderStart?.value) {
|
|
314
|
+
const { value: hookFn, definedAtInfo } = pageConfigGlobal.configValues.onPrerenderStart;
|
|
315
|
+
// config.onPrerenderStart isn't a computed nor a cumulative config => definedAtInfo should always be defined
|
|
316
|
+
(0, utils_js_1.assert)(definedAtInfo);
|
|
317
|
+
const hookFilePath = definedAtInfo.filePath;
|
|
318
|
+
onPrerenderStartHook = {
|
|
319
|
+
hookFn,
|
|
320
|
+
hookName: 'onPrerenderStart',
|
|
321
|
+
hookFilePath
|
|
322
|
+
};
|
|
326
323
|
}
|
|
327
324
|
}
|
|
328
325
|
// Old design
|
|
@@ -111,7 +111,7 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
|
|
|
111
111
|
if (!isHtmlOnly) {
|
|
112
112
|
// Don't allow the user to manipulate with injectFilter(): injecting <script type="application/json"> before the stream can break the app when:
|
|
113
113
|
// - using https://vike.dev/stream#initial-data-after-stream-end
|
|
114
|
-
// - `pageContext` is modified during the stream, e.g. /
|
|
114
|
+
// - `pageContext` is modified during the stream, e.g. https://github.com/brillout/vike-with-pinia which uses https://vuejs.org/api/composition-api-lifecycle.html#onserverprefetch
|
|
115
115
|
// The <script> tags are handled separately by vike down below.
|
|
116
116
|
htmlTags.push({
|
|
117
117
|
// Needs to be called after `resolvePageContextPromise()`
|
|
@@ -627,7 +627,10 @@ exports.isStreamPipeWeb = isStreamPipeWeb;
|
|
|
627
627
|
const __streamPipeNode = '__streamPipeNode';
|
|
628
628
|
/** @deprecated */
|
|
629
629
|
function pipeNodeStream(pipe) {
|
|
630
|
-
(0, utils_js_1.assertWarning)(false, 'pipeNodeStream() is outdated, use stampPipe() instead. See https://vike.dev/stream', {
|
|
630
|
+
(0, utils_js_1.assertWarning)(false, 'pipeNodeStream() is outdated, use stampPipe() instead. See https://vike.dev/stream', {
|
|
631
|
+
onlyOnce: true,
|
|
632
|
+
showStackTrace: true
|
|
633
|
+
});
|
|
631
634
|
return { [__streamPipeNode]: pipe };
|
|
632
635
|
}
|
|
633
636
|
exports.pipeNodeStream = pipeNodeStream;
|
|
@@ -28,14 +28,14 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
|
28
28
|
}
|
|
29
29
|
/* Remove?
|
|
30
30
|
Object.values(pageConfig.configElements).forEach((configElement) => {
|
|
31
|
-
if (configElement.
|
|
31
|
+
if (configElement.importPath) {
|
|
32
32
|
const { env } = configElement
|
|
33
33
|
assert(env)
|
|
34
34
|
const onlyAssets = env === 'server-only'
|
|
35
35
|
const eagerlyImported = env === '_routing-eager'
|
|
36
36
|
if (onlyAssets || eagerlyImported) {
|
|
37
37
|
clientDependencies.push({
|
|
38
|
-
id: configElement.
|
|
38
|
+
id: configElement.importPath,
|
|
39
39
|
onlyAssets,
|
|
40
40
|
eagerlyImported
|
|
41
41
|
})
|