vike 0.4.225-commit-6fc12fc → 0.4.225-commit-765fb9c
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/prepareViteApiCall.js +1 -1
- package/dist/cjs/node/api/preview.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +15 -8
- package/dist/esm/node/api/prepareViteApiCall.js +1 -1
- package/dist/esm/node/api/preview.js +2 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSetup.d.ts +2 -2
- package/dist/esm/utils/assertSetup.js +15 -8
- package/package.json +1 -1
|
@@ -62,9 +62,9 @@ function clear() {
|
|
|
62
62
|
}
|
|
63
63
|
async function resolveConfigs(viteConfigFromUserApiOptions, operation) {
|
|
64
64
|
const viteInfo = await getViteInfo(viteConfigFromUserApiOptions, operation);
|
|
65
|
-
const { viteConfigResolved } = await assertViteRoot2(viteInfo.root, viteInfo.viteConfigFromUserEnhanced, operation);
|
|
66
65
|
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig2)(viteInfo.root, operation === 'dev', viteInfo.vikeVitePluginOptions);
|
|
67
66
|
const viteConfigFromUserEnhanced = applyVikeViteConfig(viteInfo.viteConfigFromUserEnhanced, vikeConfig);
|
|
67
|
+
const { viteConfigResolved } = await assertViteRoot2(viteInfo.root, viteConfigFromUserEnhanced, operation);
|
|
68
68
|
return {
|
|
69
69
|
vikeConfig,
|
|
70
70
|
viteConfigResolved, // ONLY USE if strictly necessary. (We plan to remove assertViteRoot2() as explained in the comments of that function.)
|
|
@@ -11,12 +11,14 @@ const getOutDirs_js_1 = require("../plugin/shared/getOutDirs.js");
|
|
|
11
11
|
const utils_js_1 = require("./utils.js");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
13
|
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const utils_js_2 = require("../runtime/utils.js");
|
|
14
15
|
/**
|
|
15
16
|
* Programmatically trigger `$ vike preview`
|
|
16
17
|
*
|
|
17
18
|
* https://vike.dev/api#preview
|
|
18
19
|
*/
|
|
19
20
|
async function preview(options = {}) {
|
|
21
|
+
(0, utils_js_2.onSetupPreview)();
|
|
20
22
|
const { viteConfigFromUserEnhanced, viteConfigResolved } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options, 'preview');
|
|
21
23
|
if (viteConfigResolved.vitePluginServerEntry?.inject) {
|
|
22
24
|
const outDir = (0, getOutDirs_js_1.getOutDirs)(viteConfigResolved).outDirRoot;
|
|
@@ -7,12 +7,12 @@ exports.assertIsNotProductionRuntime = assertIsNotProductionRuntime;
|
|
|
7
7
|
exports.onSetupRuntime = onSetupRuntime;
|
|
8
8
|
exports.onSetupBuild = onSetupBuild;
|
|
9
9
|
exports.onSetupPrerender = onSetupPrerender;
|
|
10
|
+
exports.onSetupPreview = onSetupPreview;
|
|
10
11
|
exports.setNodeEnvProduction = setNodeEnvProduction;
|
|
11
12
|
exports.markSetup_viteDevServer = markSetup_viteDevServer;
|
|
12
13
|
exports.markSetup_vitePreviewServer = markSetup_vitePreviewServer;
|
|
13
14
|
exports.markSetup_vikeVitePlugin = markSetup_vikeVitePlugin;
|
|
14
15
|
exports.markSetup_isViteDev = markSetup_isViteDev;
|
|
15
|
-
exports.markSetup_isPrerendering = markSetup_isPrerendering;
|
|
16
16
|
const assert_js_1 = require("./assert.js");
|
|
17
17
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
18
18
|
const debug_js_1 = require("./debug.js");
|
|
@@ -34,7 +34,7 @@ function onSetupRuntime() {
|
|
|
34
34
|
if (isTest())
|
|
35
35
|
return;
|
|
36
36
|
assertNodeEnvIsNotUndefinedString();
|
|
37
|
-
if (!
|
|
37
|
+
if (!setup.viteDevServer && setup.isViteDev === undefined) {
|
|
38
38
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
39
39
|
(0, assert_js_1.assertWarning)(!isNodeEnvDev(), `The ${getEnvDescription()}, which is contradictory because the environment seems to be a production environment (Vite isn't loaded), see https://vike.dev/NODE_ENV`, { onlyOnce: true });
|
|
40
40
|
(0, assert_js_1.assertUsage)(!setup.vikeVitePlugin, `Loading Vike's Vite plugin (the ${picocolors_1.default.cyan('vike/plugin')} module) is prohibited in production.`);
|
|
@@ -42,11 +42,10 @@ function onSetupRuntime() {
|
|
|
42
42
|
(0, assert_js_1.assert)(!setup.shouldNotBeProduction);
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
if (!setup.vitePreviewServer && !setup.isPrerendering) {
|
|
45
|
+
if (!setup.isPreview && !setup.vitePreviewServer && !setup.isPrerendering) {
|
|
46
46
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
47
47
|
(0, assert_js_1.assertWarning)(isNodeEnvDev(), `The ${getEnvDescription()}, but Vite is loaded which is prohibited in production, see https://vike.dev/NODE_ENV`, { onlyOnce: true });
|
|
48
48
|
}
|
|
49
|
-
// These two assert() calls aren't that interesting
|
|
50
49
|
(0, assert_js_1.assert)(setup.vikeVitePlugin);
|
|
51
50
|
(0, assert_js_1.assert)(setup.shouldNotBeProduction);
|
|
52
51
|
}
|
|
@@ -63,15 +62,19 @@ function onSetupBuild() {
|
|
|
63
62
|
setNodeEnvProduction()
|
|
64
63
|
*/
|
|
65
64
|
}
|
|
65
|
+
// Called by ../node/prerender/runPrerender.ts
|
|
66
66
|
function onSetupPrerender() {
|
|
67
67
|
markSetup_isPrerendering();
|
|
68
68
|
if (getNodeEnv())
|
|
69
69
|
assertUsageNodeEnvIsNotDev('pre-rendering');
|
|
70
70
|
setNodeEnvProduction();
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
// Called by ../node/api/preview.ts
|
|
73
|
+
function onSetupPreview() {
|
|
74
|
+
markSetup_isPreview();
|
|
75
|
+
if (getNodeEnv())
|
|
76
|
+
assertUsageNodeEnvIsNotDev('pre-rendering');
|
|
77
|
+
setNodeEnvProduction();
|
|
75
78
|
}
|
|
76
79
|
function isTest() {
|
|
77
80
|
return (0, isVitest_js_1.isVitest)() || isNodeEnv('test');
|
|
@@ -100,12 +103,16 @@ function markSetup_isViteDev(isViteDev) {
|
|
|
100
103
|
debug('markSetup_isViteDev()', new Error().stack);
|
|
101
104
|
setup.isViteDev = isViteDev;
|
|
102
105
|
}
|
|
103
|
-
// Called by ../node/prerender/runPrerender.ts
|
|
104
106
|
function markSetup_isPrerendering() {
|
|
105
107
|
if (debug.isActivated)
|
|
106
108
|
debug('markSetup_isPrerendering()', new Error().stack);
|
|
107
109
|
setup.isPrerendering = true;
|
|
108
110
|
}
|
|
111
|
+
function markSetup_isPreview() {
|
|
112
|
+
if (debug.isActivated)
|
|
113
|
+
debug('markSetup_isPreview()', new Error().stack);
|
|
114
|
+
setup.isPreview = true;
|
|
115
|
+
}
|
|
109
116
|
function assertUsageNodeEnvIsNotDev(operation) {
|
|
110
117
|
if (!isNodeEnvDev())
|
|
111
118
|
return;
|
|
@@ -24,9 +24,9 @@ function clear() {
|
|
|
24
24
|
}
|
|
25
25
|
async function resolveConfigs(viteConfigFromUserApiOptions, operation) {
|
|
26
26
|
const viteInfo = await getViteInfo(viteConfigFromUserApiOptions, operation);
|
|
27
|
-
const { viteConfigResolved } = await assertViteRoot2(viteInfo.root, viteInfo.viteConfigFromUserEnhanced, operation);
|
|
28
27
|
const vikeConfig = await getVikeConfig2(viteInfo.root, operation === 'dev', viteInfo.vikeVitePluginOptions);
|
|
29
28
|
const viteConfigFromUserEnhanced = applyVikeViteConfig(viteInfo.viteConfigFromUserEnhanced, vikeConfig);
|
|
29
|
+
const { viteConfigResolved } = await assertViteRoot2(viteInfo.root, viteConfigFromUserEnhanced, operation);
|
|
30
30
|
return {
|
|
31
31
|
vikeConfig,
|
|
32
32
|
viteConfigResolved, // ONLY USE if strictly necessary. (We plan to remove assertViteRoot2() as explained in the comments of that function.)
|
|
@@ -6,12 +6,14 @@ import { getOutDirs } from '../plugin/shared/getOutDirs.js';
|
|
|
6
6
|
import { assertWarning } from './utils.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
+
import { onSetupPreview } from '../runtime/utils.js';
|
|
9
10
|
/**
|
|
10
11
|
* Programmatically trigger `$ vike preview`
|
|
11
12
|
*
|
|
12
13
|
* https://vike.dev/api#preview
|
|
13
14
|
*/
|
|
14
15
|
async function preview(options = {}) {
|
|
16
|
+
onSetupPreview();
|
|
15
17
|
const { viteConfigFromUserEnhanced, viteConfigResolved } = await prepareViteApiCall(options, 'preview');
|
|
16
18
|
if (viteConfigResolved.vitePluginServerEntry?.inject) {
|
|
17
19
|
const outDir = getOutDirs(viteConfigResolved).outDirRoot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.225-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.225-commit-765fb9c";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.225-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.225-commit-765fb9c';
|
|
@@ -2,19 +2,19 @@ export { assertIsNotProductionRuntime };
|
|
|
2
2
|
export { onSetupRuntime };
|
|
3
3
|
export { onSetupBuild };
|
|
4
4
|
export { onSetupPrerender };
|
|
5
|
+
export { onSetupPreview };
|
|
5
6
|
export { setNodeEnvProduction };
|
|
6
7
|
export { markSetup_viteDevServer };
|
|
7
8
|
export { markSetup_vitePreviewServer };
|
|
8
9
|
export { markSetup_vikeVitePlugin };
|
|
9
10
|
export { markSetup_isViteDev };
|
|
10
|
-
export { markSetup_isPrerendering };
|
|
11
11
|
declare function assertIsNotProductionRuntime(): void | undefined;
|
|
12
12
|
declare function onSetupRuntime(): void | undefined;
|
|
13
13
|
declare function onSetupBuild(): void;
|
|
14
14
|
declare function onSetupPrerender(): void;
|
|
15
|
+
declare function onSetupPreview(): void;
|
|
15
16
|
declare function markSetup_viteDevServer(): void | undefined;
|
|
16
17
|
declare function markSetup_vitePreviewServer(): void | undefined;
|
|
17
18
|
declare function markSetup_vikeVitePlugin(): void;
|
|
18
19
|
declare function markSetup_isViteDev(isViteDev: boolean): void;
|
|
19
|
-
declare function markSetup_isPrerendering(): void;
|
|
20
20
|
declare function setNodeEnvProduction(): void | undefined;
|
|
@@ -2,12 +2,12 @@ export { assertIsNotProductionRuntime };
|
|
|
2
2
|
export { onSetupRuntime };
|
|
3
3
|
export { onSetupBuild };
|
|
4
4
|
export { onSetupPrerender };
|
|
5
|
+
export { onSetupPreview };
|
|
5
6
|
export { setNodeEnvProduction };
|
|
6
7
|
export { markSetup_viteDevServer };
|
|
7
8
|
export { markSetup_vitePreviewServer };
|
|
8
9
|
export { markSetup_vikeVitePlugin };
|
|
9
10
|
export { markSetup_isViteDev };
|
|
10
|
-
export { markSetup_isPrerendering };
|
|
11
11
|
import { assert, assertUsage, assertWarning } from './assert.js';
|
|
12
12
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
13
13
|
import { createDebugger } from './debug.js';
|
|
@@ -29,7 +29,7 @@ function onSetupRuntime() {
|
|
|
29
29
|
if (isTest())
|
|
30
30
|
return;
|
|
31
31
|
assertNodeEnvIsNotUndefinedString();
|
|
32
|
-
if (!
|
|
32
|
+
if (!setup.viteDevServer && setup.isViteDev === undefined) {
|
|
33
33
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
34
34
|
assertWarning(!isNodeEnvDev(), `The ${getEnvDescription()}, which is contradictory because the environment seems to be a production environment (Vite isn't loaded), see https://vike.dev/NODE_ENV`, { onlyOnce: true });
|
|
35
35
|
assertUsage(!setup.vikeVitePlugin, `Loading Vike's Vite plugin (the ${pc.cyan('vike/plugin')} module) is prohibited in production.`);
|
|
@@ -37,11 +37,10 @@ function onSetupRuntime() {
|
|
|
37
37
|
assert(!setup.shouldNotBeProduction);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
if (!setup.vitePreviewServer && !setup.isPrerendering) {
|
|
40
|
+
if (!setup.isPreview && !setup.vitePreviewServer && !setup.isPrerendering) {
|
|
41
41
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
42
42
|
assertWarning(isNodeEnvDev(), `The ${getEnvDescription()}, but Vite is loaded which is prohibited in production, see https://vike.dev/NODE_ENV`, { onlyOnce: true });
|
|
43
43
|
}
|
|
44
|
-
// These two assert() calls aren't that interesting
|
|
45
44
|
assert(setup.vikeVitePlugin);
|
|
46
45
|
assert(setup.shouldNotBeProduction);
|
|
47
46
|
}
|
|
@@ -58,15 +57,19 @@ function onSetupBuild() {
|
|
|
58
57
|
setNodeEnvProduction()
|
|
59
58
|
*/
|
|
60
59
|
}
|
|
60
|
+
// Called by ../node/prerender/runPrerender.ts
|
|
61
61
|
function onSetupPrerender() {
|
|
62
62
|
markSetup_isPrerendering();
|
|
63
63
|
if (getNodeEnv())
|
|
64
64
|
assertUsageNodeEnvIsNotDev('pre-rendering');
|
|
65
65
|
setNodeEnvProduction();
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
// Called by ../node/api/preview.ts
|
|
68
|
+
function onSetupPreview() {
|
|
69
|
+
markSetup_isPreview();
|
|
70
|
+
if (getNodeEnv())
|
|
71
|
+
assertUsageNodeEnvIsNotDev('pre-rendering');
|
|
72
|
+
setNodeEnvProduction();
|
|
70
73
|
}
|
|
71
74
|
function isTest() {
|
|
72
75
|
return isVitest() || isNodeEnv('test');
|
|
@@ -95,12 +98,16 @@ function markSetup_isViteDev(isViteDev) {
|
|
|
95
98
|
debug('markSetup_isViteDev()', new Error().stack);
|
|
96
99
|
setup.isViteDev = isViteDev;
|
|
97
100
|
}
|
|
98
|
-
// Called by ../node/prerender/runPrerender.ts
|
|
99
101
|
function markSetup_isPrerendering() {
|
|
100
102
|
if (debug.isActivated)
|
|
101
103
|
debug('markSetup_isPrerendering()', new Error().stack);
|
|
102
104
|
setup.isPrerendering = true;
|
|
103
105
|
}
|
|
106
|
+
function markSetup_isPreview() {
|
|
107
|
+
if (debug.isActivated)
|
|
108
|
+
debug('markSetup_isPreview()', new Error().stack);
|
|
109
|
+
setup.isPreview = true;
|
|
110
|
+
}
|
|
104
111
|
function assertUsageNodeEnvIsNotDev(operation) {
|
|
105
112
|
if (!isNodeEnvDev())
|
|
106
113
|
return;
|