vike 0.4.255 → 0.4.256-commit-414bdc0
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/client/runtime-client-routing/createPageContextClient.d.ts +2 -24
- package/dist/client/runtime-client-routing/getGlobalContextClientInternal.d.ts +2 -24
- package/dist/client/runtime-client-routing/getPageContextFromHooks.d.ts +8 -96
- package/dist/client/runtime-client-routing/renderPageClient.d.ts +8 -96
- package/dist/client/runtime-server-routing/createPageContextClient.d.ts +2 -24
- package/dist/client/runtime-server-routing/getGlobalContextClientInternal.d.ts +2 -24
- package/dist/client/shared/getGlobalContextClientInternalShared.d.ts +2 -24
- package/dist/node/prerender/runPrerender.d.ts +9 -36
- package/dist/node/prerender/runPrerender.js +17 -11
- package/dist/node/vite/index.js +2 -0
- package/dist/node/vite/plugins/pluginExtractAssets.js +2 -0
- package/dist/node/vite/plugins/pluginReplaceConstantsGlobalThis.js +2 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/common.d.ts +20 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/common.js +7 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/detectDeprecated.d.ts +3 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/detectDeprecated.js +15 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/getDeployConfigs.d.ts +27 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/getDeployConfigs.js +70 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/getServerInfo.d.ts +7 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/getServerInfo.js +33 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/pluginResolveAlias.d.ts +3 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/pluginResolveAlias.js +19 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/pluginResolvePlusServer.d.ts +6 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/pluginResolvePlusServer.js +22 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/pluginUnwrapProdOptions.d.ts +3 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/pluginUnwrapProdOptions.js +19 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/pluginVikeVirtualEntry.d.ts +3 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy/pluginVikeVirtualEntry.js +25 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy.d.ts +5 -0
- package/dist/node/vite/plugins/pluginUniversalDeploy.js +58 -0
- package/dist/node/vite/shared/addSsrMiddleware.js +1 -0
- package/dist/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +18 -0
- package/dist/server/assertEnvServer.js +1 -1
- package/dist/server/runtime/fetch.d.ts +10 -0
- package/dist/server/runtime/fetch.js +5 -0
- package/dist/server/runtime/globalContext.d.ts +10 -120
- package/dist/server/runtime/renderPageServer/createHttpResponse.d.ts +5 -3
- package/dist/server/runtime/renderPageServer/createHttpResponse.js +13 -1
- package/dist/server/runtime/renderPageServer/createPageContextServer.d.ts +15 -39
- package/dist/server/runtime/renderPageServer/loadPageConfigsLazyServerSide.d.ts +9 -36
- package/dist/server/runtime/renderPageServer/renderPageServerAfterRoute.d.ts +36 -144
- package/dist/server/runtime/renderPageServer.d.ts +13 -39
- package/dist/server/runtime/renderPageServer.js +51 -3
- package/dist/server/runtime/universal-middleware.d.ts +9 -2
- package/dist/server/runtime/universal-middleware.js +9 -1
- package/dist/shared-server-client/createGlobalContextShared.d.ts +4 -48
- package/dist/shared-server-client/page-configs/resolveVikeConfigPublic.d.ts +1 -0
- package/dist/types/Config.d.ts +28 -1
- package/dist/types/PageContext.d.ts +6 -0
- package/dist/types/Server.d.ts +8 -0
- package/dist/types/Server.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/dist/utils/assertKeys.js +2 -2
- package/dist/utils/assertNodeVersion.js +1 -1
- package/dist/utils/assertVersion.js +1 -1
- package/dist/utils/joinEnglish.d.ts +4 -1
- package/dist/utils/joinEnglish.js +4 -4
- package/dist/utils/path.js +1 -1
- package/fetch.js +3 -0
- package/package.json +29 -11
package/dist/node/vite/index.js
CHANGED
|
@@ -40,6 +40,7 @@ import { pluginStripPointerImportAttribute } from './plugins/pluginStripPointerI
|
|
|
40
40
|
import { getVikeConfigInternalEarly, isOnlyResolvingUserConfig } from '../api/resolveViteConfigFromUser.js';
|
|
41
41
|
import './assertEnvVite.js';
|
|
42
42
|
import { isStorybook } from '../../utils/isStorybook.js';
|
|
43
|
+
import { pluginUniversalDeploy } from './plugins/pluginUniversalDeploy.js';
|
|
43
44
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
44
45
|
setGetClientEntrySrcDev(getClientEntrySrcDev);
|
|
45
46
|
assertIsNotProductionRuntime();
|
|
@@ -70,6 +71,7 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
70
71
|
...pluginStaticReplace(vikeConfig),
|
|
71
72
|
...pluginNonRunnabeDev(),
|
|
72
73
|
...pluginStripPointerImportAttribute(),
|
|
74
|
+
...pluginUniversalDeploy(vikeConfig),
|
|
73
75
|
...(await pluginViteConfigVikeExtensions(vikeConfig)),
|
|
74
76
|
];
|
|
75
77
|
Object.assign(plugin, pluginAddendum);
|
|
@@ -41,6 +41,8 @@ const filterFunction = (id) => extractAssetsRE.test(id);
|
|
|
41
41
|
function pluginExtractAssets() {
|
|
42
42
|
let config;
|
|
43
43
|
let vikeConfig;
|
|
44
|
+
if (handleAssetsManifest_isFixEnabled())
|
|
45
|
+
return [];
|
|
44
46
|
let isFixEnabled;
|
|
45
47
|
return [
|
|
46
48
|
// This plugin removes all JavaScript from server-side only code, so that only CSS imports remains. (And also static files imports e.g. `import logoURL from './logo.svg.js'`).
|
|
@@ -39,9 +39,11 @@ function pluginReplaceConstantsGlobalThis() {
|
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
configEnvironment: {
|
|
42
|
+
order: 'pre',
|
|
42
43
|
handler(name, config) {
|
|
43
44
|
const isClientSide = !isViteServerSide_configEnvironment(name, config);
|
|
44
45
|
return {
|
|
46
|
+
consumer: isClientSide ? 'client' : 'server',
|
|
45
47
|
define: {
|
|
46
48
|
'globalThis.__VIKE__IS_CLIENT': JSON.stringify(isClientSide),
|
|
47
49
|
},
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import '../../assertEnvVite.js';
|
|
3
|
+
export declare const pluginCommon: {
|
|
4
|
+
applyToEnvironment(env: {
|
|
5
|
+
name: string;
|
|
6
|
+
getTopLevelConfig(): import("vite").ResolvedConfig;
|
|
7
|
+
config: import("vite").ResolvedConfig & {
|
|
8
|
+
define?: Record<string, any>;
|
|
9
|
+
resolve: Required<import("vite").ResolveOptions>;
|
|
10
|
+
consumer: "client" | "server";
|
|
11
|
+
keepProcessEnv?: boolean;
|
|
12
|
+
optimizeDeps: import("vite").DepOptimizationOptions;
|
|
13
|
+
dev: import("vite").ResolvedDevEnvironmentOptions;
|
|
14
|
+
build: import("vite").ResolvedBuildEnvironmentOptions;
|
|
15
|
+
plugins: readonly Plugin[];
|
|
16
|
+
};
|
|
17
|
+
logger: import("vite").Logger;
|
|
18
|
+
}): boolean;
|
|
19
|
+
sharedDuringBuild: true;
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { assertWarning } from '../../../../utils/assert.js';
|
|
2
|
+
import pc from '@brillout/picocolors';
|
|
3
|
+
import '../../assertEnvVite.js';
|
|
4
|
+
export function hasVikeServerOrVikePhoton(vikeConfig) {
|
|
5
|
+
const vikeExtendsNames = new Set(vikeConfig._extensions.map((plusFile) => ('fileExportsByConfigName' in plusFile ? plusFile.fileExportsByConfigName : {}).name));
|
|
6
|
+
const vikeServerOrVikePhoton = vikeExtendsNames.has('vike-server')
|
|
7
|
+
? 'vike-server'
|
|
8
|
+
: vikeExtendsNames.has('vike-photon')
|
|
9
|
+
? 'vike-photon'
|
|
10
|
+
: null;
|
|
11
|
+
if (vikeServerOrVikePhoton) {
|
|
12
|
+
assertWarning(false, `${pc.cyan(vikeServerOrVikePhoton)} is deprecated, see ${pc.underline('https://vike.dev/migration/universal-deploy')}`, { onlyOnce: true });
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { getDeployConfigs };
|
|
2
|
+
import type { fromVike } from 'convert-route';
|
|
3
|
+
import type { PageConfigPublicWithRoute } from '../../../../shared-server-client/page-configs/resolveVikeConfigPublic.js';
|
|
4
|
+
import '../../assertEnvVite.js';
|
|
5
|
+
declare function getDeployConfigs(pageId: string, page: PageConfigPublicWithRoute): {
|
|
6
|
+
route: string;
|
|
7
|
+
vercel: {
|
|
8
|
+
isr: {
|
|
9
|
+
expiration: number;
|
|
10
|
+
} | undefined;
|
|
11
|
+
edge: boolean;
|
|
12
|
+
};
|
|
13
|
+
} | null;
|
|
14
|
+
export declare function getPageContextRoute(routeIr: ReturnType<typeof fromVike>): {
|
|
15
|
+
pathname: ({
|
|
16
|
+
optional: boolean;
|
|
17
|
+
} & ({
|
|
18
|
+
value: string;
|
|
19
|
+
catchAll?: never;
|
|
20
|
+
} | {
|
|
21
|
+
value?: never;
|
|
22
|
+
catchAll: {
|
|
23
|
+
name?: string;
|
|
24
|
+
greedy: boolean;
|
|
25
|
+
};
|
|
26
|
+
}))[];
|
|
27
|
+
} | undefined;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import pc from '@brillout/picocolors';
|
|
2
|
+
export { getDeployConfigs };
|
|
3
|
+
import { assert, assertUsage, assertWarning } from '../../../../utils/assert.js';
|
|
4
|
+
import { isObject } from '../../../../utils/isObject.js';
|
|
5
|
+
import '../../assertEnvVite.js';
|
|
6
|
+
function getDeployConfigs(pageId, page) {
|
|
7
|
+
const route = typeof page.route === 'string' ? page.route : null;
|
|
8
|
+
// Vercel specific configs
|
|
9
|
+
const rawIsr = extractIsr(page.config);
|
|
10
|
+
let isr = assertIsr(rawIsr);
|
|
11
|
+
const edge = extractEdge(page.config);
|
|
12
|
+
const isrOrEdge = isr ? 'isr' : edge ? 'edge' : null;
|
|
13
|
+
if (typeof page.route === 'function' && isrOrEdge) {
|
|
14
|
+
assertWarning(false, `Page ${pageId}: ${pc.cyan(isrOrEdge)} is not supported when using route function. Remove ${pc.cyan(isrOrEdge)} config or use a route string if possible.`, { onlyOnce: true });
|
|
15
|
+
isr = null;
|
|
16
|
+
}
|
|
17
|
+
if (edge && rawIsr !== null && typeof rawIsr === 'object') {
|
|
18
|
+
assertUsage(false, `Page ${pageId}: ISR cannot be enabled for edge functions. Remove ${pc.cyan('isr')} config or set \`{ edge: false }\`.`);
|
|
19
|
+
}
|
|
20
|
+
if (isrOrEdge && route) {
|
|
21
|
+
return {
|
|
22
|
+
route,
|
|
23
|
+
// route: [...new Set([...toRou3(routeIr), ...getPageContextRoute(routeIr)])],
|
|
24
|
+
// Supported by vite-plugin-vercel@11
|
|
25
|
+
vercel: {
|
|
26
|
+
isr: isr ? { expiration: isr } : undefined,
|
|
27
|
+
edge: Boolean(edge),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function extractIsr(pageConfig) {
|
|
34
|
+
if (!pageConfig.isr)
|
|
35
|
+
return null;
|
|
36
|
+
const isr = pageConfig.isr;
|
|
37
|
+
assertUsage(isObject(isr) &&
|
|
38
|
+
typeof isr.expiration === 'number' &&
|
|
39
|
+
isr.expiration > 0, ' `{ expiration }` must be a positive number');
|
|
40
|
+
return isr;
|
|
41
|
+
}
|
|
42
|
+
function assertIsr(isr) {
|
|
43
|
+
if (isr === null || isr === undefined)
|
|
44
|
+
return null;
|
|
45
|
+
return isr.expiration;
|
|
46
|
+
}
|
|
47
|
+
function extractEdge(exports) {
|
|
48
|
+
if (exports === null || typeof exports !== 'object')
|
|
49
|
+
return null;
|
|
50
|
+
if (!('edge' in exports))
|
|
51
|
+
return null;
|
|
52
|
+
const edge = exports.edge;
|
|
53
|
+
assertUsage(typeof edge === 'boolean', ' `{ edge }` must be a boolean');
|
|
54
|
+
return edge;
|
|
55
|
+
}
|
|
56
|
+
export function getPageContextRoute(routeIr) {
|
|
57
|
+
const lastSegment = routeIr.pathname.at(-1);
|
|
58
|
+
assert(lastSegment);
|
|
59
|
+
if (lastSegment.catchAll)
|
|
60
|
+
return;
|
|
61
|
+
return {
|
|
62
|
+
pathname: [
|
|
63
|
+
...routeIr.pathname.slice(0, -1),
|
|
64
|
+
{
|
|
65
|
+
...lastSegment,
|
|
66
|
+
value: `${lastSegment.value}.pageContext.json`,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
2
|
+
import '../../assertEnvVite.js';
|
|
3
|
+
export declare function getServerInfo(vikeConfig: VikeConfigInternal): {
|
|
4
|
+
serverEntryId: string;
|
|
5
|
+
serverEntryVike: string;
|
|
6
|
+
serverFilePath: string | null;
|
|
7
|
+
} | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { assert } from '../../../../utils/assert.js';
|
|
2
|
+
import { catchAllEntry } from '@universal-deploy/store';
|
|
3
|
+
import '../../assertEnvVite.js';
|
|
4
|
+
export function getServerInfo(vikeConfig) {
|
|
5
|
+
let serverEntryId;
|
|
6
|
+
let serverFilePath = null;
|
|
7
|
+
const serverConfig = vikeConfig.config.server;
|
|
8
|
+
// universal-deploy support manually disabled by user
|
|
9
|
+
if (serverConfig === false)
|
|
10
|
+
return;
|
|
11
|
+
const serverPlusFile = vikeConfig._pageConfigGlobal.configValueSources.server?.[0];
|
|
12
|
+
if (serverPlusFile) {
|
|
13
|
+
assert('filePathAbsoluteFilesystem' in serverPlusFile.definedAt);
|
|
14
|
+
serverFilePath = serverPlusFile.definedAt.filePathAbsoluteFilesystem;
|
|
15
|
+
assert(serverFilePath);
|
|
16
|
+
serverEntryId = serverFilePath;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
serverEntryId = catchAllEntry;
|
|
20
|
+
}
|
|
21
|
+
if (serverConfig !== true && !serverFilePath)
|
|
22
|
+
return;
|
|
23
|
+
const serverEntryVike = serverFilePath ?? 'vike/fetch';
|
|
24
|
+
return {
|
|
25
|
+
// Used to filter which module ID to transform.
|
|
26
|
+
// It points to a fully resolved server entry or the virtual universal-deploy catchAll entry.
|
|
27
|
+
serverEntryId,
|
|
28
|
+
// This entry will be pushed to universal-deploy via `addEntry`.
|
|
29
|
+
// It either points to the default fetchable endpoint (vike/fetch), or one defined by the user through +server.
|
|
30
|
+
serverEntryVike,
|
|
31
|
+
serverFilePath,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { pluginCommon } from './common.js';
|
|
2
|
+
import { escapeRegex } from '../../../../utils/escapeRegex.js';
|
|
3
|
+
import { catchAllEntry } from '@universal-deploy/store';
|
|
4
|
+
import '../../assertEnvVite.js';
|
|
5
|
+
export function pluginResolveAlias() {
|
|
6
|
+
return {
|
|
7
|
+
name: 'vike:pluginUniversalDeploy:alias',
|
|
8
|
+
resolveId: {
|
|
9
|
+
filter: {
|
|
10
|
+
// User facing alias for virtual:ud:catch-all
|
|
11
|
+
id: new RegExp(escapeRegex('vike:server-entry')),
|
|
12
|
+
},
|
|
13
|
+
handler() {
|
|
14
|
+
return this.resolve(catchAllEntry);
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
...pluginCommon,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { pluginCommon } from './common.js';
|
|
2
|
+
import { escapeRegex } from '../../../../utils/escapeRegex.js';
|
|
3
|
+
import '../../assertEnvVite.js';
|
|
4
|
+
/**
|
|
5
|
+
* If +server.js is defined, make virtual:ud:catch-all resolve to +server.js absolute path
|
|
6
|
+
*/
|
|
7
|
+
export function pluginVikeVirtualEntry(serverFilePath) {
|
|
8
|
+
return {
|
|
9
|
+
name: 'vike:pluginUniversalDeploy:server',
|
|
10
|
+
resolveId: {
|
|
11
|
+
order: 'pre',
|
|
12
|
+
filter: {
|
|
13
|
+
id: new RegExp(escapeRegex(serverFilePath)),
|
|
14
|
+
},
|
|
15
|
+
handler() {
|
|
16
|
+
// Will resolve the entry from the users project root
|
|
17
|
+
return this.resolve(serverFilePath);
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
...pluginCommon,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { wrapper } from 'vite-plugin-wrapper';
|
|
2
|
+
import { escapeRegex } from '../../../../utils/escapeRegex.js';
|
|
3
|
+
import '../../assertEnvVite.js';
|
|
4
|
+
export function pluginUnwrapProdOptions(serverFilePath) {
|
|
5
|
+
return wrapper({
|
|
6
|
+
resolveId: {
|
|
7
|
+
filter: {
|
|
8
|
+
id: new RegExp(escapeRegex(serverFilePath)),
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
// Unwrap all prod.* options
|
|
12
|
+
load(id) {
|
|
13
|
+
return `
|
|
14
|
+
import mod from ${JSON.stringify(id)};
|
|
15
|
+
export default { ...mod, ...mod?.prod };
|
|
16
|
+
`;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getMagicString } from '../../shared/getMagicString.js';
|
|
2
|
+
import { serverEntryVirtualId as vikeVirtualEntry } from '@brillout/vite-plugin-server-entry/plugin';
|
|
3
|
+
import { pluginCommon } from './common.js';
|
|
4
|
+
import '../../assertEnvVite.js';
|
|
5
|
+
export function pluginVikeVirtualEntry(serverEntryId) {
|
|
6
|
+
return {
|
|
7
|
+
name: 'vike:pluginUniversalDeploy:serverEntry',
|
|
8
|
+
apply: 'build',
|
|
9
|
+
transform: {
|
|
10
|
+
order: 'post',
|
|
11
|
+
filter: {
|
|
12
|
+
id: {
|
|
13
|
+
include: [serverEntryId],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
handler(code, id) {
|
|
17
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
18
|
+
// Inject Vike virtual server entry
|
|
19
|
+
magicString.prepend(`import "${vikeVirtualEntry}";\n`);
|
|
20
|
+
return getMagicStringResult();
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
...pluginCommon,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { toRou3 } from 'convert-route';
|
|
2
|
+
export { pluginUniversalDeploy };
|
|
3
|
+
import { addEntry } from '@universal-deploy/store';
|
|
4
|
+
import universalDeploy from '@universal-deploy/vite';
|
|
5
|
+
import { fromVike } from 'convert-route/vike';
|
|
6
|
+
import { pluginVikeVirtualEntry } from './pluginUniversalDeploy/pluginVikeVirtualEntry.js';
|
|
7
|
+
import { getDeployConfigs, getPageContextRoute } from './pluginUniversalDeploy/getDeployConfigs.js';
|
|
8
|
+
import { pluginCommon } from './pluginUniversalDeploy/common.js';
|
|
9
|
+
import { hasVikeServerOrVikePhoton } from './pluginUniversalDeploy/detectDeprecated.js';
|
|
10
|
+
import { getServerInfo } from './pluginUniversalDeploy/getServerInfo.js';
|
|
11
|
+
import { pluginResolveAlias } from './pluginUniversalDeploy/pluginResolveAlias.js';
|
|
12
|
+
import { pluginUnwrapProdOptions } from './pluginUniversalDeploy/pluginUnwrapProdOptions.js';
|
|
13
|
+
import '../assertEnvVite.js';
|
|
14
|
+
import { unique } from '../../../utils/unique.js';
|
|
15
|
+
function pluginUniversalDeploy(vikeConfig) {
|
|
16
|
+
if (hasVikeServerOrVikePhoton(vikeConfig))
|
|
17
|
+
return [];
|
|
18
|
+
const serverInfo = getServerInfo(vikeConfig);
|
|
19
|
+
if (!serverInfo)
|
|
20
|
+
return [];
|
|
21
|
+
const { serverEntryVike, serverEntryId, serverFilePath } = serverInfo;
|
|
22
|
+
const plugins = [
|
|
23
|
+
...universalDeploy(),
|
|
24
|
+
{
|
|
25
|
+
name: 'vike:pluginUniversalDeploy:entries',
|
|
26
|
+
config() {
|
|
27
|
+
// Map each Vike route to universal-deploy
|
|
28
|
+
for (const [pageId, page] of Object.entries(vikeConfig.pages)) {
|
|
29
|
+
const deployConfigs = getDeployConfigs(pageId, page);
|
|
30
|
+
// Skip pages without deploy configs, as they will be handled by the catch-all route
|
|
31
|
+
if (deployConfigs !== null) {
|
|
32
|
+
const { route, ...additionalConfigs } = deployConfigs;
|
|
33
|
+
const routeIr = fromVike(route);
|
|
34
|
+
const pageContextRouteIr = getPageContextRoute(routeIr);
|
|
35
|
+
addEntry({
|
|
36
|
+
...additionalConfigs,
|
|
37
|
+
id: serverEntryVike,
|
|
38
|
+
// Map Vike routes to rou3 format
|
|
39
|
+
route: unique([...toRou3(routeIr), ...(pageContextRouteIr ? toRou3(pageContextRouteIr) : [])]),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Default catch-all route
|
|
44
|
+
addEntry({
|
|
45
|
+
id: serverEntryVike,
|
|
46
|
+
route: '/**',
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
...pluginCommon,
|
|
50
|
+
},
|
|
51
|
+
pluginVikeVirtualEntry(serverFilePath ?? serverEntryId),
|
|
52
|
+
pluginResolveAlias(),
|
|
53
|
+
];
|
|
54
|
+
if (serverFilePath) {
|
|
55
|
+
plugins.push(pluginUnwrapProdOptions(serverFilePath));
|
|
56
|
+
}
|
|
57
|
+
return plugins;
|
|
58
|
+
}
|
|
@@ -4,6 +4,7 @@ import { getConfigDefinedAt, } from '../../../../shared-server-client/page-confi
|
|
|
4
4
|
import { getConfigValueSourceRelevantAnyEnv, getConfigValueSourcesRelevant, isConfigSourceValueNull, } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
5
5
|
import { getFileSuffixes } from '../../../../shared-server-node/getFileSuffixes.js';
|
|
6
6
|
import '../../assertEnvVite.js';
|
|
7
|
+
// TODO/after-PR-merge: rename_full configDefinitionsBuiltIn metaBuiltIn
|
|
7
8
|
const configDefinitionsBuiltIn = {
|
|
8
9
|
onRenderHtml: {
|
|
9
10
|
env: { server: true },
|
|
@@ -225,6 +226,10 @@ const configDefinitionsBuiltIn = {
|
|
|
225
226
|
eager: true,
|
|
226
227
|
global: true,
|
|
227
228
|
},
|
|
229
|
+
server: {
|
|
230
|
+
env: { server: true },
|
|
231
|
+
global: true,
|
|
232
|
+
},
|
|
228
233
|
cli: {
|
|
229
234
|
env: { config: true },
|
|
230
235
|
global: true,
|
|
@@ -301,6 +306,19 @@ const configDefinitionsBuiltIn = {
|
|
|
301
306
|
global: true,
|
|
302
307
|
vite: true,
|
|
303
308
|
},
|
|
309
|
+
license: {
|
|
310
|
+
env: { config: true },
|
|
311
|
+
global: true,
|
|
312
|
+
},
|
|
313
|
+
// -- Vercel --
|
|
314
|
+
isr: {
|
|
315
|
+
env: { server: true, config: true },
|
|
316
|
+
eager: true,
|
|
317
|
+
},
|
|
318
|
+
edge: {
|
|
319
|
+
env: { server: true, config: true },
|
|
320
|
+
eager: true,
|
|
321
|
+
},
|
|
304
322
|
};
|
|
305
323
|
function getConfigEnv(pageConfig, configName) {
|
|
306
324
|
const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
|
|
@@ -20,7 +20,7 @@ function onLoad() {
|
|
|
20
20
|
addEcosystemStamp();
|
|
21
21
|
}
|
|
22
22
|
// Used by:
|
|
23
|
-
// - Telefunc (to detect the user's stack https://github.com/
|
|
23
|
+
// - Telefunc (to detect the user's stack https://github.com/telefunc/telefunc/blob/8288310e88e06a42b710d39c39fb502364ca6d30/telefunc/utils/isVikeApp.ts#L4)
|
|
24
24
|
function addEcosystemStamp() {
|
|
25
25
|
const g = globalThis;
|
|
26
26
|
g._isVikeApp =
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '../assertEnvServer.js';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
fetch: (<T extends string>(request: Request, context: Universal.Context, runtime: import("@universal-middleware/core").RuntimeAdapterTarget<T>) => Promise<Response>) & import("@universal-middleware/core").WithUniversalSymbols<{
|
|
4
|
+
name: string;
|
|
5
|
+
method: ("GET" | "HEAD" | "POST" | "PUT" | "OPTIONS" | "PATCH")[];
|
|
6
|
+
path: string;
|
|
7
|
+
immutable: true;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|