vike 0.4.213 → 0.4.215
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/build.js +9 -3
- package/dist/cjs/node/api/context.js +18 -0
- package/dist/cjs/node/api/dev.js +6 -3
- package/dist/cjs/node/api/onLoad.js +9 -0
- package/dist/cjs/node/api/{enhanceViteConfig.js → prepareApiCall.js} +11 -6
- package/dist/cjs/node/api/prerender.js +6 -3
- package/dist/cjs/node/api/preview.js +6 -3
- package/dist/cjs/node/api/utils.js +21 -0
- package/dist/cjs/node/cli/entry.js +8 -8
- package/dist/cjs/node/cli/onLoad.js +2 -0
- package/dist/cjs/node/cli/parseCli.js +2 -2
- package/dist/cjs/node/plugin/index.js +3 -1
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +0 -3
- package/dist/cjs/node/plugin/plugins/commonConfig/pluginName.js +1 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +5 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -15
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -7
- package/dist/cjs/node/plugin/plugins/vite6HmrRegressionWorkaround.js +35 -0
- package/dist/cjs/node/prerender/runPrerender.js +4 -3
- package/dist/cjs/shared/page-configs/getConfigValue.js +2 -31
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +2 -2
- package/dist/cjs/shared/page-configs/getConfigValueTyped.js +32 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/api/build.d.ts +5 -3
- package/dist/esm/node/api/build.js +9 -3
- package/dist/esm/node/api/context.d.ts +5 -0
- package/dist/esm/node/api/context.js +17 -0
- package/dist/esm/node/api/dev.d.ts +6 -2
- package/dist/esm/node/api/dev.js +6 -3
- package/dist/esm/node/api/onLoad.d.ts +2 -0
- package/dist/esm/node/api/onLoad.js +7 -0
- package/dist/esm/node/api/prepareApiCall.d.ts +7 -0
- package/dist/esm/node/api/{enhanceViteConfig.js → prepareApiCall.js} +11 -6
- package/dist/esm/node/api/prerender.d.ts +4 -1
- package/dist/esm/node/api/prerender.js +6 -3
- package/dist/esm/node/api/preview.d.ts +6 -2
- package/dist/esm/node/api/preview.js +6 -3
- package/dist/esm/node/api/{APIOptions.d.ts → types.d.ts} +3 -1
- package/dist/esm/node/api/utils.d.ts +1 -0
- package/dist/esm/node/api/utils.js +5 -0
- package/dist/esm/node/cli/entry.js +8 -8
- package/dist/esm/node/cli/onLoad.js +2 -0
- package/dist/esm/node/cli/parseCli.js +2 -2
- package/dist/esm/node/plugin/index.js +3 -1
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +0 -3
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.js +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +5 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -16
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -7
- package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.js +33 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +5 -3
- package/dist/esm/node/prerender/runPrerender.js +4 -3
- package/dist/esm/shared/ConfigVike.d.ts +1 -1
- package/dist/esm/shared/page-configs/getConfigValue.d.ts +2 -8
- package/dist/esm/shared/page-configs/getConfigValue.js +1 -27
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +2 -3
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +1 -1
- package/dist/esm/shared/page-configs/getConfigValueTyped.d.ts +9 -0
- package/dist/esm/shared/page-configs/getConfigValueTyped.js +27 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +13 -6
- package/dist/esm/node/api/enhanceViteConfig.d.ts +0 -6
- /package/dist/cjs/node/api/{APIOptions.js → types.js} +0 -0
- /package/dist/esm/node/api/{APIOptions.js → types.js} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { prepareApiCall };
|
|
2
|
+
import type { InlineConfig } from 'vite';
|
|
3
|
+
import type { Operation } from './types.js';
|
|
4
|
+
declare function prepareApiCall(viteConfig: InlineConfig | undefined, operation: Operation): Promise<{
|
|
5
|
+
viteConfigEnhanced: InlineConfig;
|
|
6
|
+
configVike: import("../../shared/ConfigVike.js").ConfigVikeResolved;
|
|
7
|
+
}>;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { prepareApiCall };
|
|
2
2
|
import { resolveConfig } from 'vite';
|
|
3
3
|
import { getConfigVike } from '../shared/getConfigVike.js';
|
|
4
4
|
import { pluginName } from '../plugin/plugins/commonConfig/pluginName.js';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { setOperation } from './context.js';
|
|
6
|
+
async function prepareApiCall(viteConfig = {}, operation) {
|
|
7
|
+
setOperation(operation);
|
|
8
|
+
return enhanceViteConfig(viteConfig, operation);
|
|
9
|
+
}
|
|
10
|
+
async function enhanceViteConfig(viteConfig = {}, operation) {
|
|
11
|
+
let viteConfigResolved = await resolveViteConfig(viteConfig, operation);
|
|
7
12
|
let viteConfigEnhanced = viteConfig;
|
|
8
13
|
// Add vike to plugins if not present
|
|
9
14
|
if (!viteConfigResolved.plugins.some((p) => p.name === pluginName)) {
|
|
@@ -13,7 +18,7 @@ async function enhanceViteConfig(viteConfig = {}, command) {
|
|
|
13
18
|
...viteConfig,
|
|
14
19
|
plugins: [...(viteConfig.plugins ?? []), vikePlugin()]
|
|
15
20
|
};
|
|
16
|
-
viteConfigResolved = await resolveViteConfig(viteConfigEnhanced,
|
|
21
|
+
viteConfigResolved = await resolveViteConfig(viteConfigEnhanced, operation);
|
|
17
22
|
}
|
|
18
23
|
const configVike = await getConfigVike(viteConfigResolved);
|
|
19
24
|
// TODO: enable Vike extensions to add Vite plugins
|
|
@@ -22,6 +27,6 @@ async function enhanceViteConfig(viteConfig = {}, command) {
|
|
|
22
27
|
configVike
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
|
-
async function resolveViteConfig(viteConfig,
|
|
26
|
-
return await resolveConfig(viteConfig,
|
|
30
|
+
async function resolveViteConfig(viteConfig, operation) {
|
|
31
|
+
return await resolveConfig(viteConfig, operation === 'build' || operation === 'prerender' ? 'build' : 'serve', 'custom', operation === 'dev' ? 'development' : 'production', operation === 'preview');
|
|
27
32
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { prerender };
|
|
2
2
|
import { type PrerenderOptions } from '../prerender/runPrerender.js';
|
|
3
|
-
|
|
3
|
+
import type { ResolvedConfig } from 'vite';
|
|
4
|
+
declare function prerender(options?: PrerenderOptions): Promise<{
|
|
5
|
+
viteConfig: ResolvedConfig;
|
|
6
|
+
}>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { prerender };
|
|
2
2
|
import { runPrerenderFromAPI } from '../prerender/runPrerender.js';
|
|
3
|
-
import {
|
|
3
|
+
import { prepareApiCall } from './prepareApiCall.js';
|
|
4
4
|
async function prerender(options = {}) {
|
|
5
|
-
const { viteConfigEnhanced } = await
|
|
5
|
+
const { viteConfigEnhanced } = await prepareApiCall(options.viteConfig, 'prerender');
|
|
6
6
|
options.viteConfig = viteConfigEnhanced;
|
|
7
|
-
await runPrerenderFromAPI(options);
|
|
7
|
+
const { viteConfig } = await runPrerenderFromAPI(options);
|
|
8
|
+
return {
|
|
9
|
+
viteConfig
|
|
10
|
+
};
|
|
8
11
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { preview };
|
|
2
|
-
import type
|
|
3
|
-
|
|
2
|
+
import { type ResolvedConfig, type PreviewServer } from 'vite';
|
|
3
|
+
import type { APIOptions } from './types.js';
|
|
4
|
+
declare function preview(options?: APIOptions): Promise<{
|
|
5
|
+
viteServer: PreviewServer;
|
|
6
|
+
viteConfig: ResolvedConfig;
|
|
7
|
+
}>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { preview };
|
|
2
|
-
import {
|
|
2
|
+
import { prepareApiCall } from './prepareApiCall.js';
|
|
3
3
|
import { preview as previewVite } from 'vite';
|
|
4
4
|
async function preview(options = {}) {
|
|
5
|
-
const { viteConfigEnhanced } = await
|
|
5
|
+
const { viteConfigEnhanced } = await prepareApiCall(options.viteConfig, 'preview');
|
|
6
6
|
const server = await previewVite(viteConfigEnhanced);
|
|
7
|
-
return
|
|
7
|
+
return {
|
|
8
|
+
viteServer: server,
|
|
9
|
+
viteConfig: server.config
|
|
10
|
+
};
|
|
8
11
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { APIOptions };
|
|
1
|
+
export type { APIOptions };
|
|
2
|
+
export type { Operation };
|
|
2
3
|
import type { InlineConfig } from 'vite';
|
|
3
4
|
type APIOptions = {
|
|
4
5
|
/**
|
|
@@ -8,3 +9,4 @@ type APIOptions = {
|
|
|
8
9
|
*/
|
|
9
10
|
viteConfig?: InlineConfig;
|
|
10
11
|
};
|
|
12
|
+
type Operation = 'build' | 'dev' | 'preview' | 'prerender';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../utils/assert.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Utils needed by Vike's API
|
|
2
|
+
// We call onLoad() here so that it's called even when only a subset of the API is loaded. (Making the assert() calls inside onLoad() a lot stronger.)
|
|
3
|
+
import { onLoad } from './onLoad.js';
|
|
4
|
+
onLoad();
|
|
5
|
+
export * from '../../utils/assert.js';
|
|
@@ -21,16 +21,16 @@ async function cli() {
|
|
|
21
21
|
async function cmdDev() {
|
|
22
22
|
const startTime = performance.now();
|
|
23
23
|
try {
|
|
24
|
-
const
|
|
25
|
-
await
|
|
26
|
-
const info =
|
|
24
|
+
const { viteServer } = await dev();
|
|
25
|
+
await viteServer.listen();
|
|
26
|
+
const info = viteServer.config.logger.info;
|
|
27
27
|
const startupDurationString = pc.dim(`ready in ${pc.reset(pc.bold(String(Math.ceil(performance.now() - startTime))))} ms`);
|
|
28
28
|
const hasExistingLogs = process.stdout.bytesWritten > 0 || process.stderr.bytesWritten > 0;
|
|
29
29
|
info(` ${pc.yellow(`${pc.bold(projectInfo.projectName)} v${projectInfo.projectVersion}`)} ${startupDurationString}\n`, {
|
|
30
30
|
clear: !hasExistingLogs
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
viteServer.printUrls();
|
|
33
|
+
viteServer.bindCLIShortcuts({ print: true });
|
|
34
34
|
}
|
|
35
35
|
catch (err) {
|
|
36
36
|
console.error(pc.red(`Error while starting dev server:`));
|
|
@@ -52,9 +52,9 @@ async function cmdBuild() {
|
|
|
52
52
|
}
|
|
53
53
|
async function cmdPreview() {
|
|
54
54
|
try {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const { viteServer } = await preview();
|
|
56
|
+
viteServer.printUrls();
|
|
57
|
+
viteServer.bindCLIShortcuts({ print: true });
|
|
58
58
|
}
|
|
59
59
|
catch (err) {
|
|
60
60
|
console.error(pc.red(`Error while starting preview server:`));
|
|
@@ -4,8 +4,8 @@ import { projectInfo, includes } from './utils.js';
|
|
|
4
4
|
const commands = [
|
|
5
5
|
{ name: 'dev', desc: 'Start development server' },
|
|
6
6
|
{ name: 'build', desc: 'Build for production' },
|
|
7
|
-
{ name: 'preview', desc: 'Start preview server using production build' },
|
|
8
|
-
{ name: 'prerender', desc: 'Pre-render pages' }
|
|
7
|
+
{ name: 'preview', desc: 'Start preview server using production build (only works for SSG apps)' },
|
|
8
|
+
{ name: 'prerender', desc: 'Pre-render pages (only needed when partial.disableAutoRun is true)' }
|
|
9
9
|
];
|
|
10
10
|
function parseCli() {
|
|
11
11
|
const command = (() => {
|
|
@@ -27,6 +27,7 @@ import { fileEnv } from './plugins/fileEnv.js';
|
|
|
27
27
|
import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.js';
|
|
28
28
|
import { resolveClientEntriesDev } from './resolveClientEntriesDev.js';
|
|
29
29
|
import { workaroundCssModuleHmr } from './plugins/workaroundCssModuleHmr.js';
|
|
30
|
+
import { vite6HmrRegressionWorkaround } from './plugins/vite6HmrRegressionWorkaround.js';
|
|
30
31
|
assertNodeEnv_onVikePluginLoad();
|
|
31
32
|
markEnvAsVikePluginLoaded();
|
|
32
33
|
assertViteVersion();
|
|
@@ -52,7 +53,8 @@ function plugin(vikeConfig) {
|
|
|
52
53
|
baseUrls(vikeConfig),
|
|
53
54
|
envVarsPlugin(),
|
|
54
55
|
fileEnv(),
|
|
55
|
-
workaroundCssModuleHmr()
|
|
56
|
+
workaroundCssModuleHmr(),
|
|
57
|
+
vite6HmrRegressionWorkaround()
|
|
56
58
|
];
|
|
57
59
|
return plugins;
|
|
58
60
|
}
|
|
@@ -9,9 +9,6 @@ import pc from '@brillout/picocolors';
|
|
|
9
9
|
import { logErrorHint } from '../../runtime/renderPage/logErrorHint.js';
|
|
10
10
|
import { manifestTempFile } from './buildConfig.js';
|
|
11
11
|
let forceExit = false;
|
|
12
|
-
assertWarning(!isViteCliCall(), `Vite's CLI is deprecated ${pc.underline('https://vike.dev/migration/cli')}`, {
|
|
13
|
-
onlyOnce: true
|
|
14
|
-
});
|
|
15
12
|
function autoFullBuild() {
|
|
16
13
|
let config;
|
|
17
14
|
let configVike;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const pluginName = "vike:commonConfig
|
|
1
|
+
export declare const pluginName = "vike:commonConfig";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const pluginName = 'vike:commonConfig
|
|
1
|
+
export const pluginName = 'vike:commonConfig';
|
|
@@ -8,6 +8,10 @@ import path from 'path';
|
|
|
8
8
|
import { assertResolveAlias } from './commonConfig/assertResolveAlias.js';
|
|
9
9
|
import { pluginName } from './commonConfig/pluginName.js';
|
|
10
10
|
import { getEnvVarObject } from '../shared/getEnvVarObject.js';
|
|
11
|
+
import { isViteCliCall } from '../shared/isViteCliCall.js';
|
|
12
|
+
assertWarning(!isViteCliCall(), `Vite's CLI is deprecated ${pc.underline('https://vike.dev/migration/cli')}`, {
|
|
13
|
+
onlyOnce: true
|
|
14
|
+
});
|
|
11
15
|
function commonConfig() {
|
|
12
16
|
return [
|
|
13
17
|
{
|
|
@@ -18,7 +22,7 @@ function commonConfig() {
|
|
|
18
22
|
}
|
|
19
23
|
},
|
|
20
24
|
{
|
|
21
|
-
name:
|
|
25
|
+
name: `${pluginName}:post`,
|
|
22
26
|
enforce: 'post',
|
|
23
27
|
configResolved: {
|
|
24
28
|
order: 'post',
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
declare function crawlPlusFiles(userRootDir: string, outDirAbsoluteFilesystem: string,
|
|
2
|
+
declare function crawlPlusFiles(userRootDir: string, outDirAbsoluteFilesystem: string, crawlWithGit: null | boolean): Promise<{
|
|
3
3
|
filePathAbsoluteUserRootDir: string;
|
|
4
4
|
}[]>;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
import { assertPosixPath, assert,
|
|
2
|
+
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile } from '../../../../utils.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs/promises';
|
|
5
5
|
import glob from 'fast-glob';
|
|
6
6
|
import { exec } from 'child_process';
|
|
7
7
|
import { promisify } from 'util';
|
|
8
|
-
import pc from '@brillout/picocolors';
|
|
9
8
|
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
10
9
|
const execA = promisify(exec);
|
|
11
10
|
const TOO_MANY_UNTRACKED_FILES = 5;
|
|
12
11
|
assertIsNotProductionRuntime();
|
|
13
12
|
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
14
13
|
let gitIsNotUsable = false;
|
|
15
|
-
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem,
|
|
14
|
+
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, crawlWithGit) {
|
|
16
15
|
assertPosixPath(userRootDir);
|
|
17
16
|
assertPosixPath(outDirAbsoluteFilesystem);
|
|
18
17
|
let outDirRelativeFromUserRootDir = path.posix.relative(userRootDir, outDirAbsoluteFilesystem);
|
|
@@ -27,7 +26,6 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, craw
|
|
|
27
26
|
(!outDirRelativeFromUserRootDir.startsWith('./') &&
|
|
28
27
|
//
|
|
29
28
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
30
|
-
const timeBefore = new Date().getTime();
|
|
31
29
|
// Crawl
|
|
32
30
|
let files = [];
|
|
33
31
|
const res = crawlWithGit !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
@@ -43,18 +41,6 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, craw
|
|
|
43
41
|
}
|
|
44
42
|
// Filter build files
|
|
45
43
|
files = files.filter((filePath) => !isTemporaryBuildFile(filePath));
|
|
46
|
-
// Check performance
|
|
47
|
-
{
|
|
48
|
-
const timeAfter = new Date().getTime();
|
|
49
|
-
const timeSpent = timeAfter - timeBefore;
|
|
50
|
-
if (isDev) {
|
|
51
|
-
// We only warn in dev, because while building it's expected to take a long time as crawling is competing for resources with other tasks.
|
|
52
|
-
// Although, in dev, it's also competing for resources e.g. with Vite's `optimizeDeps`.
|
|
53
|
-
assertWarning(timeSpent < 3 * 1000, `Crawling your ${pc.cyan('+')} files took an unexpected long time (${humanizeTime(timeSpent)}). If you consistently get this warning, then consider reaching out on GitHub.`, {
|
|
54
|
-
onlyOnce: 'slow-crawling'
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
44
|
// Normalize
|
|
59
45
|
const plusFiles = files.map((filePath) => {
|
|
60
46
|
// Both `$ git-ls files` and fast-glob return posix paths
|
|
@@ -80,8 +80,8 @@ async function isV1Design(config, isDev) {
|
|
|
80
80
|
const isV1Design = pageConfigs.length > 0;
|
|
81
81
|
return isV1Design;
|
|
82
82
|
}
|
|
83
|
-
async function loadInterfaceFiles(userRootDir, outDirRoot,
|
|
84
|
-
const plusFiles = await findPlusFiles(userRootDir, outDirRoot,
|
|
83
|
+
async function loadInterfaceFiles(userRootDir, outDirRoot, crawlWithGit) {
|
|
84
|
+
const plusFiles = await findPlusFiles(userRootDir, outDirRoot, crawlWithGit);
|
|
85
85
|
const configFiles = [];
|
|
86
86
|
const valueFiles = [];
|
|
87
87
|
plusFiles.forEach((f) => {
|
|
@@ -195,7 +195,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
195
195
|
let ret;
|
|
196
196
|
let err;
|
|
197
197
|
try {
|
|
198
|
-
ret = await loadVikeConfig(userRootDir, outDirRoot,
|
|
198
|
+
ret = await loadVikeConfig(userRootDir, outDirRoot, crawlWithGit);
|
|
199
199
|
}
|
|
200
200
|
catch (err_) {
|
|
201
201
|
hasError = true;
|
|
@@ -232,8 +232,8 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
async function loadVikeConfig(userRootDir, outDirRoot,
|
|
236
|
-
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot,
|
|
235
|
+
async function loadVikeConfig(userRootDir, outDirRoot, crawlWithGit) {
|
|
236
|
+
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, crawlWithGit);
|
|
237
237
|
const importedFilesLoaded = {};
|
|
238
238
|
const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
|
|
239
239
|
const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
|
|
@@ -779,8 +779,8 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
779
779
|
});
|
|
780
780
|
return configValuesComputed;
|
|
781
781
|
}
|
|
782
|
-
async function findPlusFiles(userRootDir, outDirRoot,
|
|
783
|
-
const files = await crawlPlusFiles(userRootDir, outDirRoot,
|
|
782
|
+
async function findPlusFiles(userRootDir, outDirRoot, crawlWithGit) {
|
|
783
|
+
const files = await crawlPlusFiles(userRootDir, outDirRoot, crawlWithGit);
|
|
784
784
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
785
785
|
return plusFiles;
|
|
786
786
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { vite6HmrRegressionWorkaround };
|
|
2
|
+
// https://vite.dev/guide/migration (will be 404 after vite@7 release) > search for `hmrReload()`
|
|
3
|
+
// https://v6.vite.dev/guide/migration (will exist after vite@7 release) > search for `hmrReload()`
|
|
4
|
+
// Workaround seems to work for docs page /banner (which is HTML-only)
|
|
5
|
+
// But doesn't seem to work for /examples/render-modes/ (see https://github.com/vikejs/vike/pull/2069 commit `renable HMR test for HTML-only`)
|
|
6
|
+
function vite6HmrRegressionWorkaround() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'vike:vite6HmrRegressionWorkaround',
|
|
9
|
+
enforce: 'post',
|
|
10
|
+
hotUpdate: {
|
|
11
|
+
order: 'post',
|
|
12
|
+
handler({ modules, server, timestamp }) {
|
|
13
|
+
if (this.environment.name !== 'ssr')
|
|
14
|
+
return;
|
|
15
|
+
let hasSsrOnlyModules = false;
|
|
16
|
+
const invalidatedModules = new Set();
|
|
17
|
+
for (const mod of modules) {
|
|
18
|
+
if (mod.id == null)
|
|
19
|
+
continue;
|
|
20
|
+
const clientModule = server.environments.client.moduleGraph.getModuleById(mod.id);
|
|
21
|
+
if (clientModule != null)
|
|
22
|
+
continue;
|
|
23
|
+
this.environment.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
|
|
24
|
+
hasSsrOnlyModules = true;
|
|
25
|
+
}
|
|
26
|
+
if (hasSsrOnlyModules) {
|
|
27
|
+
server.ws.send({ type: 'full-reload' });
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -4,8 +4,8 @@ export { runPrerenderFromAutoRun };
|
|
|
4
4
|
export { runPrerender_forceExit };
|
|
5
5
|
export type { PrerenderOptions };
|
|
6
6
|
import '../runtime/page-files/setup.js';
|
|
7
|
-
import type { InlineConfig } from 'vite';
|
|
8
|
-
import type { APIOptions } from '../api/
|
|
7
|
+
import type { InlineConfig, ResolvedConfig } from 'vite';
|
|
8
|
+
import type { APIOptions } from '../api/types.js';
|
|
9
9
|
type PrerenderOptions = APIOptions & {
|
|
10
10
|
/** Initial `pageContext` values */
|
|
11
11
|
pageContextInit?: Record<string, unknown>;
|
|
@@ -26,7 +26,9 @@ type PrerenderOptions = APIOptions & {
|
|
|
26
26
|
/** @deprecated */
|
|
27
27
|
base?: string;
|
|
28
28
|
};
|
|
29
|
-
declare function runPrerenderFromAPI(options?: PrerenderOptions): Promise<
|
|
29
|
+
declare function runPrerenderFromAPI(options?: PrerenderOptions): Promise<{
|
|
30
|
+
viteConfig: ResolvedConfig;
|
|
31
|
+
}>;
|
|
30
32
|
declare function runPrerenderFromCLIPrerenderCommand(): Promise<void>;
|
|
31
33
|
declare function runPrerenderFromAutoRun(viteConfig: InlineConfig, forceExit: boolean): Promise<void>;
|
|
32
34
|
declare function runPrerender_forceExit(): void;
|
|
@@ -28,15 +28,15 @@ import { getVikeConfig } from '../plugin/plugins/importUserCode/v1-design/getVik
|
|
|
28
28
|
import { logErrorHint } from '../runtime/renderPage/logErrorHint.js';
|
|
29
29
|
import { executeHook, isUserHookError } from '../../shared/hooks/executeHook.js';
|
|
30
30
|
import { getConfigValueBuildTime } from '../../shared/page-configs/getConfigValueBuildTime.js';
|
|
31
|
-
import {
|
|
31
|
+
import { prepareApiCall } from '../api/prepareApiCall.js';
|
|
32
32
|
async function runPrerenderFromAPI(options = {}) {
|
|
33
|
-
await runPrerender(options, 'prerender()');
|
|
33
|
+
return await runPrerender(options, 'prerender()');
|
|
34
34
|
// - 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.
|
|
35
35
|
// - 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.
|
|
36
36
|
}
|
|
37
37
|
async function runPrerenderFromCLIPrerenderCommand() {
|
|
38
38
|
try {
|
|
39
|
-
const { viteConfigEnhanced } = await
|
|
39
|
+
const { viteConfigEnhanced } = await prepareApiCall(undefined, 'prerender');
|
|
40
40
|
await runPrerender({ viteConfig: viteConfigEnhanced }, '$ vike prerender');
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
@@ -115,6 +115,7 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
115
115
|
console.log(`${pc.green(`✓`)} ${prerenderedCount} HTML documents pre-rendered.`);
|
|
116
116
|
}
|
|
117
117
|
warnMissingPages(prerenderedPageContexts, doNotPrerenderList, renderContext, partial);
|
|
118
|
+
return { viteConfig };
|
|
118
119
|
}
|
|
119
120
|
async function collectDoNoPrerenderList(renderContext, pageConfigs, doNotPrerenderList, concurrencyLimit) {
|
|
120
121
|
// V1 design
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
export { getConfigValueRuntime };
|
|
2
|
-
export { getConfigValueTyped };
|
|
3
|
-
export type { TypeAsString };
|
|
4
2
|
import { type ResolveTypeAsString } from '../utils.js';
|
|
5
3
|
import type { PageConfigRuntime, ConfigValue } from './PageConfig.js';
|
|
6
4
|
import type { ConfigNameBuiltIn } from './Config.js';
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
declare function getConfigValueTyped<Type extends TypeAsString = undefined>(configValue: ConfigValue, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
10
|
-
value: ResolveTypeAsString<Type>;
|
|
11
|
-
});
|
|
12
|
-
declare function getConfigValueRuntime<Type extends TypeAsString = undefined>(pageConfig: PageConfigRuntime, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
5
|
+
import { type TypeAsString } from './getConfigValueTyped.js';
|
|
6
|
+
declare function getConfigValueRuntime<Type extends TypeAsString = undefined>(pageConfig: PageConfigRuntime, configName: ConfigNameBuiltIn, type?: Type): null | (ConfigValue & {
|
|
13
7
|
value: ResolveTypeAsString<Type>;
|
|
14
8
|
});
|
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
export { getConfigValueRuntime };
|
|
2
|
-
|
|
3
|
-
import { assert, assertUsage, getValuePrintable } from '../utils.js';
|
|
4
|
-
import pc from '@brillout/picocolors';
|
|
5
|
-
import { getConfigDefinedAtOptional } from './getConfigDefinedAt.js';
|
|
6
|
-
function getConfigValueTyped(configValue, configName, type) {
|
|
7
|
-
/* [NULL_HANDLING] Do we really need this? This doesn't seem to make sense, let's eventually (re)move this.
|
|
8
|
-
// Enable users to suppress global config values by setting the local config value to null
|
|
9
|
-
if (configValue.value === null) return null
|
|
10
|
-
*/
|
|
11
|
-
const { value, definedAtData } = configValue;
|
|
12
|
-
if (type)
|
|
13
|
-
assertConfigValueType(value, type, configName, definedAtData);
|
|
14
|
-
return configValue;
|
|
15
|
-
}
|
|
2
|
+
import { getConfigValueTyped } from './getConfigValueTyped.js';
|
|
16
3
|
function getConfigValueRuntime(pageConfig, configName, type) {
|
|
17
4
|
const configValue = pageConfig.configValues[configName];
|
|
18
5
|
if (!configValue)
|
|
19
6
|
return null;
|
|
20
7
|
return getConfigValueTyped(configValue, configName, type);
|
|
21
8
|
}
|
|
22
|
-
function assertConfigValueType(value, type, configName, definedAtData) {
|
|
23
|
-
assert(value !== null);
|
|
24
|
-
const typeActual = typeof value;
|
|
25
|
-
if (typeActual === type)
|
|
26
|
-
return;
|
|
27
|
-
const valuePrintable = getValuePrintable(value);
|
|
28
|
-
const problem = valuePrintable !== null
|
|
29
|
-
? `value ${pc.cyan(valuePrintable)}`
|
|
30
|
-
: `type ${pc.cyan(typeActual)}`;
|
|
31
|
-
const configDefinedAt = getConfigDefinedAtOptional('Config', configName, definedAtData);
|
|
32
|
-
const errMsg = `${configDefinedAt} has an invalid ${problem}: it should be a ${pc.cyan(type)} instead`;
|
|
33
|
-
assertUsage(false, errMsg);
|
|
34
|
-
}
|
|
@@ -2,8 +2,7 @@ export { getConfigValueBuildTime };
|
|
|
2
2
|
import { type ResolveTypeAsString } from '../utils.js';
|
|
3
3
|
import type { PageConfigBuildTime, ConfigValue } from './PageConfig.js';
|
|
4
4
|
import type { ConfigNameBuiltIn } from './Config.js';
|
|
5
|
-
import { type TypeAsString } from './
|
|
6
|
-
|
|
7
|
-
declare function getConfigValueBuildTime<Type extends TypeAsString = undefined>(pageConfig: PageConfigBuildTime, configName: ConfigName, type?: Type): null | (ConfigValue & {
|
|
5
|
+
import { type TypeAsString } from './getConfigValueTyped.js';
|
|
6
|
+
declare function getConfigValueBuildTime<Type extends TypeAsString = undefined>(pageConfig: PageConfigBuildTime, configName: ConfigNameBuiltIn, type?: Type): null | (ConfigValue & {
|
|
8
7
|
value: ResolveTypeAsString<Type>;
|
|
9
8
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getConfigValueBuildTime };
|
|
2
2
|
import { assert } from '../utils.js';
|
|
3
|
-
import { getConfigValueTyped } from './getConfigValue.js';
|
|
4
3
|
import { assertIsNotProductionRuntime } from '../../utils/assertIsNotProductionRuntime.js';
|
|
4
|
+
import { getConfigValueTyped } from './getConfigValueTyped.js';
|
|
5
5
|
assertIsNotProductionRuntime();
|
|
6
6
|
function getConfigValueBuildTime(pageConfig, configName, type) {
|
|
7
7
|
const configValue = getConfigValue(pageConfig, configName);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { getConfigValueTyped };
|
|
2
|
+
export type { TypeAsString };
|
|
3
|
+
import { type ResolveTypeAsString } from '../utils.js';
|
|
4
|
+
import type { ConfigValue } from './PageConfig.js';
|
|
5
|
+
import type { ConfigNameBuiltIn } from './Config.js';
|
|
6
|
+
type TypeAsString = 'string' | 'boolean' | undefined;
|
|
7
|
+
declare function getConfigValueTyped<Type extends TypeAsString = undefined>(configValue: ConfigValue, configName: ConfigNameBuiltIn, type?: Type): null | (ConfigValue & {
|
|
8
|
+
value: ResolveTypeAsString<Type>;
|
|
9
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { getConfigValueTyped };
|
|
2
|
+
import { assert, assertUsage, getValuePrintable } from '../utils.js';
|
|
3
|
+
import pc from '@brillout/picocolors';
|
|
4
|
+
import { getConfigDefinedAtOptional } from './getConfigDefinedAt.js';
|
|
5
|
+
function getConfigValueTyped(configValue, configName, type) {
|
|
6
|
+
/* [NULL_HANDLING] Do we really need this? This doesn't seem to make sense, let's eventually (re)move this.
|
|
7
|
+
// Enable users to suppress global config values by setting the local config value to null
|
|
8
|
+
if (configValue.value === null) return null
|
|
9
|
+
*/
|
|
10
|
+
const { value, definedAtData } = configValue;
|
|
11
|
+
if (type)
|
|
12
|
+
assertConfigValueType(value, type, configName, definedAtData);
|
|
13
|
+
return configValue;
|
|
14
|
+
}
|
|
15
|
+
function assertConfigValueType(value, type, configName, definedAtData) {
|
|
16
|
+
assert(value !== null);
|
|
17
|
+
const typeActual = typeof value;
|
|
18
|
+
if (typeActual === type)
|
|
19
|
+
return;
|
|
20
|
+
const valuePrintable = getValuePrintable(value);
|
|
21
|
+
const problem = valuePrintable !== null
|
|
22
|
+
? `value ${pc.cyan(valuePrintable)}`
|
|
23
|
+
: `type ${pc.cyan(typeActual)}`;
|
|
24
|
+
const configDefinedAt = getConfigDefinedAtOptional('Config', configName, definedAtData);
|
|
25
|
+
const errMsg = `${configDefinedAt} has an invalid ${problem}: it should be a ${pc.cyan(type)} instead`;
|
|
26
|
+
assertUsage(false, errMsg);
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.215";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.215';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.215",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"fast-glob": "^3.0.0",
|
|
140
140
|
"json5": "^2.0.0",
|
|
141
141
|
"semver": "^7.0.0",
|
|
142
|
-
"source-map-support": "^0.5.0"
|
|
142
|
+
"source-map-support": "^0.5.0",
|
|
143
|
+
"vite": ">=5.1.0"
|
|
143
144
|
},
|
|
144
145
|
"peerDependencies": {
|
|
145
146
|
"react-streaming": ">=0.3.42",
|
|
@@ -148,20 +149,26 @@
|
|
|
148
149
|
"peerDependenciesMeta": {
|
|
149
150
|
"react-streaming": {
|
|
150
151
|
"optional": true
|
|
152
|
+
},
|
|
153
|
+
"vite": {
|
|
154
|
+
"optional": true
|
|
151
155
|
}
|
|
152
156
|
},
|
|
153
157
|
"engines": {
|
|
154
158
|
"node": ">=18.0.0"
|
|
155
159
|
},
|
|
156
160
|
"license": "MIT",
|
|
157
|
-
"description": "
|
|
161
|
+
"description": "The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.",
|
|
158
162
|
"keywords": [
|
|
163
|
+
"vite-plugin",
|
|
164
|
+
"ssr",
|
|
165
|
+
"vite",
|
|
159
166
|
"react",
|
|
160
167
|
"vue",
|
|
161
168
|
"solid",
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
"
|
|
169
|
+
"next",
|
|
170
|
+
"remix",
|
|
171
|
+
"vike"
|
|
165
172
|
],
|
|
166
173
|
"typesVersions": {
|
|
167
174
|
"*": {
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { enhanceViteConfig };
|
|
2
|
-
import type { InlineConfig } from 'vite';
|
|
3
|
-
declare function enhanceViteConfig(viteConfig: InlineConfig | undefined, command: 'build' | 'dev' | 'preview' | 'prerender'): Promise<{
|
|
4
|
-
viteConfigEnhanced: InlineConfig;
|
|
5
|
-
configVike: import("../../shared/ConfigVike.js").ConfigVikeResolved;
|
|
6
|
-
}>;
|