vike 0.4.160 → 0.4.161-commit-0e9c635
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/cli/bin.js +5 -0
- package/dist/cjs/node/client/router.js +4 -2
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +148 -0
- package/dist/cjs/node/plugin/plugins/buildConfig.js +61 -35
- package/dist/cjs/node/plugin/plugins/commonConfig.js +5 -13
- package/dist/cjs/node/plugin/plugins/config/stemUtils.js +1 -1
- package/dist/cjs/node/plugin/plugins/distFileNames.js +9 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +6 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +16 -4
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +1 -21
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +5 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +11 -91
- 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/{loadFileConfigEnv.js → loadFileAtConfigTime.js} +5 -5
- 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 +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.js → transformFileImports.js} +7 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +21 -27
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +157 -111
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +0 -14
- package/dist/cjs/node/plugin/shared/rollupSourceMap.js +20 -0
- package/dist/cjs/node/plugin/utils.js +3 -2
- package/dist/cjs/node/prerender/runPrerender.js +13 -5
- package/dist/cjs/node/runtime/globalContext.js +15 -23
- 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/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +39 -39
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -5
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +23 -28
- 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/renderPage/renderPageAlreadyRouted.js +2 -23
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/node/shared/assertPluginManifest.js +1 -4
- package/dist/cjs/node/shared/assertV1Design.js +26 -0
- package/dist/cjs/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +3 -3
- package/dist/cjs/node/shared/prependEntriesDir.js +13 -0
- package/dist/cjs/node/shared/utils.js +2 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +53 -26
- package/dist/cjs/shared/route/executeGuardHook.js +3 -2
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/assertNodeVersion.js +2 -2
- package/dist/cjs/utils/{findUserPackageJsonPath.js → findFile.js} +11 -8
- package/dist/cjs/utils/isVersionOrAbove.js +29 -0
- package/dist/cjs/utils/nodeEnv.js +23 -1
- package/dist/cjs/utils/objectKeys.js +19 -3
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/sorter.js +62 -1
- package/dist/esm/client/client-routing-runtime/index.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/index.js +1 -1
- package/dist/esm/node/cli/bin.js +3 -1
- package/dist/esm/node/client/router.d.ts +2 -0
- package/dist/esm/node/client/router.js +3 -1
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +2 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +13 -0
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +142 -0
- package/dist/esm/node/plugin/plugins/buildConfig.d.ts +2 -0
- package/dist/esm/node/plugin/plugins/buildConfig.js +60 -34
- package/dist/esm/node/plugin/plugins/commonConfig.js +6 -14
- package/dist/esm/node/plugin/plugins/config/stemUtils.js +2 -2
- package/dist/esm/node/plugin/plugins/distFileNames.js +9 -1
- package/dist/esm/node/plugin/plugins/envVars.js +6 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +17 -5
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -19
- package/dist/esm/node/plugin/plugins/importBuild/index.d.ts +6 -1
- package/dist/esm/node/plugin/plugins/importBuild/index.js +5 -8
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +13 -93
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -0
- 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/{loadFileConfigEnv.js → loadFileAtConfigTime.js} +4 -4
- 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 +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.d.ts → transformFileImports.d.ts} +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.js → transformFileImports.js} +6 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +20 -26
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +155 -109
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -15
- package/dist/esm/node/plugin/shared/rollupSourceMap.d.ts +14 -0
- package/dist/esm/node/plugin/shared/rollupSourceMap.js +17 -0
- package/dist/esm/node/plugin/utils.d.ts +3 -2
- package/dist/esm/node/plugin/utils.js +3 -2
- package/dist/esm/node/prerender/runPrerender.js +15 -7
- package/dist/esm/node/runtime/globalContext.d.ts +3 -10
- package/dist/esm/node/runtime/globalContext.js +15 -23
- 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/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +6 -5
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +39 -39
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -5
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +24 -29
- 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/renderPage/renderPageAlreadyRouted.js +3 -24
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/node/shared/ViteManifest.d.ts +1 -0
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertPluginManifest.js +2 -5
- package/dist/esm/node/shared/assertV1Design.d.ts +4 -0
- package/dist/esm/node/shared/assertV1Design.js +23 -0
- package/dist/esm/node/shared/getClientEntry.d.ts +3 -0
- package/dist/esm/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +2 -2
- package/dist/esm/node/shared/prependEntriesDir.d.ts +2 -0
- package/dist/esm/node/shared/prependEntriesDir.js +10 -0
- package/dist/esm/node/shared/utils.d.ts +2 -0
- package/dist/esm/node/shared/utils.js +2 -0
- package/dist/esm/shared/page-configs/Config.d.ts +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +3 -3
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +53 -26
- 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/assertNodeVersion.js +2 -2
- package/dist/esm/utils/findFile.d.ts +3 -0
- package/dist/esm/utils/findFile.js +21 -0
- package/dist/esm/utils/getOutDirs.d.ts +1 -0
- package/dist/esm/utils/isVersionOrAbove.d.ts +2 -0
- package/dist/esm/utils/isVersionOrAbove.js +26 -0
- package/dist/esm/utils/nodeEnv.d.ts +4 -0
- package/dist/esm/utils/nodeEnv.js +19 -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 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/sorter.d.ts +59 -0
- package/dist/esm/utils/sorter.js +61 -0
- package/package.json +2 -2
- package/dist/cjs/node/plugin/shared/removeSourceMap.js +0 -12
- package/dist/cjs/utils/objectEntries.js +0 -8
- package/dist/esm/node/plugin/shared/removeSourceMap.d.ts +0 -7
- package/dist/esm/node/plugin/shared/removeSourceMap.js +0 -9
- package/dist/esm/node/runtime/renderPage/logHintForCjsEsmError.d.ts +0 -13
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +0 -3
- 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/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.d.ts → loadFileAtConfigTime.d.ts} +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
|
@@ -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.isVikeConfigFile = exports.vikeConfigDependencies = exports.reloadVikeConfig = exports.getVikeConfig = void 0;
|
|
6
|
+
exports.isV1Design = exports.isVikeConfigFile = exports.vikeConfigDependencies = exports.reloadVikeConfig = exports.getVikeConfig = void 0;
|
|
7
7
|
const utils_js_1 = require("../../../utils.js");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const configDefinitionsBuiltIn_js_1 = require("./getVikeConfig/configDefinitionsBuiltIn.js");
|
|
@@ -19,8 +19,9 @@ const getConfigVike_js_1 = require("../../../../shared/getConfigVike.js");
|
|
|
19
19
|
const getConfigValuesSerialized_js_1 = require("./getConfigValuesSerialized.js");
|
|
20
20
|
const crawlPlusFiles_js_1 = require("./getVikeConfig/crawlPlusFiles.js");
|
|
21
21
|
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
22
|
-
const
|
|
22
|
+
const loadFileAtConfigTime_js_1 = require("./getVikeConfig/loadFileAtConfigTime.js");
|
|
23
23
|
const resolveImportPath_js_1 = require("./getVikeConfig/resolveImportPath.js");
|
|
24
|
+
const resolveFilePath_js_1 = require("./getVikeConfig/resolveFilePath.js");
|
|
24
25
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
25
26
|
let devServerIsCorrupt = false;
|
|
26
27
|
let wasConfigInvalid = null;
|
|
@@ -74,6 +75,13 @@ async function getVikeConfig(config, isDev, tolerateInvalidConfig = false, exten
|
|
|
74
75
|
return await vikeConfigPromise;
|
|
75
76
|
}
|
|
76
77
|
exports.getVikeConfig = getVikeConfig;
|
|
78
|
+
async function isV1Design(config, isDev) {
|
|
79
|
+
const vikeConfig = await getVikeConfig(config, isDev);
|
|
80
|
+
const { pageConfigs } = vikeConfig;
|
|
81
|
+
const isV1Design = pageConfigs.length > 0;
|
|
82
|
+
return isV1Design;
|
|
83
|
+
}
|
|
84
|
+
exports.isV1Design = isV1Design;
|
|
77
85
|
async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
|
|
78
86
|
const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev, extensions);
|
|
79
87
|
const configFiles = [];
|
|
@@ -87,69 +95,77 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
87
95
|
}
|
|
88
96
|
});
|
|
89
97
|
let interfaceFilesByLocationId = {};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const interfaceFile = getInterfaceFileFromConfigFile(
|
|
99
|
-
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
100
|
-
});
|
|
101
|
-
}));
|
|
102
|
-
// Value files
|
|
103
|
-
await Promise.all(valueFiles.map(async (filePath) => {
|
|
104
|
-
const configName = getConfigName(filePath.filePathAbsoluteVite);
|
|
105
|
-
(0, utils_js_1.assert)(configName);
|
|
106
|
-
const interfaceFile = {
|
|
107
|
-
filePath,
|
|
108
|
-
fileExportsByConfigName: {
|
|
109
|
-
[configName]: {}
|
|
110
|
-
},
|
|
111
|
-
isConfigFile: false,
|
|
112
|
-
isValueFile: true,
|
|
113
|
-
configName
|
|
114
|
-
};
|
|
115
|
-
{
|
|
116
|
-
// We don't have access to the custom config definitions defined by the user yet.
|
|
117
|
-
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
118
|
-
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
119
|
-
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn, configName);
|
|
120
|
-
if (configDef && isConfigEnv(configDef, configName)) {
|
|
121
|
-
await (0, loadFileConfigEnv_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
{
|
|
125
|
-
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePath.filePathAbsoluteVite);
|
|
98
|
+
await Promise.all([
|
|
99
|
+
// Config files
|
|
100
|
+
...configFiles.map(async (filePath) => {
|
|
101
|
+
const { filePathRelativeToUserRootDir } = filePath;
|
|
102
|
+
(0, utils_js_1.assert)(filePathRelativeToUserRootDir);
|
|
103
|
+
const { configFile, extendsConfigs } = await (0, loadFileAtConfigTime_js_1.loadConfigFile)(filePath, userRootDir, [], false);
|
|
104
|
+
(0, utils_js_1.assert)(filePath.filePathRelativeToUserRootDir);
|
|
105
|
+
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathRelativeToUserRootDir);
|
|
106
|
+
const interfaceFile = getInterfaceFileFromConfigFile(configFile, false, locationId);
|
|
126
107
|
interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
|
|
127
108
|
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
128
|
-
|
|
129
|
-
|
|
109
|
+
extendsConfigs.forEach((extendsConfig) => {
|
|
110
|
+
/* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
|
|
111
|
+
```js
|
|
112
|
+
// /pages/admin/+config.h.js
|
|
113
|
+
|
|
114
|
+
import vikeVue from 'vike-vue/config'
|
|
115
|
+
// Should only apply to /pages/admin/**
|
|
116
|
+
export default { extends: [vikeVue] }
|
|
117
|
+
```
|
|
118
|
+
```js
|
|
119
|
+
// /pages/marketing/+config.h.js
|
|
120
|
+
|
|
121
|
+
import vikeReact from 'vike-react/config'
|
|
122
|
+
// Should only apply to /pages/marketing/**
|
|
123
|
+
export default { extends: [vikeReact] }
|
|
124
|
+
```
|
|
125
|
+
*/
|
|
126
|
+
const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true, locationId);
|
|
127
|
+
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
128
|
+
});
|
|
129
|
+
}),
|
|
130
|
+
// Value files
|
|
131
|
+
...valueFiles.map(async (filePath) => {
|
|
132
|
+
const { filePathRelativeToUserRootDir } = filePath;
|
|
133
|
+
(0, utils_js_1.assert)(filePathRelativeToUserRootDir);
|
|
134
|
+
const configName = getConfigName(filePathRelativeToUserRootDir);
|
|
135
|
+
(0, utils_js_1.assert)(configName);
|
|
136
|
+
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathRelativeToUserRootDir);
|
|
137
|
+
const interfaceFile = {
|
|
138
|
+
locationId,
|
|
139
|
+
filePath,
|
|
140
|
+
fileExportsByConfigName: {
|
|
141
|
+
[configName]: {}
|
|
142
|
+
},
|
|
143
|
+
isConfigFile: false,
|
|
144
|
+
isValueFile: true,
|
|
145
|
+
configName
|
|
146
|
+
};
|
|
147
|
+
{
|
|
148
|
+
// We don't have access to the custom config definitions defined by the user yet.
|
|
149
|
+
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
150
|
+
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
151
|
+
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn, configName);
|
|
152
|
+
if (configDef && isConfigEnv(configDef, configName)) {
|
|
153
|
+
await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
{
|
|
157
|
+
interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
|
|
158
|
+
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
]);
|
|
130
162
|
assertAllConfigsAreKnown(interfaceFilesByLocationId);
|
|
131
163
|
return interfaceFilesByLocationId;
|
|
132
164
|
}
|
|
133
|
-
function
|
|
134
|
-
const configDef = configDefinitionsRelevant[configName];
|
|
135
|
-
assertConfigExists(configName, Object.keys(configDefinitionsRelevant), filePathToShowToUser);
|
|
136
|
-
(0, utils_js_1.assert)(configDef);
|
|
137
|
-
return configDef;
|
|
138
|
-
}
|
|
139
|
-
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
140
|
-
return configDefinitions[configName] ?? null;
|
|
141
|
-
}
|
|
142
|
-
function isConfigEnv(configDef, configName) {
|
|
143
|
-
const configEnv = configDef.env;
|
|
144
|
-
if (configDef.cumulative) {
|
|
145
|
-
// In principle we could lift that requirement (but it requires non-trivial modifications)
|
|
146
|
-
(0, utils_js_1.assertUsage)(configEnv.config, `Config ${picocolors_1.default.cyan(configName)} needs its ${picocolors_1.default.cyan('env')} to have ${picocolors_1.default.cyan('{ config: true }')} (because ${picocolors_1.default.cyan(configName)} is a ${picocolors_1.default.cyan('cumulative')} config)`);
|
|
147
|
-
}
|
|
148
|
-
return !!configEnv.config;
|
|
149
|
-
}
|
|
150
|
-
function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
|
|
165
|
+
function getInterfaceFileFromConfigFile(configFile, isConfigExtend, locationId) {
|
|
151
166
|
const { fileExports, filePath, extendsFilePaths } = configFile;
|
|
152
167
|
const interfaceFile = {
|
|
168
|
+
locationId,
|
|
153
169
|
filePath,
|
|
154
170
|
fileExportsByConfigName: {},
|
|
155
171
|
isConfigFile: true,
|
|
@@ -165,12 +181,12 @@ function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
|
|
|
165
181
|
}
|
|
166
182
|
/** Show error message upon unknown config */
|
|
167
183
|
function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
|
|
168
|
-
|
|
184
|
+
(0, utils_js_1.objectEntries)(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
|
|
169
185
|
const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
|
|
170
|
-
const
|
|
186
|
+
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
|
|
171
187
|
interfaceFiles.forEach((interfaceFile) => {
|
|
172
188
|
Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
|
|
173
|
-
assertConfigExists(configName, Object.keys(
|
|
189
|
+
assertConfigExists(configName, Object.keys(configDefinitions), interfaceFile.filePath.filePathToShowToUser);
|
|
174
190
|
});
|
|
175
191
|
});
|
|
176
192
|
});
|
|
@@ -220,11 +236,11 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
220
236
|
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions);
|
|
221
237
|
const importedFilesLoaded = {};
|
|
222
238
|
const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
|
|
223
|
-
const pageConfigs = await Promise.all(
|
|
239
|
+
const pageConfigs = await Promise.all((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
|
|
224
240
|
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
225
241
|
.map(async ([locationId]) => {
|
|
226
242
|
const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
|
|
227
|
-
const
|
|
243
|
+
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
|
|
228
244
|
// Load value files of custom config-only configs
|
|
229
245
|
await Promise.all(getInterfaceFileList(interfaceFilesRelevant).map(async (interfaceFile) => {
|
|
230
246
|
if (!interfaceFile.isValueFile)
|
|
@@ -232,7 +248,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
232
248
|
const { configName } = interfaceFile;
|
|
233
249
|
if (isGlobalConfig(configName))
|
|
234
250
|
return;
|
|
235
|
-
const configDef = getConfigDefinition(
|
|
251
|
+
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
236
252
|
if (!isConfigEnv(configDef, configName))
|
|
237
253
|
return;
|
|
238
254
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
@@ -240,10 +256,10 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
240
256
|
return;
|
|
241
257
|
// Value files of built-in configs should have already been loaded at loadInterfaceFiles()
|
|
242
258
|
(0, utils_js_1.assert)(!(configName in configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn));
|
|
243
|
-
await (0,
|
|
259
|
+
await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
|
|
244
260
|
}));
|
|
245
|
-
|
|
246
|
-
await Promise.all((0, utils_js_1.objectEntries)(
|
|
261
|
+
let configValueSources = {};
|
|
262
|
+
await Promise.all((0, utils_js_1.objectEntries)(configDefinitions)
|
|
247
263
|
.filter(([configName]) => !isGlobalConfig(configName))
|
|
248
264
|
.map(async ([configName, configDef]) => {
|
|
249
265
|
const sources = await resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded);
|
|
@@ -251,10 +267,11 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
251
267
|
return;
|
|
252
268
|
configValueSources[configName] = sources;
|
|
253
269
|
}));
|
|
270
|
+
configValueSources = sortConfigValueSources(configValueSources, locationId);
|
|
254
271
|
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
|
|
255
|
-
applyEffectsAll(configValueSources,
|
|
256
|
-
const configValuesComputed = getComputed(configValueSources,
|
|
257
|
-
const configValues = getConfigValues(configValueSources, configValuesComputed,
|
|
272
|
+
applyEffectsAll(configValueSources, configDefinitions);
|
|
273
|
+
const configValuesComputed = getComputed(configValueSources, configDefinitions);
|
|
274
|
+
const configValues = getConfigValues(configValueSources, configValuesComputed, configDefinitions);
|
|
258
275
|
const pageConfig = {
|
|
259
276
|
pageId: locationId,
|
|
260
277
|
isErrorPage,
|
|
@@ -291,7 +308,7 @@ function interfacefileIsAlreaydLoaded(interfaceFile) {
|
|
|
291
308
|
return isAlreadyLoaded;
|
|
292
309
|
}
|
|
293
310
|
function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
|
|
294
|
-
const interfaceFilesRelevant = Object.fromEntries(
|
|
311
|
+
const interfaceFilesRelevant = Object.fromEntries((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
|
|
295
312
|
.filter(([locationId]) => {
|
|
296
313
|
return (0, filesystemRouting_js_1.isInherited)(locationId, locationIdPage);
|
|
297
314
|
})
|
|
@@ -306,14 +323,14 @@ function getInterfaceFileList(interfaceFilesByLocationId) {
|
|
|
306
323
|
return interfaceFiles;
|
|
307
324
|
}
|
|
308
325
|
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
|
|
309
|
-
const locationIds =
|
|
310
|
-
const interfaceFilesGlobal =
|
|
326
|
+
const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
|
|
327
|
+
const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
311
328
|
return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
|
|
312
329
|
}));
|
|
313
330
|
// Validate that global configs live in global interface files
|
|
314
331
|
{
|
|
315
332
|
const interfaceFilesGlobalPaths = [];
|
|
316
|
-
|
|
333
|
+
(0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
317
334
|
(0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
|
|
318
335
|
interfaceFiles.forEach(({ filePath: { filePathRelativeToUserRootDir } }) => {
|
|
319
336
|
if (filePathRelativeToUserRootDir) {
|
|
@@ -322,7 +339,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
322
339
|
});
|
|
323
340
|
});
|
|
324
341
|
const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path_1.default.posix.dirname(p))));
|
|
325
|
-
|
|
342
|
+
(0, utils_js_1.objectEntries)(interfaceFilesByLocationId).forEach(([locationId, interfaceFiles]) => {
|
|
326
343
|
interfaceFiles.forEach((interfaceFile) => {
|
|
327
344
|
Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
|
|
328
345
|
if (!(0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds) && isGlobalConfig(configName)) {
|
|
@@ -446,6 +463,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
446
463
|
const conf = interfaceFile.fileExportsByConfigName[configName];
|
|
447
464
|
(0, utils_js_1.assert)(conf);
|
|
448
465
|
const configEnv = configDef.env;
|
|
466
|
+
const { locationId } = interfaceFile;
|
|
449
467
|
const definedAtConfigFile = {
|
|
450
468
|
...interfaceFile.filePath,
|
|
451
469
|
fileExportPathToShowToUser: ['default', configName]
|
|
@@ -471,6 +489,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
471
489
|
};
|
|
472
490
|
}
|
|
473
491
|
const configValueSource = {
|
|
492
|
+
locationId,
|
|
474
493
|
value: valueFilePath,
|
|
475
494
|
valueIsFilePath: true,
|
|
476
495
|
configEnv,
|
|
@@ -487,6 +506,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
487
506
|
const import_ = (0, resolveImportPath_js_1.resolveImport)(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
|
|
488
507
|
if (import_) {
|
|
489
508
|
const configValueSource = {
|
|
509
|
+
locationId,
|
|
490
510
|
configEnv,
|
|
491
511
|
valueIsImportedAtRuntime: true,
|
|
492
512
|
definedAt: import_
|
|
@@ -497,7 +517,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
497
517
|
configName !== 'extends') {
|
|
498
518
|
if (import_.filePathAbsoluteFilesystem) {
|
|
499
519
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(import_, 'filePathAbsoluteFilesystem', 'string')); // Help TS
|
|
500
|
-
const fileExport = await (0,
|
|
520
|
+
const fileExport = await (0, loadFileAtConfigTime_js_1.loadImportedFile)(import_, userRootDir, importedFilesLoaded);
|
|
501
521
|
configValueSource.value = fileExport;
|
|
502
522
|
}
|
|
503
523
|
else {
|
|
@@ -509,6 +529,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
509
529
|
}
|
|
510
530
|
// Defined by config file, i.e. +config.js file
|
|
511
531
|
const configValueSource = {
|
|
532
|
+
locationId,
|
|
512
533
|
value: configValue,
|
|
513
534
|
configEnv,
|
|
514
535
|
valueIsImportedAtRuntime: false,
|
|
@@ -521,6 +542,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
521
542
|
const valueAlreadyLoaded = 'configValue' in conf;
|
|
522
543
|
(0, utils_js_1.assert)(valueAlreadyLoaded === !!configEnv.config);
|
|
523
544
|
const configValueSource = {
|
|
545
|
+
locationId,
|
|
524
546
|
configEnv,
|
|
525
547
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
526
548
|
definedAt: {
|
|
@@ -551,8 +573,10 @@ function isDefiningPageConfig(configName) {
|
|
|
551
573
|
return ['Page', 'route'].includes(configName);
|
|
552
574
|
}
|
|
553
575
|
function getConfigDefinitions(interfaceFilesRelevant) {
|
|
554
|
-
const
|
|
555
|
-
Object.entries(interfaceFilesRelevant)
|
|
576
|
+
const configDefinitionsMerged = { ...configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn };
|
|
577
|
+
Object.entries(interfaceFilesRelevant)
|
|
578
|
+
.reverse()
|
|
579
|
+
.forEach(([_locationId, interfaceFiles]) => {
|
|
556
580
|
interfaceFiles.forEach((interfaceFile) => {
|
|
557
581
|
const configMeta = interfaceFile.fileExportsByConfigName['meta'];
|
|
558
582
|
if (!configMeta)
|
|
@@ -571,13 +595,14 @@ function getConfigDefinitions(interfaceFilesRelevant) {
|
|
|
571
595
|
});
|
|
572
596
|
(0, utils_js_1.objectEntries)(meta).forEach(([configName, configDefinition]) => {
|
|
573
597
|
// User can override an existing config definition
|
|
574
|
-
|
|
575
|
-
...
|
|
598
|
+
configDefinitionsMerged[configName] = {
|
|
599
|
+
...configDefinitionsMerged[configName],
|
|
576
600
|
...configDefinition
|
|
577
601
|
};
|
|
578
602
|
});
|
|
579
603
|
});
|
|
580
604
|
});
|
|
605
|
+
const configDefinitions = configDefinitionsMerged;
|
|
581
606
|
return configDefinitions;
|
|
582
607
|
}
|
|
583
608
|
function assertMetaValue(metaVal, configMetaDefinedAt) {
|
|
@@ -616,8 +641,8 @@ function assertMetaValue(metaVal, configMetaDefinedAt) {
|
|
|
616
641
|
}
|
|
617
642
|
});
|
|
618
643
|
}
|
|
619
|
-
function applyEffectsAll(configValueSources,
|
|
620
|
-
(0, utils_js_1.objectEntries)(
|
|
644
|
+
function applyEffectsAll(configValueSources, configDefinitions) {
|
|
645
|
+
(0, utils_js_1.objectEntries)(configDefinitions).forEach(([configName, configDef]) => {
|
|
621
646
|
if (!configDef.effect)
|
|
622
647
|
return;
|
|
623
648
|
// The value needs to be loaded at config time, that's why we only support effect for configs that are config-only for now.
|
|
@@ -676,9 +701,9 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
676
701
|
}
|
|
677
702
|
});
|
|
678
703
|
}
|
|
679
|
-
function getComputed(configValueSources,
|
|
704
|
+
function getComputed(configValueSources, configDefinitions) {
|
|
680
705
|
const configValuesComputed = {};
|
|
681
|
-
(0, utils_js_1.objectEntries)(
|
|
706
|
+
(0, utils_js_1.objectEntries)(configDefinitions).forEach(([configName, configDef]) => {
|
|
682
707
|
if (!configDef._computed)
|
|
683
708
|
return;
|
|
684
709
|
const value = configDef._computed(configValueSources);
|
|
@@ -693,15 +718,7 @@ function getComputed(configValueSources, configDefinitionsRelevant) {
|
|
|
693
718
|
}
|
|
694
719
|
async function findPlusFiles(userRootDir, outDirRoot, isDev, extensions) {
|
|
695
720
|
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot, isDev);
|
|
696
|
-
const plusFiles = files.map(({ filePathRelativeToUserRootDir
|
|
697
|
-
return {
|
|
698
|
-
filePathRelativeToUserRootDir,
|
|
699
|
-
filePathAbsoluteVite: filePathRelativeToUserRootDir,
|
|
700
|
-
filePathAbsoluteFilesystem,
|
|
701
|
-
filePathToShowToUser: filePathRelativeToUserRootDir,
|
|
702
|
-
importPathAbsolute: null
|
|
703
|
-
};
|
|
704
|
-
});
|
|
721
|
+
const plusFiles = files.map(({ filePathRelativeToUserRootDir }) => (0, resolveFilePath_js_1.resolveFilePathRelativeToUserRootDir)(filePathRelativeToUserRootDir, userRootDir));
|
|
705
722
|
// TODO/v1-release: remove
|
|
706
723
|
extensions.forEach((extension) => {
|
|
707
724
|
extension.pageConfigsDistFiles?.forEach((pageConfigDistFile) => {
|
|
@@ -753,22 +770,6 @@ function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
|
753
770
|
)
|
|
754
771
|
}
|
|
755
772
|
*/
|
|
756
|
-
function isGlobalConfig(configName) {
|
|
757
|
-
if (configName === 'prerender')
|
|
758
|
-
return false;
|
|
759
|
-
const configNamesGlobal = getConfigNamesGlobal();
|
|
760
|
-
return (0, utils_js_1.arrayIncludes)(configNamesGlobal, configName);
|
|
761
|
-
}
|
|
762
|
-
function getConfigNamesGlobal() {
|
|
763
|
-
return Object.keys(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal);
|
|
764
|
-
}
|
|
765
|
-
function assertConfigExists(configName, configNamesRelevant, filePathToShowToUser) {
|
|
766
|
-
const configNames = [...configNamesRelevant, ...getConfigNamesGlobal()];
|
|
767
|
-
if (configNames.includes(configName))
|
|
768
|
-
return;
|
|
769
|
-
handleUnknownConfig(configName, configNames, filePathToShowToUser);
|
|
770
|
-
(0, utils_js_1.assert)(false);
|
|
771
|
-
}
|
|
772
773
|
function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
|
|
773
774
|
let errMsg = `${filePathToShowToUser} defines an unknown config ${picocolors_1.default.cyan(configName)}`;
|
|
774
775
|
let configNameSimilar = null;
|
|
@@ -839,7 +840,7 @@ function isVikeConfigFile(filePath) {
|
|
|
839
840
|
return !!getConfigName(filePath);
|
|
840
841
|
}
|
|
841
842
|
exports.isVikeConfigFile = isVikeConfigFile;
|
|
842
|
-
function getConfigValues(configValueSources, configValuesComputed,
|
|
843
|
+
function getConfigValues(configValueSources, configValuesComputed, configDefinitions) {
|
|
843
844
|
const configValues = {};
|
|
844
845
|
Object.entries(configValuesComputed).forEach(([configName, configValueComputed]) => {
|
|
845
846
|
configValues[configName] = {
|
|
@@ -848,7 +849,7 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
|
|
|
848
849
|
};
|
|
849
850
|
});
|
|
850
851
|
Object.entries(configValueSources).forEach(([configName, sources]) => {
|
|
851
|
-
const configDef =
|
|
852
|
+
const configDef = configDefinitions[configName];
|
|
852
853
|
(0, utils_js_1.assert)(configDef);
|
|
853
854
|
if (!configDef.cumulative) {
|
|
854
855
|
const configValueSource = sources[0];
|
|
@@ -962,3 +963,48 @@ function getConfigEnvValue(val, errMsgIntro) {
|
|
|
962
963
|
*/
|
|
963
964
|
return val;
|
|
964
965
|
}
|
|
966
|
+
function getConfigDefinition(configDefinitions, configName, filePathToShowToUser) {
|
|
967
|
+
const configDef = configDefinitions[configName];
|
|
968
|
+
assertConfigExists(configName, Object.keys(configDefinitions), filePathToShowToUser);
|
|
969
|
+
(0, utils_js_1.assert)(configDef);
|
|
970
|
+
return configDef;
|
|
971
|
+
}
|
|
972
|
+
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
973
|
+
return configDefinitions[configName] ?? null;
|
|
974
|
+
}
|
|
975
|
+
function isConfigEnv(configDef, configName) {
|
|
976
|
+
const configEnv = configDef.env;
|
|
977
|
+
if (configDef.cumulative) {
|
|
978
|
+
// In principle we could lift that requirement (but it requires non-trivial modifications)
|
|
979
|
+
(0, utils_js_1.assertUsage)(configEnv.config, `Config ${picocolors_1.default.cyan(configName)} needs its ${picocolors_1.default.cyan('env')} to have ${picocolors_1.default.cyan('{ config: true }')} (because ${picocolors_1.default.cyan(configName)} is a ${picocolors_1.default.cyan('cumulative')} config)`);
|
|
980
|
+
}
|
|
981
|
+
return !!configEnv.config;
|
|
982
|
+
}
|
|
983
|
+
function isGlobalConfig(configName) {
|
|
984
|
+
if (configName === 'prerender')
|
|
985
|
+
return false;
|
|
986
|
+
const configNamesGlobal = getConfigNamesGlobal();
|
|
987
|
+
return (0, utils_js_1.arrayIncludes)(configNamesGlobal, configName);
|
|
988
|
+
}
|
|
989
|
+
function getConfigNamesGlobal() {
|
|
990
|
+
return Object.keys(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal);
|
|
991
|
+
}
|
|
992
|
+
function assertConfigExists(configName, configNamesRelevant, filePathToShowToUser) {
|
|
993
|
+
const configNames = [...configNamesRelevant, ...getConfigNamesGlobal()];
|
|
994
|
+
if (configNames.includes(configName))
|
|
995
|
+
return;
|
|
996
|
+
handleUnknownConfig(configName, configNames, filePathToShowToUser);
|
|
997
|
+
(0, utils_js_1.assert)(false);
|
|
998
|
+
}
|
|
999
|
+
function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
1000
|
+
return Object.fromEntries(Object.entries(configValueSources)
|
|
1001
|
+
// Make order deterministic (no other purpose)
|
|
1002
|
+
.sort(([, [source1]], [, [source2]]) => source1.definedAt.filePathAbsoluteVite < source2.definedAt.filePathAbsoluteVite ? -1 : 1)
|
|
1003
|
+
// Sort after whether the config value was defined by an npm package
|
|
1004
|
+
.sort((0, utils_js_1.makeFirst)(([, [source]]) => {
|
|
1005
|
+
const { importPathAbsolute } = source.definedAt;
|
|
1006
|
+
return !!importPathAbsolute && (0, utils_js_1.isNpmPackageImport)(importPathAbsolute);
|
|
1007
|
+
}))
|
|
1008
|
+
// Sort after the filesystem inheritance of the config value
|
|
1009
|
+
.sort(([, [source1]], [, [source2]]) => (0, utils_js_1.reverse)((0, filesystemRouting_js_1.sortAfterInheritanceOrder)(source1.locationId, source2.locationId, locationIdPage))));
|
|
1010
|
+
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -12,6 +12,7 @@ const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
|
12
12
|
const serializeConfigValue_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValue.js");
|
|
13
13
|
const getConfigVike_js_1 = require("../../../../shared/getConfigVike.js");
|
|
14
14
|
const getConfigValuesSerialized_js_1 = require("./getConfigValuesSerialized.js");
|
|
15
|
+
const fixServerAssets_js_1 = require("../../buildConfig/fixServerAssets.js");
|
|
15
16
|
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
16
17
|
const result = (0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id);
|
|
17
18
|
(0, utils_js_1.assert)(result);
|
|
@@ -45,7 +46,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
45
46
|
isClientRouting
|
|
46
47
|
})));
|
|
47
48
|
lines.push('};');
|
|
48
|
-
if (includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
49
|
+
if (!(0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
49
50
|
importStatements.push(`import '${(0, extractAssetsQuery_js_1.extractAssetsAddQuery)((0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, false))}'`);
|
|
50
51
|
}
|
|
51
52
|
const code = [...importStatements, ...lines].join('\n');
|
|
@@ -11,20 +11,6 @@ function setGlobalContext() {
|
|
|
11
11
|
handler(viteDevServer) {
|
|
12
12
|
(0, globalContext_js_1.setGlobalContext_viteDevServer)(viteDevServer);
|
|
13
13
|
}
|
|
14
|
-
},
|
|
15
|
-
configurePreviewServer: {
|
|
16
|
-
order: 'pre',
|
|
17
|
-
handler(vitePreviewServer) {
|
|
18
|
-
(0, globalContext_js_1.setGlobalContext_vitePreviewServer)(
|
|
19
|
-
// Type cast won't be necessary after https://github.com/vitejs/vite/pull/14119 is released in Vite 5
|
|
20
|
-
vitePreviewServer);
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
configResolved: {
|
|
24
|
-
order: 'pre',
|
|
25
|
-
handler(config) {
|
|
26
|
-
(0, globalContext_js_1.setGlobalContext_viteConfig)(config);
|
|
27
|
-
}
|
|
28
14
|
}
|
|
29
15
|
};
|
|
30
16
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourceMapPassthrough = exports.sourceMapRemove = void 0;
|
|
4
|
+
// https://rollupjs.org/guide/en/#source-code-transformations
|
|
5
|
+
/** Remove entire source mapping, to save KBs. */
|
|
6
|
+
function sourceMapRemove(code) {
|
|
7
|
+
return {
|
|
8
|
+
code,
|
|
9
|
+
map: { mappings: '' }
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.sourceMapRemove = sourceMapRemove;
|
|
13
|
+
/** Don't provide any source map, pass through current source map instead. */
|
|
14
|
+
function sourceMapPassthrough(code) {
|
|
15
|
+
return {
|
|
16
|
+
code,
|
|
17
|
+
map: null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.sourceMapPassthrough = sourceMapPassthrough;
|
|
@@ -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,10 +34,12 @@ __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);
|
|
42
41
|
__exportStar(require("../../utils/assertKeys.js"), exports);
|
|
43
42
|
__exportStar(require("../../utils/injectRollupInputs.js"), exports);
|
|
44
43
|
__exportStar(require("../../utils/humanizeTime.js"), exports);
|
|
44
|
+
__exportStar(require("../../utils/pLimit.js"), exports);
|
|
45
|
+
__exportStar(require("../../utils/isVersionOrAbove.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,9 +87,10 @@ 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
|
+
(0, globalContext_js_1.setGlobalContext_prerender)(viteConfig);
|
|
93
94
|
assertLoadedConfig(viteConfig, options);
|
|
94
95
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(viteConfig);
|
|
95
96
|
const { outDirClient, outDirRoot } = (0, utils_js_1.getOutDirs)(viteConfig);
|
|
@@ -742,3 +743,10 @@ function assertIsNotAbort(err, urlOr404) {
|
|
|
742
743
|
(0, utils_js_1.assert)(abortCall);
|
|
743
744
|
(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
745
|
}
|
|
746
|
+
function handleNodeEnv() {
|
|
747
|
+
const assertNodeEnv = () => (0, utils_js_1.assertNodeEnvIsNotDev)('pre-rendering');
|
|
748
|
+
if ((0, utils_js_1.getNodeEnv)())
|
|
749
|
+
assertNodeEnv();
|
|
750
|
+
(0, utils_js_1.setNodeEnvToProduction)();
|
|
751
|
+
assertNodeEnv();
|
|
752
|
+
}
|