vike 0.4.218-commit-65f582c → 0.4.218-commit-8ebd8ee
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 +12 -3
- 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 +12 -3
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -33,6 +33,7 @@ function onSetupRuntime() {
|
|
|
33
33
|
debug('assertSetup()', new Error().stack);
|
|
34
34
|
if (isTest())
|
|
35
35
|
return;
|
|
36
|
+
assertNodeEnvIsNotUndefinedString();
|
|
36
37
|
if (!isViteLoaded()) {
|
|
37
38
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
38
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 });
|
|
@@ -41,8 +42,10 @@ function onSetupRuntime() {
|
|
|
41
42
|
(0, assert_js_1.assert)(!setup.shouldNotBeProduction);
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
if (!setup.vitePreviewServer && !setup.isPrerendering) {
|
|
46
|
+
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
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
|
+
}
|
|
46
49
|
// These two assert() calls aren't that interesting
|
|
47
50
|
(0, assert_js_1.assert)(setup.vikeVitePlugin);
|
|
48
51
|
(0, assert_js_1.assert)(setup.shouldNotBeProduction);
|
|
@@ -114,10 +117,16 @@ function getEnvDescription() {
|
|
|
114
117
|
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())}`)}`;
|
|
115
118
|
return nodeEnvDesc;
|
|
116
119
|
}
|
|
120
|
+
// For example, Wrangler bug replaces `process.env.NODE_ENV` with `"undefined"`
|
|
121
|
+
// https://github.com/cloudflare/workers-sdk/issues/7886
|
|
122
|
+
function assertNodeEnvIsNotUndefinedString() {
|
|
123
|
+
const nodeEnv = getNodeEnv();
|
|
124
|
+
(0, assert_js_1.assertWarning)(nodeEnv === 'undefined', `${picocolors_1.default.cyan('process.env.NODE_ENV=="undefined"')} which is unexpected: ${picocolors_1.default.cyan('process.env.NODE_ENV')} can be the value ${picocolors_1.default.cyan('undefined')} (in development) but it shouldn't be the string ${picocolors_1.default.cyan('"undefined"')} ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')}`, { onlyOnce: true });
|
|
125
|
+
}
|
|
117
126
|
function isNodeEnvDev() {
|
|
118
127
|
const nodeEnv = getNodeEnv();
|
|
119
128
|
// That's quite strict, let's see if some user complains
|
|
120
|
-
return
|
|
129
|
+
return nodeEnv === undefined || isNodeEnv(['development', 'dev', '']);
|
|
121
130
|
}
|
|
122
131
|
function isNodeEnv(value) {
|
|
123
132
|
const values = Array.isArray(value) ? value : [value];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.218-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.218-commit-8ebd8ee";
|
|
@@ -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-8ebd8ee';
|
|
@@ -28,6 +28,7 @@ function onSetupRuntime() {
|
|
|
28
28
|
debug('assertSetup()', new Error().stack);
|
|
29
29
|
if (isTest())
|
|
30
30
|
return;
|
|
31
|
+
assertNodeEnvIsNotUndefinedString();
|
|
31
32
|
if (!isViteLoaded()) {
|
|
32
33
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
33
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 });
|
|
@@ -36,8 +37,10 @@ function onSetupRuntime() {
|
|
|
36
37
|
assert(!setup.shouldNotBeProduction);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
if (!setup.vitePreviewServer && !setup.isPrerendering) {
|
|
41
|
+
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
42
|
+
assertWarning(isNodeEnvDev(), `The ${getEnvDescription()}, but Vite is loaded which is prohibited in production, see https://vike.dev/NODE_ENV`, { onlyOnce: true });
|
|
43
|
+
}
|
|
41
44
|
// These two assert() calls aren't that interesting
|
|
42
45
|
assert(setup.vikeVitePlugin);
|
|
43
46
|
assert(setup.shouldNotBeProduction);
|
|
@@ -109,10 +112,16 @@ function getEnvDescription() {
|
|
|
109
112
|
const nodeEnvDesc = `environment is set to be a ${pc.bold(envType)} by ${pc.cyan(`process.env.NODE_ENV===${JSON.stringify(getNodeEnv())}`)}`;
|
|
110
113
|
return nodeEnvDesc;
|
|
111
114
|
}
|
|
115
|
+
// For example, Wrangler bug replaces `process.env.NODE_ENV` with `"undefined"`
|
|
116
|
+
// https://github.com/cloudflare/workers-sdk/issues/7886
|
|
117
|
+
function assertNodeEnvIsNotUndefinedString() {
|
|
118
|
+
const nodeEnv = getNodeEnv();
|
|
119
|
+
assertWarning(nodeEnv === 'undefined', `${pc.cyan('process.env.NODE_ENV=="undefined"')} which is unexpected: ${pc.cyan('process.env.NODE_ENV')} can be the value ${pc.cyan('undefined')} (in development) but it shouldn't be the string ${pc.cyan('"undefined"')} ${pc.underline('https://vike.dev/NODE_ENV')}`, { onlyOnce: true });
|
|
120
|
+
}
|
|
112
121
|
function isNodeEnvDev() {
|
|
113
122
|
const nodeEnv = getNodeEnv();
|
|
114
123
|
// That's quite strict, let's see if some user complains
|
|
115
|
-
return
|
|
124
|
+
return nodeEnv === undefined || isNodeEnv(['development', 'dev', '']);
|
|
116
125
|
}
|
|
117
126
|
function isNodeEnv(value) {
|
|
118
127
|
const values = Array.isArray(value) ? value : [value];
|