vike 0.4.191-commit-a91fd40 → 0.4.191-commit-349a3eb
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/plugin/plugins/autoFullBuild.js +4 -4
- package/dist/cjs/node/plugin/plugins/config/assertVikeConfig.js +4 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +12 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +0 -3
- package/dist/cjs/node/runtime/html/stream.js +37 -24
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +3 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +4 -4
- package/dist/esm/node/plugin/plugins/config/assertVikeConfig.js +4 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +8 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +12 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +0 -3
- package/dist/esm/node/runtime/html/stream.js +37 -24
- package/dist/esm/shared/ConfigVike.d.ts +3 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +0 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +3 -1
- 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 +1 -1
|
@@ -94,8 +94,7 @@ async function triggerFullBuild(config, configVike, bundle) {
|
|
|
94
94
|
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
95
95
|
process.exit(1);
|
|
96
96
|
}
|
|
97
|
-
if (configVike.prerender && !configVike.prerender.disableAutoRun) {
|
|
98
|
-
return;
|
|
97
|
+
if (configVike.prerender && !configVike.prerender.disableAutoRun && configVike.disableAutoFullBuild !== 'prerender') {
|
|
99
98
|
await (0, runPrerender_js_1.runPrerenderFromAutoFullBuild)({ viteConfig: configInline });
|
|
100
99
|
forceExit = true;
|
|
101
100
|
}
|
|
@@ -107,11 +106,12 @@ function abortViteBuildSsr(configVike) {
|
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
function isDisabled(configVike) {
|
|
110
|
-
|
|
109
|
+
const { disableAutoFullBuild } = configVike;
|
|
110
|
+
if (disableAutoFullBuild === null || disableAutoFullBuild === 'prerender') {
|
|
111
111
|
// TODO/v1-release: also enable autoFullBuild when running Vite's build() API
|
|
112
112
|
return !(0, isViteCliCall_js_1.isViteCliCall)();
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
-
return
|
|
115
|
+
return disableAutoFullBuild;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -30,8 +30,10 @@ function checkConfigVike(configVike) {
|
|
|
30
30
|
}
|
|
31
31
|
{
|
|
32
32
|
const prop = 'disableAutoFullBuild';
|
|
33
|
-
if (!(0, utils_js_1.hasProp)(configVike, prop, 'boolean') &&
|
|
34
|
-
|
|
33
|
+
if (!(0, utils_js_1.hasProp)(configVike, prop, 'boolean') &&
|
|
34
|
+
!(0, utils_js_1.hasProp)(configVike, prop, 'undefined') &&
|
|
35
|
+
!(configVike[prop] === 'prerender'))
|
|
36
|
+
return { prop, errMsg: "should be a boolean or 'prerender'" };
|
|
35
37
|
}
|
|
36
38
|
{
|
|
37
39
|
const prop = 'includeAssetsImportedByServer';
|
|
@@ -33,7 +33,8 @@ const configDefinitionsBuiltIn = {
|
|
|
33
33
|
cumulative: true
|
|
34
34
|
},
|
|
35
35
|
route: {
|
|
36
|
-
env: { server: true, client: 'if-client-routing'
|
|
36
|
+
env: { server: true, client: 'if-client-routing' },
|
|
37
|
+
eager: true
|
|
37
38
|
},
|
|
38
39
|
guard: {
|
|
39
40
|
env: { server: true, client: 'if-client-routing' }
|
|
@@ -42,7 +43,8 @@ const configDefinitionsBuiltIn = {
|
|
|
42
43
|
env: { server: true }
|
|
43
44
|
},
|
|
44
45
|
iKnowThePerformanceRisksOfAsyncRouteFunctions: {
|
|
45
|
-
env: { server: true, client: 'if-client-routing'
|
|
46
|
+
env: { server: true, client: 'if-client-routing' },
|
|
47
|
+
eager: true
|
|
46
48
|
},
|
|
47
49
|
filesystemRoutingRoot: {
|
|
48
50
|
env: { config: true }
|
|
@@ -54,7 +56,8 @@ const configDefinitionsBuiltIn = {
|
|
|
54
56
|
},
|
|
55
57
|
clientRouting: {
|
|
56
58
|
// We could make it { client: false } but we don't yet because of some legacy V0.4 design code
|
|
57
|
-
env: { server: true, client: true, config: true
|
|
59
|
+
env: { server: true, client: true, config: true },
|
|
60
|
+
eager: true
|
|
58
61
|
},
|
|
59
62
|
clientHooks: {
|
|
60
63
|
env: { config: true }
|
|
@@ -75,7 +78,8 @@ const configDefinitionsBuiltIn = {
|
|
|
75
78
|
env: { config: true }
|
|
76
79
|
},
|
|
77
80
|
clientEntryLoaded: {
|
|
78
|
-
env: { server: true, client: true
|
|
81
|
+
env: { server: true, client: true },
|
|
82
|
+
eager: true,
|
|
79
83
|
_computed: (configValueSources) => {
|
|
80
84
|
{
|
|
81
85
|
const source = getConfigValueSource(configValueSources, 'clientHooks');
|
|
@@ -118,10 +122,12 @@ const configDefinitionsBuiltIn = {
|
|
|
118
122
|
exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
|
|
119
123
|
const configDefinitionsBuiltInGlobal = {
|
|
120
124
|
onPrerenderStart: {
|
|
121
|
-
env: { server: true, production: true
|
|
125
|
+
env: { server: true, production: true },
|
|
126
|
+
eager: true
|
|
122
127
|
},
|
|
123
128
|
onBeforeRoute: {
|
|
124
|
-
env: { server: true, client: 'if-client-routing'
|
|
129
|
+
env: { server: true, client: 'if-client-routing' },
|
|
130
|
+
eager: true
|
|
125
131
|
},
|
|
126
132
|
prerender: {
|
|
127
133
|
env: { config: true }
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -35,7 +35,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
35
35
|
const importStatements = [];
|
|
36
36
|
const isClientRouting = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
37
37
|
lines.push('export const configValuesSerialized = {');
|
|
38
|
-
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: false
|
|
38
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: false }, ''));
|
|
39
39
|
lines.push('};');
|
|
40
40
|
if (!(0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
41
41
|
importStatements.push(`import '${(0, extractAssetsQuery_js_1.extractAssetsAddQuery)((0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, false))}'`);
|
|
@@ -35,7 +35,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
35
35
|
lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
|
|
36
36
|
lines.push(` loadConfigValuesAll: () => import(${JSON.stringify(virtualFileIdPageConfigValuesAll)}),`);
|
|
37
37
|
lines.push(` configValuesSerialized: {`);
|
|
38
|
-
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true
|
|
38
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: true }, ' '));
|
|
39
39
|
lines.push(` },`);
|
|
40
40
|
lines.push(` },`);
|
|
41
41
|
});
|
|
@@ -45,7 +45,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
45
45
|
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
46
46
|
const lines = [];
|
|
47
47
|
lines.push(` configValuesSerialized: {`);
|
|
48
|
-
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfigGlobal, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true
|
|
48
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfigGlobal, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: true }, ' '));
|
|
49
49
|
lines.push(` },`);
|
|
50
50
|
const code = lines.join('\n');
|
|
51
51
|
return code;
|
|
@@ -13,9 +13,6 @@ function isRuntimeEnvMatch(configEnv, runtime) {
|
|
|
13
13
|
if (configEnv.client === 'if-client-routing' && !runtime.isClientRouting)
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
|
-
// Eager
|
|
17
|
-
if (runtime.isEager !== !!configEnv.eager)
|
|
18
|
-
return false;
|
|
19
16
|
// Production/development
|
|
20
17
|
if (
|
|
21
18
|
//
|
|
@@ -44,16 +44,15 @@ async function streamReadableNodeToString(readableNode) {
|
|
|
44
44
|
}
|
|
45
45
|
async function streamReadableWebToString(readableWeb) {
|
|
46
46
|
const reader = readableWeb.getReader();
|
|
47
|
-
const
|
|
47
|
+
const { decode, getClosingChunk } = decodeChunks();
|
|
48
48
|
let str = '';
|
|
49
49
|
while (true) {
|
|
50
50
|
const { done, value } = await reader.read();
|
|
51
51
|
if (done)
|
|
52
52
|
break;
|
|
53
|
-
str +=
|
|
53
|
+
str += decode(value);
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
str += decoder.decode();
|
|
55
|
+
str += getClosingChunk();
|
|
57
56
|
return str;
|
|
58
57
|
}
|
|
59
58
|
exports.streamReadableWebToString = streamReadableWebToString;
|
|
@@ -119,15 +118,16 @@ async function streamPipeNodeToString(streamPipeNode) {
|
|
|
119
118
|
}
|
|
120
119
|
exports.streamPipeNodeToString = streamPipeNodeToString;
|
|
121
120
|
function streamPipeWebToString(streamPipeWeb) {
|
|
121
|
+
const { decode, getClosingChunk } = decodeChunks();
|
|
122
122
|
let str = '';
|
|
123
123
|
let resolve;
|
|
124
124
|
const promise = new Promise((r) => (resolve = r));
|
|
125
125
|
const writable = new WritableStream({
|
|
126
126
|
write(chunk) {
|
|
127
|
-
|
|
128
|
-
str += chunk;
|
|
127
|
+
str += decode(chunk);
|
|
129
128
|
},
|
|
130
129
|
close() {
|
|
130
|
+
str += getClosingChunk();
|
|
131
131
|
resolve(str);
|
|
132
132
|
}
|
|
133
133
|
});
|
|
@@ -384,9 +384,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
384
384
|
const writeChunk = (chunk) => {
|
|
385
385
|
(0, utils_js_1.assert)(writableOriginal);
|
|
386
386
|
writableOriginal.write(chunk);
|
|
387
|
-
|
|
388
|
-
debug('data written (Node.js Writable)', getChunkAsString(chunk));
|
|
389
|
-
}
|
|
387
|
+
debugWithChunk('data written (Node.js Writable)', chunk);
|
|
390
388
|
};
|
|
391
389
|
// For libraries such as https://www.npmjs.com/package/compression
|
|
392
390
|
// - React calls writable.flush() when available
|
|
@@ -457,9 +455,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
457
455
|
const writeChunk = (chunk) => {
|
|
458
456
|
(0, utils_js_1.assert)(writerOriginal);
|
|
459
457
|
writerOriginal.write(encodeForWebStream(chunk));
|
|
460
|
-
|
|
461
|
-
debug('data written (Web Writable)', getChunkAsString(chunk));
|
|
462
|
-
}
|
|
458
|
+
debugWithChunk('data written (Web Writable)', chunk);
|
|
463
459
|
};
|
|
464
460
|
// Web Streams have compression built-in
|
|
465
461
|
// - https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API
|
|
@@ -550,14 +546,10 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
550
546
|
// If readableOriginal doesn't implement readableOriginal.cancel() then it may still emit data after we close the stream. We therefore need to check whether we closed `controllerProxy`.
|
|
551
547
|
!controllerProxyIsClosed) {
|
|
552
548
|
controllerProxy.enqueue(encodeForWebStream(chunk));
|
|
553
|
-
|
|
554
|
-
debug('data written (Web Readable)', getChunkAsString(chunk));
|
|
555
|
-
}
|
|
549
|
+
debugWithChunk('data written (Web Readable)', chunk);
|
|
556
550
|
}
|
|
557
551
|
else {
|
|
558
|
-
|
|
559
|
-
debug('data emitted but not written (Web Readable)', getChunkAsString(chunk));
|
|
560
|
-
}
|
|
552
|
+
debugWithChunk('data emitted but not written (Web Readable)', chunk);
|
|
561
553
|
}
|
|
562
554
|
};
|
|
563
555
|
// Readables don't have the notion of flushing
|
|
@@ -577,9 +569,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
577
569
|
}
|
|
578
570
|
const writeChunk = (chunk) => {
|
|
579
571
|
readableProxy.push(chunk);
|
|
580
|
-
|
|
581
|
-
debug('data written (Node.js Readable)', getChunkAsString(chunk));
|
|
582
|
-
}
|
|
572
|
+
debugWithChunk('data written (Node.js Readable)', chunk);
|
|
583
573
|
};
|
|
584
574
|
// Readables don't have the notion of flushing
|
|
585
575
|
const flushStream = null;
|
|
@@ -802,11 +792,34 @@ function inferStreamName(stream) {
|
|
|
802
792
|
(0, utils_js_1.assert)(false);
|
|
803
793
|
}
|
|
804
794
|
exports.inferStreamName = inferStreamName;
|
|
805
|
-
function
|
|
795
|
+
function decodeChunks() {
|
|
796
|
+
const decoder = new TextDecoder();
|
|
797
|
+
const decode = (chunk) => {
|
|
798
|
+
if (typeof chunk === 'string') {
|
|
799
|
+
return chunk;
|
|
800
|
+
}
|
|
801
|
+
else if (chunk instanceof Uint8Array) {
|
|
802
|
+
return decoder.decode(chunk, { stream: true });
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
(0, utils_js_1.assert)(false);
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
// https://github.com/vikejs/vike/pull/1799#discussion_r1713554096
|
|
809
|
+
const getClosingChunk = () => {
|
|
810
|
+
return decoder.decode();
|
|
811
|
+
};
|
|
812
|
+
return { decode, getClosingChunk };
|
|
813
|
+
}
|
|
814
|
+
function debugWithChunk(msg, chunk) {
|
|
815
|
+
if (!debug.isActivated)
|
|
816
|
+
return;
|
|
817
|
+
let chunkStr;
|
|
806
818
|
try {
|
|
807
|
-
|
|
819
|
+
chunkStr = new TextDecoder().decode(chunk);
|
|
808
820
|
}
|
|
809
821
|
catch (err) {
|
|
810
|
-
|
|
822
|
+
chunkStr = String(chunk);
|
|
811
823
|
}
|
|
824
|
+
debug(msg, chunkStr);
|
|
812
825
|
}
|
|
@@ -17,7 +17,7 @@ const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
|
17
17
|
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
18
18
|
// - parsePageConfigs() is loaded on both the client- and server-side.
|
|
19
19
|
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
20
|
-
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspace) {
|
|
20
|
+
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, { isEager }, tabspace) {
|
|
21
21
|
const lines = [];
|
|
22
22
|
tabspace += ' ';
|
|
23
23
|
Object.entries(pageConfig.configValuesComputed ?? {}).forEach(([configName, configValuesComputed]) => {
|
|
@@ -36,6 +36,8 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
|
|
|
36
36
|
Object.entries(pageConfig.configValueSources).forEach(([configName, sources]) => {
|
|
37
37
|
const configDef = pageConfig.configDefinitions[configName];
|
|
38
38
|
(0, utils_js_1.assert)(configDef);
|
|
39
|
+
if (isEager !== !!configDef.eager)
|
|
40
|
+
return;
|
|
39
41
|
if (!configDef.cumulative) {
|
|
40
42
|
const configValueSource = sources[0];
|
|
41
43
|
(0, utils_js_1.assert)(configValueSource);
|
|
@@ -88,8 +88,7 @@ async function triggerFullBuild(config, configVike, bundle) {
|
|
|
88
88
|
logErrorHint(err);
|
|
89
89
|
process.exit(1);
|
|
90
90
|
}
|
|
91
|
-
if (configVike.prerender && !configVike.prerender.disableAutoRun) {
|
|
92
|
-
return;
|
|
91
|
+
if (configVike.prerender && !configVike.prerender.disableAutoRun && configVike.disableAutoFullBuild !== 'prerender') {
|
|
93
92
|
await runPrerenderFromAutoFullBuild({ viteConfig: configInline });
|
|
94
93
|
forceExit = true;
|
|
95
94
|
}
|
|
@@ -101,11 +100,12 @@ function abortViteBuildSsr(configVike) {
|
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
function isDisabled(configVike) {
|
|
104
|
-
|
|
103
|
+
const { disableAutoFullBuild } = configVike;
|
|
104
|
+
if (disableAutoFullBuild === null || disableAutoFullBuild === 'prerender') {
|
|
105
105
|
// TODO/v1-release: also enable autoFullBuild when running Vite's build() API
|
|
106
106
|
return !isViteCliCall();
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
|
-
return
|
|
109
|
+
return disableAutoFullBuild;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -27,8 +27,10 @@ function checkConfigVike(configVike) {
|
|
|
27
27
|
}
|
|
28
28
|
{
|
|
29
29
|
const prop = 'disableAutoFullBuild';
|
|
30
|
-
if (!hasProp(configVike, prop, 'boolean') &&
|
|
31
|
-
|
|
30
|
+
if (!hasProp(configVike, prop, 'boolean') &&
|
|
31
|
+
!hasProp(configVike, prop, 'undefined') &&
|
|
32
|
+
!(configVike[prop] === 'prerender'))
|
|
33
|
+
return { prop, errMsg: "should be a boolean or 'prerender'" };
|
|
32
34
|
}
|
|
33
35
|
{
|
|
34
36
|
const prop = 'includeAssetsImportedByServer';
|
|
@@ -31,6 +31,14 @@ type ConfigDefinition = {
|
|
|
31
31
|
* https://vike.dev/meta
|
|
32
32
|
*/
|
|
33
33
|
effect?: ConfigEffect;
|
|
34
|
+
/**
|
|
35
|
+
* Always load the configuration value, and as soon as possible.
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*
|
|
39
|
+
* https://vike.dev/meta
|
|
40
|
+
*/
|
|
41
|
+
eager?: boolean;
|
|
34
42
|
/**
|
|
35
43
|
* Whether the configuration always applies to all pages (no config inheritance).
|
|
36
44
|
*
|
|
@@ -32,7 +32,8 @@ const configDefinitionsBuiltIn = {
|
|
|
32
32
|
cumulative: true
|
|
33
33
|
},
|
|
34
34
|
route: {
|
|
35
|
-
env: { server: true, client: 'if-client-routing'
|
|
35
|
+
env: { server: true, client: 'if-client-routing' },
|
|
36
|
+
eager: true
|
|
36
37
|
},
|
|
37
38
|
guard: {
|
|
38
39
|
env: { server: true, client: 'if-client-routing' }
|
|
@@ -41,7 +42,8 @@ const configDefinitionsBuiltIn = {
|
|
|
41
42
|
env: { server: true }
|
|
42
43
|
},
|
|
43
44
|
iKnowThePerformanceRisksOfAsyncRouteFunctions: {
|
|
44
|
-
env: { server: true, client: 'if-client-routing'
|
|
45
|
+
env: { server: true, client: 'if-client-routing' },
|
|
46
|
+
eager: true
|
|
45
47
|
},
|
|
46
48
|
filesystemRoutingRoot: {
|
|
47
49
|
env: { config: true }
|
|
@@ -53,7 +55,8 @@ const configDefinitionsBuiltIn = {
|
|
|
53
55
|
},
|
|
54
56
|
clientRouting: {
|
|
55
57
|
// We could make it { client: false } but we don't yet because of some legacy V0.4 design code
|
|
56
|
-
env: { server: true, client: true, config: true
|
|
58
|
+
env: { server: true, client: true, config: true },
|
|
59
|
+
eager: true
|
|
57
60
|
},
|
|
58
61
|
clientHooks: {
|
|
59
62
|
env: { config: true }
|
|
@@ -74,7 +77,8 @@ const configDefinitionsBuiltIn = {
|
|
|
74
77
|
env: { config: true }
|
|
75
78
|
},
|
|
76
79
|
clientEntryLoaded: {
|
|
77
|
-
env: { server: true, client: true
|
|
80
|
+
env: { server: true, client: true },
|
|
81
|
+
eager: true,
|
|
78
82
|
_computed: (configValueSources) => {
|
|
79
83
|
{
|
|
80
84
|
const source = getConfigValueSource(configValueSources, 'clientHooks');
|
|
@@ -116,10 +120,12 @@ const configDefinitionsBuiltIn = {
|
|
|
116
120
|
};
|
|
117
121
|
const configDefinitionsBuiltInGlobal = {
|
|
118
122
|
onPrerenderStart: {
|
|
119
|
-
env: { server: true, production: true
|
|
123
|
+
env: { server: true, production: true },
|
|
124
|
+
eager: true
|
|
120
125
|
},
|
|
121
126
|
onBeforeRoute: {
|
|
122
|
-
env: { server: true, client: 'if-client-routing'
|
|
127
|
+
env: { server: true, client: 'if-client-routing' },
|
|
128
|
+
eager: true
|
|
123
129
|
},
|
|
124
130
|
prerender: {
|
|
125
131
|
env: { config: true }
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -32,7 +32,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
32
32
|
const importStatements = [];
|
|
33
33
|
const isClientRouting = getConfigValueBuildTime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
34
34
|
lines.push('export const configValuesSerialized = {');
|
|
35
|
-
lines.push(...serializeConfigValues(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: false
|
|
35
|
+
lines.push(...serializeConfigValues(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: false }, ''));
|
|
36
36
|
lines.push('};');
|
|
37
37
|
if (!fixServerAssets_isEnabled() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
38
38
|
importStatements.push(`import '${extractAssetsAddQuery(getVirtualFileIdPageConfigValuesAll(pageId, false))}'`);
|
|
@@ -32,7 +32,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
32
32
|
lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
|
|
33
33
|
lines.push(` loadConfigValuesAll: () => import(${JSON.stringify(virtualFileIdPageConfigValuesAll)}),`);
|
|
34
34
|
lines.push(` configValuesSerialized: {`);
|
|
35
|
-
lines.push(...serializeConfigValues(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: true
|
|
35
|
+
lines.push(...serializeConfigValues(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: true }, ' '));
|
|
36
36
|
lines.push(` },`);
|
|
37
37
|
lines.push(` },`);
|
|
38
38
|
});
|
|
@@ -42,7 +42,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
42
42
|
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
43
43
|
const lines = [];
|
|
44
44
|
lines.push(` configValuesSerialized: {`);
|
|
45
|
-
lines.push(...serializeConfigValues(pageConfigGlobal, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: true
|
|
45
|
+
lines.push(...serializeConfigValues(pageConfigGlobal, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), { isEager: true }, ' '));
|
|
46
46
|
lines.push(` },`);
|
|
47
47
|
const code = lines.join('\n');
|
|
48
48
|
return code;
|
|
@@ -11,9 +11,6 @@ function isRuntimeEnvMatch(configEnv, runtime) {
|
|
|
11
11
|
if (configEnv.client === 'if-client-routing' && !runtime.isClientRouting)
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
|
-
// Eager
|
|
15
|
-
if (runtime.isEager !== !!configEnv.eager)
|
|
16
|
-
return false;
|
|
17
14
|
// Production/development
|
|
18
15
|
if (
|
|
19
16
|
//
|
|
@@ -55,16 +55,15 @@ async function streamReadableNodeToString(readableNode) {
|
|
|
55
55
|
}
|
|
56
56
|
async function streamReadableWebToString(readableWeb) {
|
|
57
57
|
const reader = readableWeb.getReader();
|
|
58
|
-
const
|
|
58
|
+
const { decode, getClosingChunk } = decodeChunks();
|
|
59
59
|
let str = '';
|
|
60
60
|
while (true) {
|
|
61
61
|
const { done, value } = await reader.read();
|
|
62
62
|
if (done)
|
|
63
63
|
break;
|
|
64
|
-
str +=
|
|
64
|
+
str += decode(value);
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
str += decoder.decode();
|
|
66
|
+
str += getClosingChunk();
|
|
68
67
|
return str;
|
|
69
68
|
}
|
|
70
69
|
async function stringToStreamReadableNode(str) {
|
|
@@ -128,15 +127,16 @@ async function streamPipeNodeToString(streamPipeNode) {
|
|
|
128
127
|
return promise;
|
|
129
128
|
}
|
|
130
129
|
function streamPipeWebToString(streamPipeWeb) {
|
|
130
|
+
const { decode, getClosingChunk } = decodeChunks();
|
|
131
131
|
let str = '';
|
|
132
132
|
let resolve;
|
|
133
133
|
const promise = new Promise((r) => (resolve = r));
|
|
134
134
|
const writable = new WritableStream({
|
|
135
135
|
write(chunk) {
|
|
136
|
-
|
|
137
|
-
str += chunk;
|
|
136
|
+
str += decode(chunk);
|
|
138
137
|
},
|
|
139
138
|
close() {
|
|
139
|
+
str += getClosingChunk();
|
|
140
140
|
resolve(str);
|
|
141
141
|
}
|
|
142
142
|
});
|
|
@@ -388,9 +388,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
388
388
|
const writeChunk = (chunk) => {
|
|
389
389
|
assert(writableOriginal);
|
|
390
390
|
writableOriginal.write(chunk);
|
|
391
|
-
|
|
392
|
-
debug('data written (Node.js Writable)', getChunkAsString(chunk));
|
|
393
|
-
}
|
|
391
|
+
debugWithChunk('data written (Node.js Writable)', chunk);
|
|
394
392
|
};
|
|
395
393
|
// For libraries such as https://www.npmjs.com/package/compression
|
|
396
394
|
// - React calls writable.flush() when available
|
|
@@ -461,9 +459,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
461
459
|
const writeChunk = (chunk) => {
|
|
462
460
|
assert(writerOriginal);
|
|
463
461
|
writerOriginal.write(encodeForWebStream(chunk));
|
|
464
|
-
|
|
465
|
-
debug('data written (Web Writable)', getChunkAsString(chunk));
|
|
466
|
-
}
|
|
462
|
+
debugWithChunk('data written (Web Writable)', chunk);
|
|
467
463
|
};
|
|
468
464
|
// Web Streams have compression built-in
|
|
469
465
|
// - https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API
|
|
@@ -554,14 +550,10 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
554
550
|
// If readableOriginal doesn't implement readableOriginal.cancel() then it may still emit data after we close the stream. We therefore need to check whether we closed `controllerProxy`.
|
|
555
551
|
!controllerProxyIsClosed) {
|
|
556
552
|
controllerProxy.enqueue(encodeForWebStream(chunk));
|
|
557
|
-
|
|
558
|
-
debug('data written (Web Readable)', getChunkAsString(chunk));
|
|
559
|
-
}
|
|
553
|
+
debugWithChunk('data written (Web Readable)', chunk);
|
|
560
554
|
}
|
|
561
555
|
else {
|
|
562
|
-
|
|
563
|
-
debug('data emitted but not written (Web Readable)', getChunkAsString(chunk));
|
|
564
|
-
}
|
|
556
|
+
debugWithChunk('data emitted but not written (Web Readable)', chunk);
|
|
565
557
|
}
|
|
566
558
|
};
|
|
567
559
|
// Readables don't have the notion of flushing
|
|
@@ -581,9 +573,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
581
573
|
}
|
|
582
574
|
const writeChunk = (chunk) => {
|
|
583
575
|
readableProxy.push(chunk);
|
|
584
|
-
|
|
585
|
-
debug('data written (Node.js Readable)', getChunkAsString(chunk));
|
|
586
|
-
}
|
|
576
|
+
debugWithChunk('data written (Node.js Readable)', chunk);
|
|
587
577
|
};
|
|
588
578
|
// Readables don't have the notion of flushing
|
|
589
579
|
const flushStream = null;
|
|
@@ -796,11 +786,34 @@ function inferStreamName(stream) {
|
|
|
796
786
|
}
|
|
797
787
|
assert(false);
|
|
798
788
|
}
|
|
799
|
-
function
|
|
789
|
+
function decodeChunks() {
|
|
790
|
+
const decoder = new TextDecoder();
|
|
791
|
+
const decode = (chunk) => {
|
|
792
|
+
if (typeof chunk === 'string') {
|
|
793
|
+
return chunk;
|
|
794
|
+
}
|
|
795
|
+
else if (chunk instanceof Uint8Array) {
|
|
796
|
+
return decoder.decode(chunk, { stream: true });
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
assert(false);
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
// https://github.com/vikejs/vike/pull/1799#discussion_r1713554096
|
|
803
|
+
const getClosingChunk = () => {
|
|
804
|
+
return decoder.decode();
|
|
805
|
+
};
|
|
806
|
+
return { decode, getClosingChunk };
|
|
807
|
+
}
|
|
808
|
+
function debugWithChunk(msg, chunk) {
|
|
809
|
+
if (!debug.isActivated)
|
|
810
|
+
return;
|
|
811
|
+
let chunkStr;
|
|
800
812
|
try {
|
|
801
|
-
|
|
813
|
+
chunkStr = new TextDecoder().decode(chunk);
|
|
802
814
|
}
|
|
803
815
|
catch (err) {
|
|
804
|
-
|
|
816
|
+
chunkStr = String(chunk);
|
|
805
817
|
}
|
|
818
|
+
debug(msg, chunkStr);
|
|
806
819
|
}
|
|
@@ -7,7 +7,7 @@ type ConfigVikeResolved = {
|
|
|
7
7
|
partial: boolean;
|
|
8
8
|
disableAutoRun: boolean;
|
|
9
9
|
};
|
|
10
|
-
disableAutoFullBuild: boolean | null;
|
|
10
|
+
disableAutoFullBuild: boolean | 'prerender' | null;
|
|
11
11
|
includeAssetsImportedByServer: boolean;
|
|
12
12
|
baseAssets: string;
|
|
13
13
|
baseServer: string;
|
|
@@ -63,13 +63,13 @@ type ConfigVikeUserProvided = {
|
|
|
63
63
|
disableAutoRun?: boolean;
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Disable the automatic chaining of build steps.
|
|
67
67
|
*
|
|
68
68
|
* https://vike.dev/disableAutoFullBuild
|
|
69
69
|
*
|
|
70
70
|
* @default false
|
|
71
71
|
*/
|
|
72
|
-
disableAutoFullBuild?: boolean;
|
|
72
|
+
disableAutoFullBuild?: boolean | 'prerender';
|
|
73
73
|
/** The Base URL of your server.
|
|
74
74
|
*
|
|
75
75
|
* https://vike.dev/base-url
|
|
@@ -67,8 +67,6 @@ type ConfigEnv = {
|
|
|
67
67
|
/** For Vike internal use */
|
|
68
68
|
type ConfigEnvInternal = Omit<ConfigEnv, 'client'> & {
|
|
69
69
|
client?: boolean | 'if-client-routing';
|
|
70
|
-
/** Always load value, no matter which page is loaded. */
|
|
71
|
-
eager?: true;
|
|
72
70
|
/** Load value only in production, or only in development. */
|
|
73
71
|
production?: boolean;
|
|
74
72
|
};
|
|
@@ -2,4 +2,6 @@ export { serializeConfigValues };
|
|
|
2
2
|
import type { ConfigEnvInternal, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../PageConfig.js';
|
|
3
3
|
declare function serializeConfigValues(pageConfig: PageConfigBuildTime | (PageConfigGlobalBuildTime & {
|
|
4
4
|
configValuesComputed?: undefined;
|
|
5
|
-
}), importStatements: string[], isEnvMatch: (configEnv: ConfigEnvInternal) => boolean,
|
|
5
|
+
}), importStatements: string[], isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, { isEager }: {
|
|
6
|
+
isEager: boolean;
|
|
7
|
+
}, tabspace: string): string[];
|
|
@@ -12,7 +12,7 @@ const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
|
12
12
|
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
13
13
|
// - parsePageConfigs() is loaded on both the client- and server-side.
|
|
14
14
|
assertIsNotProductionRuntime();
|
|
15
|
-
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspace) {
|
|
15
|
+
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, { isEager }, tabspace) {
|
|
16
16
|
const lines = [];
|
|
17
17
|
tabspace += ' ';
|
|
18
18
|
Object.entries(pageConfig.configValuesComputed ?? {}).forEach(([configName, configValuesComputed]) => {
|
|
@@ -31,6 +31,8 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
|
|
|
31
31
|
Object.entries(pageConfig.configValueSources).forEach(([configName, sources]) => {
|
|
32
32
|
const configDef = pageConfig.configDefinitions[configName];
|
|
33
33
|
assert(configDef);
|
|
34
|
+
if (isEager !== !!configDef.eager)
|
|
35
|
+
return;
|
|
34
36
|
if (!configDef.cumulative) {
|
|
35
37
|
const configValueSource = sources[0];
|
|
36
38
|
assert(configValueSource);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.191-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.191-commit-349a3eb";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.191-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.191-commit-349a3eb';
|