vike 0.4.223-commit-535bde1 → 0.4.223-commit-3502685
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/fileEnv.js +5 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +19 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +10 -1
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +10 -4
- package/dist/cjs/utils/path.js +1 -0
- package/dist/esm/node/plugin/plugins/fileEnv.js +5 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +20 -10
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -2
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +8 -2
- package/dist/esm/utils/path.js +1 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -60,10 +60,13 @@ function fileEnv() {
|
|
|
60
60
|
Array.from(this.getModuleIds())
|
|
61
61
|
.filter((id) => !skip(id))
|
|
62
62
|
.forEach((moduleId) => {
|
|
63
|
-
const
|
|
63
|
+
const mod = this.getModuleInfo(moduleId);
|
|
64
|
+
const { importers } = mod;
|
|
64
65
|
if (importers.length === 0) {
|
|
65
66
|
// Dynamic imports can only be verified at runtime
|
|
66
|
-
|
|
67
|
+
/* This assertion can fail: https://github.com/vikejs/vike/issues/2227
|
|
68
|
+
assert(dynamicImporters.length > 0)
|
|
69
|
+
*/
|
|
67
70
|
return;
|
|
68
71
|
}
|
|
69
72
|
assertFileEnv(moduleId, !!config.build.ssr, importers, false);
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -13,6 +13,7 @@ const child_process_1 = require("child_process");
|
|
|
13
13
|
const util_1 = require("util");
|
|
14
14
|
const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
|
|
15
15
|
const getEnvVarObject_js_1 = require("../../../../shared/getEnvVarObject.js");
|
|
16
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
16
17
|
const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
17
18
|
const debug = (0, utils_js_1.createDebugger)('vike:crawl');
|
|
18
19
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
@@ -20,6 +21,7 @@ const debug = (0, utils_js_1.createDebugger)('vike:crawl');
|
|
|
20
21
|
let gitIsNotUsable = false;
|
|
21
22
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
22
23
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
24
|
+
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(userRootDir);
|
|
23
25
|
//*/
|
|
24
26
|
const outDirRelativeFromUserRootDir = null;
|
|
25
27
|
/*/
|
|
@@ -37,8 +39,9 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
37
39
|
(!outDirRelativeFromUserRootDir.startsWith('./') &&
|
|
38
40
|
//
|
|
39
41
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
42
|
+
const crawSettings = getCrawlSettings();
|
|
40
43
|
// Crawl
|
|
41
|
-
const filesGit =
|
|
44
|
+
const filesGit = crawSettings.git !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
42
45
|
const filesGitNothingFound = !filesGit || filesGit.length === 0;
|
|
43
46
|
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await tinyglobby(userRootDir, outDirRelativeFromUserRootDir));
|
|
44
47
|
let files = !filesGitNothingFound
|
|
@@ -46,8 +49,11 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
46
49
|
: // Fallback to tinyglobby for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
47
50
|
filesGlob;
|
|
48
51
|
(0, utils_js_1.assert)(files);
|
|
49
|
-
if (debug.isActivated)
|
|
50
|
-
(0, utils_js_1.assert)(
|
|
52
|
+
if (debug.isActivated) {
|
|
53
|
+
(0, utils_js_1.assert)(filesGit);
|
|
54
|
+
(0, utils_js_1.assert)(filesGlob);
|
|
55
|
+
(0, utils_js_1.assertWarning)((0, utils_js_1.deepEqual)(filesGlob.slice().sort(), filesGit.slice().sort()), "Git and glob results aren't matching.", { onlyOnce: false });
|
|
56
|
+
}
|
|
51
57
|
// Filter build files
|
|
52
58
|
files = files.filter((filePath) => !(0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath));
|
|
53
59
|
// Normalize
|
|
@@ -134,8 +140,7 @@ async function tinyglobby(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
134
140
|
const options = {
|
|
135
141
|
ignore: getIgnoreAsPatterns(outDirRelativeFromUserRootDir),
|
|
136
142
|
cwd: userRootDir,
|
|
137
|
-
dot: false
|
|
138
|
-
expandDirectories: false
|
|
143
|
+
dot: false
|
|
139
144
|
};
|
|
140
145
|
const files = await (0, tinyglobby_1.glob)(pattern, options);
|
|
141
146
|
// Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
|
|
@@ -158,7 +163,9 @@ function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
|
158
163
|
// +Page.js
|
|
159
164
|
// +Page.telefunc.js
|
|
160
165
|
// ```
|
|
161
|
-
'**/*.telefunc.*'
|
|
166
|
+
'**/*.telefunc.*',
|
|
167
|
+
// https://github.com/vikejs/vike/discussions/2222
|
|
168
|
+
'**/*.generated.*'
|
|
162
169
|
];
|
|
163
170
|
if (outDirRelativeFromUserRootDir) {
|
|
164
171
|
(0, utils_js_1.assert)(!outDirRelativeFromUserRootDir.startsWith('/'));
|
|
@@ -172,6 +179,7 @@ function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
|
172
179
|
return (file) => !file.includes('node_modules/') &&
|
|
173
180
|
!file.includes('ejected/') &&
|
|
174
181
|
!file.includes('.telefunc.') &&
|
|
182
|
+
!file.includes('.generated.') &&
|
|
175
183
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
176
184
|
}
|
|
177
185
|
// Whether Git is installed and whether we can use it
|
|
@@ -228,9 +236,11 @@ async function runCmd2(cmd, cwd) {
|
|
|
228
236
|
stderr = stderr.toString().trim();
|
|
229
237
|
return { stdout, stderr };
|
|
230
238
|
}
|
|
231
|
-
function
|
|
232
|
-
const
|
|
233
|
-
|
|
239
|
+
function getCrawlSettings() {
|
|
240
|
+
const crawlSettings = (0, getEnvVarObject_js_1.getEnvVarObject)('VIKE_CRAWL') ?? {};
|
|
241
|
+
const wrongUsage = (settingName, settingType) => `Setting ${picocolors_1.default.cyan(settingName)} in VIKE_CRAWL should be a ${picocolors_1.default.cyan(settingType)}`;
|
|
242
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(crawlSettings, 'git', 'boolean') || (0, utils_js_1.hasProp)(crawlSettings, 'git', 'undefined'), wrongUsage('git', 'boolean'));
|
|
243
|
+
return crawlSettings;
|
|
234
244
|
}
|
|
235
245
|
function isPlusFile(filePath) {
|
|
236
246
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
@@ -15,13 +15,14 @@ const import_1 = require("@brillout/import");
|
|
|
15
15
|
const utils_js_1 = require("../../../../utils.js");
|
|
16
16
|
const transformPointerImports_js_1 = require("./transformPointerImports.js");
|
|
17
17
|
const getVikeConfig_js_1 = require("../getVikeConfig.js");
|
|
18
|
-
require("source-map-support
|
|
18
|
+
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
19
19
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
20
20
|
const module_1 = require("module");
|
|
21
21
|
// @ts-ignore `file://${__filename}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
22
22
|
const importMetaUrl = `file://${__filename}`;
|
|
23
23
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
24
24
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
25
|
+
installSourceMapSupport();
|
|
25
26
|
const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
26
27
|
const debugEsbuildResolve = (0, utils_js_1.createDebugger)('vike:esbuild-resolve');
|
|
27
28
|
if (debugEsbuildResolve.isActivated)
|
|
@@ -406,3 +407,11 @@ function cleanEsbuildErrors(errors) {
|
|
|
406
407
|
// ```
|
|
407
408
|
!note.text.includes('as external to exclude it from the bundle'))));
|
|
408
409
|
}
|
|
410
|
+
function installSourceMapSupport() {
|
|
411
|
+
// Don't break Vitest's source mapping
|
|
412
|
+
if ((0, utils_js_1.isVitest)())
|
|
413
|
+
return;
|
|
414
|
+
// How about other test runners?
|
|
415
|
+
// Should we call installSourceMapSupport() lazily in transpileAndExecuteFile() instead?
|
|
416
|
+
source_map_support_1.default.install();
|
|
417
|
+
}
|
|
@@ -44,3 +44,4 @@ __exportStar(require("../../utils/isArray.js"), exports);
|
|
|
44
44
|
__exportStar(require("../../utils/PROJECT_VERSION.js"), exports);
|
|
45
45
|
__exportStar(require("../../utils/isEqualStringList.js"), exports);
|
|
46
46
|
__exportStar(require("../../utils/isDocker.js"), exports);
|
|
47
|
+
__exportStar(require("../../utils/isVitest.js"), exports);
|
|
@@ -5,9 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.assertFilePathAbsoluteFilesystem = assertFilePathAbsoluteFilesystem;
|
|
7
7
|
exports.isFilePathAbsolute = isFilePathAbsolute;
|
|
8
|
-
const
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const assert_js_1 = require("./assert.js");
|
|
10
10
|
const path_js_1 = require("./path.js");
|
|
11
|
+
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
12
|
+
const assertSetup_js_1 = require("./assertSetup.js");
|
|
13
|
+
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
14
|
+
// Server runtime shouldn't depend on node:path
|
|
15
|
+
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
11
16
|
/**
|
|
12
17
|
* Asserts that `filePath` is an absolute file path starting from the filesystem root.
|
|
13
18
|
*
|
|
@@ -18,6 +23,7 @@ function assertFilePathAbsoluteFilesystem(filePath) {
|
|
|
18
23
|
// - For Windows users, the assert is correct.
|
|
19
24
|
// - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
|
|
20
25
|
// - But that's okay because the assertion will eventually fail for Windows users.
|
|
26
|
+
// - On Linux there doesn't seem to be a way to distinguish between an absolute path starting from the filesystem root or starting from the user root directory, see comment at isFilePathAbsoluteFilesystem()
|
|
21
27
|
(0, assert_js_1.assert)(isFilePathAbsoluteFilesystem(filePath));
|
|
22
28
|
(0, path_js_1.assertPosixPath)(filePath);
|
|
23
29
|
}
|
|
@@ -33,11 +39,11 @@ function isFilePathAbsoluteFilesystem(filePath) {
|
|
|
33
39
|
// - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
|
|
34
40
|
// - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
|
|
35
41
|
// - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
|
|
36
|
-
// - Using require.resolve() would be a solution but
|
|
42
|
+
// - Using require.resolve() or node:fs to check wehther the file/dir exsits would be a solution, but maybe too slow?
|
|
37
43
|
return filePath.startsWith('/');
|
|
38
44
|
}
|
|
39
45
|
else {
|
|
40
|
-
const yes =
|
|
46
|
+
const yes = node_path_1.default.win32.isAbsolute(filePath);
|
|
41
47
|
// Ensure isFilePathAbsoluteFilesystem() returns `false` if path is absolute starting from the user root dir (see comments above).
|
|
42
48
|
if (yes)
|
|
43
49
|
(0, assert_js_1.assert)(!filePath.startsWith('/'));
|
|
@@ -55,5 +61,5 @@ function isFilePathAbsolute(filePath) {
|
|
|
55
61
|
if (filePath.startsWith('/'))
|
|
56
62
|
return true;
|
|
57
63
|
// Seems to be reliable: https://nodejs.org/api/path.html#pathisabsolutepath
|
|
58
|
-
return
|
|
64
|
+
return node_path_1.default.isAbsolute(filePath);
|
|
59
65
|
}
|
package/dist/cjs/utils/path.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.assertPosixPath = assertPosixPath;
|
|
|
9
9
|
// - Robust shim reference: https://github.com/unjs/pathe
|
|
10
10
|
const assert_js_1 = require("./assert.js");
|
|
11
11
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
12
|
+
// While this path shim also works on the client-side, let's try to not use it on the client-side in order to minimize KBs sent to the browser.
|
|
12
13
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
13
14
|
/**********************/
|
|
14
15
|
/****** SHIMS *********/
|
|
@@ -55,10 +55,13 @@ function fileEnv() {
|
|
|
55
55
|
Array.from(this.getModuleIds())
|
|
56
56
|
.filter((id) => !skip(id))
|
|
57
57
|
.forEach((moduleId) => {
|
|
58
|
-
const
|
|
58
|
+
const mod = this.getModuleInfo(moduleId);
|
|
59
|
+
const { importers } = mod;
|
|
59
60
|
if (importers.length === 0) {
|
|
60
61
|
// Dynamic imports can only be verified at runtime
|
|
61
|
-
|
|
62
|
+
/* This assertion can fail: https://github.com/vikejs/vike/issues/2227
|
|
63
|
+
assert(dynamicImporters.length > 0)
|
|
64
|
+
*/
|
|
62
65
|
return;
|
|
63
66
|
}
|
|
64
67
|
assertFileEnv(moduleId, !!config.build.ssr, importers, false);
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
2
|
export { isPlusFile };
|
|
3
3
|
export { getPlusFileValueConfigName };
|
|
4
|
-
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList, createDebugger, deepEqual, assertUsage } from '../../../../utils.js';
|
|
4
|
+
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList, createDebugger, deepEqual, assertUsage, assertFilePathAbsoluteFilesystem, assertWarning, hasProp } from '../../../../utils.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { glob } from 'tinyglobby';
|
|
7
7
|
import { exec } from 'child_process';
|
|
8
8
|
import { promisify } from 'util';
|
|
9
9
|
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
10
10
|
import { getEnvVarObject } from '../../../../shared/getEnvVarObject.js';
|
|
11
|
+
import pc from '@brillout/picocolors';
|
|
11
12
|
const execA = promisify(exec);
|
|
12
13
|
const debug = createDebugger('vike:crawl');
|
|
13
14
|
assertIsNotProductionRuntime();
|
|
@@ -15,6 +16,7 @@ assertIsSingleModuleInstance('getVikeConfig/crawlPlusFiles.ts');
|
|
|
15
16
|
let gitIsNotUsable = false;
|
|
16
17
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
17
18
|
assertPosixPath(userRootDir);
|
|
19
|
+
assertFilePathAbsoluteFilesystem(userRootDir);
|
|
18
20
|
//*/
|
|
19
21
|
const outDirRelativeFromUserRootDir = null;
|
|
20
22
|
/*/
|
|
@@ -32,8 +34,9 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
32
34
|
(!outDirRelativeFromUserRootDir.startsWith('./') &&
|
|
33
35
|
//
|
|
34
36
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
37
|
+
const crawSettings = getCrawlSettings();
|
|
35
38
|
// Crawl
|
|
36
|
-
const filesGit =
|
|
39
|
+
const filesGit = crawSettings.git !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
37
40
|
const filesGitNothingFound = !filesGit || filesGit.length === 0;
|
|
38
41
|
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await tinyglobby(userRootDir, outDirRelativeFromUserRootDir));
|
|
39
42
|
let files = !filesGitNothingFound
|
|
@@ -41,8 +44,11 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
41
44
|
: // Fallback to tinyglobby for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
42
45
|
filesGlob;
|
|
43
46
|
assert(files);
|
|
44
|
-
if (debug.isActivated)
|
|
45
|
-
assert(
|
|
47
|
+
if (debug.isActivated) {
|
|
48
|
+
assert(filesGit);
|
|
49
|
+
assert(filesGlob);
|
|
50
|
+
assertWarning(deepEqual(filesGlob.slice().sort(), filesGit.slice().sort()), "Git and glob results aren't matching.", { onlyOnce: false });
|
|
51
|
+
}
|
|
46
52
|
// Filter build files
|
|
47
53
|
files = files.filter((filePath) => !isTemporaryBuildFile(filePath));
|
|
48
54
|
// Normalize
|
|
@@ -129,8 +135,7 @@ async function tinyglobby(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
129
135
|
const options = {
|
|
130
136
|
ignore: getIgnoreAsPatterns(outDirRelativeFromUserRootDir),
|
|
131
137
|
cwd: userRootDir,
|
|
132
|
-
dot: false
|
|
133
|
-
expandDirectories: false
|
|
138
|
+
dot: false
|
|
134
139
|
};
|
|
135
140
|
const files = await glob(pattern, options);
|
|
136
141
|
// Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
|
|
@@ -153,7 +158,9 @@ function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
|
153
158
|
// +Page.js
|
|
154
159
|
// +Page.telefunc.js
|
|
155
160
|
// ```
|
|
156
|
-
'**/*.telefunc.*'
|
|
161
|
+
'**/*.telefunc.*',
|
|
162
|
+
// https://github.com/vikejs/vike/discussions/2222
|
|
163
|
+
'**/*.generated.*'
|
|
157
164
|
];
|
|
158
165
|
if (outDirRelativeFromUserRootDir) {
|
|
159
166
|
assert(!outDirRelativeFromUserRootDir.startsWith('/'));
|
|
@@ -167,6 +174,7 @@ function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
|
167
174
|
return (file) => !file.includes('node_modules/') &&
|
|
168
175
|
!file.includes('ejected/') &&
|
|
169
176
|
!file.includes('.telefunc.') &&
|
|
177
|
+
!file.includes('.generated.') &&
|
|
170
178
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
171
179
|
}
|
|
172
180
|
// Whether Git is installed and whether we can use it
|
|
@@ -223,9 +231,11 @@ async function runCmd2(cmd, cwd) {
|
|
|
223
231
|
stderr = stderr.toString().trim();
|
|
224
232
|
return { stdout, stderr };
|
|
225
233
|
}
|
|
226
|
-
function
|
|
227
|
-
const
|
|
228
|
-
|
|
234
|
+
function getCrawlSettings() {
|
|
235
|
+
const crawlSettings = getEnvVarObject('VIKE_CRAWL') ?? {};
|
|
236
|
+
const wrongUsage = (settingName, settingType) => `Setting ${pc.cyan(settingName)} in VIKE_CRAWL should be a ${pc.cyan(settingType)}`;
|
|
237
|
+
assertUsage(hasProp(crawlSettings, 'git', 'boolean') || hasProp(crawlSettings, 'git', 'undefined'), wrongUsage('git', 'boolean'));
|
|
238
|
+
return crawlSettings;
|
|
229
239
|
}
|
|
230
240
|
function isPlusFile(filePath) {
|
|
231
241
|
assertPosixPath(filePath);
|
|
@@ -3,7 +3,6 @@ export { getConfigBuildErrorFormatted };
|
|
|
3
3
|
export { getConfigExecutionErrorIntroMsg };
|
|
4
4
|
export { isTemporaryBuildFile };
|
|
5
5
|
export type { EsbuildCache };
|
|
6
|
-
import 'source-map-support/register.js';
|
|
7
6
|
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
8
7
|
type FileExports = {
|
|
9
8
|
fileExports: Record<string, unknown>;
|
|
@@ -7,16 +7,17 @@ import fs from 'fs';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
9
|
import { import_ } from '@brillout/import';
|
|
10
|
-
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, assertWarning, isObject, toPosixPath, assertUsage, isPlainJavaScriptFile, createDebugger, assertFilePathAbsoluteFilesystem, assertIsNpmPackageImport, genPromise } from '../../../../utils.js';
|
|
10
|
+
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, assertWarning, isObject, toPosixPath, assertUsage, isPlainJavaScriptFile, createDebugger, assertFilePathAbsoluteFilesystem, assertIsNpmPackageImport, genPromise, isVitest } from '../../../../utils.js';
|
|
11
11
|
import { transformPointerImports } from './transformPointerImports.js';
|
|
12
12
|
import { vikeConfigDependencies } from '../getVikeConfig.js';
|
|
13
|
-
import 'source-map-support
|
|
13
|
+
import sourceMapSupport from 'source-map-support';
|
|
14
14
|
import { getFilePathAbsoluteUserRootDir } from '../../../../shared/getFilePath.js';
|
|
15
15
|
import { createRequire } from 'module';
|
|
16
16
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
17
17
|
const importMetaUrl = import.meta.url;
|
|
18
18
|
const require_ = createRequire(importMetaUrl);
|
|
19
19
|
assertIsNotProductionRuntime();
|
|
20
|
+
installSourceMapSupport();
|
|
20
21
|
const debug = createDebugger('vike:pointer-imports');
|
|
21
22
|
const debugEsbuildResolve = createDebugger('vike:esbuild-resolve');
|
|
22
23
|
if (debugEsbuildResolve.isActivated)
|
|
@@ -401,3 +402,11 @@ function cleanEsbuildErrors(errors) {
|
|
|
401
402
|
// ```
|
|
402
403
|
!note.text.includes('as external to exclude it from the bundle'))));
|
|
403
404
|
}
|
|
405
|
+
function installSourceMapSupport() {
|
|
406
|
+
// Don't break Vitest's source mapping
|
|
407
|
+
if (isVitest())
|
|
408
|
+
return;
|
|
409
|
+
// How about other test runners?
|
|
410
|
+
// Should we call installSourceMapSupport() lazily in transpileAndExecuteFile() instead?
|
|
411
|
+
sourceMapSupport.install();
|
|
412
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.223-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.223-commit-3502685";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.223-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.223-commit-3502685';
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export { assertFilePathAbsoluteFilesystem };
|
|
2
2
|
export { isFilePathAbsolute };
|
|
3
|
-
import path from 'path';
|
|
3
|
+
import path from 'node:path';
|
|
4
4
|
import { assert } from './assert.js';
|
|
5
5
|
import { assertPosixPath } from './path.js';
|
|
6
|
+
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
7
|
+
import { assertIsNotProductionRuntime } from './assertSetup.js';
|
|
8
|
+
assertIsNotBrowser();
|
|
9
|
+
// Server runtime shouldn't depend on node:path
|
|
10
|
+
assertIsNotProductionRuntime();
|
|
6
11
|
/**
|
|
7
12
|
* Asserts that `filePath` is an absolute file path starting from the filesystem root.
|
|
8
13
|
*
|
|
@@ -13,6 +18,7 @@ function assertFilePathAbsoluteFilesystem(filePath) {
|
|
|
13
18
|
// - For Windows users, the assert is correct.
|
|
14
19
|
// - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
|
|
15
20
|
// - But that's okay because the assertion will eventually fail for Windows users.
|
|
21
|
+
// - On Linux there doesn't seem to be a way to distinguish between an absolute path starting from the filesystem root or starting from the user root directory, see comment at isFilePathAbsoluteFilesystem()
|
|
16
22
|
assert(isFilePathAbsoluteFilesystem(filePath));
|
|
17
23
|
assertPosixPath(filePath);
|
|
18
24
|
}
|
|
@@ -28,7 +34,7 @@ function isFilePathAbsoluteFilesystem(filePath) {
|
|
|
28
34
|
// - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
|
|
29
35
|
// - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
|
|
30
36
|
// - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
|
|
31
|
-
// - Using require.resolve() would be a solution but
|
|
37
|
+
// - Using require.resolve() or node:fs to check wehther the file/dir exsits would be a solution, but maybe too slow?
|
|
32
38
|
return filePath.startsWith('/');
|
|
33
39
|
}
|
|
34
40
|
else {
|
package/dist/esm/utils/path.js
CHANGED
|
@@ -7,6 +7,7 @@ export { assertPosixPath };
|
|
|
7
7
|
// - Robust shim reference: https://github.com/unjs/pathe
|
|
8
8
|
import { assert } from './assert.js';
|
|
9
9
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
10
|
+
// While this path shim also works on the client-side, let's try to not use it on the client-side in order to minimize KBs sent to the browser.
|
|
10
11
|
assertIsNotBrowser();
|
|
11
12
|
/**********************/
|
|
12
13
|
/****** SHIMS *********/
|