vike 0.4.150-commit-d9acc70 → 0.4.150-commit-d0822a3
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/plugin/index.js +0 -2
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +3 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +17 -36
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/config/resolveExtensions.js +1 -1
- package/dist/cjs/node/plugin/plugins/config/stemUtils.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
- package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +38 -0
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +50 -18
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -0
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +2 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +33 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -4
- package/dist/cjs/utils/getDependencyPackageJson.js +1 -1
- package/dist/cjs/utils/getFilePathAbsolute.js +1 -1
- package/dist/cjs/utils/injectRollupInputs.js +29 -0
- package/dist/cjs/utils/isPlainObject.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/requireResolve.js +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +105 -66
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +1 -1
- package/dist/esm/node/plugin/index.js +0 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +3 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +17 -36
- package/dist/esm/node/plugin/plugins/commonConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.js +1 -1
- package/dist/esm/node/plugin/plugins/config/stemUtils.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +32 -0
- package/dist/esm/node/plugin/plugins/importBuild/index.js +52 -20
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -0
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +2 -1
- package/dist/esm/node/runtime/renderPage/{executeOnBeforeRenderHook.d.ts → executeOnBeforeRenderAndDataHooks.d.ts} +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +30 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -4
- package/dist/esm/shared/VikeNamespace.d.ts +2 -1
- package/dist/esm/shared/page-configs/Config.d.ts +22 -5
- package/dist/esm/shared/types.d.ts +5 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/getDependencyPackageJson.js +1 -1
- package/dist/esm/utils/getFilePathAbsolute.js +1 -1
- package/dist/esm/utils/injectRollupInputs.d.ts +7 -0
- package/dist/esm/utils/injectRollupInputs.js +26 -0
- package/dist/esm/utils/isPlainObject.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +9 -2
- package/dist/cjs/node/plugin/plugins/manifest.js +0 -59
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderHook.js +0 -23
- package/dist/esm/node/plugin/plugins/manifest.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/manifest.js +0 -53
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderHook.js +0 -20
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { executeOnBeforeRenderAndDataHooks };
|
|
2
2
|
import { type PageContextExports } from '../../../shared/getPageFiles.js';
|
|
3
3
|
import { type PageContextForUserConsumptionServerSide } from './preparePageContextForUserConsumptionServerSide.js';
|
|
4
|
-
declare function
|
|
4
|
+
declare function executeOnBeforeRenderAndDataHooks(pageContext: {
|
|
5
5
|
_pageId: string;
|
|
6
6
|
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
7
7
|
} & PageContextExports & PageContextForUserConsumptionServerSide): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { executeOnBeforeRenderAndDataHooks };
|
|
2
|
+
import { getHook } from '../../../shared/hooks/getHook.js';
|
|
3
|
+
import { preparePageContextForUserConsumptionServerSide } from './preparePageContextForUserConsumptionServerSide.js';
|
|
4
|
+
import { executeHook } from '../utils.js';
|
|
5
|
+
import { assertOnBeforeRenderHookReturn } from '../../../shared/assertOnBeforeRenderHookReturn.js';
|
|
6
|
+
async function executeOnBeforeRenderAndDataHooks(pageContext) {
|
|
7
|
+
if (pageContext._pageContextAlreadyProvidedByOnPrerenderHook) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const dataHook = getHook(pageContext, 'data');
|
|
11
|
+
const onBeforeRenderHook = getHook(pageContext, 'onBeforeRender');
|
|
12
|
+
if (!dataHook && !onBeforeRenderHook) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
preparePageContextForUserConsumptionServerSide(pageContext);
|
|
16
|
+
if (dataHook) {
|
|
17
|
+
const hookResult = await executeHook(() => dataHook.hookFn(pageContext), dataHook);
|
|
18
|
+
// Note: hookResult can be anything (e.g. an object) and is to be assigned to pageContext.data
|
|
19
|
+
const pageContextFromHook = {
|
|
20
|
+
data: hookResult
|
|
21
|
+
};
|
|
22
|
+
Object.assign(pageContext, pageContextFromHook);
|
|
23
|
+
}
|
|
24
|
+
if (onBeforeRenderHook) {
|
|
25
|
+
const hookResult = await executeHook(() => onBeforeRenderHook.hookFn(pageContext), onBeforeRenderHook);
|
|
26
|
+
assertOnBeforeRenderHookReturn(hookResult, onBeforeRenderHook.hookFilePath);
|
|
27
|
+
const pageContextFromHook = hookResult?.pageContext;
|
|
28
|
+
Object.assign(pageContext, pageContextFromHook);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -82,7 +82,7 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
82
82
|
const { createRequire } = (await import_('module')).default;
|
|
83
83
|
const { dirname } = (await import_('path')).default;
|
|
84
84
|
const { fileURLToPath } = (await import_('url')).default;
|
|
85
|
-
// @ts-ignore
|
|
85
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
86
86
|
const importMetaUrl = import.meta.url;
|
|
87
87
|
const require_ = createRequire(importMetaUrl);
|
|
88
88
|
const __dirname_ = dirname(fileURLToPath(importMetaUrl));
|
|
@@ -13,7 +13,7 @@ import { getGlobalContext } from '../globalContext.js';
|
|
|
13
13
|
import { createHttpResponseObject, createHttpResponsePageContextJson } from './createHttpResponseObject.js';
|
|
14
14
|
import { loadPageFilesServerSide } from './loadPageFilesServerSide.js';
|
|
15
15
|
import { executeOnRenderHtmlHook } from './executeOnRenderHtmlHook.js';
|
|
16
|
-
import {
|
|
16
|
+
import { executeOnBeforeRenderAndDataHooks } from './executeOnBeforeRenderAndDataHooks.js';
|
|
17
17
|
import { logRuntimeError } from './loggerRuntime.js';
|
|
18
18
|
import { isNewError } from './isNewError.js';
|
|
19
19
|
import { preparePageContextForUserConsumptionServerSide } from './preparePageContextForUserConsumptionServerSide.js';
|
|
@@ -33,11 +33,11 @@ async function renderPageAlreadyRouted(pageContext) {
|
|
|
33
33
|
await executeGuardHook(pageContext, (pageContext) => preparePageContextForUserConsumptionServerSide(pageContext));
|
|
34
34
|
}
|
|
35
35
|
if (!isError) {
|
|
36
|
-
await
|
|
36
|
+
await executeOnBeforeRenderAndDataHooks(pageContext);
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
try {
|
|
40
|
-
await
|
|
40
|
+
await executeOnBeforeRenderAndDataHooks(pageContext);
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
43
|
if (isNewError(err, pageContext.errorWhileRendering)) {
|
|
@@ -75,7 +75,7 @@ async function prerenderPage(pageContext) {
|
|
|
75
75
|
* - It isn't trivial to implement, as it requires to duplicate / factor out the isAbortError() handling
|
|
76
76
|
await executeGuardHook(pageContext, (pageContext) => preparePageContextForUserConsumptionServerSide(pageContext))
|
|
77
77
|
*/
|
|
78
|
-
await
|
|
78
|
+
await executeOnBeforeRenderAndDataHooks(pageContext);
|
|
79
79
|
const { htmlRender, renderHook } = await executeOnRenderHtmlHook(pageContext);
|
|
80
80
|
assertUsage(htmlRender !== null, `Cannot pre-render ${pc.cyan(pageContext.urlOriginal)} because the ${renderHook.hookName}() hook defined by ${renderHook.hookFilePath} didn't return an HTML string.`);
|
|
81
81
|
assert(pageContext.isClientSideNavigation === false);
|
|
@@ -15,9 +15,10 @@ declare global {
|
|
|
15
15
|
/** Extend and/or refine the `PageContext` type (`import type { PageContext } from 'vike/types'`).
|
|
16
16
|
*
|
|
17
17
|
* For example:
|
|
18
|
-
* - You can define the type of fetched data, e.g. `PageContext['movies']`.
|
|
19
18
|
* - You can refine the type of `PageContext['Page']`.
|
|
19
|
+
* - You can define the type of custom `pageContext` values such as `pageContext.user`, see https://vike.dev/pageContext#custom
|
|
20
20
|
*
|
|
21
|
+
* https://vike.dev/pageContext#typescript
|
|
21
22
|
*/
|
|
22
23
|
interface PageContext {
|
|
23
24
|
}
|
|
@@ -5,6 +5,8 @@ export type { ConfigMeta };
|
|
|
5
5
|
export type { HookName };
|
|
6
6
|
export type { HookNamePage };
|
|
7
7
|
export type { HookNameGlobal };
|
|
8
|
+
export type { DataAsync };
|
|
9
|
+
export type { DataSync };
|
|
8
10
|
export type { GuardAsync };
|
|
9
11
|
export type { GuardSync };
|
|
10
12
|
export type { OnBeforePrerenderStartAsync };
|
|
@@ -35,11 +37,21 @@ import type { Vike, VikePackages } from '../VikeNamespace.js';
|
|
|
35
37
|
import type { HooksTimeoutProvidedByUser } from '../hooks/getHook.js';
|
|
36
38
|
import type { PageContextClient, PageContextServer } from '../types.js';
|
|
37
39
|
type HookName = HookNamePage | HookNameGlobal | HookNameOldDesign;
|
|
38
|
-
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard';
|
|
40
|
+
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data';
|
|
39
41
|
type HookNameGlobal = 'onBeforePrerender' | 'onBeforeRoute' | 'onPrerenderStart';
|
|
40
42
|
type HookNameOldDesign = 'render' | 'prerender';
|
|
41
|
-
type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'isClientSideRenderable' | 'onBeforeRenderEnv' | 'hooksTimeout';
|
|
43
|
+
type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'isClientSideRenderable' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout';
|
|
42
44
|
type Config = ConfigBuiltIn & Vike.Config & (VikePackages.ConfigVikeReact | VikePackages.ConfigVikeVue | VikePackages.ConfigVikeSolid | VikePackages.ConfigVikeSvelte);
|
|
45
|
+
/** Hook for fetching data.
|
|
46
|
+
*
|
|
47
|
+
* https://vike.dev/data
|
|
48
|
+
*/
|
|
49
|
+
type DataAsync<Data> = (pageContext: PageContextServer) => Promise<Data>;
|
|
50
|
+
/** Hook for fetching data.
|
|
51
|
+
*
|
|
52
|
+
* https://vike.dev/data
|
|
53
|
+
*/
|
|
54
|
+
type DataSync<Data> = (pageContext: PageContextServer) => Data;
|
|
43
55
|
/** Protect page(s), e.g. forbid unauthorized access.
|
|
44
56
|
*
|
|
45
57
|
* https://vike.dev/guard
|
|
@@ -66,14 +78,14 @@ type OnBeforePrerenderStartSync = () => (string | {
|
|
|
66
78
|
url: string;
|
|
67
79
|
pageContext: Partial<Vike.PageContext>;
|
|
68
80
|
})[];
|
|
69
|
-
/** Hook called before the page is rendered
|
|
81
|
+
/** Hook called before the page is rendered.
|
|
70
82
|
*
|
|
71
83
|
* https://vike.dev/onBeforeRender
|
|
72
84
|
*/
|
|
73
85
|
type OnBeforeRenderAsync = (pageContext: PageContextServer) => Promise<{
|
|
74
86
|
pageContext: Partial<Vike.PageContext>;
|
|
75
87
|
} | void>;
|
|
76
|
-
/** Hook called before the page is rendered
|
|
88
|
+
/** Hook called before the page is rendered.
|
|
77
89
|
*
|
|
78
90
|
* https://vike.dev/onBeforeRender
|
|
79
91
|
*/
|
|
@@ -234,11 +246,16 @@ type ConfigBuiltIn = {
|
|
|
234
246
|
* https://vike.dev/extends
|
|
235
247
|
*/
|
|
236
248
|
extends?: Config | Config[] | ImportString | ImportString[];
|
|
237
|
-
/** Hook called before the page is rendered
|
|
249
|
+
/** Hook called before the page is rendered.
|
|
238
250
|
*
|
|
239
251
|
* https://vike.dev/onBeforeRender
|
|
240
252
|
*/
|
|
241
253
|
onBeforeRender?: OnBeforeRenderAsync | OnBeforeRenderSync | ImportString | null;
|
|
254
|
+
/** Hook for fetching data.
|
|
255
|
+
*
|
|
256
|
+
* https://vike.dev/data
|
|
257
|
+
*/
|
|
258
|
+
data?: DataAsync<unknown> | DataSync<unknown> | ImportString | null;
|
|
242
259
|
/** Determines what pageContext properties are sent to the client-side.
|
|
243
260
|
*
|
|
244
261
|
* https://vike.dev/passToClient
|
|
@@ -35,6 +35,11 @@ type PageContextBuiltInCommon<Page = [never]> = {
|
|
|
35
35
|
* https://vike.dev/route-string
|
|
36
36
|
*/
|
|
37
37
|
routeParams: Record<string, string>;
|
|
38
|
+
/** The page's data which was fetched using the data() hook.
|
|
39
|
+
*
|
|
40
|
+
* https://vike.dev/data
|
|
41
|
+
*/
|
|
42
|
+
data?: unknown;
|
|
38
43
|
/** The page's configuration values.
|
|
39
44
|
*
|
|
40
45
|
* https://vike.dev/config
|
|
@@ -6,7 +6,7 @@ export type { PageContextClientWithServerRouting } from '../shared/types.js';
|
|
|
6
6
|
export type { PageContextBuiltInServer } from '../shared/types.js';
|
|
7
7
|
export type { PageContextBuiltInClientWithClientRouting } from '../shared/types.js';
|
|
8
8
|
export type { PageContextBuiltInClientWithServerRouting } from '../shared/types.js';
|
|
9
|
-
export type { Config, ConfigMeta as Meta, GuardAsync, GuardSync, OnBeforePrerenderStartAsync, OnBeforePrerenderStartSync, OnBeforeRenderAsync, OnBeforeRenderSync, OnBeforeRouteAsync, OnBeforeRouteSync, OnHydrationEndAsync, OnHydrationEndSync, OnPageTransitionEndAsync, OnPageTransitionEndSync, OnPageTransitionStartAsync, OnPageTransitionStartSync, OnPrerenderStartAsync, OnPrerenderStartSync, OnRenderClientAsync, OnRenderClientSync, OnRenderHtmlAsync, OnRenderHtmlSync, RouteAsync, RouteSync } from '../shared/page-configs/Config.js';
|
|
9
|
+
export type { Config, ConfigMeta as Meta, DataAsync, DataSync, GuardAsync, GuardSync, OnBeforePrerenderStartAsync, OnBeforePrerenderStartSync, OnBeforeRenderAsync, OnBeforeRenderSync, OnBeforeRouteAsync, OnBeforeRouteSync, OnHydrationEndAsync, OnHydrationEndSync, OnPageTransitionEndAsync, OnPageTransitionEndSync, OnPageTransitionStartAsync, OnPageTransitionStartSync, OnPrerenderStartAsync, OnPrerenderStartSync, OnRenderClientAsync, OnRenderClientSync, OnRenderHtmlAsync, OnRenderHtmlSync, RouteAsync, RouteSync } from '../shared/page-configs/Config.js';
|
|
10
10
|
export type { ConfigEnv } from '../shared/page-configs/PageConfig.js';
|
|
11
11
|
export type { ConfigDefinition, ConfigEffect } from '../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
12
12
|
export type { ConfigEntries } from '../shared/getPageFiles/getExports.js';
|
|
@@ -14,7 +14,7 @@ import path from 'path';
|
|
|
14
14
|
import fs from 'fs';
|
|
15
15
|
import { assertIsNotProductionRuntime } from './assertIsNotProductionRuntime.js';
|
|
16
16
|
import { createRequire } from 'module';
|
|
17
|
-
// @ts-ignore
|
|
17
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
18
18
|
const importMetaUrl = import.meta.url;
|
|
19
19
|
const require_ = createRequire(importMetaUrl);
|
|
20
20
|
assertIsNotProductionRuntime();
|
|
@@ -7,7 +7,7 @@ import { assertIsNotProductionRuntime } from './assertIsNotProductionRuntime.js'
|
|
|
7
7
|
import { isNpmPackageImport } from './isNpmPackage.js';
|
|
8
8
|
import { assertPathIsFilesystemAbsolute } from './assertPathIsFilesystemAbsolute.js';
|
|
9
9
|
import { createRequire } from 'module';
|
|
10
|
-
// @ts-ignore
|
|
10
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
11
11
|
const importMetaUrl = import.meta.url;
|
|
12
12
|
const require_ = createRequire(importMetaUrl);
|
|
13
13
|
assertIsNotProductionRuntime();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { injectRollupInputs };
|
|
2
|
+
export { normalizeRollupInput };
|
|
3
|
+
import type { ResolvedConfig, Rollup } from 'vite';
|
|
4
|
+
type InputOption = Rollup.InputOption;
|
|
5
|
+
type InputsMap = Record<string, string>;
|
|
6
|
+
declare function injectRollupInputs(inputsNew: InputsMap, config: ResolvedConfig): InputsMap;
|
|
7
|
+
declare function normalizeRollupInput(input?: InputOption): InputsMap;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { injectRollupInputs };
|
|
2
|
+
export { normalizeRollupInput };
|
|
3
|
+
import { assert } from './assert.js';
|
|
4
|
+
import { isObject } from './isObject.js';
|
|
5
|
+
function injectRollupInputs(inputsNew, config) {
|
|
6
|
+
const inputsCurrent = normalizeRollupInput(config.build.rollupOptions.input);
|
|
7
|
+
const input = {
|
|
8
|
+
...inputsNew,
|
|
9
|
+
...inputsCurrent
|
|
10
|
+
};
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
13
|
+
function normalizeRollupInput(input) {
|
|
14
|
+
if (!input) {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
// Usually `input` is an oject, but the user can set it as a `string` or `string[]`
|
|
18
|
+
if (typeof input === 'string') {
|
|
19
|
+
input = [input];
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(input)) {
|
|
22
|
+
return Object.fromEntries(input.map((input) => [input, input]));
|
|
23
|
+
}
|
|
24
|
+
assert(isObject(input));
|
|
25
|
+
return input;
|
|
26
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export type { ProjectTag };
|
|
3
3
|
export { PROJECT_VERSION };
|
|
4
|
-
declare const PROJECT_VERSION: "0.4.150-commit-
|
|
4
|
+
declare const PROJECT_VERSION: "0.4.150-commit-d0822a3";
|
|
5
5
|
type PackageName = typeof projectInfo.npmPackageName;
|
|
6
6
|
type ProjectVersion = typeof projectInfo.projectVersion;
|
|
7
7
|
type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
|
|
8
8
|
declare const projectInfo: {
|
|
9
9
|
projectName: "Vike";
|
|
10
|
-
projectVersion: "0.4.150-commit-
|
|
10
|
+
projectVersion: "0.4.150-commit-d0822a3";
|
|
11
11
|
npmPackageName: "vike";
|
|
12
12
|
githubRepository: "https://github.com/vikejs/vike";
|
|
13
13
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
3
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
4
|
-
const PROJECT_VERSION = '0.4.150-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.150-commit-d0822a3';
|
|
5
5
|
const projectInfo = {
|
|
6
6
|
projectName: 'Vike',
|
|
7
7
|
projectVersion: PROJECT_VERSION,
|
|
@@ -5,7 +5,7 @@ import { assertIsNotProductionRuntime } from './assertIsNotProductionRuntime.js'
|
|
|
5
5
|
import { assertPosixPath, toPosixPath } from './filesystemPathHandling.js';
|
|
6
6
|
import { scriptFileExtensionList } from './isScriptFile.js';
|
|
7
7
|
import { createRequire } from 'module';
|
|
8
|
-
// @ts-ignore
|
|
8
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
9
9
|
const importMetaUrl = import.meta.url;
|
|
10
10
|
const require_ = createRequire(importMetaUrl);
|
|
11
11
|
assertIsNotBrowser();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.150-commit-
|
|
3
|
+
"version": "0.4.150-commit-d0822a3",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@brillout/json-serializer": "^0.5.8",
|
|
17
17
|
"@brillout/picocolors": "^1.0.10",
|
|
18
18
|
"@brillout/require-shim": "^0.1.2",
|
|
19
|
-
"@brillout/vite-plugin-import-build": "
|
|
19
|
+
"@brillout/vite-plugin-import-build": "0.2.22-commit-7f1bb0a",
|
|
20
20
|
"acorn": "^8.8.2",
|
|
21
21
|
"cac": "^6.7.14",
|
|
22
22
|
"es-module-lexer": "^1.3.0",
|
|
@@ -105,6 +105,13 @@
|
|
|
105
105
|
"require": "./dist/cjs/node/runtime/page-files/setup.js",
|
|
106
106
|
"node": "./dist/esm/node/runtime/page-files/setup.js",
|
|
107
107
|
"types": "./dist/esm/node/runtime/page-files/setup.d.ts"
|
|
108
|
+
},
|
|
109
|
+
"./__internal/loadImportBuild": {
|
|
110
|
+
"worker": "./dist/esm/node/runtime/globalContext/loadImportBuild.js",
|
|
111
|
+
"edge-light": "./dist/esm/node/runtime/globalContext/loadImportBuild.js",
|
|
112
|
+
"require": "./dist/cjs/node/runtime/globalContext/loadImportBuild.js",
|
|
113
|
+
"node": "./dist/esm/node/runtime/globalContext/loadImportBuild.js",
|
|
114
|
+
"types": "./dist/esm/node/runtime/globalContext/loadImportBuild.d.ts"
|
|
108
115
|
}
|
|
109
116
|
},
|
|
110
117
|
"peerDependencies": {
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.manifest = void 0;
|
|
7
|
-
const utils_js_1 = require("../utils.js");
|
|
8
|
-
const assertPluginManifest_js_1 = require("../../shared/assertPluginManifest.js");
|
|
9
|
-
const extractExportNamesPlugin_js_1 = require("./extractExportNamesPlugin.js");
|
|
10
|
-
const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const globalContext_js_1 = require("../../runtime/globalContext.js");
|
|
13
|
-
function manifest() {
|
|
14
|
-
let configVike;
|
|
15
|
-
let config;
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
name: 'vike:pluginManifest',
|
|
19
|
-
apply: 'build',
|
|
20
|
-
async configResolved(config_) {
|
|
21
|
-
config = config_;
|
|
22
|
-
configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
23
|
-
},
|
|
24
|
-
generateBundle() {
|
|
25
|
-
if ((0, utils_js_1.viteIsSSR)(config))
|
|
26
|
-
return;
|
|
27
|
-
const runtimeManifest = (0, globalContext_js_1.getRuntimeManifest)(configVike);
|
|
28
|
-
const manifest = {
|
|
29
|
-
version: utils_js_1.projectInfo.projectVersion,
|
|
30
|
-
usesClientRouter: (0, extractExportNamesPlugin_js_1.isUsingClientRouter)(),
|
|
31
|
-
manifestKeyMap: getManifestKeyMap(configVike, config),
|
|
32
|
-
...runtimeManifest
|
|
33
|
-
};
|
|
34
|
-
(0, assertPluginManifest_js_1.assertPluginManifest)(manifest);
|
|
35
|
-
this.emitFile({
|
|
36
|
-
fileName: `vike.json`,
|
|
37
|
-
type: 'asset',
|
|
38
|
-
source: JSON.stringify(manifest, null, 2)
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
exports.manifest = manifest;
|
|
45
|
-
function getManifestKeyMap(configVike, config) {
|
|
46
|
-
const manifestKeyMap = {};
|
|
47
|
-
configVike.extensions
|
|
48
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
49
|
-
.flat()
|
|
50
|
-
.filter(utils_js_1.isNotNullish)
|
|
51
|
-
.forEach(({ importPath, filePath }) => {
|
|
52
|
-
// Recreating https://github.com/vitejs/vite/blob/8158ece72b66307e7b607b98496891610ca70ea2/packages/vite/src/node/plugins/manifest.ts#L38
|
|
53
|
-
const filePathRelative = path_1.default.posix.relative(config.root, (0, utils_js_1.toPosixPath)(filePath));
|
|
54
|
-
(0, utils_js_1.assertPosixPath)(filePathRelative);
|
|
55
|
-
(0, utils_js_1.assertPosixPath)(importPath);
|
|
56
|
-
manifestKeyMap[importPath] = filePathRelative;
|
|
57
|
-
});
|
|
58
|
-
return manifestKeyMap;
|
|
59
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeOnBeforeRenderHooks = void 0;
|
|
4
|
-
const getHook_js_1 = require("../../../shared/hooks/getHook.js");
|
|
5
|
-
const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePageContextForUserConsumptionServerSide.js");
|
|
6
|
-
const utils_js_1 = require("../utils.js");
|
|
7
|
-
const assertOnBeforeRenderHookReturn_js_1 = require("../../../shared/assertOnBeforeRenderHookReturn.js");
|
|
8
|
-
async function executeOnBeforeRenderHooks(pageContext) {
|
|
9
|
-
if (pageContext._pageContextAlreadyProvidedByOnPrerenderHook) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const hook = (0, getHook_js_1.getHook)(pageContext, 'onBeforeRender');
|
|
13
|
-
if (!hook) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const onBeforeRender = hook.hookFn;
|
|
17
|
-
(0, preparePageContextForUserConsumptionServerSide_js_1.preparePageContextForUserConsumptionServerSide)(pageContext);
|
|
18
|
-
const hookResult = await (0, utils_js_1.executeHook)(() => onBeforeRender(pageContext), hook);
|
|
19
|
-
(0, assertOnBeforeRenderHookReturn_js_1.assertOnBeforeRenderHookReturn)(hookResult, hook.hookFilePath);
|
|
20
|
-
const pageContextFromHook = hookResult?.pageContext;
|
|
21
|
-
Object.assign(pageContext, pageContextFromHook);
|
|
22
|
-
}
|
|
23
|
-
exports.executeOnBeforeRenderHooks = executeOnBeforeRenderHooks;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export { manifest };
|
|
2
|
-
import { projectInfo, viteIsSSR, toPosixPath, assertPosixPath, isNotNullish } from '../utils.js';
|
|
3
|
-
import { assertPluginManifest } from '../../shared/assertPluginManifest.js';
|
|
4
|
-
import { isUsingClientRouter } from './extractExportNamesPlugin.js';
|
|
5
|
-
import { getConfigVike } from '../../shared/getConfigVike.js';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { getRuntimeManifest } from '../../runtime/globalContext.js';
|
|
8
|
-
function manifest() {
|
|
9
|
-
let configVike;
|
|
10
|
-
let config;
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
name: 'vike:pluginManifest',
|
|
14
|
-
apply: 'build',
|
|
15
|
-
async configResolved(config_) {
|
|
16
|
-
config = config_;
|
|
17
|
-
configVike = await getConfigVike(config);
|
|
18
|
-
},
|
|
19
|
-
generateBundle() {
|
|
20
|
-
if (viteIsSSR(config))
|
|
21
|
-
return;
|
|
22
|
-
const runtimeManifest = getRuntimeManifest(configVike);
|
|
23
|
-
const manifest = {
|
|
24
|
-
version: projectInfo.projectVersion,
|
|
25
|
-
usesClientRouter: isUsingClientRouter(),
|
|
26
|
-
manifestKeyMap: getManifestKeyMap(configVike, config),
|
|
27
|
-
...runtimeManifest
|
|
28
|
-
};
|
|
29
|
-
assertPluginManifest(manifest);
|
|
30
|
-
this.emitFile({
|
|
31
|
-
fileName: `vike.json`,
|
|
32
|
-
type: 'asset',
|
|
33
|
-
source: JSON.stringify(manifest, null, 2)
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
function getManifestKeyMap(configVike, config) {
|
|
40
|
-
const manifestKeyMap = {};
|
|
41
|
-
configVike.extensions
|
|
42
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
43
|
-
.flat()
|
|
44
|
-
.filter(isNotNullish)
|
|
45
|
-
.forEach(({ importPath, filePath }) => {
|
|
46
|
-
// Recreating https://github.com/vitejs/vite/blob/8158ece72b66307e7b607b98496891610ca70ea2/packages/vite/src/node/plugins/manifest.ts#L38
|
|
47
|
-
const filePathRelative = path.posix.relative(config.root, toPosixPath(filePath));
|
|
48
|
-
assertPosixPath(filePathRelative);
|
|
49
|
-
assertPosixPath(importPath);
|
|
50
|
-
manifestKeyMap[importPath] = filePathRelative;
|
|
51
|
-
});
|
|
52
|
-
return manifestKeyMap;
|
|
53
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export { executeOnBeforeRenderHooks };
|
|
2
|
-
import { getHook } from '../../../shared/hooks/getHook.js';
|
|
3
|
-
import { preparePageContextForUserConsumptionServerSide } from './preparePageContextForUserConsumptionServerSide.js';
|
|
4
|
-
import { executeHook } from '../utils.js';
|
|
5
|
-
import { assertOnBeforeRenderHookReturn } from '../../../shared/assertOnBeforeRenderHookReturn.js';
|
|
6
|
-
async function executeOnBeforeRenderHooks(pageContext) {
|
|
7
|
-
if (pageContext._pageContextAlreadyProvidedByOnPrerenderHook) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const hook = getHook(pageContext, 'onBeforeRender');
|
|
11
|
-
if (!hook) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const onBeforeRender = hook.hookFn;
|
|
15
|
-
preparePageContextForUserConsumptionServerSide(pageContext);
|
|
16
|
-
const hookResult = await executeHook(() => onBeforeRender(pageContext), hook);
|
|
17
|
-
assertOnBeforeRenderHookReturn(hookResult, hook.hookFilePath);
|
|
18
|
-
const pageContextFromHook = hookResult?.pageContext;
|
|
19
|
-
Object.assign(pageContext, pageContextFromHook);
|
|
20
|
-
}
|