vike 0.4.220-commit-a9f46b8 → 0.4.220-commit-9a798ce
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/api/utils.js +1 -1
- package/dist/cjs/{utils → node/plugin}/getOutDirs.js +11 -11
- package/dist/cjs/node/plugin/index.js +1 -7
- package/dist/cjs/node/plugin/onLoad.js +6 -1
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +12 -13
- package/dist/cjs/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +6 -3
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +24 -21
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -3
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +10 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +158 -176
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
- package/dist/cjs/node/plugin/plugins/previewConfig.js +3 -4
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/context.js +6 -4
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +25 -0
- package/dist/cjs/node/prerender/runPrerender.js +9 -4
- package/dist/cjs/node/prerender/utils.js +2 -2
- package/dist/cjs/node/runtime/globalContext.js +42 -36
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +6 -5
- package/dist/cjs/node/runtime/renderPage.js +10 -5
- package/dist/cjs/node/runtime/utils.js +2 -2
- package/dist/cjs/node/shared/resolveBase.js +9 -0
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +2 -2
- package/dist/cjs/shared/utils.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findFile.js +3 -3
- package/dist/cjs/utils/isDev.js +2 -1
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
- package/dist/cjs/utils/requireResolve.js +3 -3
- package/dist/esm/node/api/utils.d.ts +1 -1
- package/dist/esm/node/api/utils.js +1 -1
- package/dist/esm/{utils → node/plugin}/getOutDirs.js +5 -5
- package/dist/esm/node/plugin/index.d.ts +29 -1
- package/dist/esm/node/plugin/index.js +2 -8
- package/dist/esm/node/plugin/onLoad.js +7 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +12 -13
- package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +7 -4
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +25 -22
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +4 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +4 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +10 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -95
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +159 -177
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +3 -4
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/context.d.ts +2 -2
- package/dist/esm/node/prerender/context.js +6 -4
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +5 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +23 -0
- package/dist/esm/node/prerender/runPrerender.js +9 -4
- package/dist/esm/node/prerender/utils.d.ts +2 -2
- package/dist/esm/node/prerender/utils.js +2 -2
- package/dist/esm/node/runtime/globalContext.d.ts +15 -9
- package/dist/esm/node/runtime/globalContext.js +43 -37
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +5 -5
- package/dist/esm/node/runtime/renderPage.js +10 -5
- package/dist/esm/node/runtime/utils.d.ts +2 -2
- package/dist/esm/node/runtime/utils.js +2 -2
- package/dist/esm/node/shared/resolveBase.d.ts +4 -1
- package/dist/esm/node/shared/resolveBase.js +9 -0
- package/dist/esm/shared/page-configs/Config.d.ts +76 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +25 -19
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +1 -1
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +2 -2
- package/dist/esm/shared/utils.d.ts +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/findFile.js +1 -1
- package/dist/esm/utils/isDev.js +2 -1
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -17
- package/dist/cjs/node/shared/assertPluginManifest.js +0 -20
- package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -16
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -15
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -12
- package/dist/esm/node/shared/assertPluginManifest.js +0 -18
- package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -10
- package/dist/esm/node/shared/assertRuntimeManifest.js +0 -14
- /package/dist/cjs/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
- /package/dist/esm/{utils → node/plugin}/getOutDirs.d.ts +0 -0
- /package/dist/esm/utils/{filesystemPathHandling.d.ts → toPosixPath.d.ts} +0 -0
- /package/dist/esm/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
|
@@ -22,7 +22,7 @@ import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig
|
|
|
22
22
|
import { clearFilesEnvMap, resolveConfigEnvWithFileName, resolvePointerImportOfConfig } from './getVikeConfig/resolvePointerImport.js';
|
|
23
23
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
24
24
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
25
|
-
import {
|
|
25
|
+
import { assertExtensionsRequire, assertExtensionsConventions } from './assertExtensions.js';
|
|
26
26
|
import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
27
27
|
import { getConfigValuesBase } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
28
28
|
const configDefinitionsBuiltIn = getConfigDefinitionsBuiltIn();
|
|
@@ -108,7 +108,7 @@ async function loadInterfaceFiles(userRootDir) {
|
|
|
108
108
|
valueFiles.push(f);
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
|
-
let
|
|
111
|
+
let interfaceFilesAll = {};
|
|
112
112
|
await Promise.all([
|
|
113
113
|
// Config files
|
|
114
114
|
...configFiles.map(async (filePath) => {
|
|
@@ -118,8 +118,8 @@ async function loadInterfaceFiles(userRootDir) {
|
|
|
118
118
|
assert(filePath.filePathAbsoluteUserRootDir);
|
|
119
119
|
const locationId = getLocationId(filePathAbsoluteUserRootDir);
|
|
120
120
|
const interfaceFile = getInterfaceFileFromConfigFile(configFile, false, locationId);
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
interfaceFilesAll[locationId] = interfaceFilesAll[locationId] ?? [];
|
|
122
|
+
interfaceFilesAll[locationId].push(interfaceFile);
|
|
123
123
|
extendsConfigs.forEach((extendsConfig) => {
|
|
124
124
|
/* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
|
|
125
125
|
```js
|
|
@@ -139,7 +139,7 @@ async function loadInterfaceFiles(userRootDir) {
|
|
|
139
139
|
*/
|
|
140
140
|
const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true, locationId);
|
|
141
141
|
assertExtensionsConventions(interfaceFile);
|
|
142
|
-
|
|
142
|
+
interfaceFilesAll[locationId].push(interfaceFile);
|
|
143
143
|
});
|
|
144
144
|
}),
|
|
145
145
|
// Value files
|
|
@@ -164,18 +164,18 @@ async function loadInterfaceFiles(userRootDir) {
|
|
|
164
164
|
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
165
165
|
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
166
166
|
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
|
|
167
|
-
if (configDef &&
|
|
167
|
+
if (configDef && shouldBeLoadableAtBuildTime(configDef)) {
|
|
168
168
|
await loadValueFile(interfaceFile, configName, userRootDir);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
{
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
interfaceFilesAll[locationId] = interfaceFilesAll[locationId] ?? [];
|
|
173
|
+
interfaceFilesAll[locationId].push(interfaceFile);
|
|
174
174
|
}
|
|
175
175
|
})
|
|
176
176
|
]);
|
|
177
|
-
assertAllConfigsAreKnown(
|
|
178
|
-
return
|
|
177
|
+
assertAllConfigsAreKnown(interfaceFilesAll);
|
|
178
|
+
return interfaceFilesAll;
|
|
179
179
|
}
|
|
180
180
|
function getInterfaceFileFromConfigFile(configFile, isConfigExtend, locationId) {
|
|
181
181
|
const { fileExports, filePath, extendsFilePaths } = configFile;
|
|
@@ -195,9 +195,9 @@ function getInterfaceFileFromConfigFile(configFile, isConfigExtend, locationId)
|
|
|
195
195
|
return interfaceFile;
|
|
196
196
|
}
|
|
197
197
|
/** Show error message upon unknown config */
|
|
198
|
-
function assertAllConfigsAreKnown(
|
|
199
|
-
objectEntries(
|
|
200
|
-
const interfaceFilesRelevant = getInterfaceFilesRelevant(
|
|
198
|
+
function assertAllConfigsAreKnown(interfaceFilesAll) {
|
|
199
|
+
objectEntries(interfaceFilesAll).forEach(([locationId, interfaceFiles]) => {
|
|
200
|
+
const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesAll, locationId);
|
|
201
201
|
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
|
|
202
202
|
interfaceFiles.forEach((interfaceFile) => {
|
|
203
203
|
Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
|
|
@@ -240,9 +240,9 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
240
240
|
pageConfigs: [],
|
|
241
241
|
pageConfigGlobal: {
|
|
242
242
|
configDefinitions: {},
|
|
243
|
+
interfaceFiles: {},
|
|
243
244
|
configValueSources: {}
|
|
244
245
|
},
|
|
245
|
-
vikeConfigGlobal: resolveVikeConfigGlobal({}, {}),
|
|
246
246
|
global: getPageConfigUserFriendlyNew({ configValues: {} })
|
|
247
247
|
};
|
|
248
248
|
return dummyData;
|
|
@@ -250,49 +250,86 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
253
|
-
const
|
|
253
|
+
const interfaceFilesAll = await loadInterfaceFiles(userRootDir);
|
|
254
254
|
const importedFilesLoaded = {};
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
255
|
+
const { pageConfigGlobal, pageConfigs } = await getPageConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded);
|
|
256
|
+
// interop vike(options) in vite.config.js
|
|
257
|
+
temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
|
|
258
|
+
// global
|
|
259
|
+
const configValues = getConfigValues(pageConfigGlobal);
|
|
260
|
+
const global = getPageConfigUserFriendlyNew({ configValues });
|
|
261
|
+
return { pageConfigs, pageConfigGlobal, global };
|
|
260
262
|
}
|
|
261
|
-
async function getGlobalConfigs(
|
|
262
|
-
|
|
263
|
-
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
264
|
-
return isGlobalLocation(locationId, locationIds);
|
|
265
|
-
}));
|
|
263
|
+
async function getGlobalConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded) {
|
|
264
|
+
/* TODO/now: dedupe
|
|
266
265
|
// Validate that global configs live in global interface files
|
|
267
266
|
{
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
267
|
+
const interfaceFilesGlobalPaths: string[] = []
|
|
268
|
+
objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
269
|
+
assert(isGlobalLocation(locationId, locationIds))
|
|
270
|
+
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
271
|
+
if (filePathAbsoluteUserRootDir) {
|
|
272
|
+
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir)
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
})
|
|
276
|
+
const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))))
|
|
277
|
+
objectEntries(interfaceFilesAll).forEach(([locationId, interfaceFiles]) => {
|
|
278
|
+
interfaceFiles.forEach((interfaceFile) => {
|
|
279
|
+
Object.keys(interfaceFile.fileExportsByConfigName).forEach((configName) => {
|
|
280
|
+
if (!isGlobalLocation(locationId, locationIds) && isGlobalConfig(configName)) {
|
|
281
|
+
assertUsage(
|
|
282
|
+
false,
|
|
283
|
+
[
|
|
284
|
+
`${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(
|
|
285
|
+
configName
|
|
286
|
+
)} which is global:`,
|
|
287
|
+
globalPaths.length
|
|
288
|
+
? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, 'or')} instead`
|
|
289
|
+
: `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`
|
|
290
|
+
].join(' ')
|
|
291
|
+
)
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
})
|
|
292
296
|
}
|
|
293
|
-
|
|
297
|
+
//*/
|
|
298
|
+
}
|
|
299
|
+
function temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir) {
|
|
300
|
+
assert(isObject(vikeVitePluginOptions));
|
|
301
|
+
assertWarning(Object.keys(vikeVitePluginOptions).length === 0, `Define Vike settings in +config.js instead of vite.config.js ${pc.underline('https://vike.dev/migration/settings')}`, { onlyOnce: true });
|
|
302
|
+
Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
|
|
303
|
+
var _a;
|
|
304
|
+
assert(includes(objectKeys(configDefinitionsBuiltInGlobal), configName));
|
|
305
|
+
const configDef = configDefinitionsBuiltInGlobal[configName];
|
|
306
|
+
const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
|
|
307
|
+
sources.push({
|
|
308
|
+
value,
|
|
309
|
+
configEnv: configDef.env,
|
|
310
|
+
definedAtFilePath: {
|
|
311
|
+
...getFilePathResolved({
|
|
312
|
+
userRootDir,
|
|
313
|
+
filePathAbsoluteUserRootDir: '/vite.config.js'
|
|
314
|
+
}),
|
|
315
|
+
fileExportPathToShowToUser: null
|
|
316
|
+
},
|
|
317
|
+
locationId: '/',
|
|
318
|
+
interfaceFile: null,
|
|
319
|
+
isOverriden: configDef.cumulative ? false : sources.length > 0,
|
|
320
|
+
valueIsImportedAtRuntime: false,
|
|
321
|
+
valueIsDefinedByPlusFile: false
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
async function getPageConfigs(interfaceFilesAll, userRootDir, importedFilesLoaded) {
|
|
326
|
+
const locationIds = objectKeys(interfaceFilesAll);
|
|
327
|
+
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesAll).filter(([locationId]) => {
|
|
328
|
+
return isGlobalLocation(locationId, locationIds);
|
|
329
|
+
}));
|
|
294
330
|
const pageConfigGlobal = {
|
|
295
331
|
configDefinitions: configDefinitionsBuiltInGlobal,
|
|
332
|
+
interfaceFiles: interfaceFilesGlobal,
|
|
296
333
|
configValueSources: {}
|
|
297
334
|
};
|
|
298
335
|
await Promise.all(objectEntries(configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
|
|
@@ -301,56 +338,15 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
301
338
|
if (!configValueSource)
|
|
302
339
|
return;
|
|
303
340
|
pageConfigGlobal.configValueSources[configName] = sources;
|
|
304
|
-
// TODO/now
|
|
305
|
-
if (configName === 'onBeforeRoute' || configName === 'onPrerenderStart') {
|
|
306
|
-
assert(!('value' in configValueSource));
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
assert('value' in configValueSource);
|
|
310
|
-
// TODO/now
|
|
311
|
-
if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
|
|
312
|
-
return;
|
|
313
|
-
pageConfigGlobalValues[configName] = configValueSource.value;
|
|
314
|
-
}
|
|
315
341
|
}));
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
|
|
320
|
-
var _a;
|
|
321
|
-
assert(includes(objectKeys(configDefinitionsBuiltInGlobal), configName));
|
|
322
|
-
const configDef = configDefinitionsBuiltInGlobal[configName];
|
|
323
|
-
const sources = ((_a = pageConfigGlobal.configValueSources)[configName] ?? (_a[configName] = []));
|
|
324
|
-
sources.push({
|
|
325
|
-
value,
|
|
326
|
-
configEnv: configDef.env,
|
|
327
|
-
definedAtFilePath: {
|
|
328
|
-
...getFilePathResolved({
|
|
329
|
-
userRootDir,
|
|
330
|
-
filePathAbsoluteUserRootDir: '/vite.config.js'
|
|
331
|
-
}),
|
|
332
|
-
fileExportPathToShowToUser: null
|
|
333
|
-
},
|
|
334
|
-
locationId: '/',
|
|
335
|
-
isOverriden: configDef.cumulative ? false : sources.length > 0,
|
|
336
|
-
valueIsImportedAtRuntime: false,
|
|
337
|
-
valueIsDefinedByPlusFile: false
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
const configValues = getConfigValues(pageConfigGlobal);
|
|
342
|
-
const global = getPageConfigUserFriendlyNew({ configValues });
|
|
343
|
-
return { pageConfigGlobal, vikeConfigGlobal, global };
|
|
344
|
-
}
|
|
345
|
-
async function getPageConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
|
|
346
|
-
const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
|
|
347
|
-
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
342
|
+
const pageConfigs = [];
|
|
343
|
+
await Promise.all(objectEntries(interfaceFilesAll)
|
|
344
|
+
.filter(([_locationId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
348
345
|
.map(async ([locationId]) => {
|
|
349
|
-
const interfaceFilesRelevant = getInterfaceFilesRelevant(
|
|
346
|
+
const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesAll, locationId);
|
|
350
347
|
const interfaceFilesRelevantList = Object.values(interfaceFilesRelevant).flat(1);
|
|
351
|
-
assertExtensionsPeerDependencies(interfaceFilesRelevantList);
|
|
352
348
|
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
|
|
353
|
-
// Load value files of custom
|
|
349
|
+
// Load value files of `env.config===true` custom configs
|
|
354
350
|
await Promise.all(interfaceFilesRelevantList.map(async (interfaceFile) => {
|
|
355
351
|
if (!interfaceFile.isValueFile)
|
|
356
352
|
return;
|
|
@@ -358,7 +354,7 @@ async function getPageConfigs(interfaceFilesByLocationId, userRootDir, importedF
|
|
|
358
354
|
if (isGlobalConfig(configName))
|
|
359
355
|
return;
|
|
360
356
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
361
|
-
if (!
|
|
357
|
+
if (!shouldBeLoadableAtBuildTime(configDef))
|
|
362
358
|
return;
|
|
363
359
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
364
360
|
if (isAlreadyLoaded)
|
|
@@ -380,53 +376,34 @@ async function getPageConfigs(interfaceFilesByLocationId, userRootDir, importedF
|
|
|
380
376
|
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
|
|
381
377
|
applyEffectsAll(configValueSources, configDefinitions);
|
|
382
378
|
const configValuesComputed = getComputed(configValueSources, configDefinitions);
|
|
383
|
-
assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId);
|
|
384
379
|
const pageConfig = {
|
|
385
380
|
pageId: locationId,
|
|
386
381
|
isErrorPage,
|
|
387
382
|
routeFilesystem,
|
|
388
383
|
configDefinitions,
|
|
384
|
+
interfaceFiles: interfaceFilesRelevant,
|
|
389
385
|
configValueSources,
|
|
390
386
|
configValuesComputed
|
|
391
387
|
};
|
|
392
|
-
|
|
388
|
+
pageConfigs.push(pageConfig);
|
|
393
389
|
}));
|
|
394
|
-
assertPageConfigs(pageConfigs);
|
|
395
|
-
return pageConfigs;
|
|
390
|
+
assertPageConfigs(pageConfigs, interfaceFilesAll);
|
|
391
|
+
return { pageConfigs, pageConfigGlobal };
|
|
396
392
|
}
|
|
397
|
-
function
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
const { configValueBase, value, configName } = entry;
|
|
403
|
-
configValues[configName] = { ...configValueBase, value };
|
|
404
|
-
}
|
|
405
|
-
if (entry.configValueBase.type === 'standard') {
|
|
406
|
-
assert('sourceRelevant' in entry); // Help TS
|
|
407
|
-
const { configValueBase, sourceRelevant, configName } = entry;
|
|
408
|
-
assert('value' in sourceRelevant);
|
|
409
|
-
const { value } = sourceRelevant;
|
|
410
|
-
configValues[configName] = { ...configValueBase, value };
|
|
411
|
-
}
|
|
412
|
-
if (entry.configValueBase.type === 'cumulative') {
|
|
413
|
-
assert('sourcesRelevant' in entry); // Help TS
|
|
414
|
-
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
415
|
-
const values = [];
|
|
416
|
-
sourcesRelevant.forEach((source) => {
|
|
417
|
-
assert('value' in source);
|
|
418
|
-
values.push(source.value);
|
|
419
|
-
});
|
|
420
|
-
configValues[configName] = { ...configValueBase, value: values };
|
|
421
|
-
}
|
|
393
|
+
function assertPageConfigs(pageConfigs, interfaceFilesAll) {
|
|
394
|
+
pageConfigs.forEach((pageConfig) => {
|
|
395
|
+
assertGlobalConfigs(pageConfig, interfaceFilesAll);
|
|
396
|
+
assertExtensionsRequire(pageConfig);
|
|
397
|
+
assertOnBeforeRenderEnv(pageConfig);
|
|
422
398
|
});
|
|
423
|
-
return configValues;
|
|
424
399
|
}
|
|
425
400
|
// TODO/now: refactor
|
|
426
|
-
// - Dedupe: most of the
|
|
401
|
+
// - Dedupe: most of the assertGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
|
|
427
402
|
// - This assertUsage() message is slightly better: use this one for getGlobalConfigs()
|
|
428
403
|
// Global configs should be defined at global locations
|
|
429
|
-
function
|
|
404
|
+
function assertGlobalConfigs(pageConfig, interfaceFilesAll) {
|
|
405
|
+
const interfaceFilesRelevantList = Object.values(pageConfig.interfaceFiles).flat(1);
|
|
406
|
+
const { configDefinitions } = pageConfig;
|
|
430
407
|
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
431
408
|
const configNames = [];
|
|
432
409
|
if (interfaceFile.isValueFile) {
|
|
@@ -440,9 +417,9 @@ function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions,
|
|
|
440
417
|
return;
|
|
441
418
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
442
419
|
if (configDef.global === true) {
|
|
443
|
-
const locationIds = objectKeys(
|
|
420
|
+
const locationIds = objectKeys(interfaceFilesAll);
|
|
444
421
|
if (!isGlobalLocation(interfaceFile.locationId, locationIds)) {
|
|
445
|
-
const interfaceFilesGlobal = objectFromEntries(objectEntries(
|
|
422
|
+
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesAll).filter(([locationId]) => {
|
|
446
423
|
return isGlobalLocation(locationId, locationIds);
|
|
447
424
|
}));
|
|
448
425
|
const configFilesGlobal = [];
|
|
@@ -468,11 +445,6 @@ function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions,
|
|
|
468
445
|
});
|
|
469
446
|
});
|
|
470
447
|
}
|
|
471
|
-
function assertPageConfigs(pageConfigs) {
|
|
472
|
-
pageConfigs.forEach((pageConfig) => {
|
|
473
|
-
assertOnBeforeRenderEnv(pageConfig);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
448
|
function assertOnBeforeRenderEnv(pageConfig) {
|
|
477
449
|
const onBeforeRenderConfig = pageConfig.configValueSources.onBeforeRender?.[0];
|
|
478
450
|
if (!onBeforeRenderConfig)
|
|
@@ -482,6 +454,34 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
482
454
|
// When using Server Routing, loading a onBeforeRender() hook on the client-side hasn't any effect (the Server Routing's client runtime never calls it); it unnecessarily bloats client bundle sizes
|
|
483
455
|
assertUsage(!(onBeforeRenderEnv.client && !isClientRouting), `Page ${pageConfig.pageId} has an onBeforeRender() hook with env ${pc.cyan(JSON.stringify(onBeforeRenderEnv))} which doesn't make sense because the page is using Server Routing: onBeforeRender() can be run in the client only when using Client Routing.`);
|
|
484
456
|
}
|
|
457
|
+
function getConfigValues(pageConfig) {
|
|
458
|
+
const configValues = {};
|
|
459
|
+
getConfigValuesBase(pageConfig, (configEnv) => !!configEnv.config, null).forEach((entry) => {
|
|
460
|
+
if (entry.configValueBase.type === 'computed') {
|
|
461
|
+
assert('value' in entry); // Help TS
|
|
462
|
+
const { configValueBase, value, configName } = entry;
|
|
463
|
+
configValues[configName] = { ...configValueBase, value };
|
|
464
|
+
}
|
|
465
|
+
if (entry.configValueBase.type === 'standard') {
|
|
466
|
+
assert('sourceRelevant' in entry); // Help TS
|
|
467
|
+
const { configValueBase, sourceRelevant, configName } = entry;
|
|
468
|
+
assert('value' in sourceRelevant);
|
|
469
|
+
const { value } = sourceRelevant;
|
|
470
|
+
configValues[configName] = { ...configValueBase, value };
|
|
471
|
+
}
|
|
472
|
+
if (entry.configValueBase.type === 'cumulative') {
|
|
473
|
+
assert('sourcesRelevant' in entry); // Help TS
|
|
474
|
+
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
475
|
+
const values = [];
|
|
476
|
+
sourcesRelevant.forEach((source) => {
|
|
477
|
+
assert('value' in source);
|
|
478
|
+
values.push(source.value);
|
|
479
|
+
});
|
|
480
|
+
configValues[configName] = { ...configValueBase, value: values };
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
return configValues;
|
|
484
|
+
}
|
|
485
485
|
function interfacefileIsAlreaydLoaded(interfaceFile) {
|
|
486
486
|
const configMapValues = Object.values(interfaceFile.fileExportsByConfigName);
|
|
487
487
|
const isAlreadyLoaded = configMapValues.some((conf) => 'configValue' in conf);
|
|
@@ -490,8 +490,8 @@ function interfacefileIsAlreaydLoaded(interfaceFile) {
|
|
|
490
490
|
}
|
|
491
491
|
return isAlreadyLoaded;
|
|
492
492
|
}
|
|
493
|
-
function getInterfaceFilesRelevant(
|
|
494
|
-
const interfaceFilesRelevant = Object.fromEntries(objectEntries(
|
|
493
|
+
function getInterfaceFilesRelevant(interfaceFilesAll, locationIdPage) {
|
|
494
|
+
const interfaceFilesRelevant = Object.fromEntries(objectEntries(interfaceFilesAll)
|
|
495
495
|
.filter(([locationId]) => {
|
|
496
496
|
return isInherited(locationId, locationIdPage);
|
|
497
497
|
})
|
|
@@ -591,7 +591,10 @@ function isInterfaceFileUserLand(interfaceFile) {
|
|
|
591
591
|
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded, isHighestInheritancePrecedence) {
|
|
592
592
|
const conf = interfaceFile.fileExportsByConfigName[configName];
|
|
593
593
|
assert(conf);
|
|
594
|
-
const
|
|
594
|
+
const configValueSourceCommon = {
|
|
595
|
+
locationId: interfaceFile.locationId,
|
|
596
|
+
interfaceFile
|
|
597
|
+
};
|
|
595
598
|
const definedAtFilePath_ = {
|
|
596
599
|
...interfaceFile.filePath,
|
|
597
600
|
fileExportPathToShowToUser: ['default', configName]
|
|
@@ -619,7 +622,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
619
622
|
};
|
|
620
623
|
}
|
|
621
624
|
const configValueSource = {
|
|
622
|
-
|
|
625
|
+
...configValueSourceCommon,
|
|
623
626
|
value: valueFilePath,
|
|
624
627
|
valueIsFilePath: true,
|
|
625
628
|
configEnv: configDef.env,
|
|
@@ -638,7 +641,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
638
641
|
const resolved = resolvePointerImportOfConfig(configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
|
|
639
642
|
if (resolved) {
|
|
640
643
|
const configValueSource = {
|
|
641
|
-
|
|
644
|
+
...configValueSourceCommon,
|
|
642
645
|
configEnv: resolved.configEnvResolved,
|
|
643
646
|
valueIsImportedAtRuntime: true,
|
|
644
647
|
valueIsDefinedByPlusFile: false,
|
|
@@ -646,7 +649,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
646
649
|
definedAtFilePath: resolved.pointerImport
|
|
647
650
|
};
|
|
648
651
|
// Load pointer import
|
|
649
|
-
if (
|
|
652
|
+
if (shouldBeLoadableAtBuildTime(configDef) &&
|
|
650
653
|
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
651
654
|
configName !== 'extends') {
|
|
652
655
|
if (resolved.pointerImport.filePathAbsoluteFilesystem) {
|
|
@@ -662,7 +665,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
662
665
|
}
|
|
663
666
|
// Defined inside +config.js
|
|
664
667
|
const configValueSource = {
|
|
665
|
-
|
|
668
|
+
...configValueSourceCommon,
|
|
666
669
|
value: configValue,
|
|
667
670
|
configEnv: configDef.env,
|
|
668
671
|
valueIsImportedAtRuntime: false,
|
|
@@ -678,7 +681,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
678
681
|
const valueAlreadyLoaded = 'configValue' in conf;
|
|
679
682
|
assert(valueAlreadyLoaded === !!configEnvResolved.config);
|
|
680
683
|
const configValueSource = {
|
|
681
|
-
|
|
684
|
+
...configValueSourceCommon,
|
|
682
685
|
configEnv: configEnvResolved,
|
|
683
686
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
684
687
|
valueIsDefinedByPlusFile: true,
|
|
@@ -1036,7 +1039,7 @@ function getConfigDefinition(configDefinitions, configName, filePathToShowToUser
|
|
|
1036
1039
|
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
1037
1040
|
return configDefinitions[configName] ?? null;
|
|
1038
1041
|
}
|
|
1039
|
-
function
|
|
1042
|
+
function shouldBeLoadableAtBuildTime(configDef) {
|
|
1040
1043
|
return !!configDef.env.config && !configDef._valueIsFilePath;
|
|
1041
1044
|
}
|
|
1042
1045
|
function isGlobalConfig(configName) {
|
|
@@ -1046,6 +1049,17 @@ function isGlobalConfig(configName) {
|
|
|
1046
1049
|
const configNamesGlobal = getConfigNamesGlobal();
|
|
1047
1050
|
return includes(configNamesGlobal, configName);
|
|
1048
1051
|
}
|
|
1052
|
+
/*
|
|
1053
|
+
// TODO/now
|
|
1054
|
+
function isGlobalConfig(configName: string, configDefinitions: ConfigDefinitions): configName is ConfigNameGlobal {
|
|
1055
|
+
const configSpec = configDefinitions[configName]
|
|
1056
|
+
assert(configSpec)
|
|
1057
|
+
const globalValue = configSpec.global
|
|
1058
|
+
if (!globalValue) return false
|
|
1059
|
+
if (globalValue === true ) return true
|
|
1060
|
+
return globalValue(value)
|
|
1061
|
+
}
|
|
1062
|
+
*/
|
|
1049
1063
|
function getConfigNamesGlobal() {
|
|
1050
1064
|
return Object.keys(configDefinitionsBuiltInGlobal);
|
|
1051
1065
|
}
|
|
@@ -1081,35 +1095,3 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
1081
1095
|
function getConfigValueInterfaceFile(interfaceFile, configName) {
|
|
1082
1096
|
return interfaceFile.fileExportsByConfigName[configName]?.configValue;
|
|
1083
1097
|
}
|
|
1084
|
-
// TODO/now: refactor code below
|
|
1085
|
-
function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
|
|
1086
|
-
const configs = [vikeVitePluginOptions, pageConfigGlobalValues];
|
|
1087
|
-
const vikeConfigGlobal = {
|
|
1088
|
-
disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
1089
|
-
prerender: resolvePrerenderOptions(configs),
|
|
1090
|
-
includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
|
|
1091
|
-
baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
|
|
1092
|
-
baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
|
|
1093
|
-
disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
1094
|
-
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
|
|
1095
|
-
};
|
|
1096
|
-
return vikeConfigGlobal;
|
|
1097
|
-
}
|
|
1098
|
-
function resolvePrerenderOptions(configs) {
|
|
1099
|
-
if (!configs.some((c) => c.prerender)) {
|
|
1100
|
-
return false;
|
|
1101
|
-
}
|
|
1102
|
-
const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
|
|
1103
|
-
return {
|
|
1104
|
-
partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
|
|
1105
|
-
noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
|
|
1106
|
-
parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
|
|
1107
|
-
disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
|
|
1108
|
-
};
|
|
1109
|
-
}
|
|
1110
|
-
function isObject2(p) {
|
|
1111
|
-
return typeof p === 'object';
|
|
1112
|
-
}
|
|
1113
|
-
function pickFirst(arr) {
|
|
1114
|
-
return arr.filter((v) => v !== undefined)[0];
|
|
1115
|
-
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -22,7 +22,9 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
22
22
|
const { pageConfigs } = vikeConfig;
|
|
23
23
|
const pageConfig = pageConfigs.find((pageConfig) => pageConfig.pageId === pageId);
|
|
24
24
|
assert(pageConfig, { id, pageId });
|
|
25
|
-
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId,
|
|
25
|
+
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId,
|
|
26
|
+
// TODO/now: add meta.default
|
|
27
|
+
vikeConfig.global.config.includeAssetsImportedByServer ?? true, isDev);
|
|
26
28
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
27
29
|
return code;
|
|
28
30
|
}
|
|
@@ -7,7 +7,7 @@ import pc from '@brillout/picocolors';
|
|
|
7
7
|
import { logDockerHint } from './devConfig/index.js';
|
|
8
8
|
function previewConfig() {
|
|
9
9
|
let config;
|
|
10
|
-
// let
|
|
10
|
+
// let vikeConfig: VikeConfigObject
|
|
11
11
|
return {
|
|
12
12
|
name: 'vike:previewConfig',
|
|
13
13
|
apply: applyPreview,
|
|
@@ -22,8 +22,7 @@ function previewConfig() {
|
|
|
22
22
|
async configResolved(config_) {
|
|
23
23
|
config = config_;
|
|
24
24
|
logDockerHint(config.preview.host);
|
|
25
|
-
//
|
|
26
|
-
// vikeConfigGlobal = vikeConfig.vikeConfigGlobal
|
|
25
|
+
// vikeConfig = await getVikeConfig(config)
|
|
27
26
|
},
|
|
28
27
|
configurePreviewServer(server) {
|
|
29
28
|
/* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
|
|
@@ -33,7 +32,7 @@ function previewConfig() {
|
|
|
33
32
|
return () => {
|
|
34
33
|
assertDist();
|
|
35
34
|
/* We don't use this condition (we wrongfully always use the SSR middleware) because of the regression introduced by https://github.com/vitejs/vite/pull/14756 which stops servering .html files when `appType: 'custom'`.
|
|
36
|
-
if (!
|
|
35
|
+
if (!vikeConfig.global.config.prerender || vikeConfig.global.config.prerender.partial) {
|
|
37
36
|
addSsrMiddleware(server.middlewares, config, true)
|
|
38
37
|
}
|
|
39
38
|
/*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// We call onLoad() here so that it's called even when only a subset of the plugin is loaded. (Making the assert() calls inside onLoad() a lot stronger.)
|
|
3
3
|
import { onLoad } from './onLoad.js';
|
|
4
4
|
onLoad();
|
|
5
|
-
//
|
|
5
|
+
// It's common practice for Vike's Vite plugin to import from Vike's sever runtime
|
|
6
6
|
export * from '../runtime/utils.js';
|
|
7
7
|
// Utils only needed by `plugin/*`
|
|
8
8
|
export * from '../../utils/viteIsSSR.js';
|
|
@@ -2,8 +2,8 @@ export { isPrerenderAutoRunEnabled };
|
|
|
2
2
|
export { temp_disablePrerenderAutoRun };
|
|
3
3
|
export { isPrerendering };
|
|
4
4
|
export { setContextIsPrerendering };
|
|
5
|
-
import type {
|
|
6
|
-
declare function isPrerenderAutoRunEnabled(
|
|
5
|
+
import type { VikeConfigObject } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
6
|
+
declare function isPrerenderAutoRunEnabled(vikeConfig: VikeConfigObject): boolean;
|
|
7
7
|
declare function temp_disablePrerenderAutoRun(): void;
|
|
8
8
|
declare function isPrerendering(): boolean;
|
|
9
9
|
declare function setContextIsPrerendering(): void;
|
|
@@ -3,12 +3,14 @@ export { temp_disablePrerenderAutoRun };
|
|
|
3
3
|
export { isPrerendering };
|
|
4
4
|
export { setContextIsPrerendering };
|
|
5
5
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
6
|
+
import { resolvePrerenderConfig } from './resolvePrerenderConfig.js';
|
|
6
7
|
const globalObject = getGlobalObject('prerender/context.ts', {});
|
|
7
|
-
function isPrerenderAutoRunEnabled(
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
function isPrerenderAutoRunEnabled(vikeConfig) {
|
|
9
|
+
const prerenderConfig = resolvePrerenderConfig(vikeConfig.global.config.prerender);
|
|
10
|
+
return (prerenderConfig &&
|
|
11
|
+
!prerenderConfig.disableAutoRun &&
|
|
10
12
|
!globalObject.isDisabled &&
|
|
11
|
-
|
|
13
|
+
vikeConfig.global.config.disableAutoFullBuild !== 'prerender');
|
|
12
14
|
}
|
|
13
15
|
// TODO/v1-release: remove
|
|
14
16
|
function temp_disablePrerenderAutoRun() {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { resolvePrerenderConfig };
|
|
2
|
+
import type { ConfigResolved } from '../../shared/page-configs/Config/PageContextConfig.js';
|
|
3
|
+
type PrerenderConfigSemiResolved = ConfigResolved['prerender'];
|
|
4
|
+
type PrerenderConfig = false | Exclude<Required<NonNullable<PrerenderConfigSemiResolved>[number]>, boolean>;
|
|
5
|
+
declare function resolvePrerenderConfig(prerenderConfigs: PrerenderConfigSemiResolved): PrerenderConfig;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { resolvePrerenderConfig };
|
|
2
|
+
// TODO/now:
|
|
3
|
+
// - prerender.value
|
|
4
|
+
// - correct isPrerendering
|
|
5
|
+
function resolvePrerenderConfig(prerenderConfigs) {
|
|
6
|
+
if (!prerenderConfigs || prerenderConfigs.every((configVal) => !configVal)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const prerenderSettings = prerenderConfigs.filter(isObject2);
|
|
10
|
+
const prerenderConfig = {
|
|
11
|
+
partial: pickFirst(prerenderSettings.map((c) => c.partial)) ?? false,
|
|
12
|
+
noExtraDir: pickFirst(prerenderSettings.map((c) => c.noExtraDir)) ?? false,
|
|
13
|
+
parallel: pickFirst(prerenderSettings.map((c) => c.parallel)) ?? true,
|
|
14
|
+
disableAutoRun: pickFirst(prerenderSettings.map((c) => c.disableAutoRun)) ?? false
|
|
15
|
+
};
|
|
16
|
+
return prerenderConfig;
|
|
17
|
+
}
|
|
18
|
+
function isObject2(p) {
|
|
19
|
+
return typeof p === 'object';
|
|
20
|
+
}
|
|
21
|
+
function pickFirst(arr) {
|
|
22
|
+
return arr.filter((v) => v !== undefined)[0];
|
|
23
|
+
}
|