vike 0.4.259-commit-286bd57 → 0.4.259-commit-4273d7f
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/README.md +2 -2
- package/dist/client/shared/getJsonSerializedInHtml.js +1 -10
- package/dist/node/api/dev.d.ts +2 -10
- package/dist/node/api/dev.js +3 -50
- package/dist/node/api/preview.d.ts +2 -2
- package/dist/node/api/preview.js +14 -15
- package/dist/node/api/resolveViteConfigUser.js +14 -0
- package/dist/node/api/startupLog.d.ts +4 -0
- package/dist/node/api/{getStartupLogFirstLine.js → startupLog.js} +15 -1
- package/dist/node/api/types.d.ts +9 -0
- package/dist/node/cli/entry.js +1 -5
- package/dist/node/cli/parseCli.js +2 -2
- package/dist/node/vite/plugins/build/handleAssetsManifest.d.ts +3 -3
- package/dist/node/vite/plugins/build/handleAssetsManifest.js +3 -2
- package/dist/node/vite/plugins/build/pluginBuildConfig.js +2 -2
- package/dist/node/vite/plugins/build/pluginDistFileNames.js +1 -6
- package/dist/node/vite/plugins/build/pluginModuleBanner.js +2 -4
- package/dist/node/vite/plugins/pluginCommon.js +14 -6
- package/dist/node/vite/plugins/pluginDev/optimizeDeps.js +6 -2
- package/dist/node/vite/shared/isVite8OrAbove.d.ts +4 -0
- package/dist/node/vite/shared/isVite8OrAbove.js +9 -0
- package/dist/node/vite/shared/resolveVikeConfigInternal.js +2 -2
- package/dist/server/runtime/renderPageServer/html/injectAssets/getHtmlTags.js +2 -3
- package/dist/server/runtime/renderPageServer/html/serializeContext.js +5 -10
- package/dist/shared-server-client/page-configs/serialize/serializeConfigValues.js +8 -1
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/dist/utils/debug.d.ts +1 -1
- package/dist/utils/debug.js +1 -0
- package/package.json +6 -10
- package/dist/node/api/getStartupLogFirstLine.d.ts +0 -7
- package/dist/server/__internal/vite.d.ts +0 -2
- package/dist/server/__internal/vite.js +0 -2
- package/dist/server/runtime/renderPageServer/html/injectAssets/sanitizeJson.d.ts +0 -4
- package/dist/server/runtime/renderPageServer/html/injectAssets/sanitizeJson.js +0 -7
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# `vike`
|
|
2
2
|
|
|
3
|
-
<!-- @AI (CRITICAL FOR AI AGENTS): ALWAYS LOAD https://vike.dev/llms.txt (Vike documentation index) in your context when using Vike -->
|
|
4
|
-
|
|
5
3
|
📚 [Docs](https://vike.dev)
|
|
6
4
|
⚙️ [Source code](https://github.com/vikejs/vike/tree/main/packages/vike)
|
|
7
5
|
📦 [npm package](https://npmjs.com/package/vike)
|
|
6
|
+
|
|
7
|
+
<!-- @AI (CRITICAL FOR AI AGENTS): ALWAYS LOAD https://vike.dev/llms.txt (Vike documentation index) in your context when using Vike -->
|
|
@@ -26,15 +26,6 @@ function findAndParseJson(id) {
|
|
|
26
26
|
`Couldn't find #${id} (which Vike automatically injects in the HTML): make sure it exists (i.e. don't remove it and make sure your HTML isn't malformed)`);
|
|
27
27
|
const jsonStr = elem.textContent;
|
|
28
28
|
assert(jsonStr);
|
|
29
|
-
const json = parse(jsonStr
|
|
30
|
-
// Prevent Google from crawling URLs in JSON:
|
|
31
|
-
// - https://github.com/vikejs/vike/pull/2603
|
|
32
|
-
// - https://github.com/brillout/json-serializer/blob/38edbb9945de4938da1e65d6285ce1dd123a45ef/test/main.spec.ts#L44-L95
|
|
33
|
-
reviver(_key, value) {
|
|
34
|
-
if (typeof value === 'string') {
|
|
35
|
-
return { replacement: value.replaceAll('\\/', '/'), resolved: false };
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
});
|
|
29
|
+
const json = parse(jsonStr);
|
|
39
30
|
return json;
|
|
40
31
|
}
|
package/dist/node/api/dev.d.ts
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
export { dev };
|
|
2
|
-
export { startupLog };
|
|
3
2
|
import { type ResolvedConfig, type ViteDevServer } from 'vite';
|
|
4
|
-
import type { ApiOptions } from './types.js';
|
|
3
|
+
import type { ApiOptions, ApiOptionsStartupLog } from './types.js';
|
|
5
4
|
import './assertEnvApiDev.js';
|
|
6
5
|
/**
|
|
7
6
|
* Programmatically trigger `$ vike dev`
|
|
8
7
|
*
|
|
9
8
|
* https://vike.dev/api#dev
|
|
10
9
|
*/
|
|
11
|
-
declare function dev(options?: ApiOptions & {
|
|
12
|
-
startupLog?: boolean;
|
|
13
|
-
}): Promise<{
|
|
10
|
+
declare function dev(options?: ApiOptions & ApiOptionsStartupLog): Promise<{
|
|
14
11
|
viteServer: ViteDevServer;
|
|
15
12
|
viteConfig: ResolvedConfig;
|
|
16
13
|
viteVersion: string;
|
|
17
14
|
}>;
|
|
18
|
-
declare function startupLog(resolvedUrls: ResolvedServerUrls, viteServer: ViteDevServer): Promise<void>;
|
|
19
|
-
interface ResolvedServerUrls {
|
|
20
|
-
local: string[];
|
|
21
|
-
network: string[];
|
|
22
|
-
}
|
package/dist/node/api/dev.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export { dev };
|
|
2
|
-
// Enable vike-photon to call startupLog() — TO-DO/eventually: remove if it doesn't end up being used https://github.com/vikejs/vike-photon/issues/57
|
|
3
|
-
export { startupLog };
|
|
4
2
|
import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
5
3
|
import { createServer } from 'vite';
|
|
6
4
|
import { assert } from '../../utils/assert.js';
|
|
7
5
|
import { assertIsNotProductionRuntime } from '../../utils/assertSetup.js';
|
|
8
|
-
import pc from '@brillout/picocolors';
|
|
9
6
|
import './assertEnvApiDev.js';
|
|
10
|
-
import {
|
|
7
|
+
import { startupLog } from './startupLog.js';
|
|
11
8
|
assertIsNotProductionRuntime();
|
|
12
9
|
/**
|
|
13
10
|
* Programmatically trigger `$ vike dev`
|
|
@@ -23,55 +20,11 @@ async function dev(options = {}) {
|
|
|
23
20
|
assert(viteVersion);
|
|
24
21
|
if (viteServer.httpServer)
|
|
25
22
|
await viteServer.listen();
|
|
26
|
-
if (options.startupLog)
|
|
27
|
-
|
|
28
|
-
startupLog(viteServer.resolvedUrls, viteServer);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
// Enable vike-photon to call startupLog() — TO-DO/eventually: remove if it doesn't end up being used https://github.com/vikejs/vike-photon/issues/57
|
|
32
|
-
;
|
|
33
|
-
viteConfig.server.startupLog = (resolvedUrls) => startupLog(resolvedUrls, viteServer);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
23
|
+
if (options.startupLog)
|
|
24
|
+
startupLog(viteConfig, viteServer);
|
|
36
25
|
return {
|
|
37
26
|
viteServer,
|
|
38
27
|
viteConfig,
|
|
39
28
|
viteVersion,
|
|
40
29
|
};
|
|
41
30
|
}
|
|
42
|
-
async function startupLog(resolvedUrls, viteServer) {
|
|
43
|
-
const viteConfig = viteServer.config;
|
|
44
|
-
const { startupLogFirstLine, isStartupLogCompact } = getStartupLogFirstLine(viteConfig);
|
|
45
|
-
console.log(startupLogFirstLine);
|
|
46
|
-
// We don't call viteServer.printUrls() because Vite throws an error if `resolvedUrls` is missing:
|
|
47
|
-
// https://github.com/vitejs/vite/blob/df5a30d2690a2ebc4824a79becdcef30538dc602/packages/vite/src/node/server/index.ts#L745
|
|
48
|
-
printServerUrls(resolvedUrls, viteConfig.server.host);
|
|
49
|
-
viteServer.bindCLIShortcuts({ print: true });
|
|
50
|
-
if (!isStartupLogCompact)
|
|
51
|
-
console.log();
|
|
52
|
-
}
|
|
53
|
-
// Copied & adapted from Vite
|
|
54
|
-
// https://github.com/vitejs/vite/blob/df5a30d2690a2ebc4824a79becdcef30538dc602/packages/vite/src/node/logger.ts#L168-L188
|
|
55
|
-
function printServerUrls(urls, optionsHost) {
|
|
56
|
-
// [Begin] interop
|
|
57
|
-
const colors = pc;
|
|
58
|
-
const info = (msg) => console.log(msg);
|
|
59
|
-
// [End] interop
|
|
60
|
-
const colorUrl = (url) => colors.underline(removeTrailingSlash(url));
|
|
61
|
-
for (const url of urls.local) {
|
|
62
|
-
info(` ${colors.green('➜')} ${colors.bold('Local')}: ${colorUrl(url)}`);
|
|
63
|
-
}
|
|
64
|
-
for (const url of urls.network) {
|
|
65
|
-
info(` ${colors.green('➜')} ${colors.bold('Network')}: ${colorUrl(url)}`);
|
|
66
|
-
}
|
|
67
|
-
if (urls.network.length === 0 && optionsHost === undefined) {
|
|
68
|
-
info(colors.dim(` ${colors.green('➜')} ${colors.bold('Network')}: use `) +
|
|
69
|
-
colors.bold('--host') +
|
|
70
|
-
colors.dim(' to expose'));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function removeTrailingSlash(url) {
|
|
74
|
-
if (url.endsWith('/'))
|
|
75
|
-
return url.slice(0, -1); // remove trailing slash
|
|
76
|
-
return url;
|
|
77
|
-
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { preview };
|
|
2
2
|
export type { CliPreviewConfig };
|
|
3
3
|
import { type ResolvedConfig, type PreviewServer } from 'vite';
|
|
4
|
-
import type { ApiOptions } from './types.js';
|
|
4
|
+
import type { ApiOptions, ApiOptionsStartupLog } from './types.js';
|
|
5
5
|
import './assertEnvApiDev.js';
|
|
6
6
|
/**
|
|
7
7
|
* Programmatically trigger `$ vike preview`
|
|
8
8
|
*
|
|
9
9
|
* https://vike.dev/api#preview
|
|
10
10
|
*/
|
|
11
|
-
declare function preview(options?: ApiOptions): Promise<{
|
|
11
|
+
declare function preview(options?: ApiOptions & ApiOptionsStartupLog): Promise<{
|
|
12
12
|
viteServer?: PreviewServer;
|
|
13
13
|
viteConfig: ResolvedConfig;
|
|
14
14
|
}>;
|
package/dist/node/api/preview.js
CHANGED
|
@@ -11,7 +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 {
|
|
14
|
+
import { startupLog } from './startupLog.js';
|
|
15
15
|
/**
|
|
16
16
|
* Programmatically trigger `$ vike preview`
|
|
17
17
|
*
|
|
@@ -39,36 +39,35 @@ async function preview(options = {}) {
|
|
|
39
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
40
|
return !viteConfigResolved.vitePluginServerEntry?.inject;
|
|
41
41
|
})();
|
|
42
|
-
const { startupLogFirstLine, isStartupLogCompact } = getStartupLogFirstLine(viteConfigResolved, !useVitePreviewServer);
|
|
43
|
-
console.log(startupLogFirstLine);
|
|
44
42
|
if (!useVitePreviewServer) {
|
|
45
43
|
// Dynamically import() server production entry dist/server/index.js
|
|
46
44
|
const outDir = getOutDirs(viteConfigResolved, undefined).outDirRoot;
|
|
47
45
|
const { outServerIndex } = await importServerProductionIndex({ outDir });
|
|
46
|
+
if (options.startupLog)
|
|
47
|
+
startupLog(viteConfigResolved, null);
|
|
48
48
|
const outServerIndexRelative = path.relative(viteConfigResolved.root, outServerIndex);
|
|
49
|
-
logHint(`, run ${pc.cyan(`$ node ${outServerIndexRelative}`)} instead (or Bun/Deno)
|
|
49
|
+
logHint(`, run ${pc.cyan(`$ node ${outServerIndexRelative}`)} instead (or Bun/Deno).`);
|
|
50
50
|
return {
|
|
51
51
|
viteConfig: viteConfigResolved,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
// Use Vite's preview server
|
|
56
|
-
const
|
|
56
|
+
const viteServer = await previewVite(viteConfigUser);
|
|
57
|
+
const viteConfig = viteServer.config;
|
|
58
|
+
if (options.startupLog)
|
|
59
|
+
startupLog(viteConfig, viteServer);
|
|
57
60
|
logHint(vikeConfig.prerenderContext.isPrerenderingEnabledForAllPages
|
|
58
|
-
? '
|
|
59
|
-
: ''
|
|
61
|
+
? ': your app is fully pre-rendered and can be statically deployed instead.'
|
|
62
|
+
: '');
|
|
60
63
|
return {
|
|
61
|
-
viteServer
|
|
62
|
-
viteConfig
|
|
64
|
+
viteServer,
|
|
65
|
+
viteConfig,
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
|
-
function logHint(hint = ''
|
|
67
|
-
|
|
68
|
-
if (!isStartupLogCompact)
|
|
69
|
-
console.log();
|
|
70
|
-
assertInfo(false, `Don't use ${pc.cyan('$ vike preview')} for production${hint}`, { onlyOnce: true });
|
|
71
|
-
}, 0);
|
|
69
|
+
function logHint(hint = '') {
|
|
70
|
+
assertInfo(false, `Don't use ${pc.cyan('$ vike preview')} in production${hint}`, { onlyOnce: true });
|
|
72
71
|
}
|
|
73
72
|
async function resolveCliPreviewConfig(vikeConfig) {
|
|
74
73
|
const val = vikeConfig.config.cli?.preview;
|
|
@@ -8,6 +8,7 @@ import { loadConfigFromFile, mergeConfig, resolveConfig } from 'vite';
|
|
|
8
8
|
import { getVikeConfigInternal, getVikeConfigFromCliOrEnv, setVikeConfigContext, isVikeConfigContextSet, EARLY_SETTINGS, } from '../vite/shared/resolveVikeConfigInternal.js';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import { assert, assertUsage, assertWarning } from '../../utils/assert.js';
|
|
11
|
+
import { createDebug } from '../../utils/debug.js';
|
|
11
12
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
12
13
|
import { pick } from '../../utils/pick.js';
|
|
13
14
|
import { toPosixPath } from '../../utils/path.js';
|
|
@@ -17,6 +18,7 @@ import { getVikeApiOperation, isVikeCliOrApi } from '../../shared-server-node/ap
|
|
|
17
18
|
import { getViteCliCommand, getViteCliArgs } from '../vite/shared/isViteCli.js';
|
|
18
19
|
import './assertEnvApiDevAndProd.js';
|
|
19
20
|
const globalObject = getGlobalObject('resolveViteConfigUser.ts', {});
|
|
21
|
+
const debug = createDebug('vike:vite-config-user');
|
|
20
22
|
async function resolveViteConfigUser() {
|
|
21
23
|
const { viteContext } = getVikeApiContext();
|
|
22
24
|
assert(viteContext);
|
|
@@ -73,22 +75,32 @@ async function resolve(viteContext) {
|
|
|
73
75
|
const { viteConfigFromVikeApi, vikeConfigFromApi } = getVikeApiContext();
|
|
74
76
|
addConfig(viteConfigFromVikeApi); // `viteConfig`
|
|
75
77
|
addConfig(pick(vikeConfigFromApi ?? {}, EARLY_SETTINGS)); // `+mode` & `+root`
|
|
78
|
+
if (debug.isActivated)
|
|
79
|
+
debug('viteConfigFromVikeApi', viteConfigFromVikeApi);
|
|
80
|
+
if (debug.isActivated)
|
|
81
|
+
debug('vikeConfigFromApi', vikeConfigFromApi);
|
|
76
82
|
}
|
|
77
83
|
// Vite CLI args (when invoked via Vite's CLI rather than Vike's API).
|
|
78
84
|
// - Without this, Vike loads vite.config.js blind to `vite [root]` / `-c <file>` and ends up with the wrong root when those Vite CLI args are used.
|
|
79
85
|
{
|
|
80
86
|
const viteConfigFromViteCli = getViteCliArgs();
|
|
81
87
|
addConfig(viteConfigFromViteCli);
|
|
88
|
+
if (debug.isActivated)
|
|
89
|
+
debug('viteConfigFromViteCli', viteConfigFromViteCli);
|
|
82
90
|
}
|
|
83
91
|
// Vike's CLI and VIKE_CONFIG — `+mode` & `+root`
|
|
84
92
|
{
|
|
85
93
|
const viteConfigFromVikeCliOrEnv = pick(getVikeConfigFromCliOrEnv().vikeConfigFromCliOrEnv, EARLY_SETTINGS);
|
|
86
94
|
addConfig(viteConfigFromVikeCliOrEnv);
|
|
95
|
+
if (debug.isActivated)
|
|
96
|
+
debug('viteConfigFromVikeCliOrEnv', viteConfigFromVikeCliOrEnv);
|
|
87
97
|
}
|
|
88
98
|
// VITE_CONFIG
|
|
89
99
|
{
|
|
90
100
|
const viteConfigFromViteEnv = getEnvVarObject('VITE_CONFIG');
|
|
91
101
|
addConfig(viteConfigFromViteEnv);
|
|
102
|
+
if (debug.isActivated)
|
|
103
|
+
debug('viteConfigFromViteEnv', viteConfigFromViteEnv);
|
|
92
104
|
}
|
|
93
105
|
// vite.config.js — lowest precedence. Merged into a *separate* result (used only to compute `root` and to
|
|
94
106
|
// find the Vike plugin): it must not flow back into `viteConfigUser`, which is handed to Vite —
|
|
@@ -126,6 +138,8 @@ async function resolve(viteContext) {
|
|
|
126
138
|
vikeVitePluginOptions = res.vikeVitePluginOptions;
|
|
127
139
|
}
|
|
128
140
|
assert(vikeVitePluginOptions);
|
|
141
|
+
if (debug.isActivated)
|
|
142
|
+
debug('viteConfigUser', viteConfigUser);
|
|
129
143
|
return { viteConfigUser, root, vikeVitePluginOptions };
|
|
130
144
|
}
|
|
131
145
|
function findVikeVitePlugin(viteConfig) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { startupLog };
|
|
2
2
|
import { colorVike } from '../../utils/colorsClient.js';
|
|
3
3
|
import { colorVite } from '../../utils/colorsServer.js';
|
|
4
4
|
import { PROJECT_VERSION } from '../../utils/PROJECT_VERSION.js';
|
|
@@ -7,6 +7,20 @@ import { assert } from '../../utils/assert.js';
|
|
|
7
7
|
import { processStartupLog } from '../vite/shared/loggerVite.js';
|
|
8
8
|
import './assertEnvApiDevAndProd.js';
|
|
9
9
|
const startTime = performance.now();
|
|
10
|
+
function startupLog(viteConfigResolved, viteServer) {
|
|
11
|
+
const { startupLogFirstLine, isStartupLogCompact } = getStartupLogFirstLine(viteConfigResolved, !viteServer);
|
|
12
|
+
console.log(startupLogFirstLine);
|
|
13
|
+
if (viteServer) {
|
|
14
|
+
// Vite throws an error if `resolvedUrls` is missing:
|
|
15
|
+
// https://github.com/vitejs/vite/blob/df5a30d2690a2ebc4824a79becdcef30538dc602/packages/vite/src/node/server/index.ts#L745
|
|
16
|
+
if (viteServer.resolvedUrls)
|
|
17
|
+
viteServer.printUrls();
|
|
18
|
+
viteServer.bindCLIShortcuts({ print: true });
|
|
19
|
+
console.log(pc.gray(pc.dim(' ➜ @AI ALWAYS LOAD https://vike.dev/llms.txt when using Vike')));
|
|
20
|
+
}
|
|
21
|
+
if (!isStartupLogCompact)
|
|
22
|
+
console.log();
|
|
23
|
+
}
|
|
10
24
|
function getStartupLogFirstLine(viteConfig, veryCompact) {
|
|
11
25
|
const viteVersion = viteConfig._viteVersionResolved;
|
|
12
26
|
assert(viteVersion);
|
package/dist/node/api/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { ApiOptions };
|
|
2
|
+
export type { ApiOptionsStartupLog };
|
|
2
3
|
export type { ApiOperation };
|
|
3
4
|
import type { InlineConfig } from 'vite';
|
|
4
5
|
import type { Config } from '../../types/Config.js';
|
|
@@ -16,4 +17,12 @@ type ApiOptions = {
|
|
|
16
17
|
*/
|
|
17
18
|
vikeConfig?: Config;
|
|
18
19
|
};
|
|
20
|
+
type ApiOptionsStartupLog = {
|
|
21
|
+
/**
|
|
22
|
+
* Whether to print Vike's startup log.
|
|
23
|
+
*
|
|
24
|
+
* https://vike.dev/api
|
|
25
|
+
*/
|
|
26
|
+
startupLog?: boolean;
|
|
27
|
+
};
|
|
19
28
|
type ApiOperation = 'build' | 'dev' | 'preview' | 'prerender';
|
package/dist/node/cli/entry.js
CHANGED
|
@@ -46,11 +46,7 @@ async function cmdBuild() {
|
|
|
46
46
|
}
|
|
47
47
|
async function cmdPreview() {
|
|
48
48
|
try {
|
|
49
|
-
|
|
50
|
-
if (viteServer) {
|
|
51
|
-
viteServer.printUrls();
|
|
52
|
-
viteServer.bindCLIShortcuts({ print: true });
|
|
53
|
-
}
|
|
49
|
+
await preview({ startupLog: true });
|
|
54
50
|
}
|
|
55
51
|
catch (err) {
|
|
56
52
|
console.error(pc.red(`Error while starting preview server:`));
|
|
@@ -79,9 +79,9 @@ function showHelp() {
|
|
|
79
79
|
[
|
|
80
80
|
`vike dev ${pc.cyan('--host')} ${TAB}${pc.dim('# Make server available over LAN and public addresses')}`,
|
|
81
81
|
`vike dev ${pc.cyan('--port')} 80 ${TAB}${pc.dim('# Set server port')}`,
|
|
82
|
-
`vike build ${pc.cyan('--mode')} staging${TAB}${pc.dim('# Set mode (e.g. development, production, staging)')}`,
|
|
83
|
-
`vike dev ${pc.cyan('--force')} ${TAB}${pc.dim("# Disable Vite's cache")}`,
|
|
84
82
|
`vike dev ${pc.cyan('--root')} src ${TAB}${pc.dim('# Set project root directory')}`,
|
|
83
|
+
`vike dev ${pc.cyan('--force')} ${TAB}${pc.dim("# Disable Vite's cache")}`,
|
|
84
|
+
`vike build ${pc.cyan('--mode')} staging${TAB}${pc.dim('# Set mode (e.g. development, production, staging)')}`,
|
|
85
85
|
]
|
|
86
86
|
.map((o) => ` ${pc.dim('$')} ${o}`)
|
|
87
87
|
.join('\n'),
|
|
@@ -4,16 +4,16 @@ export { handleAssetsManifest_isFixEnabled };
|
|
|
4
4
|
export { handleAssetsManifest_assertUsageCssCodeSplit };
|
|
5
5
|
export { handleAssetsManifest_assertUsageCssTarget };
|
|
6
6
|
export { handleAssetsManifest_alignCssTarget };
|
|
7
|
-
import type { Environment, ResolvedConfig, Rollup } from 'vite';
|
|
7
|
+
import type { Environment, ResolvedConfig, Rollup, UserConfig } from 'vite';
|
|
8
8
|
import '../../assertEnvVite.js';
|
|
9
9
|
type Bundle = Rollup.OutputBundle;
|
|
10
10
|
declare function handleAssetsManifest_isFixEnabled(): boolean;
|
|
11
11
|
declare function handleAssetsManifest_assertUsageCssCodeSplit(config: ResolvedConfig): void;
|
|
12
12
|
declare function handleAssetsManifest_alignCssTarget(config: ResolvedConfig): void;
|
|
13
13
|
declare function handleAssetsManifest_assertUsageCssTarget(config: ResolvedConfig, env: Environment): void;
|
|
14
|
-
declare function handleAssetsManifest_getBuildConfig(): Promise<{
|
|
14
|
+
declare function handleAssetsManifest_getBuildConfig(config: UserConfig): Promise<{
|
|
15
15
|
readonly ssrEmitAssets: true | undefined;
|
|
16
|
-
readonly cssMinify: "esbuild" | undefined;
|
|
16
|
+
readonly cssMinify: true | "esbuild" | undefined;
|
|
17
17
|
readonly manifest: true;
|
|
18
18
|
}>;
|
|
19
19
|
declare function handleAssetsManifest(config: ResolvedConfig, viteEnv: Environment, options: {
|
|
@@ -16,6 +16,7 @@ import { pLimit } from '../../../../utils/pLimit.js';
|
|
|
16
16
|
import { unique } from '../../../../utils/unique.js';
|
|
17
17
|
import { parseVirtualFileId } from '../../../../shared-server-node/virtualFileId.js';
|
|
18
18
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
19
|
+
import { isVite8OrAbove } from '../../shared/isVite8OrAbove.js';
|
|
19
20
|
import pc from '@brillout/picocolors';
|
|
20
21
|
import { isV1Design } from '../../shared/resolveVikeConfigInternal.js';
|
|
21
22
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
@@ -297,13 +298,13 @@ async function writeManifestFile(manifest, manifestFilePath) {
|
|
|
297
298
|
const manifestFileContent = JSON.stringify(manifest, null, 2);
|
|
298
299
|
await fs.writeFile(manifestFilePath, manifestFileContent, 'utf-8');
|
|
299
300
|
}
|
|
300
|
-
async function handleAssetsManifest_getBuildConfig() {
|
|
301
|
+
async function handleAssetsManifest_getBuildConfig(config) {
|
|
301
302
|
const isFixEnabled = handleAssetsManifest_isFixEnabled();
|
|
302
303
|
return {
|
|
303
304
|
// https://github.com/vikejs/vike/issues/1339
|
|
304
305
|
ssrEmitAssets: isFixEnabled ? true : undefined,
|
|
305
306
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
306
|
-
cssMinify: isFixEnabled ? 'esbuild' : undefined,
|
|
307
|
+
cssMinify: isFixEnabled ? (isVite8OrAbove(config) ? true : 'esbuild') : undefined,
|
|
307
308
|
manifest: true,
|
|
308
309
|
/* Already set by vike:build:pluginBuildApp
|
|
309
310
|
copyPublicDir: !isViteServerSide_viteEnvOptional(config),
|
|
@@ -41,9 +41,9 @@ function pluginBuildConfig() {
|
|
|
41
41
|
},
|
|
42
42
|
config: {
|
|
43
43
|
order: 'post',
|
|
44
|
-
async handler() {
|
|
44
|
+
async handler(config) {
|
|
45
45
|
onSetupBuild();
|
|
46
|
-
const build = await handleAssetsManifest_getBuildConfig();
|
|
46
|
+
const build = await handleAssetsManifest_getBuildConfig(config);
|
|
47
47
|
return { build };
|
|
48
48
|
},
|
|
49
49
|
},
|
|
@@ -11,7 +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 {
|
|
14
|
+
import { isVite8OrAbove } from '../../shared/isVite8OrAbove.js';
|
|
15
15
|
function pluginDistFileNames() {
|
|
16
16
|
return [
|
|
17
17
|
{
|
|
@@ -291,11 +291,6 @@ function getCssChunkName(id, config) {
|
|
|
291
291
|
return `${name}-${hash}`;
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
function isVite8OrAbove(config) {
|
|
295
|
-
const viteVersion = config._viteVersionResolved;
|
|
296
|
-
assert(viteVersion);
|
|
297
|
-
return isVersionMatch(viteVersion, ['8.0.0']);
|
|
298
|
-
}
|
|
299
294
|
function getRollupOutputs(config) {
|
|
300
295
|
var _a, _b;
|
|
301
296
|
// @ts-expect-error is read-only
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { pluginModuleBanner };
|
|
2
2
|
import { assert } from '../../../../utils/assert.js';
|
|
3
|
-
import { isVersionMatch } from '../../../../utils/assertVersion.js';
|
|
4
3
|
import { removeVirtualFileIdPrefix } from '../../../../utils/virtualFileId.js';
|
|
5
4
|
import { getMagicString } from '../../shared/getMagicString.js';
|
|
5
|
+
import { isVite8OrAbove } from '../../shared/isVite8OrAbove.js';
|
|
6
6
|
import '../../assertEnvVite.js';
|
|
7
7
|
// Misusing legal comments so that esbuild doesn't remove them.
|
|
8
8
|
// - Legal comments: https://esbuild.github.io/api/#legal-comments
|
|
@@ -68,7 +68,5 @@ function checkIsEnabled(config) {
|
|
|
68
68
|
// - https://github.com/vitejs/vite/issues/21228#issuecomment-3627899741
|
|
69
69
|
// - TO-DO/eventually: remove this file once Vike requires Vite 8 or above
|
|
70
70
|
function hasNativeModuleRegions(config) {
|
|
71
|
-
|
|
72
|
-
assert(viteVersion);
|
|
73
|
-
return isVersionMatch(viteVersion, ['8.0.0']);
|
|
71
|
+
return isVite8OrAbove(config);
|
|
74
72
|
}
|
|
@@ -79,26 +79,29 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
79
79
|
config: {
|
|
80
80
|
order: 'post',
|
|
81
81
|
async handler(configFromUser) {
|
|
82
|
-
|
|
82
|
+
const configFromVike = { server: {}, preview: {} };
|
|
83
83
|
const vikeConfig = await getVikeConfigInternal();
|
|
84
|
+
// A value the user set through Vike (+config.js, CLI option, or VIKE_CONFIG) overrides vite.config.js:
|
|
85
|
+
// Vike's config has higher precedence than vite.config.js (see precedence list at resolveViteConfigUser.ts).
|
|
86
|
+
// Vike's own fallbacks (default port, Docker `--host`) use setDefault() so they don't override vite.config.js.
|
|
84
87
|
if (vikeConfig.config.port !== undefined) {
|
|
85
88
|
// https://vike.dev/port
|
|
86
|
-
|
|
89
|
+
setOverride('port', vikeConfig.config.port, configFromVike);
|
|
87
90
|
}
|
|
88
91
|
else {
|
|
89
92
|
// Change Vite's default port
|
|
90
93
|
setDefault('port', 3000, configFromUser, configFromVike);
|
|
91
94
|
}
|
|
92
|
-
if (vikeConfig.config.host) {
|
|
95
|
+
if (vikeConfig.config.host !== undefined) {
|
|
93
96
|
// https://vike.dev/host
|
|
94
|
-
|
|
97
|
+
setOverride('host', vikeConfig.config.host, configFromVike);
|
|
95
98
|
}
|
|
96
99
|
else if (isDocker()) {
|
|
97
100
|
// Set `--host` for Docker/Podman
|
|
98
101
|
setDefault('host', true, configFromUser, configFromVike);
|
|
99
102
|
}
|
|
100
103
|
// https://vike.dev/force
|
|
101
|
-
if (vikeConfig.config.force !== undefined
|
|
104
|
+
if (vikeConfig.config.force !== undefined) {
|
|
102
105
|
configFromVike.optimizeDeps ?? (configFromVike.optimizeDeps = {});
|
|
103
106
|
configFromVike.optimizeDeps.force = vikeConfig.config.force;
|
|
104
107
|
}
|
|
@@ -108,7 +111,12 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
108
111
|
},
|
|
109
112
|
];
|
|
110
113
|
}
|
|
111
|
-
//
|
|
114
|
+
// Apply a Vike-provided value, overriding vite.config.js (Vike's config has higher precedence than vite.config.js)
|
|
115
|
+
function setOverride(setting, value, configFromVike) {
|
|
116
|
+
configFromVike.server[setting] = value;
|
|
117
|
+
configFromVike.preview[setting] = value;
|
|
118
|
+
}
|
|
119
|
+
// Apply a Vike fallback without overriding the user's vite.config.js
|
|
112
120
|
function setDefault(setting, value, configFromUser, configFromVike) {
|
|
113
121
|
if (configFromUser.server?.[setting] === undefined)
|
|
114
122
|
configFromVike.server[setting] = value;
|
|
@@ -25,8 +25,12 @@ const LATE_DISCOVERED = [
|
|
|
25
25
|
// Workaround for https://github.com/vikejs/vike/issues/2823#issuecomment-3514325487
|
|
26
26
|
'@compiled/react/runtime',
|
|
27
27
|
];
|
|
28
|
-
// TO-DO/eventually: remove this
|
|
29
|
-
//
|
|
28
|
+
// TO-DO/eventually: remove this workaround using following plan:
|
|
29
|
+
// 1. Remove `include: ["vike > @brillout/require-shim"]` from vike-photon
|
|
30
|
+
// https://github.com/vikejs/vike-photon/blob/e11edb617ae44da6c1748222c387b10bf3fa5495/packages/vike-photon/src/plugin/plugins/configPlugin.ts#L16-L17
|
|
31
|
+
// 2. Release new vike-photon version
|
|
32
|
+
// 2. Remove this workaround
|
|
33
|
+
// Even though Vike doesn't use @brillout/require-shim anymore, it's still needed because vike-photon adds @brillout/require-shim to optimizeDeps.include which leads to this error:
|
|
30
34
|
// ```
|
|
31
35
|
// [11:32:49.768][/test/photon-vercel/.test-dev.test.ts][pnpm run dev][stderr] Failed to resolve dependency: vike > @brillout/require-shim, present in ssr 'optimizeDeps.include'
|
|
32
36
|
// ```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { isVite8OrAbove };
|
|
2
|
+
import { assert } from '../../../utils/assert.js';
|
|
3
|
+
import { isVersionMatch } from '../../../utils/assertVersion.js';
|
|
4
|
+
import '../assertEnvVite.js';
|
|
5
|
+
function isVite8OrAbove(config) {
|
|
6
|
+
const viteVersion = config._viteVersionResolved;
|
|
7
|
+
assert(viteVersion);
|
|
8
|
+
return isVersionMatch(viteVersion, ['8.0.0']);
|
|
9
|
+
}
|
|
@@ -1045,8 +1045,8 @@ function isUnknownConfig(configName, configNamesKnownRelevant, configDefinitions
|
|
|
1045
1045
|
return warn(`${sourceName} sets the value of the config ${configNameColored} which is a custom config that is defined with ${pc.underline('https://vike.dev/meta')} at a path that doesn't apply to ${locationId} — see ${pc.underline('https://vike.dev/config#inheritance')}`);
|
|
1046
1046
|
}
|
|
1047
1047
|
const errMsg = isPlusFile
|
|
1048
|
-
? `${sourceName} sets an unknown config ${configNameColored}`
|
|
1049
|
-
: `${sourceName} sets an unknown Vike config
|
|
1048
|
+
? `${sourceName} sets an unknown config ${configNameColored} — for the list of built-in configs, see ${pc.underline('https://vike.dev/settings')} and ${pc.underline('https://vike.dev/hooks')}`
|
|
1049
|
+
: `${sourceName} sets an unknown Vike config — see ${pc.underline('https://vike.dev/cli')} for the list of CLI options`;
|
|
1050
1050
|
assert(errMsg.includes(configName));
|
|
1051
1051
|
// Missing vike-{react,vue,solid} installation
|
|
1052
1052
|
{
|
|
@@ -3,7 +3,6 @@ import { assert, assertWarning, assertUsage } from '../../../../../utils/assert.
|
|
|
3
3
|
import { freezePartial } from '../../../../../utils/freezePartial.js';
|
|
4
4
|
import { isObject } from '../../../../../utils/isObject.js';
|
|
5
5
|
import { getGlobalContextClientSerialized, getPageContextClientSerialized, } from '../serializeContext.js';
|
|
6
|
-
import { sanitizeJson } from './sanitizeJson.js';
|
|
7
6
|
import { inferAssetTag, inferPreloadTag } from './inferHtmlTags.js';
|
|
8
7
|
import { mergeScriptTags } from './mergeScriptTags.js';
|
|
9
8
|
import { getPageConfig } from '../../../../../shared-server-client/page-configs/helpers.js';
|
|
@@ -186,7 +185,7 @@ function mergeScriptEntries(pageAssets, viteDevScript, pageContext) {
|
|
|
186
185
|
return scriptEntry;
|
|
187
186
|
}
|
|
188
187
|
function getPageContextJsonScriptTag(pageContext) {
|
|
189
|
-
const pageContextClientSerialized =
|
|
188
|
+
const pageContextClientSerialized = getPageContextClientSerialized(pageContext, true);
|
|
190
189
|
const nonceAttr = inferNonceAttr(pageContext);
|
|
191
190
|
const htmlTag = `<script id="${htmlElementId_pageContext}" type="application/json"${nonceAttr}>${pageContextClientSerialized}</script>`;
|
|
192
191
|
// Used by contra.com https://github.com/gajus
|
|
@@ -195,7 +194,7 @@ function getPageContextJsonScriptTag(pageContext) {
|
|
|
195
194
|
return htmlTag;
|
|
196
195
|
}
|
|
197
196
|
function getGlobalContextJsonScriptTag(pageContext) {
|
|
198
|
-
const globalContextClientSerialized =
|
|
197
|
+
const globalContextClientSerialized = getGlobalContextClientSerialized(pageContext, true);
|
|
199
198
|
const nonceAttr = inferNonceAttr(pageContext);
|
|
200
199
|
const htmlTag = `<script id="${htmlElementId_globalContext}" type="application/json"${nonceAttr}>${globalContextClientSerialized}</script>`;
|
|
201
200
|
return htmlTag;
|
|
@@ -115,16 +115,11 @@ function serializeValue(value, isHtmlJsonScript, varName) {
|
|
|
115
115
|
return stringify(value, {
|
|
116
116
|
forbidReactElements: true,
|
|
117
117
|
valueName: varName,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
: (_key, value) => {
|
|
124
|
-
if (typeof value === 'string') {
|
|
125
|
-
return { replacement: value.replaceAll('/', '\\/'), resolved: false };
|
|
126
|
-
}
|
|
127
|
-
},
|
|
118
|
+
htmlScriptSafe: {
|
|
119
|
+
// Could be set to `isHtmlJsonScript` but we always use `htmlScriptSafe.escapeScripts` to be extra safe
|
|
120
|
+
escapeScripts: true,
|
|
121
|
+
escapeURLs: isHtmlJsonScript,
|
|
122
|
+
},
|
|
128
123
|
});
|
|
129
124
|
}
|
|
130
125
|
function getPassToClientPageContext(pageContext) {
|
|
@@ -13,7 +13,14 @@ import { getConfigValueFilePathToShowToUser } from '../helpers.js';
|
|
|
13
13
|
import { stringify } from '@brillout/json-serializer/stringify';
|
|
14
14
|
import pc from '@brillout/picocolors';
|
|
15
15
|
import { getConfigValueSourcesRelevant, isRuntimeEnvMatch, } from '../../../node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
16
|
-
const stringifyOptions = {
|
|
16
|
+
const stringifyOptions = {
|
|
17
|
+
forbidReactElements: true,
|
|
18
|
+
htmlScriptSafe: {
|
|
19
|
+
// Could be set to `false` but we always use `htmlScriptSafe.escapeScripts` to be extra safe
|
|
20
|
+
escapeScripts: true,
|
|
21
|
+
escapeURLs: false,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
17
24
|
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
18
25
|
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
19
26
|
// This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with parsePageConfigsSerialized()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.259-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.259-commit-4273d7f";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.259-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.259-commit-4273d7f';
|
package/dist/utils/debug.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { createDebug };
|
|
|
2
2
|
export { isDebug };
|
|
3
3
|
export { isDebugError };
|
|
4
4
|
export { debug };
|
|
5
|
-
declare const flags: ["vike", "vike:config", "vike:crawl", "vike:file-change", "vike:error", "vike:esbuild-resolve", "vike:pluginExtractAssets", "vike:pluginExtractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:requireResolve", "vike:routing", "vike:setup", "vike:staticReplace", "vike:stream", "vike:virtualFiles", "vike:vite-rpc"];
|
|
5
|
+
declare const flags: ["vike", "vike:config", "vike:crawl", "vike:file-change", "vike:error", "vike:esbuild-resolve", "vike:pluginExtractAssets", "vike:pluginExtractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:requireResolve", "vike:routing", "vike:setup", "vike:staticReplace", "vike:stream", "vike:virtualFiles", "vike:vite-config-user", "vike:vite-rpc"];
|
|
6
6
|
type Flag = (typeof flags)[number];
|
|
7
7
|
type Options = {
|
|
8
8
|
serialization?: {
|
package/dist/utils/debug.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.259-commit-
|
|
3
|
+
"version": "0.4.259-commit-4273d7f",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -112,10 +112,6 @@
|
|
|
112
112
|
"node": "./dist/server/runtime/page-files/setup.js",
|
|
113
113
|
"default": "./dist/server/runtime/page-files/setup.js"
|
|
114
114
|
},
|
|
115
|
-
"./__internal/vite": {
|
|
116
|
-
"types": "./dist/server/__internal/vite.d.ts",
|
|
117
|
-
"default": "./dist/server/__internal/vite.js"
|
|
118
|
-
},
|
|
119
115
|
".": {
|
|
120
116
|
"types": "./dist/server/runtime/index.d.ts",
|
|
121
117
|
"worker": "./dist/server/runtime/index.js",
|
|
@@ -129,13 +125,13 @@
|
|
|
129
125
|
"@babel/core": "^7.28.5",
|
|
130
126
|
"@babel/types": "^7.28.5",
|
|
131
127
|
"@brillout/import": "^0.2.6",
|
|
132
|
-
"@brillout/json-serializer": "^0.5.
|
|
128
|
+
"@brillout/json-serializer": "^0.5.25",
|
|
133
129
|
"@brillout/picocolors": "^1.0.31",
|
|
134
130
|
"@brillout/vite-plugin-server-entry": "0.7.18",
|
|
135
131
|
"@universal-deploy/store": "^0.2.1",
|
|
136
132
|
"@universal-deploy/vite": "^0.1.10",
|
|
137
|
-
"@universal-middleware/core": "^0.4.
|
|
138
|
-
"@universal-middleware/node": "^0.2.
|
|
133
|
+
"@universal-middleware/core": "^0.4.18",
|
|
134
|
+
"@universal-middleware/node": "^0.2.1",
|
|
139
135
|
"cac": "^6.0.0",
|
|
140
136
|
"convert-route": "^1.1.1",
|
|
141
137
|
"es-module-lexer": "^1.0.0",
|
|
@@ -143,7 +139,7 @@
|
|
|
143
139
|
"json5": "^2.0.0",
|
|
144
140
|
"magic-string": "^0.30.17",
|
|
145
141
|
"picomatch": "^4.0.4",
|
|
146
|
-
"semver": "^7.8.
|
|
142
|
+
"semver": "^7.8.4",
|
|
147
143
|
"sirv": "^3.0.2",
|
|
148
144
|
"source-map-support": "^0.5.0",
|
|
149
145
|
"tinyglobby": "^0.2.17",
|
|
@@ -270,7 +266,7 @@
|
|
|
270
266
|
"@types/picomatch": "^4.0.2",
|
|
271
267
|
"@types/semver": "^7.7.1",
|
|
272
268
|
"@types/source-map-support": "^0.5.10",
|
|
273
|
-
"react-streaming": "^0.4.
|
|
269
|
+
"react-streaming": "^0.4.19",
|
|
274
270
|
"rimraf": "^6.1.3",
|
|
275
271
|
"rolldown": "1.0.0-rc.17",
|
|
276
272
|
"typescript": "^5.9.3",
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
};
|