vike 0.4.172 → 0.4.174
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 +3 -0
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -8
- package/dist/cjs/node/plugin/plugins/config/index.js +9 -5
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +135 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +22 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +19 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +22 -42
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
- package/dist/cjs/node/plugin/plugins/previewConfig.js +2 -2
- package/dist/cjs/node/plugin/resolveClientEntriesDev.js +59 -0
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +7 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerVite.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/cjs/node/runtime/onLoad.js +4 -0
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/cjs/node/runtime/renderPage.js +7 -4
- package/dist/cjs/node/{plugin/shared → shared}/isErrorDebug.js +1 -1
- package/dist/cjs/node/shared/utils.js +1 -0
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/utils/assert.js +9 -3
- package/dist/cjs/utils/findFile.js +5 -3
- package/dist/cjs/utils/findPackageJson.js +19 -0
- package/dist/cjs/utils/joinEnglish.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +2 -2
- package/dist/esm/node/plugin/index.js +3 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +5 -9
- package/dist/esm/node/plugin/plugins/config/index.js +9 -5
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +129 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +23 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +20 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +14 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +21 -41
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +2 -2
- package/dist/esm/node/plugin/resolveClientEntriesDev.d.ts +4 -0
- package/dist/esm/node/plugin/resolveClientEntriesDev.js +56 -0
- package/dist/esm/node/plugin/shared/addSsrMiddleware.d.ts +2 -2
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +7 -1
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/esm/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/plugin/shared/loggerVite.js +1 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/esm/node/runtime/onLoad.js +4 -0
- package/dist/esm/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/esm/node/runtime/renderPage.js +7 -4
- package/dist/esm/node/{plugin/shared → shared}/isErrorDebug.js +1 -1
- package/dist/esm/node/shared/utils.d.ts +1 -0
- package/dist/esm/node/shared/utils.js +1 -0
- package/dist/esm/shared/ConfigVike.d.ts +7 -0
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +5 -2
- package/dist/esm/shared/page-configs/Config.d.ts +13 -1
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/assert.d.ts +2 -0
- package/dist/esm/utils/assert.js +8 -2
- package/dist/esm/utils/findFile.js +5 -3
- package/dist/esm/utils/findPackageJson.d.ts +5 -0
- package/dist/esm/utils/findPackageJson.js +16 -0
- package/dist/esm/utils/joinEnglish.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +5 -4
- /package/dist/esm/node/{plugin/shared → shared}/isErrorDebug.d.ts +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export { getPageAssets };
|
|
2
|
-
|
|
2
|
+
export { setResolveClientEntriesDev };
|
|
3
|
+
import { assert, prependBase, toPosixPath, unique, getGlobalObject } from '../utils.js';
|
|
3
4
|
import { retrieveAssetsDev } from './getPageAssets/retrieveAssetsDev.js';
|
|
4
5
|
import { retrieveAssetsProd } from './getPageAssets/retrieveAssetsProd.js';
|
|
5
6
|
import { inferMediaType } from './inferMediaType.js';
|
|
6
7
|
import { getManifestEntry } from './getPageAssets/getManifestEntry.js';
|
|
7
8
|
import { sortPageAssetsForEarlyHintsHeader } from './getPageAssets/sortPageAssetsForEarlyHintsHeader.js';
|
|
8
9
|
import { getGlobalContext } from '../globalContext.js';
|
|
9
|
-
|
|
10
|
+
const globalObject = getGlobalObject('getPageAssets.ts', {
|
|
11
|
+
resolveClientEntriesDev: null
|
|
12
|
+
});
|
|
10
13
|
async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
11
14
|
const globalContext = getGlobalContext();
|
|
12
15
|
const isDev = !globalContext.isProduction;
|
|
@@ -14,7 +17,7 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
14
17
|
let clientEntriesSrc;
|
|
15
18
|
if (isDev) {
|
|
16
19
|
const { viteDevServer } = globalContext;
|
|
17
|
-
clientEntriesSrc = await Promise.all(clientEntries.map((clientEntry) => resolveClientEntriesDev(clientEntry, viteDevServer)));
|
|
20
|
+
clientEntriesSrc = await Promise.all(clientEntries.map((clientEntry) => globalObject.resolveClientEntriesDev(clientEntry, viteDevServer)));
|
|
18
21
|
assetUrls = await retrieveAssetsDev(clientDependencies, viteDevServer);
|
|
19
22
|
}
|
|
20
23
|
else {
|
|
@@ -54,62 +57,6 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
54
57
|
sortPageAssetsForEarlyHintsHeader(pageAssets);
|
|
55
58
|
return pageAssets;
|
|
56
59
|
}
|
|
57
|
-
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
58
|
-
let root = viteDevServer.config.root;
|
|
59
|
-
assert(root);
|
|
60
|
-
root = toPosixPath(root);
|
|
61
|
-
// The `?import` suffix is needed for MDX to be transpiled:
|
|
62
|
-
// - Not transpiled: `/pages/markdown.page.mdx`
|
|
63
|
-
// - Transpiled: `/pages/markdown.page.mdx?import`
|
|
64
|
-
// But `?import` doesn't work with `/@fs/`:
|
|
65
|
-
// - Not transpiled: /@fs/home/runner/work/vike/vike/examples/react-full/pages/markdown.page.mdx
|
|
66
|
-
// - Not transpiled: /@fs/home/runner/work/vike/vike/examples/react-full/pages/markdown.page.mdx?import
|
|
67
|
-
if (clientEntry.endsWith('?import')) {
|
|
68
|
-
assert(clientEntry.startsWith('/'));
|
|
69
|
-
return clientEntry;
|
|
70
|
-
}
|
|
71
|
-
assertPosixPath(clientEntry);
|
|
72
|
-
let filePath;
|
|
73
|
-
if (clientEntry.startsWith('/')) {
|
|
74
|
-
filePath = pathJoin(root, clientEntry);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
const { createRequire } = (await import_('module')).default;
|
|
78
|
-
const { dirname } = (await import_('path')).default;
|
|
79
|
-
const { fileURLToPath } = (await import_('url')).default;
|
|
80
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
81
|
-
const importMetaUrl = import.meta.url;
|
|
82
|
-
const require_ = createRequire(importMetaUrl);
|
|
83
|
-
const __dirname_ = dirname(fileURLToPath(importMetaUrl));
|
|
84
|
-
// @ts-expect-error
|
|
85
|
-
// Bun workaround https://github.com/vikejs/vike/pull/1048
|
|
86
|
-
const res = typeof Bun !== 'undefined' ? (toPath) => Bun.resolveSync(toPath, __dirname_) : require_.resolve;
|
|
87
|
-
if (clientEntry.startsWith('@@vike/')) {
|
|
88
|
-
assert(clientEntry.endsWith('.js'));
|
|
89
|
-
try {
|
|
90
|
-
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
91
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/runtime/renderPage/getPageAssets.js
|
|
92
|
-
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
// For users
|
|
96
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/runtime/renderPage/getPageAssets.js
|
|
97
|
-
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
assertIsNpmPackageImport(clientEntry);
|
|
102
|
-
filePath = res(clientEntry);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (!filePath.startsWith('/')) {
|
|
106
|
-
assert(process.platform === 'win32');
|
|
107
|
-
filePath = '/' + filePath;
|
|
108
|
-
}
|
|
109
|
-
filePath = '/@fs' + filePath;
|
|
110
|
-
assertPosixPath(filePath);
|
|
111
|
-
return filePath;
|
|
112
|
-
}
|
|
113
60
|
function resolveClientEntriesProd(clientEntry, assetsManifest) {
|
|
114
61
|
const { manifestEntry } = getManifestEntry(clientEntry, assetsManifest);
|
|
115
62
|
assert(manifestEntry.isEntry || manifestEntry.isDynamicEntry || clientEntry.endsWith('.css'), { clientEntry });
|
|
@@ -117,3 +64,6 @@ function resolveClientEntriesProd(clientEntry, assetsManifest) {
|
|
|
117
64
|
assert(!file.startsWith('/'));
|
|
118
65
|
return '/' + file;
|
|
119
66
|
}
|
|
67
|
+
function setResolveClientEntriesDev(resolveClientEntriesDev) {
|
|
68
|
+
globalObject.resolveClientEntriesDev = resolveClientEntriesDev;
|
|
69
|
+
}
|
|
@@ -199,7 +199,7 @@ function logHttpRequest(urlOriginal, httpRequestId) {
|
|
|
199
199
|
logRuntimeInfo?.(getRequestInfoMessage(urlOriginal), httpRequestId, 'info', clearErrors);
|
|
200
200
|
}
|
|
201
201
|
function getRequestInfoMessage(urlOriginal) {
|
|
202
|
-
return `HTTP request: ${
|
|
202
|
+
return `HTTP request: ${prettyUrl(urlOriginal)}`;
|
|
203
203
|
}
|
|
204
204
|
function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
205
205
|
const statusCode = pageContextReturn.httpResponse?.statusCode ?? null;
|
|
@@ -215,7 +215,7 @@ function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
|
215
215
|
// - We should show `HTTP response ${urlOriginal} ERR` instead.
|
|
216
216
|
// - Maybe we can/should make the error available at pageContext.errorWhileRendering
|
|
217
217
|
assert(errorWhileRendering === null || errorWhileRendering === undefined);
|
|
218
|
-
msg = `HTTP response ${
|
|
218
|
+
msg = `HTTP response ${prettyUrl(urlOriginal)} ${pc.dim('null')}`;
|
|
219
219
|
// Erroneous value (it shoud sometimes be `false`) but it's fine as it doesn't seem to have much of an impact.
|
|
220
220
|
isNominal = true;
|
|
221
221
|
}
|
|
@@ -235,7 +235,7 @@ function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
|
235
235
|
const urlRedirect = headerRedirect[1];
|
|
236
236
|
urlOriginal = urlRedirect;
|
|
237
237
|
}
|
|
238
|
-
msg = `HTTP ${type} ${
|
|
238
|
+
msg = `HTTP ${type} ${prettyUrl(urlOriginal)} ${color(statusCode ?? 'ERR')}`;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
logRuntimeInfo?.(msg, httpRequestId, isNominal ? 'info' : 'error');
|
|
@@ -443,9 +443,12 @@ function checkBaseUrl(pageContextInit, httpRequestId) {
|
|
|
443
443
|
const { urlWithoutPageContextRequestSuffix } = handlePageContextRequestUrl(urlOriginal);
|
|
444
444
|
const { hasBaseServer } = parseUrl(urlWithoutPageContextRequestSuffix, baseServer);
|
|
445
445
|
if (!hasBaseServer) {
|
|
446
|
-
logRuntimeInfo?.(`${getRequestInfoMessage(urlOriginal)} skipped because URL ${
|
|
446
|
+
logRuntimeInfo?.(`${getRequestInfoMessage(urlOriginal)} skipped because URL ${prettyUrl(urlOriginal)} doesn't start with Base URL ${prettyUrl(baseServer)} (https://vike.dev/base-url)`, httpRequestId, 'info');
|
|
447
447
|
const pageContextHttpResponseNull = getPageContextHttpResponseNull(pageContextInit);
|
|
448
448
|
return pageContextHttpResponseNull;
|
|
449
449
|
}
|
|
450
450
|
return null;
|
|
451
451
|
}
|
|
452
|
+
function prettyUrl(url) {
|
|
453
|
+
return pc.bold(decodeURI(url));
|
|
454
|
+
}
|
|
@@ -14,6 +14,9 @@ type ConfigVikeResolved = {
|
|
|
14
14
|
redirects: Record<string, string>;
|
|
15
15
|
trailingSlash: boolean;
|
|
16
16
|
disableUrlNormalization: boolean;
|
|
17
|
+
crawl: {
|
|
18
|
+
git: null | boolean;
|
|
19
|
+
};
|
|
17
20
|
};
|
|
18
21
|
type ConfigVikeUserProvided = {
|
|
19
22
|
/**
|
|
@@ -98,4 +101,8 @@ type ConfigVikeUserProvided = {
|
|
|
98
101
|
* @default false
|
|
99
102
|
*/
|
|
100
103
|
disableUrlNormalization?: boolean;
|
|
104
|
+
/** @experimental https://github.com/vikejs/vike/issues/1655 */
|
|
105
|
+
crawl?: {
|
|
106
|
+
git?: boolean;
|
|
107
|
+
};
|
|
101
108
|
};
|
|
@@ -2,6 +2,6 @@ export { analyzeClientSide };
|
|
|
2
2
|
import type { PageConfigRuntime } from '../page-configs/PageConfig.js';
|
|
3
3
|
import type { PageFile } from './getPageFileObject.js';
|
|
4
4
|
declare function analyzeClientSide(pageConfig: PageConfigRuntime | null, pageFilesAll: PageFile[], pageId: string): {
|
|
5
|
-
|
|
5
|
+
clientEntryLoaded: boolean;
|
|
6
6
|
isClientRouting: boolean;
|
|
7
7
|
};
|
|
@@ -5,13 +5,13 @@ function analyzeClientSide(pageConfig, pageFilesAll, pageId) {
|
|
|
5
5
|
// V1 design
|
|
6
6
|
if (pageConfig) {
|
|
7
7
|
const isClientRouting = getConfigValueRuntime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
8
|
-
const
|
|
9
|
-
return {
|
|
8
|
+
const clientEntryLoaded = getConfigValueRuntime(pageConfig, 'clientEntryLoaded', 'boolean')?.value ?? false;
|
|
9
|
+
return { clientEntryLoaded, isClientRouting };
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
12
12
|
// TODO/v1-release: remove
|
|
13
13
|
// V0.4 design
|
|
14
14
|
const { isHtmlOnly, isClientRouting } = analyzePageClientSide(pageFilesAll, pageId);
|
|
15
|
-
return {
|
|
15
|
+
return { clientEntryLoaded: !isHtmlOnly, isClientRouting };
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export type { PageContextConfig };
|
|
2
2
|
import type { VikePackages } from '../../VikeNamespace.js';
|
|
3
|
-
import type { ConfigBuiltIn } from '../Config.js';
|
|
3
|
+
import type { ConfigBuiltIn, ImportString } from '../Config.js';
|
|
4
4
|
import type { Combine, IsNotEmpty, XOR5 } from './helpers.js';
|
|
5
|
-
type
|
|
5
|
+
type WithoutImportString<T> = {
|
|
6
|
+
[K in keyof T]: Exclude<T[K], ImportString>;
|
|
7
|
+
};
|
|
8
|
+
type PageContextConfig = ConfigBuiltIn & Vike.ConfigResolved & WithoutImportString<Omit<Vike.Config, keyof Vike.ConfigResolved>> & (ConfigVikePackagesNotEmptyXor extends true ? ConfigVikePackagesIntersection : ConfigVikePackagesCombined);
|
|
6
9
|
type ConfigVikePackagesIntersection = VikePackages.ConfigVikeReact & VikePackages.ConfigVikeVue & VikePackages.ConfigVikeSolid & VikePackages.ConfigVikeSvelte & VikePackages.ConfigVikeAngular;
|
|
7
10
|
type ConfigVikePackagesCombined = Combine<VikePackages.ConfigVikeReact, Combine<VikePackages.ConfigVikeVue, Combine<VikePackages.ConfigVikeSolid, Combine<VikePackages.ConfigVikeSvelte, VikePackages.ConfigVikeAngular>>>>;
|
|
8
11
|
type ConfigVikePackagesNotEmptyXor = XOR5<IsNotEmpty<VikePackages.ConfigVikeReact>, IsNotEmpty<VikePackages.ConfigVikeVue>, IsNotEmpty<VikePackages.ConfigVikeSolid>, IsNotEmpty<VikePackages.ConfigVikeSvelte>, IsNotEmpty<VikePackages.ConfigVikeAngular>>;
|
|
@@ -5,6 +5,7 @@ export type { ConfigMeta };
|
|
|
5
5
|
export type { HookName };
|
|
6
6
|
export type { HookNamePage };
|
|
7
7
|
export type { HookNameGlobal };
|
|
8
|
+
export type { ImportString };
|
|
8
9
|
export type { DataAsync };
|
|
9
10
|
export type { DataSync };
|
|
10
11
|
export type { GuardAsync };
|
|
@@ -40,7 +41,7 @@ type HookName = HookNamePage | HookNameGlobal | HookNameOldDesign;
|
|
|
40
41
|
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data';
|
|
41
42
|
type HookNameGlobal = 'onBeforePrerender' | 'onBeforeRoute' | 'onPrerenderStart';
|
|
42
43
|
type HookNameOldDesign = 'render' | 'prerender';
|
|
43
|
-
type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | '
|
|
44
|
+
type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'clientEntryLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks';
|
|
44
45
|
type Config = ConfigBuiltIn & Vike.Config & (VikePackages.ConfigVikeReact | VikePackages.ConfigVikeVue | VikePackages.ConfigVikeSolid | VikePackages.ConfigVikeSvelte | VikePackages.ConfigVikeAngular);
|
|
45
46
|
/** Hook for fetching data.
|
|
46
47
|
*
|
|
@@ -326,6 +327,12 @@ type ConfigBuiltIn = {
|
|
|
326
327
|
* https://vike.dev/clientRouting
|
|
327
328
|
*/
|
|
328
329
|
clientRouting?: boolean | ImportString;
|
|
330
|
+
/**
|
|
331
|
+
* Whether hooks are loaded on the client-side.
|
|
332
|
+
*
|
|
333
|
+
* https://vike.dev/clientHooks
|
|
334
|
+
*/
|
|
335
|
+
clientHooks?: boolean | null | ImportString;
|
|
329
336
|
/** Create new or modify existing configurations.
|
|
330
337
|
*
|
|
331
338
|
* https://vike.dev/meta
|
|
@@ -352,6 +359,11 @@ type ConfigBuiltIn = {
|
|
|
352
359
|
* https://vike.dev/extends
|
|
353
360
|
*/
|
|
354
361
|
name?: string;
|
|
362
|
+
/** Used by Vike extensions to enforce their peer dependencies.
|
|
363
|
+
*
|
|
364
|
+
* https://vike.dev/require
|
|
365
|
+
*/
|
|
366
|
+
require?: Record<string, string>;
|
|
355
367
|
};
|
|
356
368
|
type ConfigMeta = Record<string, ConfigDefinition>;
|
|
357
369
|
type ImportString = `import:${string}`;
|
|
@@ -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, 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';
|
|
9
|
+
export type { Config, ConfigMeta as Meta, ImportString, 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';
|
|
@@ -7,6 +7,7 @@ export { addOnBeforeLogHook };
|
|
|
7
7
|
export { getAssertErrMsg };
|
|
8
8
|
export { overwriteAssertProductionLogger };
|
|
9
9
|
export { isBug };
|
|
10
|
+
export { setAlwaysShowStackTrace };
|
|
10
11
|
type Logger = (msg: string | Error, logType: 'warn' | 'info') => void;
|
|
11
12
|
declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
|
|
12
13
|
declare function assertUsage(condition: unknown, errMsg: string, { showStackTrace }?: {
|
|
@@ -27,3 +28,4 @@ declare function getAssertErrMsg(thing: unknown): {
|
|
|
27
28
|
} | null;
|
|
28
29
|
declare function overwriteAssertProductionLogger(logger: Logger): void;
|
|
29
30
|
declare function isBug(err: unknown): boolean;
|
|
31
|
+
declare function setAlwaysShowStackTrace(): void;
|
package/dist/esm/utils/assert.js
CHANGED
|
@@ -7,6 +7,7 @@ export { addOnBeforeLogHook };
|
|
|
7
7
|
export { getAssertErrMsg };
|
|
8
8
|
export { overwriteAssertProductionLogger };
|
|
9
9
|
export { isBug };
|
|
10
|
+
export { setAlwaysShowStackTrace };
|
|
10
11
|
import { onAssertModuleLoad } from './assertSingleInstance.js';
|
|
11
12
|
import { createErrorWithCleanStackTrace } from './createErrorWithCleanStackTrace.js';
|
|
12
13
|
import { getGlobalObject } from './getGlobalObject.js';
|
|
@@ -40,9 +41,9 @@ function assert(condition, debugInfo) {
|
|
|
40
41
|
const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : JSON.stringify(debugInfo);
|
|
41
42
|
return pc.dim(`Debug info (for Vike maintainers; you can ignore this): ${debugInfoSerialized}`);
|
|
42
43
|
})();
|
|
44
|
+
const link = pc.blue('https://github.com/vikejs/vike/issues/new');
|
|
43
45
|
let errMsg = [
|
|
44
|
-
`You stumbled upon a Vike bug.`,
|
|
45
|
-
`Go to ${pc.blue('https://github.com/vikejs/vike/issues/new')} and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).`,
|
|
46
|
+
`You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).`,
|
|
46
47
|
debugStr
|
|
47
48
|
]
|
|
48
49
|
.filter(Boolean)
|
|
@@ -57,6 +58,7 @@ function assert(condition, debugInfo) {
|
|
|
57
58
|
function assertUsage(condition, errMsg, { showStackTrace } = {}) {
|
|
58
59
|
if (condition)
|
|
59
60
|
return;
|
|
61
|
+
showStackTrace = showStackTrace || globalObject.alwaysShowStackTrace;
|
|
60
62
|
errMsg = addWhitespace(errMsg);
|
|
61
63
|
errMsg = addPrefixAssertType(errMsg, 'Wrong Usage');
|
|
62
64
|
errMsg = addPrefixProjctName(errMsg);
|
|
@@ -77,6 +79,7 @@ function getProjectError(errMsg) {
|
|
|
77
79
|
function assertWarning(condition, msg, { onlyOnce, showStackTrace }) {
|
|
78
80
|
if (condition)
|
|
79
81
|
return;
|
|
82
|
+
showStackTrace = showStackTrace || globalObject.alwaysShowStackTrace;
|
|
80
83
|
msg = addWhitespace(msg);
|
|
81
84
|
msg = addPrefixAssertType(msg, 'Warning');
|
|
82
85
|
msg = addPrefixProjctName(msg);
|
|
@@ -187,3 +190,6 @@ function overwriteAssertProductionLogger(logger) {
|
|
|
187
190
|
function isBug(err) {
|
|
188
191
|
return !String(err).includes('[Bug]');
|
|
189
192
|
}
|
|
193
|
+
function setAlwaysShowStackTrace() {
|
|
194
|
+
globalObject.alwaysShowStackTrace = true;
|
|
195
|
+
}
|
|
@@ -2,19 +2,21 @@ export { findFile };
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { isArray } from './isArray.js';
|
|
5
|
+
import { assertPosixPath } from './filesystemPathHandling.js';
|
|
5
6
|
function findFile(arg, cwd) {
|
|
7
|
+
assertPosixPath(cwd);
|
|
6
8
|
const filenames = isArray(arg) ? arg : [arg];
|
|
7
9
|
let dir = cwd;
|
|
8
10
|
while (true) {
|
|
9
11
|
for (const filename of filenames) {
|
|
10
|
-
const configFilePath = path.join(dir, `./${filename}`);
|
|
12
|
+
const configFilePath = path.posix.join(dir, `./${filename}`);
|
|
11
13
|
if (fs.existsSync(configFilePath)) {
|
|
12
|
-
|
|
14
|
+
assertPosixPath(configFilePath);
|
|
13
15
|
return configFilePath;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
const dirPrevious = dir;
|
|
17
|
-
dir = path.dirname(dir);
|
|
19
|
+
dir = path.posix.dirname(dir);
|
|
18
20
|
if (dir === dirPrevious) {
|
|
19
21
|
return null;
|
|
20
22
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { findPackageJson };
|
|
2
|
+
import { findFile } from './findFile.js';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
5
|
+
const importMetaUrl = import.meta.url;
|
|
6
|
+
const require_ = createRequire(importMetaUrl);
|
|
7
|
+
function findPackageJson(cwd) {
|
|
8
|
+
const packageJsonPath = findFile('package.json', cwd);
|
|
9
|
+
if (!packageJsonPath)
|
|
10
|
+
return null;
|
|
11
|
+
const packageJson = require_(packageJsonPath);
|
|
12
|
+
return {
|
|
13
|
+
packageJson,
|
|
14
|
+
packageJsonPath
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -7,5 +7,5 @@ function joinEnglish(arr, conjunction, colorizer = (s) => s) {
|
|
|
7
7
|
return colorizer(arr[0]);
|
|
8
8
|
const firsts = arr.slice(0, arr.length - 1);
|
|
9
9
|
const last = arr[arr.length - 1];
|
|
10
|
-
return firsts.map(colorizer).join(', ') +
|
|
10
|
+
return firsts.map(colorizer).join(', ') + `, ${conjunction} ` + colorizer(last);
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.174",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@brillout/import": "^0.2.3",
|
|
17
17
|
"@brillout/json-serializer": "^0.5.10",
|
|
18
|
-
"@brillout/picocolors": "^1.0.
|
|
18
|
+
"@brillout/picocolors": "^1.0.13",
|
|
19
19
|
"@brillout/require-shim": "^0.1.2",
|
|
20
20
|
"@brillout/vite-plugin-server-entry": "^0.4.5",
|
|
21
21
|
"acorn": "^8.0.0",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"es-module-lexer": "^1.0.0",
|
|
24
24
|
"esbuild": "^0.19.0",
|
|
25
25
|
"fast-glob": "^3.0.0",
|
|
26
|
+
"semver": "^7.6.2",
|
|
26
27
|
"sirv": "^2.0.0",
|
|
27
28
|
"source-map-support": "^0.5.0"
|
|
28
29
|
},
|
|
@@ -194,8 +195,8 @@
|
|
|
194
195
|
"@biomejs/biome": "^1.5.3",
|
|
195
196
|
"@brillout/import": "^0.2.3",
|
|
196
197
|
"@brillout/json-serializer": "^0.5.8",
|
|
197
|
-
"@brillout/picocolors": "^1.0.
|
|
198
|
-
"@brillout/release-me": "^0.3.
|
|
198
|
+
"@brillout/picocolors": "^1.0.13",
|
|
199
|
+
"@brillout/release-me": "^0.3.8",
|
|
199
200
|
"@brillout/require-shim": "^0.1.2",
|
|
200
201
|
"@brillout/vite-plugin-server-entry": "^0.4.0",
|
|
201
202
|
"@types/estree": "^1.0.5",
|
|
File without changes
|