vike 0.4.149 → 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/assertResolveAlias.js +3 -0
- 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 +57 -19
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +2 -1
- package/dist/cjs/node/runtime/html/stream.js +57 -17
- package/dist/cjs/node/runtime/index-deprecated.js +3 -2
- package/dist/cjs/node/runtime/index.js +3 -2
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +33 -0
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +13 -5
- package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +6 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/cjs/node/runtime/renderPage/inferMediaType.js +38 -0
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -4
- package/dist/cjs/shared/page-configs/assertExports.js +11 -4
- package/dist/cjs/shared/route/resolveRedirects.js +2 -10
- package/dist/cjs/shared/route/resolveUrlPathname.js +48 -0
- package/dist/cjs/utils/debug.js +29 -15
- package/dist/cjs/utils/getDependencyPackageJson.js +1 -1
- package/dist/cjs/utils/getFilePathAbsolute.js +1 -1
- package/dist/cjs/utils/getOutDirs.js +11 -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/assertResolveAlias.js +3 -0
- 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 +59 -21
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/debug.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
- 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/html/stream.js +57 -17
- package/dist/esm/node/runtime/index-deprecated.js +3 -2
- package/dist/esm/node/runtime/index.js +3 -2
- 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/getHttpResponseBody.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +13 -5
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +6 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/esm/node/runtime/renderPage/inferMediaType.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/inferMediaType.js +38 -0
- 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/page-configs/assertExports.js +11 -4
- package/dist/esm/shared/route/resolveRedirects.js +2 -10
- package/dist/esm/shared/route/resolveUrlPathname.d.ts +12 -0
- package/dist/esm/shared/route/resolveUrlPathname.js +45 -0
- package/dist/esm/shared/types.d.ts +5 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/debug.d.ts +2 -2
- package/dist/esm/utils/debug.js +29 -15
- package/dist/esm/utils/debugGlob.d.ts +1 -1
- package/dist/esm/utils/getDependencyPackageJson.js +1 -1
- package/dist/esm/utils/getFilePathAbsolute.js +1 -1
- package/dist/esm/utils/getOutDirs.js +11 -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 +10 -3
- 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
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugEnabled };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
type Namespace = 'vike:error' | 'vike:extractAssets' | 'vike:extractExportNames' | 'vike:glob' | 'vike:pageFiles' | 'vike:log' | 'vike:routing' | 'vike:virtual-files' | 'vike:stem' | 'vike:stream';
|
|
4
|
+
type Namespace = 'vike:error' | 'vike:extractAssets' | 'vike:extractExportNames' | 'vike:glob' | 'vike:pageFiles' | 'vike:log' | 'vike:routing' | 'vike:virtual-files' | 'vike:stem' | 'vike:stream' | 'vike:outDir';
|
|
5
5
|
type Debug = ReturnType<typeof createDebugger>;
|
|
6
6
|
type Options = {
|
|
7
7
|
serialization?: {
|
|
@@ -9,7 +9,7 @@ type Options = {
|
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
declare function createDebugger(namespace: Namespace, optionsGlobal?: Options): ((...msgs: unknown[]) => void) & {
|
|
12
|
-
options: (
|
|
12
|
+
options: (optionsLocal: Options) => (...msgs: unknown[]) => void;
|
|
13
13
|
isEnabled: boolean;
|
|
14
14
|
};
|
|
15
15
|
declare function isDebugEnabled(namespace: Namespace): boolean;
|
package/dist/esm/utils/debug.js
CHANGED
|
@@ -11,28 +11,42 @@ assert(!isBrowser());
|
|
|
11
11
|
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
12
12
|
function createDebugger(namespace, optionsGlobal) {
|
|
13
13
|
checkType(namespace);
|
|
14
|
-
const debugWithOptions = (
|
|
14
|
+
const debugWithOptions = (optionsLocal) => {
|
|
15
15
|
return (...msgs) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let [msgFirst, ...msgsRest] = msgs;
|
|
19
|
-
const padding = ' '.repeat(namespace.length + 1);
|
|
20
|
-
const optionsResolved = { ...optionsGlobal, ...options };
|
|
21
|
-
msgFirst = formatMsg(msgFirst, optionsResolved, padding, 'FIRST');
|
|
22
|
-
msgsRest = msgsRest.map((msg, i) => {
|
|
23
|
-
const position = i === msgsRest.length - 1 ? 'LAST' : 'MIDDLE';
|
|
24
|
-
return formatMsg(msg, optionsResolved, padding, position);
|
|
25
|
-
});
|
|
26
|
-
console.log('\x1b[1m%s\x1b[0m', namespace, msgFirst);
|
|
27
|
-
msgsRest.forEach((msg) => {
|
|
28
|
-
console.log(msg);
|
|
29
|
-
});
|
|
16
|
+
const options = { ...optionsGlobal, ...optionsLocal };
|
|
17
|
+
debug_(namespace, options, ...msgs);
|
|
30
18
|
};
|
|
31
19
|
};
|
|
32
20
|
const debug = (...msgs) => debugWithOptions({})(...msgs);
|
|
33
21
|
objectAssign(debug, { options: debugWithOptions, isEnabled: isDebugEnabled(namespace) });
|
|
34
22
|
return debug;
|
|
35
23
|
}
|
|
24
|
+
function debug_(namespace, options, ...msgs) {
|
|
25
|
+
if (!isDebugEnabled(namespace))
|
|
26
|
+
return;
|
|
27
|
+
let [msgFirst, ...msgsRest] = msgs;
|
|
28
|
+
const padding = ' '.repeat(namespace.length + 1);
|
|
29
|
+
msgFirst = formatMsg(msgFirst, options, padding, 'FIRST');
|
|
30
|
+
msgsRest = msgsRest.map((msg, i) => {
|
|
31
|
+
const position = i === msgsRest.length - 1 ? 'LAST' : 'MIDDLE';
|
|
32
|
+
return formatMsg(msg, options, padding, position);
|
|
33
|
+
});
|
|
34
|
+
let logFirst;
|
|
35
|
+
let logsRest;
|
|
36
|
+
const noNewLine = msgsRest.length <= 1 && [msgFirst, ...msgsRest].every((m) => typeof m === 'string' && !m.includes('\n'));
|
|
37
|
+
if (noNewLine) {
|
|
38
|
+
logFirst = [msgFirst, ...msgsRest].map((m) => String(m).trim());
|
|
39
|
+
logsRest = [];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
logFirst = [msgFirst];
|
|
43
|
+
logsRest = msgsRest;
|
|
44
|
+
}
|
|
45
|
+
console.log('\x1b[1m%s\x1b[0m', namespace, ...logFirst);
|
|
46
|
+
logsRest.forEach((msg) => {
|
|
47
|
+
console.log(msg);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
36
50
|
function isDebugEnabled(namespace) {
|
|
37
51
|
checkType(namespace);
|
|
38
52
|
let DEBUG;
|
|
@@ -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();
|
|
@@ -5,7 +5,10 @@ import { assert, assertUsage } from './assert.js';
|
|
|
5
5
|
import { pathJoin } from './path-shim.js';
|
|
6
6
|
import { assertPosixPath, toPosixPath } from './filesystemPathHandling.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
|
+
import { createDebugger } from './debug.js';
|
|
9
|
+
const debug = createDebugger('vike:outDir');
|
|
8
10
|
function getOutDirs(config) {
|
|
11
|
+
debug('getOutDirs()', new Error().stack);
|
|
9
12
|
let outDirRoot;
|
|
10
13
|
{
|
|
11
14
|
const outDir = getOutDirFromViteResolvedConfig(config);
|
|
@@ -19,11 +22,16 @@ function getOutDirs(config) {
|
|
|
19
22
|
outDirRoot = outDir.slice(0, -1 * '/client'.length);
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
const outDirs = getOutDirsAll(outDirRoot, config.root);
|
|
26
|
+
debug('outDirRoot', outDirRoot);
|
|
27
|
+
debug('outDirs', outDirs);
|
|
28
|
+
return outDirs;
|
|
23
29
|
}
|
|
24
30
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
25
31
|
function resolveOutDir(config) {
|
|
32
|
+
debug('resolveOutDir()', new Error().stack);
|
|
26
33
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
34
|
+
debug('outDir', 'outDir');
|
|
27
35
|
// outDir may already be resolved when using Telefunc + vike (because both Telefunc and vike use this logic)
|
|
28
36
|
if (!isOutDirRoot(outDir)) {
|
|
29
37
|
assertOutDirResolved(outDir, config);
|
|
@@ -32,9 +40,11 @@ function resolveOutDir(config) {
|
|
|
32
40
|
else {
|
|
33
41
|
const { outDirClient, outDirServer } = determineOutDirs(outDir);
|
|
34
42
|
if (viteIsSSR(config)) {
|
|
43
|
+
debug('outDirServer', 'outDirServer');
|
|
35
44
|
return outDirServer;
|
|
36
45
|
}
|
|
37
46
|
else {
|
|
47
|
+
debug('outDirClient', 'outDirClient');
|
|
38
48
|
return outDirClient;
|
|
39
49
|
}
|
|
40
50
|
}
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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": {
|
|
@@ -162,7 +169,7 @@
|
|
|
162
169
|
"vike": "./node/cli/bin-entry.js"
|
|
163
170
|
},
|
|
164
171
|
"devDependencies": {
|
|
165
|
-
"@brillout/release-me": "^0.1.
|
|
172
|
+
"@brillout/release-me": "^0.1.11",
|
|
166
173
|
"@types/estree": "^1.0.0",
|
|
167
174
|
"@types/jest": "^27.4.1",
|
|
168
175
|
"@types/node": "^20.1.0",
|
|
@@ -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
|
-
}
|