vike 0.4.165-commit-8eba585 → 0.4.166-commit-6a8acaa
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/plugins/buildConfig.js +11 -6
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +17 -22
- package/dist/cjs/node/plugin/plugins/envVars.js +3 -2
- package/dist/cjs/node/plugin/plugins/fileEnv.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +6 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +22 -18
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +7 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -3
- package/dist/cjs/node/plugin/shared/getFilePath.js +142 -0
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +3 -8
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +6 -7
- package/dist/cjs/node/prerender/utils.js +2 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -9
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +6 -12
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +5 -0
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/shared/route/abort.js +2 -1
- package/dist/cjs/shared/route/executeGuardHook.js +2 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/cjs/utils/isNpmPackage.js +11 -2
- package/dist/cjs/utils/parseUrl.js +8 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/history.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/history.js +5 -5
- package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +12 -7
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -23
- package/dist/esm/node/plugin/plugins/envVars.js +4 -3
- package/dist/esm/node/plugin/plugins/fileEnv.js +7 -4
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +7 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +6 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +22 -18
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +7 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -3
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +21 -0
- package/dist/esm/node/plugin/shared/getFilePath.js +136 -0
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/runPrerender.js +2 -3
- package/dist/esm/node/prerender/utils.d.ts +2 -1
- package/dist/esm/node/prerender/utils.js +2 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -10
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +7 -13
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +2 -0
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/shared/page-configs/FilePath.d.ts +41 -29
- package/dist/esm/shared/route/abort.js +2 -1
- package/dist/esm/shared/route/executeGuardHook.js +2 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/isNpmPackage.d.ts +5 -1
- package/dist/esm/utils/isNpmPackage.js +10 -1
- package/dist/esm/utils/parseUrl.js +8 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +25 -13
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getFilePath.js +0 -90
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -19
- package/dist/cjs/utils/getFilePathAbsolute.js +0 -70
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getFilePath.d.ts +0 -20
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getFilePath.js +0 -84
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.d.ts +0 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -16
- package/dist/esm/utils/getFilePathAbsolute.d.ts +0 -5
- package/dist/esm/utils/getFilePathAbsolute.js +0 -64
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export { getPageAssets };
|
|
2
|
-
import { assert, prependBase, assertPosixPath, toPosixPath,
|
|
2
|
+
import { assert, prependBase, assertPosixPath, toPosixPath, unique, pathJoin, assertIsNpmPackageImport } from '../utils.js';
|
|
3
3
|
import { retrieveAssetsDev } from './getPageAssets/retrieveAssetsDev.js';
|
|
4
4
|
import { retrieveAssetsProd } from './getPageAssets/retrieveAssetsProd.js';
|
|
5
5
|
import { inferMediaType } from './inferMediaType.js';
|
|
6
6
|
import { getManifestEntry } from './getPageAssets/getManifestEntry.js';
|
|
7
7
|
import { sortPageAssetsForEarlyHintsHeader } from './getPageAssets/sortPageAssetsForEarlyHintsHeader.js';
|
|
8
8
|
import { getGlobalContext } from '../globalContext.js';
|
|
9
|
-
import { assertClientEntryId } from './getPageAssets/assertClientEntryId.js';
|
|
10
9
|
import { import_ } from '@brillout/import';
|
|
11
10
|
async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
12
11
|
const globalContext = getGlobalContext();
|
|
@@ -56,7 +55,6 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
56
55
|
return pageAssets;
|
|
57
56
|
}
|
|
58
57
|
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
59
|
-
assertClientEntryId(clientEntry);
|
|
60
58
|
let root = viteDevServer.config.root;
|
|
61
59
|
assert(root);
|
|
62
60
|
root = toPosixPath(root);
|
|
@@ -73,11 +71,9 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
73
71
|
assertPosixPath(clientEntry);
|
|
74
72
|
let filePath;
|
|
75
73
|
if (clientEntry.startsWith('/')) {
|
|
76
|
-
// User files
|
|
77
74
|
filePath = pathJoin(root, clientEntry);
|
|
78
75
|
}
|
|
79
|
-
else
|
|
80
|
-
// Vike client entry
|
|
76
|
+
else {
|
|
81
77
|
const { createRequire } = (await import_('module')).default;
|
|
82
78
|
const { dirname } = (await import_('path')).default;
|
|
83
79
|
const { fileURLToPath } = (await import_('url')).default;
|
|
@@ -88,10 +84,7 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
88
84
|
// @ts-expect-error
|
|
89
85
|
// Bun workaround https://github.com/vikejs/vike/pull/1048
|
|
90
86
|
const res = typeof Bun !== 'undefined' ? (toPath) => Bun.resolveSync(toPath, __dirname_) : require_.resolve;
|
|
91
|
-
if (
|
|
92
|
-
filePath = res(clientEntry);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
87
|
+
if (clientEntry.startsWith('@@vike/')) {
|
|
95
88
|
assert(clientEntry.endsWith('.js'));
|
|
96
89
|
try {
|
|
97
90
|
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
@@ -104,9 +97,10 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
104
97
|
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
105
98
|
}
|
|
106
99
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
else {
|
|
101
|
+
assertIsNpmPackageImport(clientEntry);
|
|
102
|
+
filePath = res(clientEntry);
|
|
103
|
+
}
|
|
110
104
|
}
|
|
111
105
|
if (!filePath.startsWith('/')) {
|
|
112
106
|
assert(process.platform === 'win32');
|
|
@@ -4,6 +4,7 @@ export { isCjsEsmError };
|
|
|
4
4
|
export { isKnownError };
|
|
5
5
|
export { getHint };
|
|
6
6
|
import { assert, formatHintLog, isNotNullish, isObject, unique } from '../utils.js';
|
|
7
|
+
import pc from '@brillout/picocolors';
|
|
7
8
|
const knownErrors = [
|
|
8
9
|
{
|
|
9
10
|
errMsg: 'jsxDEV is not a function',
|
|
@@ -44,6 +45,7 @@ function getHint(error) {
|
|
|
44
45
|
}
|
|
45
46
|
function logHint(hint) {
|
|
46
47
|
hint = formatHintLog(hint);
|
|
48
|
+
hint = pc.bold(hint);
|
|
47
49
|
console.error(hint);
|
|
48
50
|
}
|
|
49
51
|
function isKnownError(error) {
|
|
@@ -29,7 +29,6 @@ export * from '../../utils/isPropertyGetter.js';
|
|
|
29
29
|
export * from '../../utils/debug.js';
|
|
30
30
|
export * from '../../utils/urlToFile.js';
|
|
31
31
|
export * from '../../utils/getGlobalObject.js';
|
|
32
|
-
export * from '../../shared/hooks/executeHook.js';
|
|
33
32
|
export * from '../../utils/freezePartial.js';
|
|
34
33
|
export * from '../../utils/isNpmPackage.js';
|
|
35
34
|
export * from '../../utils/isNotNullish.js';
|
|
@@ -32,7 +32,6 @@ export * from '../../utils/isPropertyGetter.js';
|
|
|
32
32
|
export * from '../../utils/debug.js';
|
|
33
33
|
export * from '../../utils/urlToFile.js';
|
|
34
34
|
export * from '../../utils/getGlobalObject.js';
|
|
35
|
-
export * from '../../shared/hooks/executeHook.js';
|
|
36
35
|
export * from '../../utils/freezePartial.js';
|
|
37
36
|
export * from '../../utils/isNpmPackage.js';
|
|
38
37
|
export * from '../../utils/isNotNullish.js';
|
|
@@ -2,51 +2,63 @@ export type { FilePath };
|
|
|
2
2
|
export type { FilePathResolved };
|
|
3
3
|
type FilePathResolved = FilePath & {
|
|
4
4
|
filePathAbsoluteFilesystem: string;
|
|
5
|
+
/**
|
|
6
|
+
* The file's path, shown to the user in logs.
|
|
7
|
+
*
|
|
8
|
+
* Resolved: it always shows a file path. (It nevers shows an import path such as `vike-react/config`.)
|
|
9
|
+
*
|
|
10
|
+
* Its value is equivalent to `filePath.filePathAbsoluteUserRootDir ?? filePath.filePathAbsoluteFilesystem`.
|
|
11
|
+
*/
|
|
5
12
|
filePathToShowToUserResolved: string;
|
|
6
13
|
};
|
|
7
|
-
type
|
|
8
|
-
|
|
14
|
+
type IsReferencedByUserLandFile = {
|
|
15
|
+
filePathAbsoluteUserRootDir: string;
|
|
16
|
+
} | {
|
|
17
|
+
importPathAbsolute: string;
|
|
18
|
+
};
|
|
19
|
+
type FilePath = FilePathProps & IsReferencedByUserLandFile;
|
|
20
|
+
type FilePathProps = {
|
|
21
|
+
/**
|
|
22
|
+
* The file's path, absolute starting from the filesystem root.
|
|
9
23
|
*
|
|
10
|
-
*
|
|
11
|
-
* - `vike-react/config`, or
|
|
12
|
-
* - `/pages/+config.js`.
|
|
24
|
+
* Example: `/home/rom/code/my-app/pages/some-page/+Page.js`
|
|
13
25
|
*
|
|
14
|
-
*
|
|
26
|
+
* The value is `null` for imports using path aliases. (Because Vike cannot resolve path aliases, otherwise Vike would need to re-implement https://www.npmjs.com/package/@rollup/plugin-alias.)
|
|
15
27
|
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
28
|
+
filePathAbsoluteFilesystem: string | null;
|
|
29
|
+
/**
|
|
30
|
+
* The file's path, absolute starting from the user root directory (i.e. Vite's `config.root`).
|
|
31
|
+
*
|
|
32
|
+
* Example: `/pages/some-page/+Page.js`.
|
|
18
33
|
*
|
|
19
|
-
*
|
|
34
|
+
* Its value is `null` if the file is outside of the user root directory (i.e. Vite's `config.root`).
|
|
20
35
|
*
|
|
21
|
-
* The value is `null` upon aliased import paths which we cannot resolve (we'd need to re-implement https://www.npmjs.com/package/@rollup/plugin-alias).
|
|
22
36
|
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
37
|
+
filePathAbsoluteUserRootDir: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* The file's path, shown to the user in logs.
|
|
25
40
|
*
|
|
26
|
-
* Unresolved: it may show an import path of a
|
|
41
|
+
* Unresolved: it may show an import path instead of a file path such as `vike-react/config`.
|
|
27
42
|
*
|
|
28
|
-
*
|
|
43
|
+
* Its value is equivalent to `filePath.filePathAbsoluteUserRootDir ?? filePath.importPathAbsolute`.
|
|
29
44
|
*/
|
|
30
45
|
filePathToShowToUser: string;
|
|
31
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* The file's non-relative path, from Vite's perspective.
|
|
32
48
|
*
|
|
33
|
-
*
|
|
49
|
+
* Examples:
|
|
50
|
+
* - `/pages/+config.js`
|
|
51
|
+
* - `vike-react/config`
|
|
34
52
|
*
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
filePathToShowToUserResolved: string | null;
|
|
38
|
-
/** The file's path, absolute starting from the user root directory (i.e. Vite's `config.root`).
|
|
53
|
+
* We use it to generate import paths in virtual modules. (Since import paths in virtual modules cannot be relative.)
|
|
39
54
|
*
|
|
40
|
-
*
|
|
55
|
+
* Its value is equivalent to `filePath.filePathAbsoluteUserRootDir ?? filePath.importPathAbsolute`.
|
|
41
56
|
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
57
|
+
filePathAbsoluteVite: string;
|
|
58
|
+
/**
|
|
59
|
+
* The file's non-relative import path. It's either:
|
|
44
60
|
* - an npm package import (e.g. `vike-react/config`), or
|
|
45
|
-
* -
|
|
61
|
+
* - a path alias import (e.g. `#components/Counter').
|
|
46
62
|
*/
|
|
47
63
|
importPathAbsolute: string | null;
|
|
48
|
-
}
|
|
49
|
-
importPathAbsolute: string;
|
|
50
|
-
} | {
|
|
51
|
-
filePathAbsoluteUserRootDir: string;
|
|
52
|
-
});
|
|
64
|
+
};
|
|
@@ -7,7 +7,8 @@ export { logAbortErrorHandled };
|
|
|
7
7
|
export { getPageContextFromAllRewrites };
|
|
8
8
|
export { AbortRender };
|
|
9
9
|
export { assertNoInfiniteAbortLoop };
|
|
10
|
-
import {
|
|
10
|
+
import { isUserHookError } from '../hooks/executeHook.js';
|
|
11
|
+
import { assert, assertInfo, assertUsage, assertWarning, checkType, hasProp, isUriWithProtocol, joinEnglish, objectAssign, truncateString } from './utils.js';
|
|
11
12
|
import pc from '@brillout/picocolors';
|
|
12
13
|
/**
|
|
13
14
|
* Abort the rendering of the current page, and redirect the user to another URL instead.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { executeGuardHook };
|
|
2
2
|
import { getHook, getHookTimeoutDefault } from '../hooks/getHook.js';
|
|
3
|
-
import { assert, assertUsage,
|
|
3
|
+
import { assert, assertUsage, isCallable } from './utils.js';
|
|
4
|
+
import { executeHook } from '../hooks/executeHook.js';
|
|
4
5
|
const errIntro = 'The guard() hook defined by';
|
|
5
6
|
async function executeGuardHook(pageContext, prepareForUserConsumption) {
|
|
6
7
|
let hook;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { executeOnBeforeRouteHook };
|
|
2
2
|
import { assertPageContextProvidedByUser } from '../assertPageContextProvidedByUser.js';
|
|
3
|
-
import { assertUsage, hasProp, isObjectWithKeys, objectAssign, assertWarning, assertUsageUrl, joinEnglish, assert
|
|
3
|
+
import { assertUsage, hasProp, isObjectWithKeys, objectAssign, assertWarning, assertUsageUrl, joinEnglish, assert } from './utils.js';
|
|
4
4
|
import { assertRouteParams, assertSyncRouting } from './resolveRouteFunction.js';
|
|
5
5
|
import pc from '@brillout/picocolors';
|
|
6
|
+
import { executeHook } from '../hooks/executeHook.js';
|
|
6
7
|
async function executeOnBeforeRouteHook(pageContext) {
|
|
7
8
|
const pageContextFromOnBeforeRouteHook = {};
|
|
8
9
|
if (!pageContext._onBeforeRouteHook)
|
|
@@ -10,7 +10,6 @@ export * from '../../utils/isStringRecord.js';
|
|
|
10
10
|
export * from '../../utils/unique.js';
|
|
11
11
|
export * from '../../utils/isBrowser.js';
|
|
12
12
|
export * from '../../utils/parseUrl.js';
|
|
13
|
-
export * from '../hooks/executeHook.js';
|
|
14
13
|
export * from '../../utils/checkType.js';
|
|
15
14
|
export * from '../../utils/joinEnglish.js';
|
|
16
15
|
export * from '../../utils/projectInfo.js';
|
|
@@ -19,7 +19,6 @@ export * from '../../utils/isStringRecord.js';
|
|
|
19
19
|
export * from '../../utils/unique.js';
|
|
20
20
|
export * from '../../utils/isBrowser.js';
|
|
21
21
|
export * from '../../utils/parseUrl.js';
|
|
22
|
-
export * from '../hooks/executeHook.js';
|
|
23
22
|
export * from '../../utils/checkType.js';
|
|
24
23
|
export * from '../../utils/joinEnglish.js';
|
|
25
24
|
export * from '../../utils/projectInfo.js';
|
|
@@ -5,6 +5,7 @@ import { assertPosixPath } from './filesystemPathHandling.js';
|
|
|
5
5
|
/** Assert path is absolute from the filesystem root */
|
|
6
6
|
function assertPathIsFilesystemAbsolute(p) {
|
|
7
7
|
assertPosixPath(p);
|
|
8
|
+
assert(!p.startsWith('/@fs/'));
|
|
8
9
|
if (process.platform === 'win32') {
|
|
9
10
|
assert(path.win32.isAbsolute(p));
|
|
10
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugEnabled };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
type Flag = 'vike:routing' | 'vike:error' | 'vike:stream' | 'vike:log' | 'vike:virtual-files' | 'vike:outDir' | 'vike:extractExportNames' | 'vike:extractAssets' | 'vike:glob' | 'vike:pageFiles' | 'vike:setup' | 'vike:pointer-imports';
|
|
4
|
+
type Flag = 'vike:routing' | 'vike:error' | 'vike:stream' | 'vike:log' | 'vike:virtual-files' | 'vike:outDir' | 'vike:extractExportNames' | 'vike:extractAssets' | 'vike:glob' | 'vike:pageFiles' | 'vike:setup' | 'vike:pointer-imports' | 'vike:optimizeDeps';
|
|
5
5
|
type Debug = ReturnType<typeof createDebugger>;
|
|
6
6
|
type Options = {
|
|
7
7
|
serialization?: {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export { isNpmPackageImport };
|
|
2
|
+
export { assertIsNpmPackageImport };
|
|
2
3
|
export { isValidPathAlias };
|
|
3
4
|
export { parse };
|
|
4
5
|
export { isDistinguishable };
|
|
5
|
-
declare function isNpmPackageImport(str: string
|
|
6
|
+
declare function isNpmPackageImport(str: string, { cannotBePathAlias }: {
|
|
7
|
+
cannotBePathAlias: true;
|
|
8
|
+
}): boolean;
|
|
9
|
+
declare function assertIsNpmPackageImport(str: string): void;
|
|
6
10
|
declare function isValidPathAlias(alias: string): boolean;
|
|
7
11
|
declare function isDistinguishable(alias: string): boolean;
|
|
8
12
|
declare function parse(str: string | undefined): null | {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { isNpmPackageImport };
|
|
2
|
+
export { assertIsNpmPackageImport };
|
|
2
3
|
export { isValidPathAlias };
|
|
3
4
|
/* Currently not used
|
|
4
5
|
export { isNpmPackageName }
|
|
@@ -11,10 +12,18 @@ export { isDistinguishable };
|
|
|
11
12
|
import { assert } from './assert.js';
|
|
12
13
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
13
14
|
assertIsNotBrowser();
|
|
14
|
-
function isNpmPackageImport(str) {
|
|
15
|
+
function isNpmPackageImport(str, { cannotBePathAlias }) {
|
|
16
|
+
// We cannot distinguish path alises that look like npm package imports
|
|
17
|
+
assert(cannotBePathAlias);
|
|
15
18
|
const res = parse(str);
|
|
16
19
|
return res !== null;
|
|
17
20
|
}
|
|
21
|
+
function assertIsNpmPackageImport(str) {
|
|
22
|
+
assert(isNpmPackageImport(str, {
|
|
23
|
+
// If `str` is a path alias that looks like an npm package => assertIsNpmPackageImport() is erroneous but that's okay because the assertion will eventually fail for some other user using a disambiguated path alias.
|
|
24
|
+
cannotBePathAlias: true
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
18
27
|
function isNpmPackageName(str) {
|
|
19
28
|
const res = parse(str);
|
|
20
29
|
return res !== null && res.importPath === null;
|
|
@@ -12,7 +12,14 @@ export { isUriWithProtocol };
|
|
|
12
12
|
import { slice } from './slice.js';
|
|
13
13
|
import { assert, assertUsage } from './assert.js';
|
|
14
14
|
import pc from '@brillout/picocolors';
|
|
15
|
-
const PROTOCOLS = [
|
|
15
|
+
const PROTOCOLS = [
|
|
16
|
+
'http://',
|
|
17
|
+
'https://',
|
|
18
|
+
// For [Tauri](https://tauri.app/)
|
|
19
|
+
'tauri://',
|
|
20
|
+
// For Electron: https://github.com/vikejs/vike/issues/1557
|
|
21
|
+
'file://'
|
|
22
|
+
];
|
|
16
23
|
function isParsable(url) {
|
|
17
24
|
// `parseUrl()` works with these URLs
|
|
18
25
|
return (PROTOCOLS.some((p) => url.startsWith(p)) ||
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.166-commit-6a8acaa";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.166-commit-6a8acaa";
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.166-commit-6a8acaa",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"require": "./dist/cjs/node/runtime/index-deprecated.js",
|
|
34
34
|
"node": "./dist/esm/node/runtime/index-deprecated.js",
|
|
35
35
|
"browser": "./dist/esm/client/node.js",
|
|
36
|
-
"types": "./dist/esm/node/runtime/index-deprecated.d.ts"
|
|
36
|
+
"types": "./dist/esm/node/runtime/index-deprecated.d.ts",
|
|
37
|
+
"default": "./dist/esm/node/runtime/index-deprecated.js"
|
|
37
38
|
},
|
|
38
39
|
"./server": {
|
|
39
40
|
"worker": "./dist/esm/node/runtime/index.js",
|
|
@@ -41,7 +42,8 @@
|
|
|
41
42
|
"require": "./dist/cjs/node/runtime/index.js",
|
|
42
43
|
"node": "./dist/esm/node/runtime/index.js",
|
|
43
44
|
"browser": "./dist/esm/client/node.js",
|
|
44
|
-
"types": "./dist/esm/node/runtime/index.d.ts"
|
|
45
|
+
"types": "./dist/esm/node/runtime/index.d.ts",
|
|
46
|
+
"default": "./dist/esm/node/runtime/index.js"
|
|
45
47
|
},
|
|
46
48
|
"./client": {
|
|
47
49
|
"types": "./dist/esm/client/server-routing-runtime/index.d.ts"
|
|
@@ -55,7 +57,8 @@
|
|
|
55
57
|
"require": "./dist/cjs/node/client/router.js",
|
|
56
58
|
"node": "./dist/esm/node/client/router.js",
|
|
57
59
|
"browser": "./dist/esm/client/client-routing-runtime/index.js",
|
|
58
|
-
"types": "./dist/esm/client/client-routing-runtime/index.d.ts"
|
|
60
|
+
"types": "./dist/esm/client/client-routing-runtime/index.d.ts",
|
|
61
|
+
"default": "./dist/esm/client/client-routing-runtime/index.js"
|
|
59
62
|
},
|
|
60
63
|
"./routing": {
|
|
61
64
|
"worker": "./dist/esm/shared/route/routing.js",
|
|
@@ -63,22 +66,26 @@
|
|
|
63
66
|
"require": "./dist/cjs/shared/route/routing.js",
|
|
64
67
|
"node": "./dist/esm/shared/route/routing.js",
|
|
65
68
|
"browser": "./dist/esm/shared/route/routing.js",
|
|
66
|
-
"types": "./dist/esm/shared/route/routing.d.ts"
|
|
69
|
+
"types": "./dist/esm/shared/route/routing.d.ts",
|
|
70
|
+
"default": "./dist/esm/shared/route/routing.js"
|
|
67
71
|
},
|
|
68
72
|
"./cli": {
|
|
69
73
|
"require": "./dist/cjs/node/cli/index.js",
|
|
70
74
|
"node": "./dist/esm/node/cli/index.js",
|
|
71
|
-
"types": "./dist/esm/node/cli/index.d.ts"
|
|
75
|
+
"types": "./dist/esm/node/cli/index.d.ts",
|
|
76
|
+
"default": "./dist/esm/node/cli/index.js"
|
|
72
77
|
},
|
|
73
78
|
"./prerender": {
|
|
74
79
|
"require": "./dist/cjs/node/prerender/index.js",
|
|
75
80
|
"node": "./dist/esm/node/prerender/index.js",
|
|
76
|
-
"types": "./dist/esm/node/prerender/index.d.ts"
|
|
81
|
+
"types": "./dist/esm/node/prerender/index.d.ts",
|
|
82
|
+
"default": "./dist/esm/node/prerender/index.js"
|
|
77
83
|
},
|
|
78
84
|
"./plugin": {
|
|
79
85
|
"require": "./dist/cjs/node/plugin/index.js",
|
|
80
86
|
"node": "./dist/esm/node/plugin/index.js",
|
|
81
|
-
"types": "./dist/esm/node/plugin/index.d.ts"
|
|
87
|
+
"types": "./dist/esm/node/plugin/index.d.ts",
|
|
88
|
+
"default": "./dist/esm/node/plugin/index.js"
|
|
82
89
|
},
|
|
83
90
|
"./RenderErrorPage": {
|
|
84
91
|
"worker": "./dist/esm/shared/RenderErrorPage.js",
|
|
@@ -86,7 +93,8 @@
|
|
|
86
93
|
"require": "./dist/cjs/shared/RenderErrorPage.js",
|
|
87
94
|
"node": "./dist/esm/shared/RenderErrorPage.js",
|
|
88
95
|
"browser": "./dist/esm/shared/RenderErrorPage.js",
|
|
89
|
-
"types": "./dist/esm/shared/RenderErrorPage.d.ts"
|
|
96
|
+
"types": "./dist/esm/shared/RenderErrorPage.d.ts",
|
|
97
|
+
"default": "./dist/esm/shared/RenderErrorPage.js"
|
|
90
98
|
},
|
|
91
99
|
"./abort": {
|
|
92
100
|
"worker": "./dist/esm/shared/abort.js",
|
|
@@ -94,24 +102,28 @@
|
|
|
94
102
|
"require": "./dist/cjs/shared/abort.js",
|
|
95
103
|
"node": "./dist/esm/shared/abort.js",
|
|
96
104
|
"browser": "./dist/esm/shared/abort.js",
|
|
97
|
-
"types": "./dist/esm/shared/abort.d.ts"
|
|
105
|
+
"types": "./dist/esm/shared/abort.d.ts",
|
|
106
|
+
"default": "./dist/esm/shared/abort.js"
|
|
98
107
|
},
|
|
99
108
|
"./__internal": {
|
|
100
109
|
"require": "./dist/cjs/__internal/index.js",
|
|
101
110
|
"node": "./dist/esm/__internal/index.js",
|
|
102
|
-
"types": "./dist/esm/__internal/index.d.ts"
|
|
111
|
+
"types": "./dist/esm/__internal/index.d.ts",
|
|
112
|
+
"default": "./dist/esm/__internal/index.js"
|
|
103
113
|
},
|
|
104
114
|
"./__internal/setup": {
|
|
105
115
|
"require": "./dist/cjs/node/runtime/page-files/setup.js",
|
|
106
116
|
"node": "./dist/esm/node/runtime/page-files/setup.js",
|
|
107
|
-
"types": "./dist/esm/node/runtime/page-files/setup.d.ts"
|
|
117
|
+
"types": "./dist/esm/node/runtime/page-files/setup.d.ts",
|
|
118
|
+
"default": "./dist/esm/node/runtime/page-files/setup.js"
|
|
108
119
|
},
|
|
109
120
|
"./__internal/loadImportBuild": {
|
|
110
121
|
"worker": "./dist/esm/node/runtime/globalContext/loadImportBuild.js",
|
|
111
122
|
"edge-light": "./dist/esm/node/runtime/globalContext/loadImportBuild.js",
|
|
112
123
|
"require": "./dist/cjs/node/runtime/globalContext/loadImportBuild.js",
|
|
113
124
|
"node": "./dist/esm/node/runtime/globalContext/loadImportBuild.js",
|
|
114
|
-
"types": "./dist/esm/node/runtime/globalContext/loadImportBuild.d.ts"
|
|
125
|
+
"types": "./dist/esm/node/runtime/globalContext/loadImportBuild.d.ts",
|
|
126
|
+
"default": "./dist/esm/node/runtime/globalContext/loadImportBuild.js"
|
|
115
127
|
}
|
|
116
128
|
},
|
|
117
129
|
"peerDependencies": {
|
|
@@ -1,90 +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.getFilePathUnresolved = exports.getFilePathResolved = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const utils_js_1 = require("../../../../utils.js");
|
|
9
|
-
function getFilePathUnresolved(args) {
|
|
10
|
-
const { filePathAbsoluteFilesystem, filePathAbsoluteUserRootDir } = args;
|
|
11
|
-
let filePathAbsoluteVite;
|
|
12
|
-
if (args.filePathAbsoluteUserRootDir !== null) {
|
|
13
|
-
filePathAbsoluteVite = args.filePathAbsoluteUserRootDir;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
(0, utils_js_1.assert)(args.importPathAbsolute !== null); // Help TS
|
|
17
|
-
filePathAbsoluteVite = args.importPathAbsolute;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
...args,
|
|
21
|
-
filePathAbsoluteVite,
|
|
22
|
-
filePathToShowToUser: filePathAbsoluteVite,
|
|
23
|
-
filePathToShowToUserResolved: filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.getFilePathUnresolved = getFilePathUnresolved;
|
|
27
|
-
function getFilePathResolved(args) {
|
|
28
|
-
const { userRootDir, importPathAbsolute } = args;
|
|
29
|
-
let filePathAbsoluteFilesystem;
|
|
30
|
-
let filePathAbsoluteUserRootDir;
|
|
31
|
-
if ('filePathAbsoluteFilesystem' in args) {
|
|
32
|
-
filePathAbsoluteFilesystem = args.filePathAbsoluteFilesystem;
|
|
33
|
-
filePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir });
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
filePathAbsoluteUserRootDir = args.filePathAbsoluteUserRootDir;
|
|
37
|
-
filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
|
|
38
|
-
}
|
|
39
|
-
let filePathResolved;
|
|
40
|
-
const common = {
|
|
41
|
-
filePathAbsoluteUserRootDir,
|
|
42
|
-
filePathAbsoluteFilesystem,
|
|
43
|
-
importPathAbsolute,
|
|
44
|
-
userRootDir
|
|
45
|
-
};
|
|
46
|
-
if (importPathAbsolute) {
|
|
47
|
-
filePathResolved = getFilePathUnresolved({
|
|
48
|
-
...common,
|
|
49
|
-
importPathAbsolute
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
54
|
-
filePathResolved = getFilePathUnresolved({
|
|
55
|
-
...common,
|
|
56
|
-
filePathAbsoluteUserRootDir
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
60
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(filePathResolved, 'filePathAbsoluteFilesystem', 'string'));
|
|
61
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(filePathResolved, 'filePathToShowToUserResolved', 'string'));
|
|
62
|
-
return filePathResolved;
|
|
63
|
-
}
|
|
64
|
-
exports.getFilePathResolved = getFilePathResolved;
|
|
65
|
-
function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
|
|
66
|
-
(0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
|
|
67
|
-
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
68
|
-
const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathAbsoluteUserRootDir);
|
|
69
|
-
return filePathAbsoluteFilesystem;
|
|
70
|
-
}
|
|
71
|
-
function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
|
|
72
|
-
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
73
|
-
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
74
|
-
let filePathAbsoluteUserRootDir = null;
|
|
75
|
-
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
76
|
-
{
|
|
77
|
-
let filePathAbsoluteUserRootDir1 = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
78
|
-
if (!filePathAbsoluteUserRootDir1.startsWith('/'))
|
|
79
|
-
filePathAbsoluteUserRootDir1 = '/' + filePathAbsoluteUserRootDir1;
|
|
80
|
-
filePathAbsoluteUserRootDir = filePathAbsoluteUserRootDir1;
|
|
81
|
-
}
|
|
82
|
-
{
|
|
83
|
-
let filePathAbsoluteUserRootDir2 = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
84
|
-
(0, utils_js_1.assert)(!filePathAbsoluteUserRootDir2.startsWith('.') && !filePathAbsoluteUserRootDir2.startsWith('/'));
|
|
85
|
-
filePathAbsoluteUserRootDir2 = '/' + filePathAbsoluteUserRootDir2;
|
|
86
|
-
(0, utils_js_1.assert)(filePathAbsoluteFilesystem === filePathAbsoluteUserRootDir2);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return filePathAbsoluteUserRootDir;
|
|
90
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertClientEntryId = void 0;
|
|
4
|
-
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
6
|
-
function assertClientEntryId(id) {
|
|
7
|
-
(0, utils_js_1.assertPosixPath)(id);
|
|
8
|
-
(0, utils_js_1.assert)(!id.startsWith('/@fs'), id);
|
|
9
|
-
(0, utils_js_1.assert)(
|
|
10
|
-
// Client entry
|
|
11
|
-
id.startsWith('@@vike/') ||
|
|
12
|
-
// User files
|
|
13
|
-
id.startsWith('/') ||
|
|
14
|
-
// Page code importer
|
|
15
|
-
(0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id) ||
|
|
16
|
-
// Import
|
|
17
|
-
(0, utils_js_1.isNpmPackageImport)(id), id);
|
|
18
|
-
}
|
|
19
|
-
exports.assertClientEntryId = assertClientEntryId;
|
|
@@ -1,70 +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.getFilePathAbsoluteUserRootDir = exports.getFilePathAbsoluteFilesystem = void 0;
|
|
7
|
-
const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
8
|
-
const assert_js_1 = require("./assert.js");
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const assertIsNotProductionRuntime_js_1 = require("./assertIsNotProductionRuntime.js");
|
|
11
|
-
const isNpmPackage_js_1 = require("./isNpmPackage.js");
|
|
12
|
-
const assertPathIsFilesystemAbsolute_js_1 = require("./assertPathIsFilesystemAbsolute.js");
|
|
13
|
-
const module_1 = require("module");
|
|
14
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
15
|
-
const importMetaUrl = `file://${__filename}`;
|
|
16
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
17
|
-
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
18
|
-
// Vite handles paths such as /pages/index.page.js which are relative to `config.root`.
|
|
19
|
-
// Make them absolute starting from the filesystem root.
|
|
20
|
-
// Also resolve plus files living in npm packages such as restack/renderer/+onRenderHtml.js
|
|
21
|
-
function getFilePathAbsoluteFilesystem(filePath, config) {
|
|
22
|
-
(0, filesystemPathHandling_js_1.assertPosixPath)(filePath);
|
|
23
|
-
if (filePath.startsWith('/@fs/')) {
|
|
24
|
-
return filePath;
|
|
25
|
-
}
|
|
26
|
-
let filePathUnresolved;
|
|
27
|
-
if ((0, isNpmPackage_js_1.isNpmPackageImport)(filePath)) {
|
|
28
|
-
filePathUnresolved = filePath;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
(0, assert_js_1.assert)(filePath.startsWith('/'));
|
|
32
|
-
const { root } = config;
|
|
33
|
-
(0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(root);
|
|
34
|
-
filePathUnresolved = path_1.default.posix.join(root, filePath);
|
|
35
|
-
(0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathUnresolved);
|
|
36
|
-
}
|
|
37
|
-
let filePathAbsoluteFilesystem;
|
|
38
|
-
try {
|
|
39
|
-
filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
console.error(err);
|
|
43
|
-
(0, assert_js_1.assert)(false);
|
|
44
|
-
}
|
|
45
|
-
filePathAbsoluteFilesystem = (0, filesystemPathHandling_js_1.toPosixPath)(filePathAbsoluteFilesystem);
|
|
46
|
-
(0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
47
|
-
return filePathAbsoluteFilesystem;
|
|
48
|
-
}
|
|
49
|
-
exports.getFilePathAbsoluteFilesystem = getFilePathAbsoluteFilesystem;
|
|
50
|
-
function getFilePathAbsoluteUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
|
|
51
|
-
(0, filesystemPathHandling_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
52
|
-
(0, filesystemPathHandling_js_1.assertPosixPath)(userRootDir);
|
|
53
|
-
let filePathAbsoluteUserRootDir = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
54
|
-
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
55
|
-
(0, assert_js_1.assert)(!filePathAbsoluteUserRootDir.startsWith('.') && !filePathAbsoluteUserRootDir.startsWith('/'),
|
|
56
|
-
// Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
|
|
57
|
-
{ filePathAbsoluteUserRootDir, filePathAbsoluteFilesystem, userRootDir });
|
|
58
|
-
filePathAbsoluteUserRootDir = `/${filePathAbsoluteUserRootDir}`;
|
|
59
|
-
return filePathAbsoluteUserRootDir;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
if (alwaysRelative) {
|
|
63
|
-
return filePathAbsoluteUserRootDir;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
return filePathAbsoluteFilesystem;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.getFilePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir;
|