vike 0.4.239-commit-9dcde6d → 0.4.239-commit-95ab407
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/esm/node/runtime/globalContext.js +26 -24
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +40 -24
- package/dist/esm/node/vite/shared/getMagicString.js +3 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +2 -2
|
@@ -543,35 +543,37 @@ function isProd() {
|
|
|
543
543
|
}
|
|
544
544
|
function isProdOptional() {
|
|
545
545
|
const vikeApiOperation = getVikeApiOperation()?.operation ?? null;
|
|
546
|
-
const yes =
|
|
547
546
|
// setGlobalContext_prodBuildEntry() was called
|
|
548
|
-
!!globalObject.prodBuildEntry
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
547
|
+
const yes1 = !!globalObject.prodBuildEntry;
|
|
548
|
+
const yes2 = globalObject.isPrerendering === true;
|
|
549
|
+
// Vike CLI & Vike API
|
|
550
|
+
const yes3 = !!vikeApiOperation && vikeApiOperation !== 'dev';
|
|
551
|
+
// Vite command
|
|
552
|
+
const yes4 = globalObject.isProductionAccordingToVite === true;
|
|
553
|
+
// getGlobalContextAsync(isProduction)
|
|
554
|
+
const yes5 = globalObject.isProductionAccordingToUser === true;
|
|
555
|
+
// vite-plugin-vercel
|
|
556
|
+
const yes6 = globalObject.isProductionAccordingToPhotonVercel === true;
|
|
557
|
+
const yes = yes1 || yes2 || yes3 || yes4 || yes5 || yes6;
|
|
558
|
+
const no1 = !!globalObject.viteDevServer;
|
|
559
|
+
// Vike CLI & Vike API
|
|
560
|
+
const no2 = vikeApiOperation === 'dev';
|
|
561
|
+
// Vite command
|
|
562
|
+
const no3 = globalObject.isProductionAccordingToVite === false;
|
|
563
|
+
// getGlobalContextAsync(isProduction)
|
|
564
|
+
const no4 = globalObject.isProductionAccordingToUser === false;
|
|
565
|
+
// @cloudflare/vite-plugin
|
|
566
|
+
const no5 = isNonRunnableDev() === true;
|
|
567
|
+
const no = no1 || no2 || no3 || no4 || no5;
|
|
568
|
+
const debug = { yes1, yes2, yes3, yes4, yes5, yes6, no1, no2, no3, no4, no5 };
|
|
569
|
+
assert(typeof yes === 'boolean', debug);
|
|
570
|
+
assert(typeof no === 'boolean', debug);
|
|
569
571
|
if (yes) {
|
|
570
|
-
assert(no === false);
|
|
572
|
+
assert(no === false, debug);
|
|
571
573
|
return true;
|
|
572
574
|
}
|
|
573
575
|
if (no) {
|
|
574
|
-
assert(yes === false);
|
|
576
|
+
assert(yes === false, debug);
|
|
575
577
|
return false;
|
|
576
578
|
}
|
|
577
579
|
return null;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
export { pluginNonRunnableDev };
|
|
2
|
-
import { createViteRPC, assertIsNotProductionRuntime,
|
|
2
|
+
import { createViteRPC, assertIsNotProductionRuntime, isRunnableDevEnvironment, assert, isDevCheck } from '../utils.js';
|
|
3
3
|
import { retrievePageAssetsDev } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsDev.js';
|
|
4
4
|
import { getViteConfigRuntime } from '../shared/getViteConfigRuntime.js';
|
|
5
5
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
6
|
+
// TODO/now: move to vite/index.ts
|
|
6
7
|
assertIsNotProductionRuntime();
|
|
7
|
-
|
|
8
|
-
const
|
|
8
|
+
/* We cannot use [`filter.id`](https://rolldown.rs/plugins/hook-filters) because Vite's optimizeDeps bundles the package `vike` into node_modules/.vite/deps_ssr/chunk-WBC5FHD7.js
|
|
9
|
+
const distFileIsNonRunnableDev = requireResolveDistFile('dist/esm/utils/isNonRunnableDev.js')
|
|
10
|
+
const distFileGlobalContext = requireResolveDistFile('dist/esm/node/runtime/globalContext.js')
|
|
9
11
|
const filterRolldown = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
id: {
|
|
13
|
+
include: [distFileIsNonRunnableDev, distFileGlobalContext].map(
|
|
14
|
+
(filePath) => new RegExp(`^${escapeRegex(filePath)}($|${escapeRegex('?')}.*)`),
|
|
15
|
+
),
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
*/
|
|
19
|
+
const __VIKE__DYNAMIC_IMPORT = '__VIKE__DYNAMIC_IMPORT';
|
|
20
|
+
const __VIKE__IS_NON_RUNNABLE_DEV = '__VIKE__IS_NON_RUNNABLE_DEV';
|
|
18
21
|
function getViteRpcFunctions(viteDevServer) {
|
|
19
22
|
return {
|
|
20
23
|
async transformIndexHtmlRPC(html) {
|
|
@@ -32,7 +35,7 @@ function pluginNonRunnableDev() {
|
|
|
32
35
|
let config;
|
|
33
36
|
return [
|
|
34
37
|
{
|
|
35
|
-
name: 'vike:pluginNonRunnableDev',
|
|
38
|
+
name: 'vike:pluginNonRunnableDev:1',
|
|
36
39
|
apply: (_, configEnv) => isDevCheck(configEnv),
|
|
37
40
|
configureServer: {
|
|
38
41
|
handler(viteDevServer) {
|
|
@@ -45,26 +48,39 @@ function pluginNonRunnableDev() {
|
|
|
45
48
|
},
|
|
46
49
|
},
|
|
47
50
|
transform: {
|
|
48
|
-
filter:
|
|
51
|
+
filter: {
|
|
52
|
+
code: {
|
|
53
|
+
include: __VIKE__IS_NON_RUNNABLE_DEV,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
handler(code, id) {
|
|
57
|
+
assert(config._isDev);
|
|
58
|
+
if (isRunnableDevEnvironment(this.environment))
|
|
59
|
+
return;
|
|
60
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
61
|
+
magicString.replaceAll(__VIKE__IS_NON_RUNNABLE_DEV, JSON.stringify(true));
|
|
62
|
+
return getMagicStringResult();
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'vike:pluginNonRunnableDev:2',
|
|
68
|
+
apply: (_, configEnv) => isDevCheck(configEnv),
|
|
69
|
+
transform: {
|
|
70
|
+
filter: {
|
|
71
|
+
code: {
|
|
72
|
+
include: __VIKE__DYNAMIC_IMPORT,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
49
75
|
handler(code, id) {
|
|
50
76
|
assert(config._isDev);
|
|
51
|
-
assert(filterFunction(id));
|
|
52
|
-
const idWithoutQuery = getIdWithoutQuery(id);
|
|
53
77
|
if (isRunnableDevEnvironment(this.environment))
|
|
54
78
|
return;
|
|
55
79
|
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
56
|
-
|
|
57
|
-
magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(true));
|
|
58
|
-
}
|
|
59
|
-
if (idWithoutQuery === distFileGlobalContext) {
|
|
60
|
-
magicString.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
|
|
61
|
-
}
|
|
80
|
+
magicString.replaceAll(__VIKE__DYNAMIC_IMPORT, 'import');
|
|
62
81
|
return getMagicStringResult();
|
|
63
82
|
},
|
|
64
83
|
},
|
|
65
84
|
},
|
|
66
85
|
];
|
|
67
86
|
}
|
|
68
|
-
function getIdWithoutQuery(id) {
|
|
69
|
-
return id.split('?')[0];
|
|
70
|
-
}
|
|
@@ -4,6 +4,9 @@ import MagicString from 'magic-string';
|
|
|
4
4
|
function getMagicString(code, id) {
|
|
5
5
|
const magicString = new MagicString(code);
|
|
6
6
|
const getMagicStringResult = () => {
|
|
7
|
+
/* TODO/now uncomment + dedupe
|
|
8
|
+
if (!magicString.hasChanged()) return undefined
|
|
9
|
+
*/
|
|
7
10
|
return {
|
|
8
11
|
code: magicString.toString(),
|
|
9
12
|
map: magicString.generateMap({ hires: true, source: id }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.239-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.239-commit-95ab407";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.239-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.239-commit-95ab407';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.239-commit-
|
|
3
|
+
"version": "0.4.239-commit-95ab407",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"@brillout/json-serializer": "^0.5.20",
|
|
118
118
|
"@brillout/picocolors": "^1.0.26",
|
|
119
119
|
"@brillout/require-shim": "^0.1.2",
|
|
120
|
-
"@brillout/vite-plugin-server-entry": "^0.7.
|
|
120
|
+
"@brillout/vite-plugin-server-entry": "^0.7.15",
|
|
121
121
|
"acorn": "^8.0.0",
|
|
122
122
|
"cac": "^6.0.0",
|
|
123
123
|
"es-module-lexer": "^1.0.0",
|