vike 0.4.218-commit-ea8bb27 → 0.4.218-commit-65f582c
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/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +22 -14
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSetup.js +22 -14
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ function onSetupRuntime() {
|
|
|
35
35
|
return;
|
|
36
36
|
if (!isViteLoaded()) {
|
|
37
37
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
38
|
-
(0, assert_js_1.assertWarning)(!isNodeEnvDev(), `The ${getEnvDescription()}, which
|
|
38
|
+
(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 });
|
|
39
39
|
(0, assert_js_1.assertUsage)(!setup.vikeVitePlugin, "Loading Vike's Vite plugin (the vike/plugin module) is prohibited in production.");
|
|
40
40
|
// This assert() one of the main goal of this file: it ensures assertIsNotProductionRuntime()
|
|
41
41
|
(0, assert_js_1.assert)(!setup.shouldNotBeProduction);
|
|
@@ -62,7 +62,7 @@ function onSetupBuild() {
|
|
|
62
62
|
}
|
|
63
63
|
function onSetupPrerender() {
|
|
64
64
|
markSetup_isPrerendering();
|
|
65
|
-
if (
|
|
65
|
+
if (getNodeEnv())
|
|
66
66
|
assertUsageNodeEnvIsNotDev('pre-rendering');
|
|
67
67
|
setNodeEnvProduction();
|
|
68
68
|
}
|
|
@@ -71,7 +71,7 @@ function isViteLoaded() {
|
|
|
71
71
|
return setup.viteDevServer || setup.vitePreviewServer || setup.isViteDev !== undefined;
|
|
72
72
|
}
|
|
73
73
|
function isTest() {
|
|
74
|
-
return (0, isVitest_js_1.isVitest)() ||
|
|
74
|
+
return (0, isVitest_js_1.isVitest)() || isNodeEnv('test');
|
|
75
75
|
}
|
|
76
76
|
// Called by Vite hook configureServer()
|
|
77
77
|
function markSetup_viteDevServer() {
|
|
@@ -110,26 +110,34 @@ function assertUsageNodeEnvIsNotDev(operation) {
|
|
|
110
110
|
(0, assert_js_1.assertWarning)(false, `The ${getEnvDescription()} which is forbidden upon ${operation}, see https://vike.dev/NODE_ENV`, { onlyOnce: true });
|
|
111
111
|
}
|
|
112
112
|
function getEnvDescription() {
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const envType = `${(isDev ? 'development' : 'production')} environment`;
|
|
116
|
-
const nodeEnvDesc = `environment is set to be a ${picocolors_1.default.bold(envType)} by ${picocolors_1.default.cyan(`process.env.NODE_ENV===${JSON.stringify(nodeEnv)}`)}`;
|
|
113
|
+
const envType = `${(isNodeEnvDev() ? 'development' : 'production')} environment`;
|
|
114
|
+
const nodeEnvDesc = `environment is set to be a ${picocolors_1.default.bold(envType)} by ${picocolors_1.default.cyan(`process.env.NODE_ENV===${JSON.stringify(getNodeEnv())}`)}`;
|
|
117
115
|
return nodeEnvDesc;
|
|
118
116
|
}
|
|
119
117
|
function isNodeEnvDev() {
|
|
120
|
-
const nodeEnv =
|
|
118
|
+
const nodeEnv = getNodeEnv();
|
|
121
119
|
// That's quite strict, let's see if some user complains
|
|
122
|
-
return !nodeEnv || ['development', 'dev']
|
|
120
|
+
return !nodeEnv || isNodeEnv(['development', 'dev']);
|
|
123
121
|
}
|
|
124
|
-
function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return
|
|
122
|
+
function isNodeEnv(value) {
|
|
123
|
+
const values = Array.isArray(value) ? value : [value];
|
|
124
|
+
const nodeEnv = getNodeEnv();
|
|
125
|
+
return nodeEnv !== undefined && values.includes(nodeEnv.toLowerCase());
|
|
126
|
+
}
|
|
127
|
+
function getNodeEnv() {
|
|
128
|
+
let val;
|
|
129
|
+
try {
|
|
130
|
+
val = process.env.NODE_ENV;
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return val;
|
|
128
136
|
}
|
|
129
137
|
function setNodeEnvProduction() {
|
|
130
138
|
// The statement `process.env['NODE_ENV'] = 'production'` chokes webpack v4
|
|
131
139
|
const proc = process;
|
|
132
140
|
const { env } = proc;
|
|
133
141
|
env.NODE_ENV = 'production';
|
|
134
|
-
(0, assert_js_1.assert)(
|
|
142
|
+
(0, assert_js_1.assert)(isNodeEnv('production'));
|
|
135
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.218-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.218-commit-65f582c";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.218-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.218-commit-65f582c';
|
|
@@ -30,7 +30,7 @@ function onSetupRuntime() {
|
|
|
30
30
|
return;
|
|
31
31
|
if (!isViteLoaded()) {
|
|
32
32
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
33
|
-
assertWarning(!isNodeEnvDev(), `The ${getEnvDescription()}, which
|
|
33
|
+
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 });
|
|
34
34
|
assertUsage(!setup.vikeVitePlugin, "Loading Vike's Vite plugin (the vike/plugin module) is prohibited in production.");
|
|
35
35
|
// This assert() one of the main goal of this file: it ensures assertIsNotProductionRuntime()
|
|
36
36
|
assert(!setup.shouldNotBeProduction);
|
|
@@ -57,7 +57,7 @@ function onSetupBuild() {
|
|
|
57
57
|
}
|
|
58
58
|
function onSetupPrerender() {
|
|
59
59
|
markSetup_isPrerendering();
|
|
60
|
-
if (
|
|
60
|
+
if (getNodeEnv())
|
|
61
61
|
assertUsageNodeEnvIsNotDev('pre-rendering');
|
|
62
62
|
setNodeEnvProduction();
|
|
63
63
|
}
|
|
@@ -66,7 +66,7 @@ function isViteLoaded() {
|
|
|
66
66
|
return setup.viteDevServer || setup.vitePreviewServer || setup.isViteDev !== undefined;
|
|
67
67
|
}
|
|
68
68
|
function isTest() {
|
|
69
|
-
return isVitest() ||
|
|
69
|
+
return isVitest() || isNodeEnv('test');
|
|
70
70
|
}
|
|
71
71
|
// Called by Vite hook configureServer()
|
|
72
72
|
function markSetup_viteDevServer() {
|
|
@@ -105,26 +105,34 @@ function assertUsageNodeEnvIsNotDev(operation) {
|
|
|
105
105
|
assertWarning(false, `The ${getEnvDescription()} which is forbidden upon ${operation}, see https://vike.dev/NODE_ENV`, { onlyOnce: true });
|
|
106
106
|
}
|
|
107
107
|
function getEnvDescription() {
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const envType = `${(isDev ? 'development' : 'production')} environment`;
|
|
111
|
-
const nodeEnvDesc = `environment is set to be a ${pc.bold(envType)} by ${pc.cyan(`process.env.NODE_ENV===${JSON.stringify(nodeEnv)}`)}`;
|
|
108
|
+
const envType = `${(isNodeEnvDev() ? 'development' : 'production')} environment`;
|
|
109
|
+
const nodeEnvDesc = `environment is set to be a ${pc.bold(envType)} by ${pc.cyan(`process.env.NODE_ENV===${JSON.stringify(getNodeEnv())}`)}`;
|
|
112
110
|
return nodeEnvDesc;
|
|
113
111
|
}
|
|
114
112
|
function isNodeEnvDev() {
|
|
115
|
-
const nodeEnv =
|
|
113
|
+
const nodeEnv = getNodeEnv();
|
|
116
114
|
// That's quite strict, let's see if some user complains
|
|
117
|
-
return !nodeEnv || ['development', 'dev']
|
|
115
|
+
return !nodeEnv || isNodeEnv(['development', 'dev']);
|
|
118
116
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return
|
|
117
|
+
function isNodeEnv(value) {
|
|
118
|
+
const values = Array.isArray(value) ? value : [value];
|
|
119
|
+
const nodeEnv = getNodeEnv();
|
|
120
|
+
return nodeEnv !== undefined && values.includes(nodeEnv.toLowerCase());
|
|
121
|
+
}
|
|
122
|
+
function getNodeEnv() {
|
|
123
|
+
let val;
|
|
124
|
+
try {
|
|
125
|
+
val = process.env.NODE_ENV;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
return val;
|
|
123
131
|
}
|
|
124
132
|
function setNodeEnvProduction() {
|
|
125
133
|
// The statement `process.env['NODE_ENV'] = 'production'` chokes webpack v4
|
|
126
134
|
const proc = process;
|
|
127
135
|
const { env } = proc;
|
|
128
136
|
env.NODE_ENV = 'production';
|
|
129
|
-
assert(
|
|
137
|
+
assert(isNodeEnv('production'));
|
|
130
138
|
}
|