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
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getFilePath.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export { getFilePathResolved };
|
|
2
|
-
export { getFilePathUnresolved };
|
|
3
|
-
import type { FilePath, FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
4
|
-
declare function getFilePathUnresolved(args: {
|
|
5
|
-
filePathAbsoluteFilesystem: string | null;
|
|
6
|
-
filePathAbsoluteUserRootDir: string | null;
|
|
7
|
-
importPathAbsolute: string | null;
|
|
8
|
-
} & ({
|
|
9
|
-
filePathAbsoluteUserRootDir: string;
|
|
10
|
-
} | {
|
|
11
|
-
importPathAbsolute: string;
|
|
12
|
-
})): FilePath;
|
|
13
|
-
declare function getFilePathResolved(args: {
|
|
14
|
-
userRootDir: string;
|
|
15
|
-
importPathAbsolute: string | null;
|
|
16
|
-
} & ({
|
|
17
|
-
filePathAbsoluteFilesystem: string;
|
|
18
|
-
} | {
|
|
19
|
-
filePathAbsoluteUserRootDir: string;
|
|
20
|
-
})): FilePathResolved;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
export { getFilePathResolved };
|
|
2
|
-
export { getFilePathUnresolved };
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { assert, assertPosixPath, hasProp } from '../../../../utils.js';
|
|
5
|
-
function getFilePathUnresolved(args) {
|
|
6
|
-
const { filePathAbsoluteFilesystem, filePathAbsoluteUserRootDir } = args;
|
|
7
|
-
let filePathAbsoluteVite;
|
|
8
|
-
if (args.filePathAbsoluteUserRootDir !== null) {
|
|
9
|
-
filePathAbsoluteVite = args.filePathAbsoluteUserRootDir;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
assert(args.importPathAbsolute !== null); // Help TS
|
|
13
|
-
filePathAbsoluteVite = args.importPathAbsolute;
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
...args,
|
|
17
|
-
filePathAbsoluteVite,
|
|
18
|
-
filePathToShowToUser: filePathAbsoluteVite,
|
|
19
|
-
filePathToShowToUserResolved: filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function getFilePathResolved(args) {
|
|
23
|
-
const { userRootDir, importPathAbsolute } = args;
|
|
24
|
-
let filePathAbsoluteFilesystem;
|
|
25
|
-
let filePathAbsoluteUserRootDir;
|
|
26
|
-
if ('filePathAbsoluteFilesystem' in args) {
|
|
27
|
-
filePathAbsoluteFilesystem = args.filePathAbsoluteFilesystem;
|
|
28
|
-
filePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir });
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
filePathAbsoluteUserRootDir = args.filePathAbsoluteUserRootDir;
|
|
32
|
-
filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
|
|
33
|
-
}
|
|
34
|
-
let filePathResolved;
|
|
35
|
-
const common = {
|
|
36
|
-
filePathAbsoluteUserRootDir,
|
|
37
|
-
filePathAbsoluteFilesystem,
|
|
38
|
-
importPathAbsolute,
|
|
39
|
-
userRootDir
|
|
40
|
-
};
|
|
41
|
-
if (importPathAbsolute) {
|
|
42
|
-
filePathResolved = getFilePathUnresolved({
|
|
43
|
-
...common,
|
|
44
|
-
importPathAbsolute
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
assert(filePathAbsoluteUserRootDir);
|
|
49
|
-
filePathResolved = getFilePathUnresolved({
|
|
50
|
-
...common,
|
|
51
|
-
filePathAbsoluteUserRootDir
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
assert(filePathAbsoluteFilesystem);
|
|
55
|
-
assert(hasProp(filePathResolved, 'filePathAbsoluteFilesystem', 'string'));
|
|
56
|
-
assert(hasProp(filePathResolved, 'filePathToShowToUserResolved', 'string'));
|
|
57
|
-
return filePathResolved;
|
|
58
|
-
}
|
|
59
|
-
function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
|
|
60
|
-
assertPosixPath(filePathAbsoluteUserRootDir);
|
|
61
|
-
assertPosixPath(userRootDir);
|
|
62
|
-
const filePathAbsoluteFilesystem = path.posix.join(userRootDir, filePathAbsoluteUserRootDir);
|
|
63
|
-
return filePathAbsoluteFilesystem;
|
|
64
|
-
}
|
|
65
|
-
function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
|
|
66
|
-
assertPosixPath(filePathAbsoluteFilesystem);
|
|
67
|
-
assertPosixPath(userRootDir);
|
|
68
|
-
let filePathAbsoluteUserRootDir = null;
|
|
69
|
-
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
70
|
-
{
|
|
71
|
-
let filePathAbsoluteUserRootDir1 = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
72
|
-
if (!filePathAbsoluteUserRootDir1.startsWith('/'))
|
|
73
|
-
filePathAbsoluteUserRootDir1 = '/' + filePathAbsoluteUserRootDir1;
|
|
74
|
-
filePathAbsoluteUserRootDir = filePathAbsoluteUserRootDir1;
|
|
75
|
-
}
|
|
76
|
-
{
|
|
77
|
-
let filePathAbsoluteUserRootDir2 = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
78
|
-
assert(!filePathAbsoluteUserRootDir2.startsWith('.') && !filePathAbsoluteUserRootDir2.startsWith('/'));
|
|
79
|
-
filePathAbsoluteUserRootDir2 = '/' + filePathAbsoluteUserRootDir2;
|
|
80
|
-
assert(filePathAbsoluteFilesystem === filePathAbsoluteUserRootDir2);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return filePathAbsoluteUserRootDir;
|
|
84
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { assertClientEntryId };
|
|
2
|
-
import { assert, assertPosixPath, isNpmPackageImport } from '../../utils.js';
|
|
3
|
-
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
4
|
-
function assertClientEntryId(id) {
|
|
5
|
-
assertPosixPath(id);
|
|
6
|
-
assert(!id.startsWith('/@fs'), id);
|
|
7
|
-
assert(
|
|
8
|
-
// Client entry
|
|
9
|
-
id.startsWith('@@vike/') ||
|
|
10
|
-
// User files
|
|
11
|
-
id.startsWith('/') ||
|
|
12
|
-
// Page code importer
|
|
13
|
-
isVirtualFileIdPageConfigValuesAll(id) ||
|
|
14
|
-
// Import
|
|
15
|
-
isNpmPackageImport(id), id);
|
|
16
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { getFilePathAbsoluteFilesystem };
|
|
2
|
-
export { getFilePathAbsoluteUserRootDir };
|
|
3
|
-
import type { ResolvedConfig } from 'vite';
|
|
4
|
-
declare function getFilePathAbsoluteFilesystem(filePath: string, config: ResolvedConfig): string;
|
|
5
|
-
declare function getFilePathAbsoluteUserRootDir(filePathAbsoluteFilesystem: string, userRootDir: string, alwaysRelative?: boolean): string;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export { getFilePathAbsoluteFilesystem };
|
|
2
|
-
export { getFilePathAbsoluteUserRootDir };
|
|
3
|
-
import { assertPosixPath, toPosixPath } from './filesystemPathHandling.js';
|
|
4
|
-
import { assert } from './assert.js';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { assertIsNotProductionRuntime } from './assertIsNotProductionRuntime.js';
|
|
7
|
-
import { isNpmPackageImport } from './isNpmPackage.js';
|
|
8
|
-
import { assertPathIsFilesystemAbsolute } from './assertPathIsFilesystemAbsolute.js';
|
|
9
|
-
import { createRequire } from 'module';
|
|
10
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
11
|
-
const importMetaUrl = import.meta.url;
|
|
12
|
-
const require_ = createRequire(importMetaUrl);
|
|
13
|
-
assertIsNotProductionRuntime();
|
|
14
|
-
// Vite handles paths such as /pages/index.page.js which are relative to `config.root`.
|
|
15
|
-
// Make them absolute starting from the filesystem root.
|
|
16
|
-
// Also resolve plus files living in npm packages such as restack/renderer/+onRenderHtml.js
|
|
17
|
-
function getFilePathAbsoluteFilesystem(filePath, config) {
|
|
18
|
-
assertPosixPath(filePath);
|
|
19
|
-
if (filePath.startsWith('/@fs/')) {
|
|
20
|
-
return filePath;
|
|
21
|
-
}
|
|
22
|
-
let filePathUnresolved;
|
|
23
|
-
if (isNpmPackageImport(filePath)) {
|
|
24
|
-
filePathUnresolved = filePath;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
assert(filePath.startsWith('/'));
|
|
28
|
-
const { root } = config;
|
|
29
|
-
assertPathIsFilesystemAbsolute(root);
|
|
30
|
-
filePathUnresolved = path.posix.join(root, filePath);
|
|
31
|
-
assertPathIsFilesystemAbsolute(filePathUnresolved);
|
|
32
|
-
}
|
|
33
|
-
let filePathAbsoluteFilesystem;
|
|
34
|
-
try {
|
|
35
|
-
filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
console.error(err);
|
|
39
|
-
assert(false);
|
|
40
|
-
}
|
|
41
|
-
filePathAbsoluteFilesystem = toPosixPath(filePathAbsoluteFilesystem);
|
|
42
|
-
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
43
|
-
return filePathAbsoluteFilesystem;
|
|
44
|
-
}
|
|
45
|
-
function getFilePathAbsoluteUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
|
|
46
|
-
assertPosixPath(filePathAbsoluteFilesystem);
|
|
47
|
-
assertPosixPath(userRootDir);
|
|
48
|
-
let filePathAbsoluteUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
49
|
-
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
50
|
-
assert(!filePathAbsoluteUserRootDir.startsWith('.') && !filePathAbsoluteUserRootDir.startsWith('/'),
|
|
51
|
-
// Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
|
|
52
|
-
{ filePathAbsoluteUserRootDir, filePathAbsoluteFilesystem, userRootDir });
|
|
53
|
-
filePathAbsoluteUserRootDir = `/${filePathAbsoluteUserRootDir}`;
|
|
54
|
-
return filePathAbsoluteUserRootDir;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
if (alwaysRelative) {
|
|
58
|
-
return filePathAbsoluteUserRootDir;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
return filePathAbsoluteFilesystem;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|