vike 0.4.237-commit-2d6f480 → 0.4.237-commit-2c1db32
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 +1 -1
- package/dist/cjs/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +7 -7
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +121 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -124
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -1
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +4 -4
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +1 -1
- package/dist/cjs/node/vite/shared/getOutDirs.js +2 -6
- package/dist/cjs/node/vite/shared/isViteServerSide.js +25 -56
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/api/build.js +1 -1
- package/dist/esm/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +3 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +7 -7
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.d.ts +2 -0
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +118 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +0 -4
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +7 -124
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild.js +1 -2
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +1 -1
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +1 -1
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +2 -2
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.d.ts +1 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +4 -4
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.js +3 -7
- package/dist/esm/node/vite/shared/isViteServerSide.d.ts +4 -4
- package/dist/esm/node/vite/shared/isViteServerSide.js +25 -56
- package/dist/esm/types/Config.d.ts +1 -3
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js
CHANGED
|
@@ -13,7 +13,7 @@ async function generateVirtualFileGlobalEntryWithOldDesign(id, options, config,
|
|
|
13
13
|
const idParsed = parseVirtualFileId(id);
|
|
14
14
|
assert(idParsed && idParsed.type === 'global-entry');
|
|
15
15
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
16
|
-
assert(isForClientSide === !isViteServerSide_extraSafe(config,
|
|
16
|
+
assert(isForClientSide === !isViteServerSide_extraSafe(config, env, options));
|
|
17
17
|
const code = await getCode(config, isForClientSide, isClientRouting, isDev, id);
|
|
18
18
|
return code;
|
|
19
19
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { generateVirtualFilePageEntry };
|
|
2
|
-
|
|
3
|
-
declare function generateVirtualFilePageEntry(id: string, isDev: boolean, config: ResolvedConfig): Promise<string>;
|
|
2
|
+
declare function generateVirtualFilePageEntry(id: string, isDev: boolean): Promise<string>;
|
|
@@ -8,7 +8,7 @@ import { serializeConfigValues } from '../../../../shared/page-configs/serialize
|
|
|
8
8
|
import { handleAssetsManifest_isFixEnabled } from '../pluginBuild/handleAssetsManifest.js';
|
|
9
9
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
10
10
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
11
|
-
async function generateVirtualFilePageEntry(id, isDev
|
|
11
|
+
async function generateVirtualFilePageEntry(id, isDev) {
|
|
12
12
|
const result = parseVirtualFileId(id);
|
|
13
13
|
assert(result && result.type === 'page-entry');
|
|
14
14
|
/* This assertion fails when using includeAssetsImportedByServer
|
|
@@ -32,11 +32,11 @@ async function generateVirtualFilePageEntry(id, isDev, config) {
|
|
|
32
32
|
throw getProjectError('Outdated request');
|
|
33
33
|
//*/
|
|
34
34
|
}
|
|
35
|
-
const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config),
|
|
35
|
+
const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config), isDev);
|
|
36
36
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
37
37
|
return code;
|
|
38
38
|
}
|
|
39
|
-
function getCode(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer,
|
|
39
|
+
function getCode(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
40
40
|
const lines = [];
|
|
41
41
|
const importStatements = [];
|
|
42
42
|
const filesEnv = new Map();
|
|
@@ -44,7 +44,7 @@ function getCode(pageConfig, isForClientSide, pageId, includeAssetsImportedBySer
|
|
|
44
44
|
lines.push('export const configValuesSerialized = {');
|
|
45
45
|
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, { isForClientSide, isClientRouting, isDev }, '', false));
|
|
46
46
|
lines.push('};');
|
|
47
|
-
if (!handleAssetsManifest_isFixEnabled(
|
|
47
|
+
if (!handleAssetsManifest_isFixEnabled() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
48
48
|
importStatements.push(`import '${extractAssetsAddQuery(generateVirtualFileId({ type: 'page-entry', pageId, isForClientSide: false }))}'`);
|
|
49
49
|
}
|
|
50
50
|
const code = [...importStatements, ...lines].join('\n');
|
|
@@ -46,7 +46,7 @@ function pluginVirtualFiles() {
|
|
|
46
46
|
const idParsed = parseVirtualFileId(id);
|
|
47
47
|
if (idParsed) {
|
|
48
48
|
if (idParsed.type === 'page-entry') {
|
|
49
|
-
const code = await generateVirtualFilePageEntry(id, isDev
|
|
49
|
+
const code = await generateVirtualFilePageEntry(id, isDev);
|
|
50
50
|
return code;
|
|
51
51
|
}
|
|
52
52
|
if (idParsed.type === 'global-entry') {
|
|
@@ -2,7 +2,7 @@ export { getOutDirs };
|
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
export type { OutDirs };
|
|
4
4
|
import type { UserConfig, ResolvedConfig } from 'vite';
|
|
5
|
-
import { ViteEnv } from './isViteServerSide.js';
|
|
5
|
+
import { type ViteEnv } from './isViteServerSide.js';
|
|
6
6
|
type OutDirs = {
|
|
7
7
|
/** Absolute path to `outDir` */
|
|
8
8
|
outDirRoot: string;
|
|
@@ -2,7 +2,7 @@ export { getOutDirs };
|
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
import { assert, assertPosixPath, assertUsage, createDebugger, pathJoin, toPosixPath } from '../utils.js';
|
|
5
|
-
import {
|
|
5
|
+
import { isViteServerSide_viteEnvOptional } from './isViteServerSide.js';
|
|
6
6
|
const debug = createDebugger('vike:outDir');
|
|
7
7
|
function getOutDirs(configGlobal, viteEnv) {
|
|
8
8
|
debug('getOutDirs()', new Error().stack);
|
|
@@ -16,13 +16,9 @@ function getOutDirs(configGlobal, viteEnv) {
|
|
|
16
16
|
}
|
|
17
17
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
18
18
|
function resolveOutDir(config, isServerSide) {
|
|
19
|
-
debug('resolveOutDir()'
|
|
20
|
-
debug('isServerSide', isServerSide);
|
|
19
|
+
debug('resolveOutDir()');
|
|
21
20
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
22
21
|
debug('outDir', outDir);
|
|
23
|
-
/* outDir may already be resolved when using Telefunc + Vike (because both Telefunc and Vike use this logic)
|
|
24
|
-
assert(isOutDirRoot(outDir))
|
|
25
|
-
*/
|
|
26
22
|
const { outDirClient, outDirServer } = getOutDirsAll(outDir);
|
|
27
23
|
if (isServerSide) {
|
|
28
24
|
debug('outDirServer', 'outDirServer');
|
|
@@ -107,7 +103,7 @@ function assertOutDirResolved(outDir, configGlobal, viteEnv) {
|
|
|
107
103
|
assert('/client'.length === '/server'.length);
|
|
108
104
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
109
105
|
const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
|
|
110
|
-
const isServerSide =
|
|
106
|
+
const isServerSide = isViteServerSide_viteEnvOptional(configGlobal, viteEnv);
|
|
111
107
|
if (isServerSide) {
|
|
112
108
|
assertUsage(outDir.endsWith('/server'), wrongUsage);
|
|
113
109
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { isViteServerSide };
|
|
2
2
|
export { isViteClientSide };
|
|
3
|
-
export {
|
|
3
|
+
export { isViteServerSide_viteEnvOptional };
|
|
4
4
|
export { isViteServerSide_onlySsrEnv };
|
|
5
5
|
export { isViteServerSide_extraSafe };
|
|
6
6
|
export type { ViteEnv };
|
|
@@ -10,9 +10,9 @@ type ViteEnv = {
|
|
|
10
10
|
config: EnvironmentOptions | Environment['config'];
|
|
11
11
|
};
|
|
12
12
|
declare function isViteServerSide(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
|
|
13
|
-
declare function
|
|
13
|
+
declare function isViteServerSide_viteEnvOptional(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv | undefined): boolean;
|
|
14
14
|
declare function isViteClientSide(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
15
15
|
declare function isViteServerSide_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
16
|
-
declare function isViteServerSide_extraSafe(config: ResolvedConfig, options: {
|
|
16
|
+
declare function isViteServerSide_extraSafe(config: ResolvedConfig, viteEnv: ViteEnv, options: {
|
|
17
17
|
ssr?: boolean;
|
|
18
|
-
} | undefined
|
|
18
|
+
} | undefined): boolean;
|
|
@@ -1,56 +1,45 @@
|
|
|
1
1
|
export { isViteServerSide };
|
|
2
2
|
export { isViteClientSide };
|
|
3
|
-
export {
|
|
3
|
+
export { isViteServerSide_viteEnvOptional };
|
|
4
4
|
export { isViteServerSide_onlySsrEnv };
|
|
5
5
|
export { isViteServerSide_extraSafe };
|
|
6
6
|
import { assert } from '../../../utils/assert.js';
|
|
7
7
|
function isViteServerSide_impl(configGlobal, viteEnv) {
|
|
8
8
|
assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
9
|
-
const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
10
|
-
const isServerSide2 = !viteEnv?.config.build ? null : getBuildSsrValue(viteEnv.config.build.ssr);
|
|
11
|
-
const isServerSide3 = !configGlobal.build ? null : getBuildSsrValue(configGlobal.build.ssr);
|
|
12
|
-
const isServerSide4 = viteEnv?.name === 'ssr' ? true : viteEnv?.name === 'client' ? false : null;
|
|
13
9
|
const debug = {
|
|
14
10
|
viteEnvIsUndefined: !viteEnv,
|
|
15
11
|
viteEnvName: viteEnv?.name ?? null,
|
|
16
12
|
viteEnvConsumer: viteEnv?.config.consumer ?? null,
|
|
17
13
|
configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
|
|
18
14
|
configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
|
|
19
|
-
isServerSide1,
|
|
20
|
-
isServerSide2,
|
|
21
|
-
isServerSide3,
|
|
22
|
-
isServerSide4,
|
|
23
15
|
};
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
return isServerSide1;
|
|
30
|
-
}
|
|
31
|
-
if (isServerSide2 !== null) {
|
|
32
|
-
// assert(isServerSide2 === isServerSide4 || isServerSide4 === null, debug)
|
|
33
|
-
return isServerSide2;
|
|
34
|
-
}
|
|
35
|
-
if (isServerSide3 !== null) {
|
|
36
|
-
// assert(isServerSide3 === isServerSide4 || isServerSide4 === null, debug)
|
|
37
|
-
return isServerSide3;
|
|
16
|
+
if (!viteEnv) {
|
|
17
|
+
const isServerSide = getBuildSsrValue(configGlobal.build?.ssr);
|
|
18
|
+
assert(typeof isServerSide === 'boolean', debug);
|
|
19
|
+
return isServerSide;
|
|
38
20
|
}
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
else {
|
|
22
|
+
const isServerSide1 = !viteEnv.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
23
|
+
const isServerSide2 = getBuildSsrValue(viteEnv.config.build?.ssr);
|
|
24
|
+
const isServerSide3 = viteEnv.name === 'ssr' ? true : viteEnv.name === 'client' ? false : null;
|
|
25
|
+
const isServerSide = isServerSide1 ?? isServerSide2;
|
|
26
|
+
assert(isServerSide === isServerSide1 || isServerSide1 === null, debug);
|
|
27
|
+
assert(isServerSide === isServerSide2 || isServerSide2 === null, debug);
|
|
28
|
+
assert(isServerSide === isServerSide3 || isServerSide3 === null, debug);
|
|
29
|
+
assert(isServerSide !== null);
|
|
30
|
+
return isServerSide;
|
|
41
31
|
}
|
|
42
|
-
assert(!viteEnv);
|
|
43
|
-
return !!configGlobal.build?.ssr;
|
|
44
32
|
}
|
|
45
33
|
function getBuildSsrValue(buildSsr) {
|
|
46
34
|
if (buildSsr === undefined)
|
|
47
35
|
return null;
|
|
36
|
+
assert(typeof buildSsr === 'boolean' || typeof buildSsr === 'string');
|
|
48
37
|
return !!buildSsr;
|
|
49
38
|
}
|
|
50
39
|
function isViteServerSide(configGlobal, viteEnv) {
|
|
51
40
|
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
52
41
|
}
|
|
53
|
-
function
|
|
42
|
+
function isViteServerSide_viteEnvOptional(configGlobal, viteEnv) {
|
|
54
43
|
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
55
44
|
}
|
|
56
45
|
function isViteClientSide(configGlobal, viteEnv) {
|
|
@@ -61,37 +50,17 @@ function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
|
|
|
61
50
|
return viteEnv.name ? viteEnv.name === 'ssr' : isViteServerSide(configGlobal, viteEnv);
|
|
62
51
|
}
|
|
63
52
|
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
64
|
-
function isViteServerSide_extraSafe(config,
|
|
53
|
+
function isViteServerSide_extraSafe(config, viteEnv, options) {
|
|
65
54
|
const isServerSide = isViteServerSide(config, viteEnv);
|
|
66
55
|
const debug = {
|
|
56
|
+
isServerSide,
|
|
67
57
|
configCommand: config.command,
|
|
68
|
-
configBuildSsr: config.build.ssr,
|
|
58
|
+
configBuildSsr: getBuildSsrValue(config.build.ssr),
|
|
69
59
|
optionsIsUndefined: options === undefined,
|
|
70
|
-
optionsSsr: options?.ssr,
|
|
71
|
-
isServerSide,
|
|
60
|
+
optionsSsr: options?.ssr ?? null,
|
|
72
61
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return res;
|
|
78
|
-
}
|
|
79
|
-
return isServerSide;
|
|
80
|
-
}
|
|
81
|
-
if (config.command === 'build') {
|
|
82
|
-
const res = config.build.ssr;
|
|
83
|
-
assert(typeof res === 'boolean', debug);
|
|
84
|
-
assert(res === options?.ssr || options?.ssr === undefined, debug);
|
|
85
|
-
assert(res === isServerSide, debug);
|
|
86
|
-
return res;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
const res = options?.ssr;
|
|
90
|
-
assert(typeof res === 'boolean', debug);
|
|
91
|
-
/* This assertion can fail, seems to be a Vite bug? It's very unexpected.
|
|
92
|
-
if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
|
|
93
|
-
*/
|
|
94
|
-
assert(res === isServerSide, debug);
|
|
95
|
-
return res;
|
|
96
|
-
}
|
|
62
|
+
assert(options, debug);
|
|
63
|
+
assert(typeof options.ssr === 'boolean', debug);
|
|
64
|
+
assert(options.ssr === isServerSide, debug);
|
|
65
|
+
return isServerSide;
|
|
97
66
|
}
|
|
@@ -403,9 +403,7 @@ type ConfigBuiltIn = {
|
|
|
403
403
|
includeAssetsImportedByServer?: boolean;
|
|
404
404
|
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
405
405
|
disableAutoFullBuild?: boolean | 'prerender';
|
|
406
|
-
/**
|
|
407
|
-
* @deprecated It's value is now always true.
|
|
408
|
-
*/
|
|
406
|
+
/** @deprecated It's value is now always true. */
|
|
409
407
|
vite6BuilderApp?: true;
|
|
410
408
|
/** The Base URL of your server.
|
|
411
409
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.237-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.237-commit-2c1db32";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.237-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.237-commit-2c1db32';
|