vike 0.4.166 → 0.4.167-commit-c08a6bb
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/extractAssetsPlugin.js +11 -13
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -4
- 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/getConfigFileExport.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +21 -17
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +34 -23
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +33 -10
- package/dist/cjs/node/plugin/shared/getFilePath.js +83 -29
- package/dist/cjs/node/plugin/shared/isErrorDebug.js +1 -1
- 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/html/stream.js +5 -5
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +1 -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 +13 -1
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -3
- 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/index.js +2 -3
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/utils/assertIsNotProductionRuntime.js +5 -5
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/cjs/utils/debug.js +48 -14
- package/dist/cjs/utils/isNpmPackage.js +11 -2
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/trackLogs.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +31 -24
- 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/extractAssetsPlugin.js +12 -14
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +3 -5
- 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/debug.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +21 -17
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +33 -22
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +34 -11
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +10 -9
- package/dist/esm/node/plugin/shared/getFilePath.js +83 -29
- package/dist/esm/node/plugin/shared/isErrorDebug.js +2 -2
- 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/html/stream.js +5 -5
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -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 +13 -1
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/shared/addUrlComputedProps.d.ts +2 -2
- package/dist/esm/shared/page-configs/FilePath.d.ts +41 -29
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +1 -3
- 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/index.js +2 -3
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/utils/assertIsNotProductionRuntime.js +5 -5
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/esm/utils/debug.d.ts +5 -4
- package/dist/esm/utils/debug.js +45 -14
- package/dist/esm/utils/debugGlob.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/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/trackLogs.js +2 -2
- package/package.json +1 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -19
- package/dist/cjs/utils/getFilePathAbsolute.js +0 -70
- 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/utils/debug.js
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
|
-
export {
|
|
2
|
+
export { isDebugActivated };
|
|
3
3
|
import { isBrowser } from './isBrowser.js';
|
|
4
4
|
import { isCallable } from './isCallable.js';
|
|
5
5
|
import { objectAssign } from './objectAssign.js';
|
|
6
|
-
import { assert } from './assert.js';
|
|
6
|
+
import { assert, assertUsage } from './assert.js';
|
|
7
7
|
import { checkType } from './checkType.js';
|
|
8
8
|
import { getTerminalWidth } from './getTerminWidth.js';
|
|
9
|
+
import pc from '@brillout/picocolors';
|
|
9
10
|
// Avoid this to be loaded in the browser. For isomorphic code: instead of `import { createDebugger } from './utils.js'`, use `globalThis.createDebugger()`.
|
|
10
11
|
assert(!isBrowser());
|
|
11
12
|
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
13
|
+
const flags = [
|
|
14
|
+
'vike:error',
|
|
15
|
+
'vike:extractAssets',
|
|
16
|
+
'vike:extractExportNames',
|
|
17
|
+
'vike:glob',
|
|
18
|
+
'vike:log',
|
|
19
|
+
'vike:optimizeDeps',
|
|
20
|
+
'vike:outDir',
|
|
21
|
+
'vike:pageFiles',
|
|
22
|
+
'vike:pointer-imports',
|
|
23
|
+
'vike:routing',
|
|
24
|
+
'vike:setup',
|
|
25
|
+
'vike:stream',
|
|
26
|
+
'vike:virtual-files'
|
|
27
|
+
];
|
|
28
|
+
const flagRegex = /\bvike:[a-zA-Z-]+/g;
|
|
29
|
+
assertDEBUG();
|
|
12
30
|
function createDebugger(flag, optionsGlobal) {
|
|
13
31
|
checkType(flag);
|
|
32
|
+
assert(flags.includes(flag));
|
|
14
33
|
const debugWithOptions = (optionsLocal) => {
|
|
15
34
|
return (...msgs) => {
|
|
16
35
|
const options = { ...optionsGlobal, ...optionsLocal };
|
|
@@ -18,11 +37,11 @@ function createDebugger(flag, optionsGlobal) {
|
|
|
18
37
|
};
|
|
19
38
|
};
|
|
20
39
|
const debug = (...msgs) => debugWithOptions({})(...msgs);
|
|
21
|
-
objectAssign(debug, { options: debugWithOptions,
|
|
40
|
+
objectAssign(debug, { options: debugWithOptions, isActivated: isDebugActivated(flag) });
|
|
22
41
|
return debug;
|
|
23
42
|
}
|
|
24
43
|
function debug_(flag, options, ...msgs) {
|
|
25
|
-
if (!
|
|
44
|
+
if (!isDebugActivated(flag))
|
|
26
45
|
return;
|
|
27
46
|
let [msgFirst, ...msgsRest] = msgs;
|
|
28
47
|
const padding = ' '.repeat(flag.length + 1);
|
|
@@ -47,17 +66,12 @@ function debug_(flag, options, ...msgs) {
|
|
|
47
66
|
console.log(msg);
|
|
48
67
|
});
|
|
49
68
|
}
|
|
50
|
-
function
|
|
69
|
+
function isDebugActivated(flag) {
|
|
51
70
|
checkType(flag);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
DEBUG = process.env.DEBUG;
|
|
57
|
-
}
|
|
58
|
-
catch { }
|
|
59
|
-
const isEnabled = DEBUG?.includes(flag) ?? false;
|
|
60
|
-
return isEnabled;
|
|
71
|
+
assert(flags.includes(flag));
|
|
72
|
+
const DEBUG = getDEBUG();
|
|
73
|
+
const isActivated = DEBUG?.includes(flag) ?? false;
|
|
74
|
+
return isActivated;
|
|
61
75
|
}
|
|
62
76
|
function formatMsg(info, options, padding, position) {
|
|
63
77
|
if (info === undefined) {
|
|
@@ -119,3 +133,20 @@ function replaceFunctionSerializer(_key, value) {
|
|
|
119
133
|
}
|
|
120
134
|
return value;
|
|
121
135
|
}
|
|
136
|
+
function assertDEBUG() {
|
|
137
|
+
const DEBUG = getDEBUG() ?? '';
|
|
138
|
+
const flagsActivated = DEBUG.match(flagRegex) ?? [];
|
|
139
|
+
flagsActivated.forEach((flag) => {
|
|
140
|
+
assertUsage(flags.includes(flag), `Unknown DEBUG flag ${pc.cyan(flag)}. Valid flags:\n${flags.map((f) => ` ${pc.cyan(f)}`).join('\n')}`);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function getDEBUG() {
|
|
144
|
+
let DEBUG;
|
|
145
|
+
// - `process` can be undefined in edge workers
|
|
146
|
+
// - We want bundlers to be able to statically replace `process.env.*`
|
|
147
|
+
try {
|
|
148
|
+
DEBUG = process.env.DEBUG;
|
|
149
|
+
}
|
|
150
|
+
catch { }
|
|
151
|
+
return DEBUG;
|
|
152
|
+
}
|
|
@@ -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;
|
|
@@ -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.167-commit-c08a6bb";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.167-commit-c08a6bb";
|
|
7
7
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isDebugActivated } from './debug.js';
|
|
2
2
|
import pc from '@brillout/picocolors';
|
|
3
3
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
4
4
|
assertIsNotBrowser();
|
|
5
|
-
if (
|
|
5
|
+
if (isDebugActivated('vike:log')) {
|
|
6
6
|
trackLogs();
|
|
7
7
|
}
|
|
8
8
|
// https://stackoverflow.com/questions/45395369/how-to-get-console-log-line-numbers-shown-in-nodejs/75109905#75109905
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -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
|
-
}
|