vike 0.4.217-commit-99ea561 → 0.4.218-commit-01a099d
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/__internal/index.js +9 -8
- package/dist/cjs/node/api/build.js +20 -11
- package/dist/cjs/node/api/index.js +17 -7
- package/dist/cjs/node/api/prepareViteApiCall.js +109 -26
- package/dist/cjs/node/api/utils.js +2 -0
- package/dist/cjs/node/cli/entry.js +17 -7
- package/dist/cjs/node/plugin/index.js +6 -5
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +2 -3
- package/dist/cjs/node/plugin/plugins/baseUrls.js +20 -18
- package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/cjs/node/plugin/plugins/commonConfig.js +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +7 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +182 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -1
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/cjs/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +17 -7
- package/dist/cjs/node/prerender/isPrerenderEnabled.js +8 -0
- package/dist/cjs/node/prerender/runPrerender.js +21 -12
- package/dist/cjs/node/runtime/globalContext.js +44 -21
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/index-common.js +0 -15
- package/dist/cjs/node/runtime/onLoad.js +17 -3
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/cjs/node/runtime-dev/index.js +17 -7
- package/dist/cjs/node/shared/resolveBase.js +2 -2
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +2 -3
- package/dist/cjs/shared/getPageFiles.js +3 -9
- package/dist/cjs/shared/hooks/getHook.js +3 -3
- package/dist/cjs/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +113 -81
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +79 -54
- package/dist/cjs/shared/route/loadPageRoutes.js +3 -3
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +4 -3
- package/dist/esm/__internal/index.d.ts +3 -5
- package/dist/esm/__internal/index.js +4 -5
- package/dist/esm/client/client-routing-runtime/createPageContext.js +7 -1
- package/dist/esm/client/client-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/entry.js +0 -1
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
- package/dist/esm/client/server-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/entry.js +0 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.js +8 -2
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/api/build.js +3 -4
- package/dist/esm/node/api/prepareViteApiCall.d.ts +9 -3
- package/dist/esm/node/api/prepareViteApiCall.js +91 -21
- package/dist/esm/node/api/utils.d.ts +2 -0
- package/dist/esm/node/api/utils.js +2 -0
- package/dist/esm/node/cli/parseCli.d.ts +1 -1
- package/dist/esm/node/plugin/index.d.ts +1 -1
- package/dist/esm/node/plugin/index.js +6 -5
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +2 -3
- package/dist/esm/node/plugin/plugins/baseUrls.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/baseUrls.js +21 -19
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +8 -10
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +99 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +182 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/esm/node/plugin/plugins/workaroundVite6HmrRegression.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/esm/node/prerender/isPrerenderEnabled.d.ts +3 -0
- package/dist/esm/node/prerender/isPrerenderEnabled.js +6 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +1 -2
- package/dist/esm/node/prerender/runPrerender.js +3 -4
- package/dist/esm/node/runtime/globalContext.d.ts +4 -4
- package/dist/esm/node/runtime/globalContext.js +44 -21
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/index-common.d.ts +0 -1
- package/dist/esm/node/runtime/index-common.js +0 -15
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -0
- package/dist/esm/node/runtime/onLoad.js +16 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/esm/node/shared/resolveBase.js +2 -2
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +2 -3
- package/dist/esm/shared/getPageFiles.d.ts +2 -5
- package/dist/esm/shared/getPageFiles.js +1 -4
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/Config.d.ts +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +7 -3
- package/dist/esm/shared/{getPageFiles/getExports.d.ts → page-configs/getPageConfigUserFriendly.d.ts} +23 -12
- package/dist/esm/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +112 -80
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +28 -4
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +79 -54
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/shared/types.d.ts +1 -1
- package/dist/esm/shared/utils.d.ts +1 -0
- package/dist/esm/shared/utils.js +1 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +4 -3
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +2 -21
- package/__internal/loadImportBuild.js +0 -3
- package/__internal/setup.js +0 -3
- package/dist/cjs/node/plugin/plugins/commonConfig/pluginName.js +0 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -128
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +0 -25
- package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +0 -22
- package/dist/cjs/node/runtime/page-files/setup.js +0 -5
- package/dist/esm/client/client-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/client/server-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/server-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts +0 -104
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -123
- package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +0 -3
- package/dist/esm/node/runtime/globalContext/loadImportBuild.d.ts +0 -18
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +0 -23
- package/dist/esm/node/runtime/page-files/getPageFilesExports.d.ts +0 -2
- package/dist/esm/node/runtime/page-files/getPageFilesExports.js +0 -20
- package/dist/esm/node/runtime/page-files/setup.d.ts +0 -1
- package/dist/esm/node/runtime/page-files/setup.js +0 -3
- package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- package/dist/cjs/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- package/dist/esm/shared/getPageFiles/{setPageFiles.d.ts → getPageFiles.d.ts} +1 -1
- /package/dist/esm/shared/page-configs/{getConfigValue.d.ts → getConfigValueRuntime.d.ts} +0 -0
- /package/dist/esm/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
export { baseUrls };
|
|
2
2
|
import { resolveBase, resolveBaseFromResolvedConfig } from '../../shared/resolveBase.js';
|
|
3
3
|
import { assert } from '../utils.js';
|
|
4
|
-
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
4
|
+
import { getVikeConfig, getVikeConfig2 } from './importUserCode/v1-design/getVikeConfig.js';
|
|
5
|
+
import { assertViteRoot, getViteRoot, normalizeViteRoot } from '../../api/prepareViteApiCall.js';
|
|
5
6
|
function baseUrls(vikeVitePluginOptions) {
|
|
6
|
-
let
|
|
7
|
+
let basesResolved;
|
|
8
|
+
let root;
|
|
7
9
|
return {
|
|
8
10
|
name: 'vike:baseUrls',
|
|
9
11
|
enforce: 'post',
|
|
10
|
-
async config(config) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
12
|
+
async config(config, env) {
|
|
13
|
+
const isDev = config._isDev;
|
|
14
|
+
assert(typeof isDev === 'boolean');
|
|
15
|
+
const operation = env.command === 'build' ? 'build' : env.isPreview ? 'preview' : 'dev';
|
|
16
|
+
root = config.root ? normalizeViteRoot(config.root) : await getViteRoot(operation);
|
|
17
|
+
assert(root);
|
|
18
|
+
const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
|
|
19
|
+
const vikeConfig = await getVikeConfig2(root, isDev, vikeVitePluginOptions);
|
|
20
|
+
basesResolved = resolveBase(baseViteOriginal, vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets);
|
|
14
21
|
// We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
|
|
15
|
-
process.env.BASE_SERVER = baseServer;
|
|
16
|
-
process.env.BASE_ASSETS = baseAssets;
|
|
22
|
+
process.env.BASE_SERVER = basesResolved.baseServer;
|
|
23
|
+
process.env.BASE_ASSETS = basesResolved.baseAssets;
|
|
17
24
|
return {
|
|
18
25
|
envPrefix: [
|
|
19
26
|
'VITE_', // Vite doesn't seem to merge in its default, see https://github.com/vikejs/vike/issues/554
|
|
20
27
|
'BASE_SERVER',
|
|
21
28
|
'BASE_ASSETS'
|
|
22
29
|
],
|
|
23
|
-
base: baseAssets, // Make Vite inject baseAssets to imports e.g. `import logoUrl from './logo.svg.js'`
|
|
24
|
-
_baseViteOriginal:
|
|
30
|
+
base: basesResolved.baseAssets, // Make Vite inject baseAssets to imports e.g. `import logoUrl from './logo.svg.js'`
|
|
31
|
+
_baseViteOriginal: baseViteOriginal
|
|
25
32
|
};
|
|
26
33
|
},
|
|
27
34
|
async configResolved(config) {
|
|
35
|
+
assertViteRoot(root, config);
|
|
28
36
|
const vikeConfig = await getVikeConfig(config);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
assert(basesResolved.baseServer === bases.baseServer);
|
|
33
|
-
assert(basesResolved.baseAssets === bases.baseAssets);
|
|
37
|
+
const basesResolved2 = resolveBaseFromResolvedConfig(vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets, config);
|
|
38
|
+
assert(basesResolved2.baseServer === basesResolved.baseServer);
|
|
39
|
+
assert(basesResolved2.baseAssets === basesResolved.baseAssets);
|
|
34
40
|
/* In dev, Vite seems buggy around setting vite.config.js#base to an absolute URL (e.g. http://localhost:8080/cdn/)
|
|
35
41
|
* - In dev, Vite removes the URL origin. (I.e. it resolves the user config `vite.config.js#base: 'http://localhost:8080/cdn/'` to resolved config `config.base === '/cdn/'`.)
|
|
36
42
|
* - Instead of having an internal Vike assertion fail, we let the user discover Vite's buggy behavior.
|
|
@@ -39,7 +45,3 @@ function baseUrls(vikeVitePluginOptions) {
|
|
|
39
45
|
}
|
|
40
46
|
};
|
|
41
47
|
}
|
|
42
|
-
function resolveBaseFromUserConfig(config, vikeVitePluginOptions) {
|
|
43
|
-
const baseViteOriginal = config.base ?? null;
|
|
44
|
-
return resolveBase(baseViteOriginal, vikeVitePluginOptions?.baseServer ?? null, vikeVitePluginOptions?.baseAssets ?? null);
|
|
45
|
-
}
|
|
@@ -11,7 +11,7 @@ import { createRequire } from 'module';
|
|
|
11
11
|
import fs from 'fs/promises';
|
|
12
12
|
import path from 'path';
|
|
13
13
|
import { fixServerAssets, fixServerAssets_assertCssCodeSplit, fixServerAssets_assertCssTarget, fixServerAssets_assertCssTarget_populate, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
14
|
-
import { set_ASSETS_MAP } from './
|
|
14
|
+
import { set_ASSETS_MAP } from './buildEntry/index.js';
|
|
15
15
|
import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
|
|
16
16
|
import { getFilePathResolved } from '../shared/getFilePath.js';
|
|
17
17
|
import { getConfigValueBuildTime } from '../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
@@ -117,7 +117,7 @@ async function getEntries(config) {
|
|
|
117
117
|
if (viteIsSSR(config)) {
|
|
118
118
|
const pageEntries = getPageEntries(pageConfigs);
|
|
119
119
|
const entries = {
|
|
120
|
-
//
|
|
120
|
+
// buildEntry: resolve('dist/esm/node/buildEntry.js'), // TODO/next-major-release: remove
|
|
121
121
|
...pageFileEntries,
|
|
122
122
|
// Ensure Rollup generates a bundle per page: https://github.com/vikejs/vike/issues/349#issuecomment-1166247275
|
|
123
123
|
...pageEntries
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getVikeManifest };
|
|
2
2
|
import { type PluginManifest } from '../../../shared/assertPluginManifest.js';
|
|
3
|
-
import type { VikeConfigGlobal } from '../importUserCode/v1-design/getVikeConfig
|
|
3
|
+
import type { VikeConfigGlobal } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
4
4
|
import type { ResolvedConfig } from 'vite';
|
|
5
5
|
declare function getVikeManifest(vikeConfigGlobal: VikeConfigGlobal, viteConfig: ResolvedConfig): PluginManifest;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { buildEntry };
|
|
2
2
|
export { set_ASSETS_MAP };
|
|
3
3
|
import type { Plugin, Rollup } from 'vite';
|
|
4
4
|
type Bundle = Rollup.OutputBundle;
|
|
5
5
|
type Options = Rollup.NormalizedOutputOptions;
|
|
6
|
-
declare function
|
|
6
|
+
declare function buildEntry(): Plugin[];
|
|
7
7
|
/** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
8
8
|
declare function set_ASSETS_MAP(options: Options, bundle: Bundle): Promise<void>;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { buildEntry };
|
|
2
2
|
export { set_ASSETS_MAP };
|
|
3
3
|
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
|
+
import { virtualFileIdImportUserCodeServer } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
5
|
+
import { getVikeManifest } from './getVikeManifest.js';
|
|
6
|
+
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
4
7
|
import { assert, getOutDirs, toPosixPath } from '../../utils.js';
|
|
8
|
+
import fs from 'fs/promises';
|
|
5
9
|
import path from 'path';
|
|
6
10
|
import { createRequire } from 'module';
|
|
7
|
-
import { getVikeManifest } from './getVikeManifest.js';
|
|
8
|
-
import fs from 'fs/promises';
|
|
9
|
-
import { virtualFileIdImportUserCodeServer } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
10
|
-
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
11
11
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
12
12
|
const importMetaUrl = import.meta.url;
|
|
13
13
|
const require_ = createRequire(importMetaUrl);
|
|
14
14
|
const ASSETS_MAP = '__VITE_ASSETS_MAP__';
|
|
15
|
-
function
|
|
15
|
+
function buildEntry() {
|
|
16
16
|
let config;
|
|
17
17
|
let vikeConfigGlobal;
|
|
18
18
|
return [
|
|
19
19
|
{
|
|
20
|
-
name: 'vike:
|
|
20
|
+
name: 'vike:buildEntry',
|
|
21
21
|
enforce: 'post',
|
|
22
22
|
async configResolved(config_) {
|
|
23
23
|
config = config_;
|
|
@@ -38,17 +38,16 @@ function getServerProductionEntryCode(config, vikeConfigGlobal) {
|
|
|
38
38
|
const vikeManifest = getVikeManifest(vikeConfigGlobal, config);
|
|
39
39
|
// Let's eventually simplify and move everything to a single virtual module
|
|
40
40
|
const importerCode = [
|
|
41
|
-
` import {
|
|
41
|
+
` import { setBuildEntry } from '${importPath}';`,
|
|
42
42
|
` import * as pageFiles from '${virtualFileIdImportUserCodeServer}';`,
|
|
43
43
|
` {`,
|
|
44
44
|
// We first set the values to a variable because of a Rollup bug, and this workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
45
45
|
` const assetsManifest = ${ASSETS_MAP};`,
|
|
46
46
|
` const pluginManifest = ${JSON.stringify(vikeManifest, null, 2)};`,
|
|
47
|
-
'
|
|
48
|
-
` pageFiles
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
` pluginManifest: () => pluginManifest,`,
|
|
47
|
+
' setBuildEntry({',
|
|
48
|
+
` pageFiles,`,
|
|
49
|
+
` assetsManifest,`,
|
|
50
|
+
` pluginManifest,`,
|
|
52
51
|
' });',
|
|
53
52
|
` }`,
|
|
54
53
|
''
|
|
@@ -85,12 +84,12 @@ function find_ASSETS_MAP(bundle) {
|
|
|
85
84
|
function getImportPath(config) {
|
|
86
85
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
87
86
|
const filePathAbsolute = toPosixPath(
|
|
88
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/
|
|
89
|
-
require_.resolve(`../../../../../../dist/esm/
|
|
87
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/buildEntry/index.js
|
|
88
|
+
require_.resolve(`../../../../../../dist/esm/__internal/index.js`));
|
|
90
89
|
if (
|
|
91
|
-
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal
|
|
90
|
+
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|
|
92
91
|
true) {
|
|
93
|
-
return 'vike/__internal
|
|
92
|
+
return 'vike/__internal';
|
|
94
93
|
}
|
|
95
94
|
else {
|
|
96
95
|
const { outDirServer } = getOutDirs(config);
|
|
@@ -6,11 +6,11 @@ import { installRequireShim_setUserRootDir } from '@brillout/require-shim';
|
|
|
6
6
|
import pc from '@brillout/picocolors';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { assertResolveAlias } from './commonConfig/assertResolveAlias.js';
|
|
9
|
-
import { pluginName } from './commonConfig/pluginName.js';
|
|
10
9
|
import { getEnvVarObject } from '../shared/getEnvVarObject.js';
|
|
11
10
|
import { isViteCliCall } from '../shared/isViteCliCall.js';
|
|
12
11
|
import { isVikeCliOrApi } from '../../api/context.js';
|
|
13
|
-
|
|
12
|
+
const pluginName = 'vike:commonConfig';
|
|
13
|
+
function commonConfig(vikeVitePluginOptions) {
|
|
14
14
|
return [
|
|
15
15
|
{
|
|
16
16
|
name: `${pluginName}:pre`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getVirtualFileImportUserCode };
|
|
2
2
|
import type { ResolvedConfig } from 'vite';
|
|
3
|
-
import type { VikeConfigGlobal } from './v1-design/getVikeConfig
|
|
3
|
+
import type { VikeConfigGlobal } from './v1-design/getVikeConfig.js';
|
|
4
4
|
declare function getVirtualFileImportUserCode(id: string, options: {
|
|
5
5
|
ssr?: boolean;
|
|
6
6
|
} | undefined, vikeConfigGlobal: VikeConfigGlobal, config: ResolvedConfig, isDev: boolean): Promise<string>;
|
|
@@ -143,9 +143,7 @@ const configDefinitionsBuiltInGlobal = {
|
|
|
143
143
|
env: { server: true, client: 'if-client-routing' },
|
|
144
144
|
eager: true
|
|
145
145
|
},
|
|
146
|
-
prerender: {
|
|
147
|
-
env: { config: true }
|
|
148
|
-
},
|
|
146
|
+
prerender: { env: { config: true } },
|
|
149
147
|
disableAutoFullBuild: { env: { config: true } },
|
|
150
148
|
includeAssetsImportedByServer: { env: { config: true } },
|
|
151
149
|
baseAssets: { env: { config: true } },
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile } from '../../../../utils.js';
|
|
2
|
+
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList } from '../../../../utils.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import glob from 'fast-glob';
|
|
5
5
|
import { exec } from 'child_process';
|
|
@@ -68,10 +68,8 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
68
68
|
'git',
|
|
69
69
|
preserveUTF8,
|
|
70
70
|
'ls-files',
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
// - Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
74
|
-
// ...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
71
|
+
// Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
72
|
+
...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
75
73
|
// Performance gain is non-negligible.
|
|
76
74
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
77
75
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
@@ -100,18 +98,18 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
100
98
|
}
|
|
101
99
|
const files = [];
|
|
102
100
|
for (const filePath of filesAll) {
|
|
103
|
-
//
|
|
104
|
-
if (
|
|
101
|
+
// + file?
|
|
102
|
+
if (!path.posix.basename(filePath).startsWith('+'))
|
|
105
103
|
continue;
|
|
106
104
|
// We have to repeat the same exclusion logic here because the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
|
|
107
105
|
if (!ignoreAsFilterFn(filePath))
|
|
108
106
|
continue;
|
|
109
|
-
// + file?
|
|
110
|
-
if (!path.posix.basename(filePath).startsWith('+'))
|
|
111
|
-
continue;
|
|
112
107
|
// JavaScript file?
|
|
113
108
|
if (!isScriptFile(filePath))
|
|
114
109
|
continue;
|
|
110
|
+
// Deleted?
|
|
111
|
+
if (filesDeleted.includes(filePath))
|
|
112
|
+
continue;
|
|
115
113
|
files.push(filePath);
|
|
116
114
|
}
|
|
117
115
|
return files;
|
|
@@ -8,11 +8,13 @@ export { getConfigValueInterfaceFile };
|
|
|
8
8
|
export type { VikeConfigObject };
|
|
9
9
|
export type { InterfaceValueFile };
|
|
10
10
|
export type { InterfaceFile };
|
|
11
|
+
export type { VikeConfigGlobal };
|
|
12
|
+
export type { VikeVitePluginOptions };
|
|
11
13
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
12
14
|
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
13
15
|
import type { ResolvedConfig } from 'vite';
|
|
14
16
|
import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
|
|
15
|
-
import
|
|
17
|
+
import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
16
18
|
type InterfaceFile = InterfaceConfigFile | InterfaceValueFile;
|
|
17
19
|
type InterfaceFileCommons = {
|
|
18
20
|
locationId: LocationId;
|
|
@@ -37,6 +39,9 @@ type VikeConfigObject = {
|
|
|
37
39
|
pageConfigs: PageConfigBuildTime[];
|
|
38
40
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
39
41
|
vikeConfigGlobal: VikeConfigGlobal;
|
|
42
|
+
vikeConfigNew: {
|
|
43
|
+
global: ReturnType<typeof getPageConfigUserFriendlyNew>;
|
|
44
|
+
};
|
|
40
45
|
};
|
|
41
46
|
declare const vikeConfigDependencies: Set<string>;
|
|
42
47
|
declare function reloadVikeConfig(config: ResolvedConfig): void;
|
|
@@ -47,3 +52,96 @@ declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePlu
|
|
|
47
52
|
declare function isV1Design(config: ResolvedConfig): Promise<boolean>;
|
|
48
53
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
49
54
|
declare function getConfigValueInterfaceFile(interfaceFile: InterfaceFile, configName: string): unknown;
|
|
55
|
+
type VikeConfigGlobal = {
|
|
56
|
+
prerender: false | {
|
|
57
|
+
noExtraDir: boolean;
|
|
58
|
+
parallel: boolean | number;
|
|
59
|
+
partial: boolean;
|
|
60
|
+
disableAutoRun: boolean;
|
|
61
|
+
};
|
|
62
|
+
disableAutoFullBuild: boolean | 'prerender' | null;
|
|
63
|
+
includeAssetsImportedByServer: boolean;
|
|
64
|
+
baseAssets: string | null;
|
|
65
|
+
baseServer: string | null;
|
|
66
|
+
redirects: Record<string, string>;
|
|
67
|
+
trailingSlash: boolean;
|
|
68
|
+
disableUrlNormalization: boolean;
|
|
69
|
+
};
|
|
70
|
+
type VikeVitePluginOptions = {
|
|
71
|
+
/**
|
|
72
|
+
* Enable pre-rendering.
|
|
73
|
+
*
|
|
74
|
+
* https://vike.dev/pre-rendering
|
|
75
|
+
*
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
prerender?: boolean | {
|
|
79
|
+
/**
|
|
80
|
+
* Don't create a new directory for each HTML file.
|
|
81
|
+
*
|
|
82
|
+
* For example, generate `dist/client/about.html` instead of `dist/client/about/index.html`.
|
|
83
|
+
*
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
noExtraDir?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Number of concurrent pre-render jobs.
|
|
89
|
+
*
|
|
90
|
+
* Set to `false` to disable concurrency.
|
|
91
|
+
*
|
|
92
|
+
* @default os.cpus().length
|
|
93
|
+
*/
|
|
94
|
+
parallel?: boolean | number;
|
|
95
|
+
/**
|
|
96
|
+
* Allow only some of your pages to be pre-rendered.
|
|
97
|
+
*
|
|
98
|
+
* This setting doesn't affect the pre-rendering process: it merely suppresses the warnings when some of your pages cannot be pre-rendered.
|
|
99
|
+
|
|
100
|
+
* @default false
|
|
101
|
+
*/
|
|
102
|
+
partial?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Disable the automatic initiation of the pre-rendering process when running `$ vike build`.
|
|
105
|
+
*
|
|
106
|
+
* Use this if you want to programmatically initiate the pre-rendering process instead.
|
|
107
|
+
*
|
|
108
|
+
* https://vike.dev/api#prerender
|
|
109
|
+
*
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
disableAutoRun?: boolean;
|
|
113
|
+
};
|
|
114
|
+
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
115
|
+
disableAutoFullBuild?: boolean | 'prerender';
|
|
116
|
+
/** The Base URL of your server.
|
|
117
|
+
*
|
|
118
|
+
* https://vike.dev/base-url
|
|
119
|
+
*/
|
|
120
|
+
baseServer?: string;
|
|
121
|
+
/** The Base URL of your static assets.
|
|
122
|
+
*
|
|
123
|
+
* https://vike.dev/base-url
|
|
124
|
+
*/
|
|
125
|
+
baseAssets?: string;
|
|
126
|
+
/** @deprecated It's now `true` by default. You can remove this option. */
|
|
127
|
+
includeAssetsImportedByServer?: boolean;
|
|
128
|
+
/** Permanent redirections (HTTP status code 301)
|
|
129
|
+
*
|
|
130
|
+
* https://vike.dev/redirects
|
|
131
|
+
*/
|
|
132
|
+
redirects?: Record<string, string>;
|
|
133
|
+
/** Whether URLs should end with a trailing slash.
|
|
134
|
+
*
|
|
135
|
+
* https://vike.dev/url-normalization
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
trailingSlash?: boolean;
|
|
140
|
+
/** Disable automatic URL normalization.
|
|
141
|
+
*
|
|
142
|
+
* https://vike.dev/url-normalization
|
|
143
|
+
*
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
disableUrlNormalization?: boolean;
|
|
147
|
+
};
|
|
@@ -23,7 +23,8 @@ import { clearFilesEnvMap, resolveConfigEnvWithFileName, resolvePointerImportOfC
|
|
|
23
23
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
24
24
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
25
25
|
import { assertExtensionsPeerDependencies, assertExtensionsConventions } from './assertExtensions.js';
|
|
26
|
-
import {
|
|
26
|
+
import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
27
|
+
import { getConfigValuesBase } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
27
28
|
assertIsNotProductionRuntime();
|
|
28
29
|
let restartVite = false;
|
|
29
30
|
let wasConfigInvalid = null;
|
|
@@ -239,7 +240,10 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
239
240
|
configDefinitions: {},
|
|
240
241
|
configValueSources: {}
|
|
241
242
|
},
|
|
242
|
-
vikeConfigGlobal: resolveVikeConfigGlobal({}, {})
|
|
243
|
+
vikeConfigGlobal: resolveVikeConfigGlobal({}, {}),
|
|
244
|
+
vikeConfigNew: {
|
|
245
|
+
global: getPageConfigUserFriendlyNew({ configValues: {} })
|
|
246
|
+
}
|
|
243
247
|
};
|
|
244
248
|
return dummyData;
|
|
245
249
|
}
|
|
@@ -248,8 +252,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
248
252
|
async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
249
253
|
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir);
|
|
250
254
|
const importedFilesLoaded = {};
|
|
251
|
-
const { pageConfigGlobal,
|
|
252
|
-
const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
|
|
255
|
+
const { pageConfigGlobal, vikeConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions);
|
|
253
256
|
const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
|
|
254
257
|
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
255
258
|
.map(async ([locationId]) => {
|
|
@@ -299,7 +302,37 @@ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
|
299
302
|
return pageConfig;
|
|
300
303
|
}));
|
|
301
304
|
assertPageConfigs(pageConfigs);
|
|
302
|
-
|
|
305
|
+
const configValues = getConfigValues(pageConfigGlobal);
|
|
306
|
+
const global = getPageConfigUserFriendlyNew({ configValues });
|
|
307
|
+
return { pageConfigs, pageConfigGlobal, vikeConfigGlobal, vikeConfigNew: { global } };
|
|
308
|
+
}
|
|
309
|
+
function getConfigValues(pageConfig) {
|
|
310
|
+
const configValues = {};
|
|
311
|
+
getConfigValuesBase(pageConfig, (configEnv) => !!configEnv.config).forEach((entry) => {
|
|
312
|
+
if (entry.configValueBase.type === 'computed') {
|
|
313
|
+
assert('value' in entry); // Help TS
|
|
314
|
+
const { configValueBase, value, configName } = entry;
|
|
315
|
+
configValues[configName] = { ...configValueBase, value };
|
|
316
|
+
}
|
|
317
|
+
if (entry.configValueBase.type === 'standard') {
|
|
318
|
+
assert('sourceRelevant' in entry); // Help TS
|
|
319
|
+
const { configValueBase, sourceRelevant, configName } = entry;
|
|
320
|
+
assert('value' in sourceRelevant);
|
|
321
|
+
const { value } = sourceRelevant;
|
|
322
|
+
configValues[configName] = { ...configValueBase, value };
|
|
323
|
+
}
|
|
324
|
+
if (entry.configValueBase.type === 'cumulative') {
|
|
325
|
+
assert('sourcesRelevant' in entry); // Help TS
|
|
326
|
+
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
327
|
+
const values = [];
|
|
328
|
+
sourcesRelevant.forEach((source) => {
|
|
329
|
+
assert('value' in source);
|
|
330
|
+
values.push(source.value);
|
|
331
|
+
});
|
|
332
|
+
configValues[configName] = { ...configValueBase, value: values };
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
return configValues;
|
|
303
336
|
}
|
|
304
337
|
// TODO/soon: refactor
|
|
305
338
|
// - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
|
|
@@ -377,7 +410,7 @@ function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
|
|
|
377
410
|
.sort(([locationId1], [locationId2]) => sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage)));
|
|
378
411
|
return interfaceFilesRelevant;
|
|
379
412
|
}
|
|
380
|
-
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
|
|
413
|
+
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded, vikeVitePluginOptions) {
|
|
381
414
|
const locationIds = objectKeys(interfaceFilesByLocationId);
|
|
382
415
|
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
383
416
|
return isGlobalLocation(locationId, locationIds);
|
|
@@ -432,7 +465,31 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
432
465
|
pageConfigGlobalValues[configName] = configValueSource.value;
|
|
433
466
|
}
|
|
434
467
|
}));
|
|
435
|
-
|
|
468
|
+
const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
|
|
469
|
+
{
|
|
470
|
+
assert(isObject(vikeVitePluginOptions));
|
|
471
|
+
Object.entries(vikeVitePluginOptions).forEach(([configName, value]) => {
|
|
472
|
+
if (pageConfigGlobal.configValueSources[configName])
|
|
473
|
+
return;
|
|
474
|
+
pageConfigGlobal.configValueSources[configName] = [];
|
|
475
|
+
pageConfigGlobal.configValueSources[configName].push({
|
|
476
|
+
value,
|
|
477
|
+
configEnv: { config: true },
|
|
478
|
+
definedAtFilePath: {
|
|
479
|
+
...getFilePathResolved({
|
|
480
|
+
userRootDir,
|
|
481
|
+
filePathAbsoluteUserRootDir: '/vite.config.js'
|
|
482
|
+
}),
|
|
483
|
+
fileExportPathToShowToUser: null
|
|
484
|
+
},
|
|
485
|
+
locationId: '/',
|
|
486
|
+
isOverriden: false,
|
|
487
|
+
valueIsImportedAtRuntime: false,
|
|
488
|
+
valueIsDefinedByPlusFile: false
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
return { pageConfigGlobal, pageConfigGlobalValues, vikeConfigGlobal };
|
|
436
493
|
}
|
|
437
494
|
async function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded) {
|
|
438
495
|
const sourcesInfo = [];
|
|
@@ -1010,3 +1067,121 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
1010
1067
|
function getConfigValueInterfaceFile(interfaceFile, configName) {
|
|
1011
1068
|
return interfaceFile.fileExportsByConfigName[configName]?.configValue;
|
|
1012
1069
|
}
|
|
1070
|
+
// TODO: refactor code below
|
|
1071
|
+
function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
|
|
1072
|
+
// TODO/v1-release: remove
|
|
1073
|
+
assertVikeConfigGlobal(vikeVitePluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
1074
|
+
const configs = [vikeVitePluginOptions];
|
|
1075
|
+
assertVikeConfigGlobal(pageConfigGlobalValues, ({ prop, errMsg }) => {
|
|
1076
|
+
// Can we add the config file path ?
|
|
1077
|
+
return `config ${pc.cyan(prop)} ${errMsg}`;
|
|
1078
|
+
});
|
|
1079
|
+
configs.push(pageConfigGlobalValues);
|
|
1080
|
+
const vikeConfigGlobal = {
|
|
1081
|
+
disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
1082
|
+
prerender: resolvePrerenderOptions(configs),
|
|
1083
|
+
includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
|
|
1084
|
+
baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
|
|
1085
|
+
baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
|
|
1086
|
+
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
1087
|
+
disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
1088
|
+
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
|
|
1089
|
+
};
|
|
1090
|
+
return vikeConfigGlobal;
|
|
1091
|
+
}
|
|
1092
|
+
function resolvePrerenderOptions(configs) {
|
|
1093
|
+
if (!configs.some((c) => c.prerender)) {
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1096
|
+
const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
|
|
1097
|
+
return {
|
|
1098
|
+
partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
|
|
1099
|
+
noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
|
|
1100
|
+
parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
|
|
1101
|
+
disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
function isObject2(p) {
|
|
1105
|
+
return typeof p === 'object';
|
|
1106
|
+
}
|
|
1107
|
+
function merge(objs) {
|
|
1108
|
+
const obj = {};
|
|
1109
|
+
objs.forEach((e) => {
|
|
1110
|
+
Object.assign(obj, e);
|
|
1111
|
+
});
|
|
1112
|
+
return obj;
|
|
1113
|
+
}
|
|
1114
|
+
function pickFirst(arr) {
|
|
1115
|
+
return arr.filter((v) => v !== undefined)[0];
|
|
1116
|
+
}
|
|
1117
|
+
function assertVikeConfigGlobal(vikeConfigGlobal, wrongUsageMsg) {
|
|
1118
|
+
const wrongUsageError = check(vikeConfigGlobal);
|
|
1119
|
+
if (wrongUsageError) {
|
|
1120
|
+
assertUsage(false, wrongUsageMsg(wrongUsageError));
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
function check(vikeConfigGlobal) {
|
|
1124
|
+
assert(isObject(vikeConfigGlobal));
|
|
1125
|
+
{
|
|
1126
|
+
const prop = 'disableUrlNormalization';
|
|
1127
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
1128
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1129
|
+
}
|
|
1130
|
+
{
|
|
1131
|
+
const prop = 'trailingSlash';
|
|
1132
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
1133
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1134
|
+
}
|
|
1135
|
+
{
|
|
1136
|
+
const prop = 'redirects';
|
|
1137
|
+
const { redirects } = vikeConfigGlobal;
|
|
1138
|
+
if (!(redirects === undefined ||
|
|
1139
|
+
(isObject(redirects) && Object.values(redirects).every((v) => typeof v === 'string'))))
|
|
1140
|
+
return { prop, errMsg: 'should be an object of strings' };
|
|
1141
|
+
}
|
|
1142
|
+
{
|
|
1143
|
+
const prop = 'disableAutoFullBuild';
|
|
1144
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') &&
|
|
1145
|
+
!hasProp(vikeConfigGlobal, prop, 'undefined') &&
|
|
1146
|
+
!(vikeConfigGlobal[prop] === 'prerender'))
|
|
1147
|
+
return { prop, errMsg: "should be a boolean or 'prerender'" };
|
|
1148
|
+
}
|
|
1149
|
+
{
|
|
1150
|
+
const prop = 'includeAssetsImportedByServer';
|
|
1151
|
+
if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
1152
|
+
return { prop, errMsg: 'should be a boolean' };
|
|
1153
|
+
}
|
|
1154
|
+
{
|
|
1155
|
+
const prop = 'prerender';
|
|
1156
|
+
if (!hasProp(vikeConfigGlobal, prop, 'object') &&
|
|
1157
|
+
!hasProp(vikeConfigGlobal, prop, 'boolean') &&
|
|
1158
|
+
!hasProp(vikeConfigGlobal, prop, 'undefined'))
|
|
1159
|
+
return { prop, errMsg: 'should be an object or a boolean' };
|
|
1160
|
+
}
|
|
1161
|
+
const configVikePrerender = vikeConfigGlobal.prerender;
|
|
1162
|
+
if (typeof configVikePrerender === 'object') {
|
|
1163
|
+
{
|
|
1164
|
+
const p = 'partial';
|
|
1165
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
1166
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1167
|
+
}
|
|
1168
|
+
{
|
|
1169
|
+
const p = 'noExtraDir';
|
|
1170
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
1171
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1172
|
+
}
|
|
1173
|
+
{
|
|
1174
|
+
const p = 'disableAutoRun';
|
|
1175
|
+
if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
|
|
1176
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
|
|
1177
|
+
}
|
|
1178
|
+
{
|
|
1179
|
+
const p = 'parallel';
|
|
1180
|
+
if (!hasProp(configVikePrerender, p, 'boolean') &&
|
|
1181
|
+
!hasProp(configVikePrerender, p, 'number') &&
|
|
1182
|
+
!hasProp(configVikePrerender, p, 'undefined'))
|
|
1183
|
+
return { prop: `prerender.${p}`, errMsg: 'should be a boolean or a number' };
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return null;
|
|
1187
|
+
}
|
|
@@ -5,7 +5,8 @@ import { getVikeConfig } from './getVikeConfig.js';
|
|
|
5
5
|
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
6
6
|
import { serializeConfigValues } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
7
7
|
async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
|
|
8
|
-
const
|
|
8
|
+
const vikeConfig = await getVikeConfig(config, { doNotRestartViteOnError: true });
|
|
9
|
+
const { pageConfigs, pageConfigGlobal } = vikeConfig;
|
|
9
10
|
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
10
11
|
}
|
|
11
12
|
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
@@ -33,7 +33,7 @@ function setGlobalContext() {
|
|
|
33
33
|
order: 'post',
|
|
34
34
|
async handler(config) {
|
|
35
35
|
const { outDirRoot } = getOutDirs(config);
|
|
36
|
-
assertFilePathAbsoluteFilesystem(outDirRoot); // Needed for
|
|
36
|
+
assertFilePathAbsoluteFilesystem(outDirRoot); // Needed for `importServerProductionEntry({ outDir })` of @brillout/vite-plugin-server-entry
|
|
37
37
|
setGlobalContext_viteConfig(config, outDirRoot);
|
|
38
38
|
const vikeConfig = await getVikeConfig(config);
|
|
39
39
|
setGlobalContext_vikeConfig(vikeConfig);
|