vike 0.4.257-commit-3b8b557 → 0.4.258-commit-e168602
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/node/api/dev.js +4 -14
- package/dist/node/api/getStartupLogFirstLine.d.ts +7 -0
- package/dist/node/api/getStartupLogFirstLine.js +20 -0
- package/dist/node/api/preview.js +30 -9
- package/dist/node/vite/plugins/build/pluginDistFileNames.js +21 -3
- package/dist/node/vite/plugins/build/pluginModuleBanner.js +10 -1
- package/dist/node/vite/plugins/pluginUniversalDeploy/getServerConfig.d.ts +1 -1
- package/dist/node/vite/plugins/pluginUniversalDeploy/getServerConfig.js +2 -2
- package/dist/node/vite/shared/loggerVite.d.ts +1 -1
- package/dist/node/vite/shared/loggerVite.js +2 -2
- package/dist/node/vite/shared/resolveVikeConfigInternal/getPlusFilesByLocationId.js +2 -2
- package/dist/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.d.ts +1 -1
- package/dist/node/vite/shared/resolveVikeConfigInternal/{configDefinitionsBuiltIn.d.ts → metaBuiltIn.d.ts} +2 -2
- package/dist/node/vite/shared/resolveVikeConfigInternal/{configDefinitionsBuiltIn.js → metaBuiltIn.js} +2 -3
- package/dist/node/vite/shared/resolveVikeConfigInternal.d.ts +1 -1
- package/dist/node/vite/shared/resolveVikeConfigInternal.js +4 -4
- package/dist/server/runtime/renderPageServer/createHttpResponse.js +8 -6
- package/dist/types/Config.d.ts +1 -1
- package/dist/types/PageConfig.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/package.json +3 -3
package/dist/node/api/dev.js
CHANGED
|
@@ -5,12 +5,9 @@ import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
|
5
5
|
import { createServer } from 'vite';
|
|
6
6
|
import { assert } from '../../utils/assert.js';
|
|
7
7
|
import { assertIsNotProductionRuntime } from '../../utils/assertSetup.js';
|
|
8
|
-
import { colorVike } from '../../utils/colorsClient.js';
|
|
9
|
-
import { colorVite } from '../../utils/colorsServer.js';
|
|
10
|
-
import { PROJECT_VERSION } from '../../utils/PROJECT_VERSION.js';
|
|
11
8
|
import pc from '@brillout/picocolors';
|
|
12
|
-
import { processStartupLog } from '../vite/shared/loggerVite.js';
|
|
13
9
|
import './assertEnvApiDev.js';
|
|
10
|
+
import { getStartupLogFirstLine } from './getStartupLogFirstLine.js';
|
|
14
11
|
assertIsNotProductionRuntime();
|
|
15
12
|
/**
|
|
16
13
|
* Programmatically trigger `$ vike dev`
|
|
@@ -42,22 +39,15 @@ async function dev(options = {}) {
|
|
|
42
39
|
viteVersion,
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
|
-
const startTime = performance.now();
|
|
46
42
|
async function startupLog(resolvedUrls, viteServer) {
|
|
47
43
|
const viteConfig = viteServer.config;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const startupDurationString = pc.dim(`ready in ${pc.reset(pc.bold(String(Math.ceil(performance.now() - startTime))))} ms`);
|
|
51
|
-
const sep = pc.dim('·');
|
|
52
|
-
const firstLine = `\n ${colorVike('Vike')} ${pc.yellow(`v${PROJECT_VERSION}`)} ${sep} ${colorVite('Vite')} ${pc.cyan(`v${viteVersion}`)} ${sep} ${startupDurationString}\n`;
|
|
53
|
-
const ret = processStartupLog(firstLine, viteConfig);
|
|
54
|
-
console.log(ret.firstLine);
|
|
55
|
-
const { isCompact } = ret;
|
|
44
|
+
const { startupLogFirstLine, isStartupLogCompact } = getStartupLogFirstLine(viteConfig);
|
|
45
|
+
console.log(startupLogFirstLine);
|
|
56
46
|
// We don't call viteServer.printUrls() because Vite throws an error if `resolvedUrls` is missing:
|
|
57
47
|
// https://github.com/vitejs/vite/blob/df5a30d2690a2ebc4824a79becdcef30538dc602/packages/vite/src/node/server/index.ts#L745
|
|
58
48
|
printServerUrls(resolvedUrls, viteConfig.server.host);
|
|
59
49
|
viteServer.bindCLIShortcuts({ print: true });
|
|
60
|
-
if (!
|
|
50
|
+
if (!isStartupLogCompact)
|
|
61
51
|
console.log();
|
|
62
52
|
}
|
|
63
53
|
// Copied & adapted from Vite
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getStartupLogFirstLine };
|
|
2
|
+
import type { ResolvedConfig } from 'vite';
|
|
3
|
+
import './assertEnvApiDevAndProd.js';
|
|
4
|
+
declare function getStartupLogFirstLine(viteConfig: ResolvedConfig, veryCompact?: boolean): {
|
|
5
|
+
startupLogFirstLine: string;
|
|
6
|
+
isStartupLogCompact: boolean;
|
|
7
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { getStartupLogFirstLine };
|
|
2
|
+
import { colorVike } from '../../utils/colorsClient.js';
|
|
3
|
+
import { colorVite } from '../../utils/colorsServer.js';
|
|
4
|
+
import { PROJECT_VERSION } from '../../utils/PROJECT_VERSION.js';
|
|
5
|
+
import pc from '@brillout/picocolors';
|
|
6
|
+
import { assert } from '../../utils/assert.js';
|
|
7
|
+
import { processStartupLog } from '../vite/shared/loggerVite.js';
|
|
8
|
+
import './assertEnvApiDevAndProd.js';
|
|
9
|
+
const startTime = performance.now();
|
|
10
|
+
function getStartupLogFirstLine(viteConfig, veryCompact) {
|
|
11
|
+
const viteVersion = viteConfig._viteVersionResolved;
|
|
12
|
+
assert(viteVersion);
|
|
13
|
+
const startupDurationString = pc.dim(`ready in ${pc.reset(pc.bold(String(Math.ceil(performance.now() - startTime))))} ms`);
|
|
14
|
+
const sep = pc.dim('·');
|
|
15
|
+
const firstLine = `${veryCompact ? '' : '\n '}${colorVike('Vike')} ${pc.yellow(`v${PROJECT_VERSION}`)} ${sep} ${colorVite('Vite')} ${pc.cyan(`v${viteVersion}`)} ${sep} ${startupDurationString}${veryCompact ? '' : '\n'}`;
|
|
16
|
+
const ret = processStartupLog(firstLine, viteConfig, veryCompact);
|
|
17
|
+
const startupLogFirstLine = ret.firstLine;
|
|
18
|
+
const { isCompact } = ret;
|
|
19
|
+
return { startupLogFirstLine, isStartupLogCompact: isCompact };
|
|
20
|
+
}
|
package/dist/node/api/preview.js
CHANGED
|
@@ -3,7 +3,7 @@ import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
|
3
3
|
import { preview as previewVite } from 'vite';
|
|
4
4
|
import { importServerProductionIndex } from '@brillout/vite-plugin-server-entry/runtime';
|
|
5
5
|
import { getOutDirs } from '../vite/shared/getOutDirs.js';
|
|
6
|
-
import {
|
|
6
|
+
import { assert, assertInfo, assertUsage } from '../../utils/assert.js';
|
|
7
7
|
import { onSetupPreview } from '../../utils/assertSetup.js';
|
|
8
8
|
import { isCallable } from '../../utils/isCallable.js';
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
@@ -11,6 +11,7 @@ import path from 'node:path';
|
|
|
11
11
|
import { getVikeConfigInternal } from '../vite/shared/resolveVikeConfigInternal.js';
|
|
12
12
|
import { isUniversalDeployVitePreview } from '../vite/plugins/pluginUniversalDeploy/getServerConfig.js';
|
|
13
13
|
import './assertEnvApiDev.js';
|
|
14
|
+
import { getStartupLogFirstLine } from './getStartupLogFirstLine.js';
|
|
14
15
|
/**
|
|
15
16
|
* Programmatically trigger `$ vike preview`
|
|
16
17
|
*
|
|
@@ -23,19 +24,29 @@ async function preview(options = {}) {
|
|
|
23
24
|
const cliPreviewConfig = await resolveCliPreviewConfig(vikeConfig);
|
|
24
25
|
assertUsage(cliPreviewConfig !== false, `${pc.cyan('$ vike preview')} isn't supported`);
|
|
25
26
|
const isUDVitePreview = isUniversalDeployVitePreview(vikeConfig, viteConfigResolved);
|
|
26
|
-
const useVitePreviewServer =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const useVitePreviewServer = (() => {
|
|
28
|
+
// === +cli.preview => manual overriding
|
|
29
|
+
if (cliPreviewConfig === 'vite')
|
|
30
|
+
return true;
|
|
31
|
+
if (cliPreviewConfig === true)
|
|
32
|
+
return false;
|
|
33
|
+
assert(cliPreviewConfig === undefined);
|
|
34
|
+
// === Universal Deploy
|
|
35
|
+
// dist/server/index.mjs doesn't exist with some deployment plugins such as vite-plugin-vercel -> we must use Vite's preview server
|
|
36
|
+
if (isUDVitePreview !== null)
|
|
37
|
+
return isUDVitePreview;
|
|
38
|
+
// === @brillout/vite-plugin-server-entry
|
|
39
|
+
// dist/server/index.mjs exists when using @brillout/vite-plugin-server-entry inject mode; otherwise it's missing -> we must use Vite's preview server
|
|
40
|
+
return !viteConfigResolved.vitePluginServerEntry?.inject;
|
|
41
|
+
})();
|
|
42
|
+
const { startupLogFirstLine, isStartupLogCompact } = getStartupLogFirstLine(viteConfigResolved, !useVitePreviewServer);
|
|
43
|
+
console.log(startupLogFirstLine);
|
|
32
44
|
if (!useVitePreviewServer) {
|
|
33
45
|
// Dynamically import() server production entry dist/server/index.js
|
|
34
46
|
const outDir = getOutDirs(viteConfigResolved, undefined).outDirRoot;
|
|
35
47
|
const { outServerIndex } = await importServerProductionIndex({ outDir });
|
|
36
48
|
const outServerIndexRelative = path.relative(viteConfigResolved.root, outServerIndex);
|
|
37
|
-
|
|
38
|
-
assertWarning(false, `Never run ${pc.cyan('$ vike preview')} in production, run ${pc.cyan(`$ node ${outServerIndexRelative}`)} instead (or Bun/Deno).`, { onlyOnce: true });
|
|
49
|
+
logHint(`, run ${pc.cyan(`$ node ${outServerIndexRelative}`)} instead (or Bun/Deno).`, isStartupLogCompact);
|
|
39
50
|
return {
|
|
40
51
|
viteConfig: viteConfigResolved,
|
|
41
52
|
};
|
|
@@ -43,12 +54,22 @@ async function preview(options = {}) {
|
|
|
43
54
|
else {
|
|
44
55
|
// Use Vite's preview server
|
|
45
56
|
const server = await previewVite(viteConfigFromUserResolved);
|
|
57
|
+
logHint(vikeConfig.prerenderContext.isPrerenderingEnabledForAllPages
|
|
58
|
+
? ' — your app is fully pre-rendered and can be statically deployed.'
|
|
59
|
+
: '', isStartupLogCompact);
|
|
46
60
|
return {
|
|
47
61
|
viteServer: server,
|
|
48
62
|
viteConfig: server.config,
|
|
49
63
|
};
|
|
50
64
|
}
|
|
51
65
|
}
|
|
66
|
+
function logHint(hint = '', isStartupLogCompact) {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
if (!isStartupLogCompact)
|
|
69
|
+
console.log();
|
|
70
|
+
assertInfo(false, `Don't use ${pc.cyan('$ vike preview')} for production${hint}`, { onlyOnce: true });
|
|
71
|
+
}, 0);
|
|
72
|
+
}
|
|
52
73
|
async function resolveCliPreviewConfig(vikeConfig) {
|
|
53
74
|
const val = vikeConfig.config.cli?.preview;
|
|
54
75
|
if (!isCallable(val)) {
|
|
@@ -11,6 +11,7 @@ import crypto from 'node:crypto';
|
|
|
11
11
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
12
12
|
import { assertModuleId, getFilePathToShowToUserModule } from '../../shared/getFilePath.js';
|
|
13
13
|
import '../../assertEnvVite.js';
|
|
14
|
+
import { isVersionMatch } from '../../../../utils/assertVersion.js';
|
|
14
15
|
function pluginDistFileNames() {
|
|
15
16
|
return [
|
|
16
17
|
{
|
|
@@ -41,7 +42,7 @@ function pluginDistFileNames() {
|
|
|
41
42
|
// - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
|
|
42
43
|
assertUsage(rollupOutput.assetFileNames.isTheOneSetByVike, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use it.");
|
|
43
44
|
}
|
|
44
|
-
{
|
|
45
|
+
if (disableCSSBundling(config)) {
|
|
45
46
|
const manualChunksOriginal = rollupOutput.manualChunks;
|
|
46
47
|
rollupOutput.manualChunks = function (id, ...args) {
|
|
47
48
|
if (manualChunksOriginal) {
|
|
@@ -54,8 +55,6 @@ function pluginDistFileNames() {
|
|
|
54
55
|
assertUsage(false, "The Vite's configuration build.rollupOptions.output.manualChunks must be a function. Reach out if you need to set it to another value.");
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
// Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
|
|
58
|
-
// TO-DO/eventually: let's bundle CSS again once Rolldown replaces Rollup
|
|
59
58
|
if (id.endsWith('.css')) {
|
|
60
59
|
const userRootDir = config.root;
|
|
61
60
|
if (id.startsWith(userRootDir)) {
|
|
@@ -255,3 +254,22 @@ function getRollupOutputs(config) {
|
|
|
255
254
|
}
|
|
256
255
|
return output;
|
|
257
256
|
}
|
|
257
|
+
function disableCSSBundling(config) {
|
|
258
|
+
// Vite 7 => disable CSS bundling, see: https://github.com/vikejs/vike/issues/1815
|
|
259
|
+
if (!isVite8OrAbove(config))
|
|
260
|
+
return true;
|
|
261
|
+
// Vite 8 doesn't support `manualChunks` when `codeSplitting` is used.
|
|
262
|
+
// - It does, however, support `manualChunks` if `codeSplitting` isn't used (despite what the following migration guide says)
|
|
263
|
+
// - https://vite.dev/guide/migration#removed-object-form-build-rollupoptions-output-manualchunks-and-deprecate-function-form-one
|
|
264
|
+
// @ts-ignore
|
|
265
|
+
if (!config.build?.rolldownOptions?.output?.codeSplitting)
|
|
266
|
+
return true;
|
|
267
|
+
// TO-DO/eventually: we should probably show a warning, because Vite 8 still builds the client and server separately (potentially leading to the CSS duplication bug):
|
|
268
|
+
// https://github.com/vitejs/ecosystem/issues/6
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
function isVite8OrAbove(config) {
|
|
272
|
+
const viteVersion = config._viteVersionResolved;
|
|
273
|
+
assert(viteVersion);
|
|
274
|
+
return isVersionMatch(viteVersion, ['8.0.0']);
|
|
275
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { pluginModuleBanner };
|
|
2
2
|
import { assert } from '../../../../utils/assert.js';
|
|
3
|
+
import { isVersionMatch } from '../../../../utils/assertVersion.js';
|
|
3
4
|
import { removeVirtualFileIdPrefix } from '../../../../utils/virtualFileId.js';
|
|
4
5
|
import { getMagicString } from '../../shared/getMagicString.js';
|
|
5
6
|
import '../../assertEnvVite.js';
|
|
@@ -56,10 +57,18 @@ function pluginModuleBanner() {
|
|
|
56
57
|
function checkIsEnabled(config) {
|
|
57
58
|
const { minify } = config.build;
|
|
58
59
|
assert(minify === false || minify, { minify });
|
|
59
|
-
const isEnabled = !minify;
|
|
60
|
+
const isEnabled = !minify && !hasNativeModuleRegions(config);
|
|
60
61
|
// Avoid the legal comments inserted in the transform() hook to be removed.
|
|
61
62
|
// https://github.com/vitejs/vite/issues/21085#issuecomment-3502781005
|
|
62
63
|
if (isEnabled && config.esbuild)
|
|
63
64
|
config.esbuild.legalComments = 'inline';
|
|
64
65
|
return isEnabled;
|
|
65
66
|
}
|
|
67
|
+
// Vite 8 / Rolldown already emits native `//#region /path/...` markers for non-minified builds.
|
|
68
|
+
// - https://github.com/vitejs/vite/issues/21228#issuecomment-3627899741
|
|
69
|
+
// - TO-DO/eventually: remove this file once Vike requires Vite 8 or above
|
|
70
|
+
function hasNativeModuleRegions(config) {
|
|
71
|
+
const viteVersion = config._viteVersionResolved;
|
|
72
|
+
assert(viteVersion);
|
|
73
|
+
return isVersionMatch(viteVersion, ['8.0.0']);
|
|
74
|
+
}
|
|
@@ -8,4 +8,4 @@ declare function getServerConfig(vikeConfig: VikeConfigInternal): {
|
|
|
8
8
|
serverEntryVike: string;
|
|
9
9
|
serverFilePath: string | null;
|
|
10
10
|
} | undefined;
|
|
11
|
-
declare function isUniversalDeployVitePreview(vikeConfig: VikeConfigInternal, viteConfigResolved: ResolvedConfig): boolean;
|
|
11
|
+
declare function isUniversalDeployVitePreview(vikeConfig: VikeConfigInternal, viteConfigResolved: ResolvedConfig): boolean | null;
|
|
@@ -41,9 +41,9 @@ function getServerConfig(vikeConfig) {
|
|
|
41
41
|
function isUniversalDeployVitePreview(vikeConfig, viteConfigResolved) {
|
|
42
42
|
const isServerConfig = getServerConfig(vikeConfig);
|
|
43
43
|
if (!isServerConfig)
|
|
44
|
-
return
|
|
44
|
+
return null; // not UD
|
|
45
45
|
// @universal-deploy/node -> real preview
|
|
46
46
|
// else -> vite preview
|
|
47
|
-
const udNodePlugin = viteConfigResolved.plugins.find((p) => p.name.
|
|
47
|
+
const udNodePlugin = viteConfigResolved.plugins.find((p) => p.name.match(/^ud:node:(?!.*:disabled$)/));
|
|
48
48
|
return !udNodePlugin;
|
|
49
49
|
}
|
|
@@ -7,7 +7,7 @@ export { swallowViteLogConnected_clean };
|
|
|
7
7
|
import type { ResolvedConfig } from 'vite';
|
|
8
8
|
import '../assertEnvVite.js';
|
|
9
9
|
declare function interceptViteLogs(config: ResolvedConfig): void;
|
|
10
|
-
declare function processStartupLog(firstLine: string, config: ResolvedConfig): {
|
|
10
|
+
declare function processStartupLog(firstLine: string, config: ResolvedConfig, veryCompact?: boolean): {
|
|
11
11
|
firstLine: string;
|
|
12
12
|
isCompact: boolean;
|
|
13
13
|
};
|
|
@@ -65,7 +65,7 @@ function intercept(loggerType, config) {
|
|
|
65
65
|
}
|
|
66
66
|
// - Clears screen if zero previous log
|
|
67
67
|
// - Manages new lines
|
|
68
|
-
function processStartupLog(firstLine, config) {
|
|
68
|
+
function processStartupLog(firstLine, config, veryCompact) {
|
|
69
69
|
const shouldClear = processStartupLog_shouldClear(config);
|
|
70
70
|
if (shouldClear) {
|
|
71
71
|
config.logger.clearScreen('info');
|
|
@@ -74,7 +74,7 @@ function processStartupLog(firstLine, config) {
|
|
|
74
74
|
// Remove leading new line (for both Vite and Vike's startup log)
|
|
75
75
|
firstLine = removeEmptyLines(firstLine);
|
|
76
76
|
}
|
|
77
|
-
return { firstLine, isCompact: !shouldClear };
|
|
77
|
+
return { firstLine, isCompact: veryCompact || !shouldClear };
|
|
78
78
|
}
|
|
79
79
|
function processStartupLog_shouldClear(config) {
|
|
80
80
|
const hasLoggedBefore = process.stdout.bytesWritten !== 0 || process.stderr.bytesWritten !== 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getPlusFilesByLocationId };
|
|
2
2
|
import { assert } from '../../../../utils/assert.js';
|
|
3
|
-
import {
|
|
3
|
+
import { metaBuiltIn } from './metaBuiltIn.js';
|
|
4
4
|
import { getLocationId } from './filesystemRouting.js';
|
|
5
5
|
import { crawlPlusFilePaths, getPlusFileValueConfigName } from './crawlPlusFilePaths.js';
|
|
6
6
|
import { getConfigFileExport } from './getConfigFileExport.js';
|
|
@@ -64,7 +64,7 @@ async function getPlusFilesByLocationId(userRootDir, esbuildCache) {
|
|
|
64
64
|
// We don't have access to the custom config definitions defined by the user yet.
|
|
65
65
|
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
66
66
|
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
67
|
-
await loadValueFile(plusFile,
|
|
67
|
+
await loadValueFile(plusFile, metaBuiltIn, userRootDir, esbuildCache);
|
|
68
68
|
}
|
|
69
69
|
}));
|
|
70
70
|
// Make lists element order deterministic
|
|
@@ -7,7 +7,7 @@ import type { FilePathResolved } from '../../../../types/FilePath.js';
|
|
|
7
7
|
import { type EsbuildCache } from './transpileAndExecuteFile.js';
|
|
8
8
|
import type { PlusFileValue } from './getPlusFilesByLocationId.js';
|
|
9
9
|
import { PointerImport } from './resolvePointerImport.js';
|
|
10
|
-
import type { ConfigDefinitionsInternal } from './
|
|
10
|
+
import type { ConfigDefinitionsInternal } from './metaBuiltIn.js';
|
|
11
11
|
import '../../assertEnvVite.js';
|
|
12
12
|
type ConfigFile = {
|
|
13
13
|
fileExports: Record<string, unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { metaBuiltIn };
|
|
2
2
|
export type { ConfigDefinition };
|
|
3
3
|
export type { ConfigDefinitions };
|
|
4
4
|
export type { ConfigDefinitionsInternal };
|
|
@@ -93,4 +93,4 @@ ConfigDefinition>;
|
|
|
93
93
|
type ConfigDefinitionsInternal = Record<string, // configName
|
|
94
94
|
ConfigDefinitionInternal>;
|
|
95
95
|
type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn | ConfigNameGlobal, ConfigDefinitionInternal>;
|
|
96
|
-
declare const
|
|
96
|
+
declare const metaBuiltIn: ConfigDefinitionsBuiltIn;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { metaBuiltIn };
|
|
2
2
|
import { assert, assertUsage } from '../../../../utils/assert.js';
|
|
3
3
|
import { getConfigDefinedAt, } from '../../../../shared-server-client/page-configs/getConfigDefinedAt.js';
|
|
4
4
|
import { getConfigValueSourceRelevantAnyEnv, getConfigValueSourcesRelevant, isConfigSourceValueNull, } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
5
5
|
import { getFileSuffixes } from '../../../../shared-server-node/getFileSuffixes.js';
|
|
6
6
|
import '../../assertEnvVite.js';
|
|
7
|
-
|
|
8
|
-
const configDefinitionsBuiltIn = {
|
|
7
|
+
const metaBuiltIn = {
|
|
9
8
|
onRenderHtml: {
|
|
10
9
|
env: { server: true },
|
|
11
10
|
},
|
|
@@ -12,7 +12,7 @@ export { getVikeConfigFromCliOrEnv };
|
|
|
12
12
|
export type { VikeConfigInternal };
|
|
13
13
|
export type { PageConfigBuildTimeBeforeComputed };
|
|
14
14
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../types/PageConfig.js';
|
|
15
|
-
import { type ConfigDefinitionsInternal, type ConfigDefinitionInternal } from './resolveVikeConfigInternal/
|
|
15
|
+
import { type ConfigDefinitionsInternal, type ConfigDefinitionInternal } from './resolveVikeConfigInternal/metaBuiltIn.js';
|
|
16
16
|
import { type GlobalConfigPublic } from '../../../shared-server-client/page-configs/resolveVikeConfigPublic.js';
|
|
17
17
|
import { type PlusFile } from './resolveVikeConfigInternal/getPlusFilesByLocationId.js';
|
|
18
18
|
import type { PrerenderContextPublic } from '../../prerender/runPrerender.js';
|
|
@@ -31,7 +31,7 @@ import { objectAssign } from '../../../utils/objectAssign.js';
|
|
|
31
31
|
import { makeFirst, lowerFirst } from '../../../utils/sorter.js';
|
|
32
32
|
import { unique } from '../../../utils/unique.js';
|
|
33
33
|
import { assertPosixPath } from '../../../utils/path.js';
|
|
34
|
-
import {
|
|
34
|
+
import { metaBuiltIn, } from './resolveVikeConfigInternal/metaBuiltIn.js';
|
|
35
35
|
import { getFileSuffixes } from '../../../shared-server-node/getFileSuffixes.js';
|
|
36
36
|
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, applyFilesystemRoutingRootEffect, } from './resolveVikeConfigInternal/filesystemRouting.js';
|
|
37
37
|
import { getViteDevServer, vikeConfigErrorRecoverMsg } from '../../../server/runtime/globalContext.js';
|
|
@@ -504,8 +504,8 @@ function getVikeConfigFromCliOrEnv() {
|
|
|
504
504
|
};
|
|
505
505
|
}
|
|
506
506
|
function getSourceNonConfigFile(configName, value, definedAt) {
|
|
507
|
-
assert(includes(objectKeys(
|
|
508
|
-
const configDef =
|
|
507
|
+
assert(includes(objectKeys(metaBuiltIn), configName));
|
|
508
|
+
const configDef = metaBuiltIn[configName];
|
|
509
509
|
const source = {
|
|
510
510
|
valueIsLoaded: true,
|
|
511
511
|
value,
|
|
@@ -773,7 +773,7 @@ function getConfigNamesSetByPlusFile(plusFile) {
|
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
function getConfigDefinitions(plusFilesRelevant, filter) {
|
|
776
|
-
let configDefinitions = { ...
|
|
776
|
+
let configDefinitions = { ...metaBuiltIn };
|
|
777
777
|
// Add user-land meta configs
|
|
778
778
|
plusFilesRelevant
|
|
779
779
|
.slice()
|
|
@@ -18,6 +18,7 @@ import { stringify } from '@brillout/json-serializer/stringify';
|
|
|
18
18
|
import '../../assertEnvServer.js';
|
|
19
19
|
const contentTypeJson = 'application/json';
|
|
20
20
|
const contentTypeHtml = 'text/html;charset=utf-8';
|
|
21
|
+
const htmlFallbackLog = 'This HTML was generated by Vike.';
|
|
21
22
|
async function createHttpResponsePage(htmlRender, renderHook, pageContext) {
|
|
22
23
|
let statusCode = pageContext.abortStatusCode;
|
|
23
24
|
if (!statusCode) {
|
|
@@ -39,7 +40,7 @@ async function createHttpResponsePage(htmlRender, renderHook, pageContext) {
|
|
|
39
40
|
return createHttpResponse(statusCode, contentTypeHtml, headers, htmlRender, earlyHints, renderHook);
|
|
40
41
|
}
|
|
41
42
|
function createHttpResponse404(errMsg404) {
|
|
42
|
-
const httpResponse = createHttpResponse(404, contentTypeHtml, [], `<p>${errMsg404}.</p
|
|
43
|
+
const httpResponse = createHttpResponse(404, contentTypeHtml, [], getHtmlFallback(`<p>${errMsg404}.</p>`));
|
|
43
44
|
return httpResponse;
|
|
44
45
|
}
|
|
45
46
|
function createHttpResponseBaseIsMissing(urlOriginal, baseServer) {
|
|
@@ -81,7 +82,7 @@ function createHttpResponseErrorFallback_noGlobalContext() {
|
|
|
81
82
|
return createHttpResponseError_('no error page (https://vike.dev/error-page) could be rendered');
|
|
82
83
|
}
|
|
83
84
|
function createHttpResponseError_(reason) {
|
|
84
|
-
const httpResponse = createHttpResponse(500, contentTypeHtml, [],
|
|
85
|
+
const httpResponse = createHttpResponse(500, contentTypeHtml, [], getHtmlFallback('<p>An error occurred.</p>', `${htmlFallbackLog} Vike returned this HTML because ${reason}.`));
|
|
85
86
|
return httpResponse;
|
|
86
87
|
}
|
|
87
88
|
function createHttpResponseErrorFallbackJson() {
|
|
@@ -101,15 +102,16 @@ function createHttpResponseRedirect({ url, statusCode }, pageContextInit) {
|
|
|
101
102
|
return createHttpResponse(statusCode, contentTypeHtml, headers,
|
|
102
103
|
// For bots / programmatic crawlig: show what's going on.
|
|
103
104
|
// For users: showing a blank page is probably better than a flickering text.
|
|
104
|
-
`<p style="display: none">Redirecting to ${escapeHtml(url)}</p
|
|
105
|
+
getHtmlFallback(`<p style="display: none">Redirecting to ${escapeHtml(url)}</p>`));
|
|
105
106
|
}
|
|
106
107
|
function createHttpResponseFromUniversalMiddleware(response, earlyHints) {
|
|
107
|
-
|
|
108
|
-
const body = response.body ??
|
|
109
|
-
`<p style="display: none">No HTTP response body.</p><script>console.log('This HTML was generated by Vike.')</script>`;
|
|
108
|
+
const body = response.body ?? getHtmlFallback('<p style="display: none">No HTTP response body.</p>');
|
|
110
109
|
const httpResponse = createHttpResponseCommon(response.status, Array.from(response.headers.entries()), body, earlyHints);
|
|
111
110
|
return httpResponse;
|
|
112
111
|
}
|
|
112
|
+
function getHtmlFallback(bodyHtml, logText = htmlFallbackLog) {
|
|
113
|
+
return `${bodyHtml}<script>console.log(${JSON.stringify(logText)})</script>`;
|
|
114
|
+
}
|
|
113
115
|
function createHttpResponse(statusCode, contentType, headers, htmlRender, earlyHints, renderHook) {
|
|
114
116
|
headers.push(['Content-Type', contentType]);
|
|
115
117
|
assert(renderHook || typeof htmlRender === 'string');
|
package/dist/types/Config.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type { OnRenderHtmlSync };
|
|
|
36
36
|
export type { RouteAsync };
|
|
37
37
|
export type { RouteSync };
|
|
38
38
|
import type { PrefetchSetting, PrefetchStaticAssets } from '../client/runtime-client-routing/prefetch/PrefetchSetting.js';
|
|
39
|
-
import type { ConfigDefinition } from '../node/vite/shared/resolveVikeConfigInternal/
|
|
39
|
+
import type { ConfigDefinition } from '../node/vite/shared/resolveVikeConfigInternal/metaBuiltIn.js';
|
|
40
40
|
import type { DocumentHtml } from '../server/runtime/renderPageServer/html/renderHtml.js';
|
|
41
41
|
import type { InjectFilterEntry } from './index.js';
|
|
42
42
|
import type { VikeVitePluginOptions } from '../node/vite/index.js';
|
|
@@ -24,7 +24,7 @@ export type { VirtualFileExportsPageEntry };
|
|
|
24
24
|
import type { ConfigValueSerialized } from '../shared-server-client/page-configs/serialize/PageConfigSerialized.js';
|
|
25
25
|
import type { LocationId } from '../node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js';
|
|
26
26
|
import type { FilePath } from './FilePath.js';
|
|
27
|
-
import type { ConfigDefinitionsInternal } from '../node/vite/shared/resolveVikeConfigInternal/
|
|
27
|
+
import type { ConfigDefinitionsInternal } from '../node/vite/shared/resolveVikeConfigInternal/metaBuiltIn.js';
|
|
28
28
|
import type { PlusFile } from '../node/vite/shared/resolveVikeConfigInternal/getPlusFilesByLocationId.js';
|
|
29
29
|
import type { ApiOperation } from '../node/api/types.js';
|
|
30
30
|
type PageConfigCommon = {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { ImportString } from '../node/vite/shared/importString.js';
|
|
|
9
9
|
export type { DataAsync, DataSync, GuardAsync, GuardSync, OnBeforePrerenderStartAsync, OnBeforePrerenderStartSync, OnBeforeRenderAsync, OnBeforeRenderSync, OnBeforeRouteAsync, OnBeforeRouteSync, OnHydrationEndAsync, OnHydrationEndSync, OnPageTransitionEndAsync, OnPageTransitionEndSync, OnPageTransitionStartAsync, OnPageTransitionStartSync, OnPrerenderStartAsync, OnPrerenderStartSync, OnRenderClientAsync, OnRenderClientSync, OnRenderHtmlAsync, OnRenderHtmlSync, RouteAsync, RouteSync, } from './Config.js';
|
|
10
10
|
export type { ConfigResolved } from './Config/ConfigResolved.js';
|
|
11
11
|
export type { ConfigEnv } from './PageConfig.js';
|
|
12
|
-
export type { ConfigDefinition, ConfigEffect, } from '../node/vite/shared/resolveVikeConfigInternal/
|
|
12
|
+
export type { ConfigDefinition, ConfigEffect, } from '../node/vite/shared/resolveVikeConfigInternal/metaBuiltIn.js';
|
|
13
13
|
export type { ConfigEntries } from '../shared-server-client/page-configs/resolveVikeConfigPublic.js';
|
|
14
14
|
export type { VikeConfig } from '../node/vite/shared/resolveVikeConfigInternal.js';
|
|
15
15
|
export type { UrlPublic as Url } from '../utils/parseUrl.js';
|
|
@@ -24,7 +24,7 @@ import type { ConfigEnv } from './PageConfig.js';
|
|
|
24
24
|
*/
|
|
25
25
|
type Env = ConfigEnv;
|
|
26
26
|
export type { Env };
|
|
27
|
-
import type { ConfigEffect } from '../node/vite/shared/resolveVikeConfigInternal/
|
|
27
|
+
import type { ConfigEffect } from '../node/vite/shared/resolveVikeConfigInternal/metaBuiltIn.js';
|
|
28
28
|
/** @deprecated Replace:
|
|
29
29
|
* `import type { Effect } from 'vike/types'`
|
|
30
30
|
* With:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.258-commit-e168602";
|
|
@@ -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.258-commit-e168602';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.258-commit-e168602",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"@brillout/picocolors": "^1.0.30",
|
|
134
134
|
"@brillout/vite-plugin-server-entry": "0.7.18",
|
|
135
135
|
"@universal-deploy/store": "^0.2.1",
|
|
136
|
-
"@universal-deploy/vite": "^0.1.
|
|
136
|
+
"@universal-deploy/vite": "^0.1.7",
|
|
137
137
|
"@universal-middleware/core": "^0.4.17",
|
|
138
138
|
"@universal-middleware/node": "^0.1.0",
|
|
139
139
|
"cac": "^6.0.0",
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
"./fetch.js"
|
|
263
263
|
],
|
|
264
264
|
"devDependencies": {
|
|
265
|
-
"@brillout/release-me": "^0.4.
|
|
265
|
+
"@brillout/release-me": "^0.4.15",
|
|
266
266
|
"@types/babel__core": "^7.20.5",
|
|
267
267
|
"@types/estree": "^1.0.5",
|
|
268
268
|
"@types/node": "^20.10.5",
|