vike 0.4.226 → 0.4.227-commit-c9cc081
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/cli/entry.js +13 -8
- package/dist/cjs/node/plugin/plugins/build/pluginAutoFullBuild.js +6 -3
- package/dist/cjs/node/plugin/plugins/build/pluginDistPackageJsonFile.js +5 -2
- package/dist/cjs/node/plugin/plugins/build/pluginModuleBanner.js +16 -3
- package/dist/cjs/node/plugin/plugins/commonConfig.js +14 -2
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +8 -6
- package/dist/cjs/node/plugin/plugins/envVars.js +27 -16
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +12 -5
- package/dist/cjs/node/plugin/plugins/fileEnv.js +19 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +8 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/previewConfig.js +10 -6
- package/dist/cjs/node/plugin/shared/getResolvedConfig.js +6 -0
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +1 -0
- package/dist/cjs/node/prerender/runPrerender.js +18 -17
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +2 -5
- package/dist/cjs/utils/assertSingleInstance.js +19 -4
- package/dist/esm/node/cli/entry.js +13 -8
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.js +6 -3
- package/dist/esm/node/plugin/plugins/build/pluginDistPackageJsonFile.js +4 -2
- package/dist/esm/node/plugin/plugins/build/pluginModuleBanner.js +13 -3
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +7 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +14 -2
- package/dist/esm/node/plugin/plugins/devConfig/index.js +8 -6
- package/dist/esm/node/plugin/plugins/envVars.js +24 -16
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +8 -5
- package/dist/esm/node/plugin/plugins/fileEnv.js +19 -12
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +8 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +10 -6
- package/dist/esm/node/plugin/shared/getResolvedConfig.d.ts +2 -0
- package/dist/esm/node/plugin/shared/getResolvedConfig.js +3 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +1 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +1 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +1 -1
- package/dist/esm/node/prerender/runPrerender.js +18 -17
- package/dist/esm/shared/page-configs/Config.d.ts +10 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +2 -5
- package/dist/esm/utils/assertSingleInstance.js +19 -4
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getResolvedConfig } from '../shared/getResolvedConfig.js';
|
|
1
2
|
export { fileEnv };
|
|
2
3
|
import { assert, assertUsage, assertWarning, capitalizeFirstLetter, joinEnglish } from '../utils.js';
|
|
3
4
|
import { extractAssetsRE } from './extractAssetsPlugin.js';
|
|
@@ -7,16 +8,20 @@ import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
|
7
8
|
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
8
9
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
9
10
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
11
|
+
import { isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
10
12
|
function fileEnv() {
|
|
11
|
-
let
|
|
13
|
+
let vite5Config;
|
|
12
14
|
let viteDevServer;
|
|
13
15
|
return {
|
|
14
16
|
name: 'vike:fileEnv',
|
|
15
17
|
load(id, options) {
|
|
18
|
+
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
16
19
|
// In build, we use generateBundle() instead of the load() hook. Using load() works for dynamic imports in dev thanks to Vite's lazy transpiling, but it doesn't work in build because Rollup transpiles any dynamically imported module even if it's never actually imported.
|
|
17
20
|
if (!viteDevServer)
|
|
18
21
|
return;
|
|
19
|
-
if (
|
|
22
|
+
if (!isV1Design(config))
|
|
23
|
+
return;
|
|
24
|
+
if (skip(config, id))
|
|
20
25
|
return;
|
|
21
26
|
// For `.vue` files: https://github.com/vikejs/vike/issues/1912#issuecomment-2394981475
|
|
22
27
|
if (id.endsWith('?direct'))
|
|
@@ -26,24 +31,25 @@ function fileEnv() {
|
|
|
26
31
|
const importers = Array.from(moduleInfo.importers)
|
|
27
32
|
.map((m) => m.id)
|
|
28
33
|
.filter((id) => id !== null);
|
|
29
|
-
assertFileEnv(id, !!options?.ssr, importers,
|
|
34
|
+
assertFileEnv(config, id, !!options?.ssr, importers,
|
|
30
35
|
// In dev, we only show a warning because we don't want to disrupt when the user plays with settings such as [ssr](https://vike.dev/ssr).
|
|
31
36
|
true);
|
|
32
37
|
},
|
|
33
38
|
// In production, we have to use transform() to replace modules with a runtime error because generateBundle() doesn't work for dynamic imports. In production, dynamic imports can only be verified at runtime.
|
|
34
39
|
async transform(code, id, options) {
|
|
40
|
+
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
35
41
|
id = normalizeId(id);
|
|
36
42
|
// In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
|
|
37
43
|
if (viteDevServer)
|
|
38
44
|
return;
|
|
39
|
-
if (skip(id))
|
|
45
|
+
if (skip(config, id))
|
|
40
46
|
return;
|
|
41
47
|
const isServerSide = !!options?.ssr;
|
|
42
48
|
if (!isWrongEnv(id, isServerSide))
|
|
43
49
|
return;
|
|
44
50
|
const { importers } = this.getModuleInfo(id);
|
|
45
51
|
// Throwing a verbose error doesn't waste client-side KBs as dynamic imports are code splitted.
|
|
46
|
-
const errMsg = getErrorMessage(id, isServerSide, importers, false, true);
|
|
52
|
+
const errMsg = getErrorMessage(config, id, isServerSide, importers, false, true);
|
|
47
53
|
// We have to inject empty exports to avoid Rollup complaining about missing exports, see https://gist.github.com/brillout/5ea45776e65bd65100a52ecd7bfda3ff
|
|
48
54
|
const { exportNames } = await getExportNames(code);
|
|
49
55
|
return sourceMapRemove([
|
|
@@ -52,8 +58,9 @@ function fileEnv() {
|
|
|
52
58
|
].join('\n'));
|
|
53
59
|
},
|
|
54
60
|
generateBundle() {
|
|
61
|
+
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
55
62
|
Array.from(this.getModuleIds())
|
|
56
|
-
.filter((id) => !skip(id))
|
|
63
|
+
.filter((id) => !skip(config, id))
|
|
57
64
|
.forEach((moduleId) => {
|
|
58
65
|
const mod = this.getModuleInfo(moduleId);
|
|
59
66
|
const { importers } = mod;
|
|
@@ -64,20 +71,20 @@ function fileEnv() {
|
|
|
64
71
|
*/
|
|
65
72
|
return;
|
|
66
73
|
}
|
|
67
|
-
assertFileEnv(moduleId, !!config.build.ssr, importers, false);
|
|
74
|
+
assertFileEnv(config, moduleId, !!config.build.ssr, importers, false);
|
|
68
75
|
});
|
|
69
76
|
},
|
|
70
77
|
configResolved(config_) {
|
|
71
|
-
|
|
78
|
+
vite5Config = config_;
|
|
72
79
|
},
|
|
73
80
|
configureServer(viteDevServer_) {
|
|
74
81
|
viteDevServer = viteDevServer_;
|
|
75
82
|
}
|
|
76
83
|
};
|
|
77
|
-
function assertFileEnv(moduleId, isServerSide, importers, onlyWarn) {
|
|
84
|
+
function assertFileEnv(config, moduleId, isServerSide, importers, onlyWarn) {
|
|
78
85
|
if (!isWrongEnv(moduleId, isServerSide))
|
|
79
86
|
return;
|
|
80
|
-
const errMsg = getErrorMessage(moduleId, isServerSide, importers, onlyWarn, false);
|
|
87
|
+
const errMsg = getErrorMessage(config, moduleId, isServerSide, importers, onlyWarn, false);
|
|
81
88
|
if (onlyWarn) {
|
|
82
89
|
assertWarning(false, errMsg, { onlyOnce: true });
|
|
83
90
|
}
|
|
@@ -85,7 +92,7 @@ function fileEnv() {
|
|
|
85
92
|
assertUsage(false, errMsg);
|
|
86
93
|
}
|
|
87
94
|
}
|
|
88
|
-
function getErrorMessage(moduleId, isServerSide, importers, onlyWarn, noColor) {
|
|
95
|
+
function getErrorMessage(config, moduleId, isServerSide, importers, onlyWarn, noColor) {
|
|
89
96
|
const modulePath = getModulePath(moduleId);
|
|
90
97
|
const envActual = isServerSide ? 'server' : 'client';
|
|
91
98
|
const envExpect = isServerSide ? 'client' : 'server';
|
|
@@ -110,7 +117,7 @@ function fileEnv() {
|
|
|
110
117
|
const suffixWrong = getSuffix(isServerSide ? 'client' : 'server');
|
|
111
118
|
return modulePath.includes(suffixWrong);
|
|
112
119
|
}
|
|
113
|
-
function skip(id) {
|
|
120
|
+
function skip(config, id) {
|
|
114
121
|
// TODO/v1-release: remove
|
|
115
122
|
if (extractAssetsRE.test(id) || extractExportNamesRE.test(id))
|
|
116
123
|
return true;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getResolvedConfig } from '../../shared/getResolvedConfig.js';
|
|
1
2
|
export { importUserCode };
|
|
2
3
|
import { normalizePath } from 'vite';
|
|
3
4
|
import { getVirtualFilePageConfigValuesAll } from './v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js';
|
|
@@ -13,16 +14,16 @@ import { getModuleFilePathAbsolute } from '../../shared/getFilePath.js';
|
|
|
13
14
|
import { updateUserFiles } from '../../../runtime/globalContext.js';
|
|
14
15
|
import { isPlusFile } from './v1-design/getVikeConfig/crawlPlusFiles.js';
|
|
15
16
|
function importUserCode() {
|
|
16
|
-
let
|
|
17
|
+
let vite5Config;
|
|
17
18
|
let vikeConfig;
|
|
18
19
|
return {
|
|
19
20
|
name: 'vike:importUserCode',
|
|
20
21
|
async configResolved(config_) {
|
|
21
22
|
vikeConfig = await getVikeConfig(config_);
|
|
22
|
-
|
|
23
|
+
vite5Config = config_;
|
|
23
24
|
// TODO/v1-release: remove
|
|
24
|
-
if (!isV1Design(
|
|
25
|
-
|
|
25
|
+
if (!isV1Design(vite5Config))
|
|
26
|
+
vite5Config.experimental.importGlobRestoreExtension = true;
|
|
26
27
|
},
|
|
27
28
|
resolveId(id) {
|
|
28
29
|
if (isVirtualFileId(id)) {
|
|
@@ -31,7 +32,7 @@ function importUserCode() {
|
|
|
31
32
|
},
|
|
32
33
|
async handleHotUpdate(ctx) {
|
|
33
34
|
try {
|
|
34
|
-
return await handleHotUpdate(ctx,
|
|
35
|
+
return await handleHotUpdate(ctx, vite5Config);
|
|
35
36
|
}
|
|
36
37
|
catch (err) {
|
|
37
38
|
// Vite swallows errors thrown by handleHotUpdate()
|
|
@@ -40,6 +41,7 @@ function importUserCode() {
|
|
|
40
41
|
}
|
|
41
42
|
},
|
|
42
43
|
async load(id, options) {
|
|
44
|
+
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
43
45
|
if (!isVirtualFileId(id))
|
|
44
46
|
return undefined;
|
|
45
47
|
id = getVirtualFileId(id);
|
|
@@ -55,7 +57,7 @@ function importUserCode() {
|
|
|
55
57
|
}
|
|
56
58
|
},
|
|
57
59
|
configureServer(server) {
|
|
58
|
-
handleFileAddRemove(server,
|
|
60
|
+
handleFileAddRemove(server, vite5Config);
|
|
59
61
|
}
|
|
60
62
|
};
|
|
61
63
|
}
|
|
@@ -896,7 +896,7 @@ function assertKnownConfig(configName, configNamesKnownRelevant, configDefinitio
|
|
|
896
896
|
if (configNamesKnownAll.includes(configName)) {
|
|
897
897
|
assertUsage(false, `${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')}`, { exitOnError });
|
|
898
898
|
}
|
|
899
|
-
const errMsg = `${sourceName} sets an unknown config ${
|
|
899
|
+
const errMsg = `${sourceName} sets an unknown Vike config, see ${pc.underline('https://vike.dev/cli')} for the list of CLI options.`;
|
|
900
900
|
// Missing vike-{react,vue,solid} installation
|
|
901
901
|
{
|
|
902
902
|
const ui = ['vike-react', 'vike-vue', 'vike-solid'];
|
|
@@ -33,20 +33,24 @@ function previewConfig() {
|
|
|
33
33
|
config.appType = 'mpa'
|
|
34
34
|
*/
|
|
35
35
|
return () => {
|
|
36
|
-
|
|
36
|
+
const prerenderConfigGlobal = resolvePrerenderConfigGlobal(config._vikeConfigObject);
|
|
37
|
+
const { isPrerenderingEnabledForAllPages, isPrerenderingEnabled } = prerenderConfigGlobal;
|
|
38
|
+
assertDist(isPrerenderingEnabledForAllPages);
|
|
37
39
|
// We cannot re-use Vite's static middleware: https://github.com/vitejs/vite/pull/14836#issuecomment-1788540300
|
|
38
40
|
addStaticAssetsMiddleware(server.middlewares);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
addSsrMiddleware(server.middlewares, config, true, prerenderConfigGlobal.isPrerenderingEnabled);
|
|
41
|
+
if (!isPrerenderingEnabledForAllPages) {
|
|
42
|
+
addSsrMiddleware(server.middlewares, config, true, isPrerenderingEnabled);
|
|
42
43
|
}
|
|
43
44
|
addStatic404Middleware(server.middlewares);
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
|
-
function assertDist() {
|
|
48
|
+
function assertDist(isPrerenderingEnabledForAllPages) {
|
|
48
49
|
const { outDirRoot, outDirClient, outDirServer } = getOutDirs(config);
|
|
49
|
-
[outDirRoot, outDirClient
|
|
50
|
+
const dirS = [outDirRoot, outDirClient];
|
|
51
|
+
if (!isPrerenderingEnabledForAllPages)
|
|
52
|
+
dirS.push(outDirServer);
|
|
53
|
+
dirS.forEach((outDirAny) => {
|
|
50
54
|
assertUsage(fs.existsSync(outDirAny), `Cannot run ${pc.cyan('$ vike preview')}: your app isn't built (the build directory ${pc.cyan(outDirAny)} is missing). Make sure to run ${pc.cyan('$ vike build')} before running ${pc.cyan('$ vike preview')}.`);
|
|
51
55
|
});
|
|
52
56
|
}
|
|
@@ -5,6 +5,7 @@ import type { PageConfigBuildTime } from '../../shared/page-configs/PageConfig.j
|
|
|
5
5
|
declare function resolvePrerenderConfigGlobal(vikeConfig: VikeConfigObject): {
|
|
6
6
|
partial: boolean;
|
|
7
7
|
noExtraDir: boolean;
|
|
8
|
+
keepDistServer: boolean;
|
|
8
9
|
parallel: number | boolean;
|
|
9
10
|
disableAutoRun: boolean;
|
|
10
11
|
} & {
|
|
@@ -10,6 +10,7 @@ function resolvePrerenderConfigGlobal(vikeConfig) {
|
|
|
10
10
|
const prerenderConfigGlobal = {
|
|
11
11
|
partial: pickFirst(prerenderSettings.map((c) => c.partial)) ?? false,
|
|
12
12
|
noExtraDir: pickFirst(prerenderSettings.map((c) => c.noExtraDir)) ?? false,
|
|
13
|
+
keepDistServer: pickFirst(prerenderSettings.map((c) => c.keepDistServer)) ?? false,
|
|
13
14
|
parallel: pickFirst(prerenderSettings.map((c) => c.parallel)) ?? true,
|
|
14
15
|
disableAutoRun: pickFirst(prerenderSettings.map((c) => c.disableAutoRun)) ?? false
|
|
15
16
|
};
|
|
@@ -46,7 +46,7 @@ declare function runPrerenderFromAPI(options?: PrerenderOptions): Promise<{
|
|
|
46
46
|
viteConfig: ResolvedConfig;
|
|
47
47
|
}>;
|
|
48
48
|
declare function runPrerenderFromCLIPrerenderCommand(): Promise<void>;
|
|
49
|
-
declare function runPrerenderFromAutoRun(viteConfig: InlineConfig | undefined
|
|
49
|
+
declare function runPrerenderFromAutoRun(viteConfig: InlineConfig | undefined): Promise<{
|
|
50
50
|
forceExit: boolean;
|
|
51
51
|
}>;
|
|
52
52
|
declare function runPrerender_forceExit(): void;
|
|
@@ -31,6 +31,7 @@ import { getOutDirs } from '../plugin/shared/getOutDirs.js';
|
|
|
31
31
|
import { isVikeCli } from '../cli/context.js';
|
|
32
32
|
import { isViteCliCall } from '../plugin/shared/isViteCliCall.js';
|
|
33
33
|
import { getVikeConfigPublic } from '../plugin/plugins/commonConfig.js';
|
|
34
|
+
import fs from 'node:fs';
|
|
34
35
|
async function runPrerenderFromAPI(options = {}) {
|
|
35
36
|
return await runPrerender(options, 'prerender()');
|
|
36
37
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
@@ -50,11 +51,9 @@ async function runPrerenderFromCLIPrerenderCommand() {
|
|
|
50
51
|
runPrerender_forceExit();
|
|
51
52
|
assert(false);
|
|
52
53
|
}
|
|
53
|
-
async function runPrerenderFromAutoRun(viteConfig
|
|
54
|
-
let prerenderContextPublic;
|
|
54
|
+
async function runPrerenderFromAutoRun(viteConfig) {
|
|
55
55
|
try {
|
|
56
|
-
|
|
57
|
-
prerenderContextPublic = ret.prerenderContextPublic;
|
|
56
|
+
await runPrerender({ viteConfig });
|
|
58
57
|
}
|
|
59
58
|
catch (err) {
|
|
60
59
|
// Avoid Rollup prefixing the error with [vike:build:pluginAutoFullBuild], see for example https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
@@ -62,8 +61,6 @@ async function runPrerenderFromAutoRun(viteConfig, config) {
|
|
|
62
61
|
logErrorHint(err);
|
|
63
62
|
process.exit(1);
|
|
64
63
|
}
|
|
65
|
-
const vike = getVikeConfigPublic(config);
|
|
66
|
-
vike.prerenderContext = prerenderContextPublic;
|
|
67
64
|
const forceExit = isVikeCli() || isViteCliCall();
|
|
68
65
|
return { forceExit };
|
|
69
66
|
}
|
|
@@ -80,7 +77,9 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
80
77
|
await disableReactStreaming();
|
|
81
78
|
const viteConfig = await resolveConfig(options.viteConfig || {}, 'build', 'production');
|
|
82
79
|
const vikeConfig = await getVikeConfig(viteConfig);
|
|
83
|
-
const
|
|
80
|
+
const vike = getVikeConfigPublic(viteConfig);
|
|
81
|
+
assert(vike.prerenderContext.isPrerenderingEnabled);
|
|
82
|
+
const { outDirClient, outDirServer } = getOutDirs(viteConfig);
|
|
84
83
|
const { root } = viteConfig;
|
|
85
84
|
const prerenderConfigGlobal = resolvePrerenderConfigGlobal(vikeConfig);
|
|
86
85
|
validatePrerenderConfig(prerenderConfigGlobal);
|
|
@@ -123,7 +122,11 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
123
122
|
}
|
|
124
123
|
await warnMissingPages(prerenderContext.prerenderedPageContexts, globalContext, doNotPrerenderList, partial);
|
|
125
124
|
const prerenderContextPublic = makePublic(prerenderContext);
|
|
126
|
-
|
|
125
|
+
objectAssign(vike.prerenderContext, prerenderContextPublic);
|
|
126
|
+
if (prerenderConfigGlobal.isPrerenderingEnabledForAllPages && !prerenderConfigGlobal.keepDistServer) {
|
|
127
|
+
fs.rmSync(outDirServer, { recursive: true });
|
|
128
|
+
}
|
|
129
|
+
return { viteConfig };
|
|
127
130
|
}
|
|
128
131
|
async function collectDoNoPrerenderList(pageConfigs, doNotPrerenderList, defaultLocalValue, concurrencyLimit, globalContext) {
|
|
129
132
|
// V1 design
|
|
@@ -592,6 +595,12 @@ async function write(urlOriginal, pageContext, fileType, fileContent, root, outD
|
|
|
592
595
|
assertPosixPath(outDirClient);
|
|
593
596
|
assertPosixPath(filePathRelative);
|
|
594
597
|
const filePath = path.posix.join(outDirClient, filePathRelative);
|
|
598
|
+
objectAssign(pageContext, {
|
|
599
|
+
_prerenderResult: {
|
|
600
|
+
filePath,
|
|
601
|
+
fileContent
|
|
602
|
+
}
|
|
603
|
+
});
|
|
595
604
|
output.push({
|
|
596
605
|
filePath,
|
|
597
606
|
fileType,
|
|
@@ -599,15 +608,7 @@ async function write(urlOriginal, pageContext, fileType, fileContent, root, outD
|
|
|
599
608
|
pageContext
|
|
600
609
|
});
|
|
601
610
|
if (onPagePrerender) {
|
|
602
|
-
|
|
603
|
-
objectAssign(prerenderPageContext, pageContext);
|
|
604
|
-
objectAssign(prerenderPageContext, {
|
|
605
|
-
_prerenderResult: {
|
|
606
|
-
filePath,
|
|
607
|
-
fileContent
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
await onPagePrerender(prerenderPageContext);
|
|
611
|
+
await onPagePrerender(pageContext);
|
|
611
612
|
}
|
|
612
613
|
else {
|
|
613
614
|
const { promises } = await import('fs');
|
|
@@ -308,6 +308,16 @@ type ConfigBuiltIn = {
|
|
|
308
308
|
* @default true
|
|
309
309
|
*/
|
|
310
310
|
enable?: boolean | null;
|
|
311
|
+
/**
|
|
312
|
+
* If you pre-render all your pages then Vike removes the `dist/server/` directory after pre-rendering has finished.
|
|
313
|
+
*
|
|
314
|
+
* If you set this setting to `true` then Vike won't remove the `dist/server/` directory.
|
|
315
|
+
*
|
|
316
|
+
* https://vike.dev/prerender#keepDistServer
|
|
317
|
+
*
|
|
318
|
+
* @default false
|
|
319
|
+
*/
|
|
320
|
+
keepDistServer?: boolean;
|
|
311
321
|
};
|
|
312
322
|
/**
|
|
313
323
|
* Install Vike extensions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.227-commit-c9cc081";
|
|
@@ -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.227-commit-c9cc081';
|
package/dist/esm/utils/assert.js
CHANGED
|
@@ -93,12 +93,9 @@ function assertWarning(condition, msg, { onlyOnce, showStackTrace }) {
|
|
|
93
93
|
if (onlyOnce) {
|
|
94
94
|
const { alreadyLogged } = globalObject;
|
|
95
95
|
const key = onlyOnce === true ? msg : onlyOnce;
|
|
96
|
-
if (alreadyLogged.has(key))
|
|
96
|
+
if (alreadyLogged.has(key))
|
|
97
97
|
return;
|
|
98
|
-
|
|
99
|
-
else {
|
|
100
|
-
alreadyLogged.add(key);
|
|
101
|
-
}
|
|
98
|
+
alreadyLogged.add(key);
|
|
102
99
|
}
|
|
103
100
|
globalObject.onBeforeLog?.();
|
|
104
101
|
if (showStackTrace) {
|
|
@@ -11,13 +11,24 @@ import { PROJECT_VERSION } from './PROJECT_VERSION.js';
|
|
|
11
11
|
/* Use original assertWarning() after all CJS is removed from node_modules/vike/dist/
|
|
12
12
|
import { assertWarning } from './assert.js'
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
let globalObject;
|
|
15
|
+
// getGlobalObjectSafe() can be called before this line
|
|
16
|
+
globalObject ?? (globalObject = genGlobalConfig());
|
|
17
|
+
function genGlobalConfig() {
|
|
18
|
+
return getGlobalObject('utils/assertSingleInstance.ts', {
|
|
19
|
+
instances: [],
|
|
20
|
+
alreadyLogged: new Set()
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// We need getGlobalObjectSafe() because globalObject is `undefined` when exported functions are called before globalObject is initialized
|
|
24
|
+
function getGlobalObjectSafe() {
|
|
25
|
+
globalObject ?? (globalObject = genGlobalConfig());
|
|
26
|
+
return globalObject;
|
|
27
|
+
}
|
|
18
28
|
const clientRuntimesClonflict = 'Client runtime of both Server Routing and Client Routing loaded https://vike.dev/client-runtimes-conflict';
|
|
19
29
|
const clientNotSingleInstance = 'Client runtime loaded twice https://vike.dev/client-runtime-duplicated';
|
|
20
30
|
function assertSingleInstance() {
|
|
31
|
+
const globalObject = getGlobalObjectSafe();
|
|
21
32
|
{
|
|
22
33
|
const versions = unique(globalObject.instances);
|
|
23
34
|
assertWarning(versions.length <= 1,
|
|
@@ -34,6 +45,7 @@ function assertSingleInstance() {
|
|
|
34
45
|
}
|
|
35
46
|
}
|
|
36
47
|
function assertSingleInstance_onClientEntryServerRouting(isProduction) {
|
|
48
|
+
const globalObject = getGlobalObjectSafe();
|
|
37
49
|
assertWarning(globalObject.isClientRouting !== true, clientRuntimesClonflict, {
|
|
38
50
|
onlyOnce: true,
|
|
39
51
|
showStackTrace: true
|
|
@@ -48,6 +60,7 @@ function assertSingleInstance_onClientEntryServerRouting(isProduction) {
|
|
|
48
60
|
assertSingleInstance();
|
|
49
61
|
}
|
|
50
62
|
function assertSingleInstance_onClientEntryClientRouting(isProduction) {
|
|
63
|
+
const globalObject = getGlobalObjectSafe();
|
|
51
64
|
assertWarning(globalObject.isClientRouting !== false, clientRuntimesClonflict, {
|
|
52
65
|
onlyOnce: true,
|
|
53
66
|
showStackTrace: true
|
|
@@ -63,10 +76,12 @@ function assertSingleInstance_onClientEntryClientRouting(isProduction) {
|
|
|
63
76
|
}
|
|
64
77
|
// Called by utils/assert.ts which is (most certainly) loaded by all entries. That way we don't have to call a callback for every entry. (There are a lot of entries: `client/router/`, `client/`, `node/runtime/`, `node/plugin/`, `node/cli`.)
|
|
65
78
|
function assertSingleInstance_onAssertModuleLoad() {
|
|
79
|
+
const globalObject = getGlobalObjectSafe();
|
|
66
80
|
globalObject.instances.push(PROJECT_VERSION);
|
|
67
81
|
assertSingleInstance();
|
|
68
82
|
}
|
|
69
83
|
function assertWarning(condition, errorMessage, { onlyOnce, showStackTrace }) {
|
|
84
|
+
const globalObject = getGlobalObjectSafe();
|
|
70
85
|
if (condition) {
|
|
71
86
|
return;
|
|
72
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.227-commit-c9cc081",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -129,6 +129,7 @@
|
|
|
129
129
|
"es-module-lexer": "^1.0.0",
|
|
130
130
|
"esbuild": "^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0",
|
|
131
131
|
"json5": "^2.0.0",
|
|
132
|
+
"magic-string": "^0.30.17",
|
|
132
133
|
"picomatch": "^4.0.2",
|
|
133
134
|
"semver": "^7.0.0",
|
|
134
135
|
"sirv": "^3.0.1",
|