vike 0.4.223-commit-535bde1 → 0.4.223-commit-17500eb
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/ignorePatternsBuiltIn.js +16 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +45 -60
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +3 -3
- 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/ignorePatternsBuiltIn.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +13 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +46 -61
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +3 -3
- 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 +3 -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);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ignorePatternsBuiltIn = void 0;
|
|
4
|
+
exports.ignorePatternsBuiltIn = [
|
|
5
|
+
'**/node_modules/**',
|
|
6
|
+
// Ejected Vike extensions, see https://github.com/snake-py/eject
|
|
7
|
+
'**/ejected/**',
|
|
8
|
+
// Allow:
|
|
9
|
+
// ```bash
|
|
10
|
+
// +Page.js
|
|
11
|
+
// +Page.telefunc.js
|
|
12
|
+
// ```
|
|
13
|
+
'**/*.telefunc.*',
|
|
14
|
+
// https://github.com/vikejs/vike/discussions/2222
|
|
15
|
+
'**/*.generated.*'
|
|
16
|
+
];
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -13,41 +13,33 @@ 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"));
|
|
17
|
+
const picomatch_1 = __importDefault(require("picomatch"));
|
|
18
|
+
const ignorePatternsBuiltIn_js_1 = require("./crawlPlusFiles/ignorePatternsBuiltIn.js");
|
|
16
19
|
const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
17
20
|
const debug = (0, utils_js_1.createDebugger)('vike:crawl');
|
|
18
21
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
19
22
|
(0, utils_js_1.assertIsSingleModuleInstance)('getVikeConfig/crawlPlusFiles.ts');
|
|
20
23
|
let gitIsNotUsable = false;
|
|
21
|
-
async function crawlPlusFiles(userRootDir
|
|
24
|
+
async function crawlPlusFiles(userRootDir) {
|
|
22
25
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
assertPosixPath(outDirAbsoluteFilesystem)
|
|
27
|
-
let outDirRelativeFromUserRootDir: string | null = path.posix.relative(userRootDir, outDirAbsoluteFilesystem)
|
|
28
|
-
if (outDirRelativeFromUserRootDir.startsWith('../')) {
|
|
29
|
-
// config.outDir is outside of config.root => it's going to be ignored anyways
|
|
30
|
-
outDirRelativeFromUserRootDir = null
|
|
31
|
-
}
|
|
32
|
-
//*/
|
|
33
|
-
(0, utils_js_1.assert)(outDirRelativeFromUserRootDir === null ||
|
|
34
|
-
/* Not true if outDirRelativeFromUserRootDir starts with a hidden directory (i.e. a directory with a name that starts with `.`)
|
|
35
|
-
!outDirRelativeFromUserRootDir.startsWith('.') &&
|
|
36
|
-
*/
|
|
37
|
-
(!outDirRelativeFromUserRootDir.startsWith('./') &&
|
|
38
|
-
//
|
|
39
|
-
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
26
|
+
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(userRootDir);
|
|
27
|
+
const userSettings = getUserSettings();
|
|
28
|
+
const { ignorePatterns, ignoreMatchers } = getIgnore(userSettings);
|
|
40
29
|
// Crawl
|
|
41
|
-
const filesGit =
|
|
30
|
+
const filesGit = userSettings.git !== false && (await gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers));
|
|
42
31
|
const filesGitNothingFound = !filesGit || filesGit.length === 0;
|
|
43
|
-
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await tinyglobby(userRootDir,
|
|
32
|
+
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await tinyglobby(userRootDir, ignorePatterns));
|
|
44
33
|
let files = !filesGitNothingFound
|
|
45
34
|
? filesGit
|
|
46
35
|
: // 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
36
|
filesGlob;
|
|
48
37
|
(0, utils_js_1.assert)(files);
|
|
49
|
-
if (debug.isActivated)
|
|
50
|
-
(0, utils_js_1.assert)(
|
|
38
|
+
if (debug.isActivated) {
|
|
39
|
+
(0, utils_js_1.assert)(filesGit);
|
|
40
|
+
(0, utils_js_1.assert)(filesGlob);
|
|
41
|
+
(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 });
|
|
42
|
+
}
|
|
51
43
|
// Filter build files
|
|
52
44
|
files = files.filter((filePath) => !(0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath));
|
|
53
45
|
// Normalize
|
|
@@ -62,7 +54,7 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
62
54
|
return plusFiles;
|
|
63
55
|
}
|
|
64
56
|
// Same as tinyglobby() but using `$ git ls-files`
|
|
65
|
-
async function gitLsFiles(userRootDir,
|
|
57
|
+
async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
66
58
|
if (gitIsNotUsable)
|
|
67
59
|
return null;
|
|
68
60
|
// Preserve UTF-8 file paths.
|
|
@@ -70,8 +62,6 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
70
62
|
// https://stackoverflow.com/questions/22827239/how-to-make-git-properly-display-utf-8-encoded-pathnames-in-the-console-window/22828826#22828826
|
|
71
63
|
// https://stackoverflow.com/questions/15884180/how-do-i-override-git-configuration-options-by-command-line-parameters/15884261#15884261
|
|
72
64
|
const preserveUTF8 = '-c core.quotepath=off';
|
|
73
|
-
const ignoreAsPatterns = getIgnoreAsPatterns(outDirRelativeFromUserRootDir);
|
|
74
|
-
const ignoreAsFilterFn = getIgnoreAsFilterFn(outDirRelativeFromUserRootDir);
|
|
75
65
|
const cmd = [
|
|
76
66
|
'git',
|
|
77
67
|
preserveUTF8,
|
|
@@ -81,7 +71,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
81
71
|
// Performance gain is non-negligible.
|
|
82
72
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
83
73
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
84
|
-
...
|
|
74
|
+
...ignorePatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
85
75
|
// --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
|
|
86
76
|
// --cached => list tracked files
|
|
87
77
|
'--others --exclude-standard --cached'
|
|
@@ -116,7 +106,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
116
106
|
if (!path_1.default.posix.basename(filePath).startsWith('+'))
|
|
117
107
|
continue;
|
|
118
108
|
// We have to repeat the same exclusion logic here because the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
|
|
119
|
-
if (
|
|
109
|
+
if (ignoreMatchers.some((m) => m(filePath)))
|
|
120
110
|
continue;
|
|
121
111
|
// JavaScript file?
|
|
122
112
|
if (!(0, utils_js_1.isScriptFile)(filePath))
|
|
@@ -129,13 +119,12 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
129
119
|
return files;
|
|
130
120
|
}
|
|
131
121
|
// Same as gitLsFiles() but using tinyglobby
|
|
132
|
-
async function tinyglobby(userRootDir,
|
|
122
|
+
async function tinyglobby(userRootDir, ignorePatterns) {
|
|
133
123
|
const pattern = `**/+*.${utils_js_1.scriptFileExtensions}`;
|
|
134
124
|
const options = {
|
|
135
|
-
ignore:
|
|
125
|
+
ignore: ignorePatterns,
|
|
136
126
|
cwd: userRootDir,
|
|
137
|
-
dot: false
|
|
138
|
-
expandDirectories: false
|
|
127
|
+
dot: false
|
|
139
128
|
};
|
|
140
129
|
const files = await (0, tinyglobby_1.glob)(pattern, options);
|
|
141
130
|
// Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
|
|
@@ -148,32 +137,6 @@ async function tinyglobby(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
148
137
|
}
|
|
149
138
|
return files;
|
|
150
139
|
}
|
|
151
|
-
// Same as getIgnoreAsFilterFn() but as glob pattern
|
|
152
|
-
function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
153
|
-
const ignoreAsPatterns = [
|
|
154
|
-
'**/node_modules/**',
|
|
155
|
-
'**/ejected/**',
|
|
156
|
-
// Allow:
|
|
157
|
-
// ```
|
|
158
|
-
// +Page.js
|
|
159
|
-
// +Page.telefunc.js
|
|
160
|
-
// ```
|
|
161
|
-
'**/*.telefunc.*'
|
|
162
|
-
];
|
|
163
|
-
if (outDirRelativeFromUserRootDir) {
|
|
164
|
-
(0, utils_js_1.assert)(!outDirRelativeFromUserRootDir.startsWith('/'));
|
|
165
|
-
ignoreAsPatterns.push(`${outDirRelativeFromUserRootDir}/**`);
|
|
166
|
-
}
|
|
167
|
-
return ignoreAsPatterns;
|
|
168
|
-
}
|
|
169
|
-
// Same as getIgnoreAsPatterns() but for Array.filter()
|
|
170
|
-
function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
171
|
-
(0, utils_js_1.assert)(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
172
|
-
return (file) => !file.includes('node_modules/') &&
|
|
173
|
-
!file.includes('ejected/') &&
|
|
174
|
-
!file.includes('.telefunc.') &&
|
|
175
|
-
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
176
|
-
}
|
|
177
140
|
// Whether Git is installed and whether we can use it
|
|
178
141
|
async function isGitNotUsable(userRootDir) {
|
|
179
142
|
// Check Git version
|
|
@@ -228,9 +191,19 @@ async function runCmd2(cmd, cwd) {
|
|
|
228
191
|
stderr = stderr.toString().trim();
|
|
229
192
|
return { stdout, stderr };
|
|
230
193
|
}
|
|
231
|
-
function
|
|
232
|
-
const
|
|
233
|
-
|
|
194
|
+
function getUserSettings() {
|
|
195
|
+
const userSettings = (0, getEnvVarObject_js_1.getEnvVarObject)('VIKE_CRAWL') ?? {};
|
|
196
|
+
const wrongUsage = (settingName, settingType) => `Setting ${picocolors_1.default.cyan(settingName)} in VIKE_CRAWL should be a ${picocolors_1.default.cyan(settingType)}`;
|
|
197
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(userSettings, 'git', 'boolean') || (0, utils_js_1.hasProp)(userSettings, 'git', 'undefined'), wrongUsage('git', 'boolean'));
|
|
198
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(userSettings, 'ignore', 'string[]') ||
|
|
199
|
+
(0, utils_js_1.hasProp)(userSettings, 'ignore', 'string') ||
|
|
200
|
+
(0, utils_js_1.hasProp)(userSettings, 'ignore', 'undefined'), wrongUsage('git', 'string or an array of strings'));
|
|
201
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(userSettings, 'ignoreBuiltIn', 'boolean') || (0, utils_js_1.hasProp)(userSettings, 'ignoreBuiltIn', 'undefined'), wrongUsage('ignoreBuiltIn', 'boolean'));
|
|
202
|
+
const settingNames = ['git', 'ignore', 'ignoreBuiltIn'];
|
|
203
|
+
Object.keys(userSettings).forEach((name) => {
|
|
204
|
+
(0, utils_js_1.assertUsage)(settingNames.includes(name), `Unknown setting ${picocolors_1.default.bold(picocolors_1.default.red(name))} in VIKE_CRAWL`);
|
|
205
|
+
});
|
|
206
|
+
return userSettings;
|
|
234
207
|
}
|
|
235
208
|
function isPlusFile(filePath) {
|
|
236
209
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
@@ -266,3 +239,15 @@ function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
|
266
239
|
)
|
|
267
240
|
}
|
|
268
241
|
*/
|
|
242
|
+
function getIgnore(userSettings) {
|
|
243
|
+
const ignorePatternsSetByUser = [userSettings.ignore].flat().filter(utils_js_1.isNotNullish);
|
|
244
|
+
const { ignoreBuiltIn } = userSettings;
|
|
245
|
+
const ignorePatterns = [...(ignoreBuiltIn === false ? [] : ignorePatternsBuiltIn_js_1.ignorePatternsBuiltIn), ...ignorePatternsSetByUser];
|
|
246
|
+
const ignoreMatchers = ignorePatterns.map((p) => (0, picomatch_1.default)(p, {
|
|
247
|
+
// We must pass the same settings than tinyglobby
|
|
248
|
+
// https://github.com/SuperchupuDev/tinyglobby/blob/fcfb08a36c3b4d48d5488c21000c95a956d9797c/src/index.ts#L191-L194
|
|
249
|
+
dot: false,
|
|
250
|
+
nocase: false
|
|
251
|
+
}));
|
|
252
|
+
return { ignorePatterns, ignoreMatchers };
|
|
253
|
+
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js
CHANGED
|
@@ -11,7 +11,7 @@ const resolvePointerImport_js_1 = require("./resolvePointerImport.js");
|
|
|
11
11
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
12
12
|
const assertExtensions_js_1 = require("./assertExtensions.js");
|
|
13
13
|
async function getPlusFilesAll(userRootDir, esbuildCache) {
|
|
14
|
-
const plusFiles = await findPlusFiles(userRootDir
|
|
14
|
+
const plusFiles = await findPlusFiles(userRootDir);
|
|
15
15
|
const configFiles = [];
|
|
16
16
|
const valueFiles = [];
|
|
17
17
|
plusFiles.forEach((f) => {
|
|
@@ -114,8 +114,8 @@ function getPlusFileFromConfigFile(configFile, isExtensionConfig, locationId, us
|
|
|
114
114
|
function sortMakeDeterministic(plusFile1, plusFile2) {
|
|
115
115
|
return plusFile1.filePath.filePathAbsoluteVite < plusFile2.filePath.filePathAbsoluteVite ? -1 : 1;
|
|
116
116
|
}
|
|
117
|
-
async function findPlusFiles(userRootDir
|
|
118
|
-
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir
|
|
117
|
+
async function findPlusFiles(userRootDir) {
|
|
118
|
+
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir);
|
|
119
119
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
120
120
|
return plusFiles;
|
|
121
121
|
}
|
|
@@ -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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ignorePatternsBuiltIn: readonly ["**/node_modules/**", "**/ejected/**", "**/*.telefunc.*", "**/*.generated.*"];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const ignorePatternsBuiltIn = [
|
|
2
|
+
'**/node_modules/**',
|
|
3
|
+
// Ejected Vike extensions, see https://github.com/snake-py/eject
|
|
4
|
+
'**/ejected/**',
|
|
5
|
+
// Allow:
|
|
6
|
+
// ```bash
|
|
7
|
+
// +Page.js
|
|
8
|
+
// +Page.telefunc.js
|
|
9
|
+
// ```
|
|
10
|
+
'**/*.telefunc.*',
|
|
11
|
+
// https://github.com/vikejs/vike/discussions/2222
|
|
12
|
+
'**/*.generated.*'
|
|
13
|
+
];
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
2
|
export { isPlusFile };
|
|
3
3
|
export { getPlusFileValueConfigName };
|
|
4
|
-
declare function crawlPlusFiles(userRootDir: string
|
|
4
|
+
declare function crawlPlusFiles(userRootDir: string): Promise<{
|
|
5
5
|
filePathAbsoluteUserRootDir: string;
|
|
6
6
|
}[]>;
|
|
7
7
|
declare function isPlusFile(filePath: string): boolean;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,48 +1,40 @@
|
|
|
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, isNotNullish } 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';
|
|
12
|
+
import picomatch from 'picomatch';
|
|
13
|
+
import { ignorePatternsBuiltIn } from './crawlPlusFiles/ignorePatternsBuiltIn.js';
|
|
11
14
|
const execA = promisify(exec);
|
|
12
15
|
const debug = createDebugger('vike:crawl');
|
|
13
16
|
assertIsNotProductionRuntime();
|
|
14
17
|
assertIsSingleModuleInstance('getVikeConfig/crawlPlusFiles.ts');
|
|
15
18
|
let gitIsNotUsable = false;
|
|
16
|
-
async function crawlPlusFiles(userRootDir
|
|
19
|
+
async function crawlPlusFiles(userRootDir) {
|
|
17
20
|
assertPosixPath(userRootDir);
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
assertPosixPath(outDirAbsoluteFilesystem)
|
|
22
|
-
let outDirRelativeFromUserRootDir: string | null = path.posix.relative(userRootDir, outDirAbsoluteFilesystem)
|
|
23
|
-
if (outDirRelativeFromUserRootDir.startsWith('../')) {
|
|
24
|
-
// config.outDir is outside of config.root => it's going to be ignored anyways
|
|
25
|
-
outDirRelativeFromUserRootDir = null
|
|
26
|
-
}
|
|
27
|
-
//*/
|
|
28
|
-
assert(outDirRelativeFromUserRootDir === null ||
|
|
29
|
-
/* Not true if outDirRelativeFromUserRootDir starts with a hidden directory (i.e. a directory with a name that starts with `.`)
|
|
30
|
-
!outDirRelativeFromUserRootDir.startsWith('.') &&
|
|
31
|
-
*/
|
|
32
|
-
(!outDirRelativeFromUserRootDir.startsWith('./') &&
|
|
33
|
-
//
|
|
34
|
-
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
21
|
+
assertFilePathAbsoluteFilesystem(userRootDir);
|
|
22
|
+
const userSettings = getUserSettings();
|
|
23
|
+
const { ignorePatterns, ignoreMatchers } = getIgnore(userSettings);
|
|
35
24
|
// Crawl
|
|
36
|
-
const filesGit =
|
|
25
|
+
const filesGit = userSettings.git !== false && (await gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers));
|
|
37
26
|
const filesGitNothingFound = !filesGit || filesGit.length === 0;
|
|
38
|
-
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await tinyglobby(userRootDir,
|
|
27
|
+
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await tinyglobby(userRootDir, ignorePatterns));
|
|
39
28
|
let files = !filesGitNothingFound
|
|
40
29
|
? filesGit
|
|
41
30
|
: // 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
31
|
filesGlob;
|
|
43
32
|
assert(files);
|
|
44
|
-
if (debug.isActivated)
|
|
45
|
-
assert(
|
|
33
|
+
if (debug.isActivated) {
|
|
34
|
+
assert(filesGit);
|
|
35
|
+
assert(filesGlob);
|
|
36
|
+
assertWarning(deepEqual(filesGlob.slice().sort(), filesGit.slice().sort()), "Git and glob results aren't matching.", { onlyOnce: false });
|
|
37
|
+
}
|
|
46
38
|
// Filter build files
|
|
47
39
|
files = files.filter((filePath) => !isTemporaryBuildFile(filePath));
|
|
48
40
|
// Normalize
|
|
@@ -57,7 +49,7 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
57
49
|
return plusFiles;
|
|
58
50
|
}
|
|
59
51
|
// Same as tinyglobby() but using `$ git ls-files`
|
|
60
|
-
async function gitLsFiles(userRootDir,
|
|
52
|
+
async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
61
53
|
if (gitIsNotUsable)
|
|
62
54
|
return null;
|
|
63
55
|
// Preserve UTF-8 file paths.
|
|
@@ -65,8 +57,6 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
65
57
|
// https://stackoverflow.com/questions/22827239/how-to-make-git-properly-display-utf-8-encoded-pathnames-in-the-console-window/22828826#22828826
|
|
66
58
|
// https://stackoverflow.com/questions/15884180/how-do-i-override-git-configuration-options-by-command-line-parameters/15884261#15884261
|
|
67
59
|
const preserveUTF8 = '-c core.quotepath=off';
|
|
68
|
-
const ignoreAsPatterns = getIgnoreAsPatterns(outDirRelativeFromUserRootDir);
|
|
69
|
-
const ignoreAsFilterFn = getIgnoreAsFilterFn(outDirRelativeFromUserRootDir);
|
|
70
60
|
const cmd = [
|
|
71
61
|
'git',
|
|
72
62
|
preserveUTF8,
|
|
@@ -76,7 +66,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
76
66
|
// Performance gain is non-negligible.
|
|
77
67
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
78
68
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
79
|
-
...
|
|
69
|
+
...ignorePatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
80
70
|
// --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
|
|
81
71
|
// --cached => list tracked files
|
|
82
72
|
'--others --exclude-standard --cached'
|
|
@@ -111,7 +101,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
111
101
|
if (!path.posix.basename(filePath).startsWith('+'))
|
|
112
102
|
continue;
|
|
113
103
|
// We have to repeat the same exclusion logic here because the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
|
|
114
|
-
if (
|
|
104
|
+
if (ignoreMatchers.some((m) => m(filePath)))
|
|
115
105
|
continue;
|
|
116
106
|
// JavaScript file?
|
|
117
107
|
if (!isScriptFile(filePath))
|
|
@@ -124,13 +114,12 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
124
114
|
return files;
|
|
125
115
|
}
|
|
126
116
|
// Same as gitLsFiles() but using tinyglobby
|
|
127
|
-
async function tinyglobby(userRootDir,
|
|
117
|
+
async function tinyglobby(userRootDir, ignorePatterns) {
|
|
128
118
|
const pattern = `**/+*.${scriptFileExtensions}`;
|
|
129
119
|
const options = {
|
|
130
|
-
ignore:
|
|
120
|
+
ignore: ignorePatterns,
|
|
131
121
|
cwd: userRootDir,
|
|
132
|
-
dot: false
|
|
133
|
-
expandDirectories: false
|
|
122
|
+
dot: false
|
|
134
123
|
};
|
|
135
124
|
const files = await glob(pattern, options);
|
|
136
125
|
// Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
|
|
@@ -143,32 +132,6 @@ async function tinyglobby(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
143
132
|
}
|
|
144
133
|
return files;
|
|
145
134
|
}
|
|
146
|
-
// Same as getIgnoreAsFilterFn() but as glob pattern
|
|
147
|
-
function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
148
|
-
const ignoreAsPatterns = [
|
|
149
|
-
'**/node_modules/**',
|
|
150
|
-
'**/ejected/**',
|
|
151
|
-
// Allow:
|
|
152
|
-
// ```
|
|
153
|
-
// +Page.js
|
|
154
|
-
// +Page.telefunc.js
|
|
155
|
-
// ```
|
|
156
|
-
'**/*.telefunc.*'
|
|
157
|
-
];
|
|
158
|
-
if (outDirRelativeFromUserRootDir) {
|
|
159
|
-
assert(!outDirRelativeFromUserRootDir.startsWith('/'));
|
|
160
|
-
ignoreAsPatterns.push(`${outDirRelativeFromUserRootDir}/**`);
|
|
161
|
-
}
|
|
162
|
-
return ignoreAsPatterns;
|
|
163
|
-
}
|
|
164
|
-
// Same as getIgnoreAsPatterns() but for Array.filter()
|
|
165
|
-
function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
166
|
-
assert(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
167
|
-
return (file) => !file.includes('node_modules/') &&
|
|
168
|
-
!file.includes('ejected/') &&
|
|
169
|
-
!file.includes('.telefunc.') &&
|
|
170
|
-
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
171
|
-
}
|
|
172
135
|
// Whether Git is installed and whether we can use it
|
|
173
136
|
async function isGitNotUsable(userRootDir) {
|
|
174
137
|
// Check Git version
|
|
@@ -223,9 +186,19 @@ async function runCmd2(cmd, cwd) {
|
|
|
223
186
|
stderr = stderr.toString().trim();
|
|
224
187
|
return { stdout, stderr };
|
|
225
188
|
}
|
|
226
|
-
function
|
|
227
|
-
const
|
|
228
|
-
|
|
189
|
+
function getUserSettings() {
|
|
190
|
+
const userSettings = getEnvVarObject('VIKE_CRAWL') ?? {};
|
|
191
|
+
const wrongUsage = (settingName, settingType) => `Setting ${pc.cyan(settingName)} in VIKE_CRAWL should be a ${pc.cyan(settingType)}`;
|
|
192
|
+
assertUsage(hasProp(userSettings, 'git', 'boolean') || hasProp(userSettings, 'git', 'undefined'), wrongUsage('git', 'boolean'));
|
|
193
|
+
assertUsage(hasProp(userSettings, 'ignore', 'string[]') ||
|
|
194
|
+
hasProp(userSettings, 'ignore', 'string') ||
|
|
195
|
+
hasProp(userSettings, 'ignore', 'undefined'), wrongUsage('git', 'string or an array of strings'));
|
|
196
|
+
assertUsage(hasProp(userSettings, 'ignoreBuiltIn', 'boolean') || hasProp(userSettings, 'ignoreBuiltIn', 'undefined'), wrongUsage('ignoreBuiltIn', 'boolean'));
|
|
197
|
+
const settingNames = ['git', 'ignore', 'ignoreBuiltIn'];
|
|
198
|
+
Object.keys(userSettings).forEach((name) => {
|
|
199
|
+
assertUsage(settingNames.includes(name), `Unknown setting ${pc.bold(pc.red(name))} in VIKE_CRAWL`);
|
|
200
|
+
});
|
|
201
|
+
return userSettings;
|
|
229
202
|
}
|
|
230
203
|
function isPlusFile(filePath) {
|
|
231
204
|
assertPosixPath(filePath);
|
|
@@ -261,3 +234,15 @@ function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
|
261
234
|
)
|
|
262
235
|
}
|
|
263
236
|
*/
|
|
237
|
+
function getIgnore(userSettings) {
|
|
238
|
+
const ignorePatternsSetByUser = [userSettings.ignore].flat().filter(isNotNullish);
|
|
239
|
+
const { ignoreBuiltIn } = userSettings;
|
|
240
|
+
const ignorePatterns = [...(ignoreBuiltIn === false ? [] : ignorePatternsBuiltIn), ...ignorePatternsSetByUser];
|
|
241
|
+
const ignoreMatchers = ignorePatterns.map((p) => picomatch(p, {
|
|
242
|
+
// We must pass the same settings than tinyglobby
|
|
243
|
+
// https://github.com/SuperchupuDev/tinyglobby/blob/fcfb08a36c3b4d48d5488c21000c95a956d9797c/src/index.ts#L191-L194
|
|
244
|
+
dot: false,
|
|
245
|
+
nocase: false
|
|
246
|
+
}));
|
|
247
|
+
return { ignorePatterns, ignoreMatchers };
|
|
248
|
+
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js
CHANGED
|
@@ -9,7 +9,7 @@ import { resolvePointerImport } from './resolvePointerImport.js';
|
|
|
9
9
|
import { getFilePathResolved } from '../../../../shared/getFilePath.js';
|
|
10
10
|
import { assertExtensionsConventions } from './assertExtensions.js';
|
|
11
11
|
async function getPlusFilesAll(userRootDir, esbuildCache) {
|
|
12
|
-
const plusFiles = await findPlusFiles(userRootDir
|
|
12
|
+
const plusFiles = await findPlusFiles(userRootDir);
|
|
13
13
|
const configFiles = [];
|
|
14
14
|
const valueFiles = [];
|
|
15
15
|
plusFiles.forEach((f) => {
|
|
@@ -112,8 +112,8 @@ function getPlusFileFromConfigFile(configFile, isExtensionConfig, locationId, us
|
|
|
112
112
|
function sortMakeDeterministic(plusFile1, plusFile2) {
|
|
113
113
|
return plusFile1.filePath.filePathAbsoluteVite < plusFile2.filePath.filePathAbsoluteVite ? -1 : 1;
|
|
114
114
|
}
|
|
115
|
-
async function findPlusFiles(userRootDir
|
|
116
|
-
const files = await crawlPlusFiles(userRootDir
|
|
115
|
+
async function findPlusFiles(userRootDir) {
|
|
116
|
+
const files = await crawlPlusFiles(userRootDir);
|
|
117
117
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
118
118
|
return plusFiles;
|
|
119
119
|
}
|
|
@@ -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-17500eb";
|
|
@@ -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-17500eb';
|
|
@@ -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 *********/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.223-commit-
|
|
3
|
+
"version": "0.4.223-commit-17500eb",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -129,6 +129,7 @@
|
|
|
129
129
|
"es-module-lexer": "^1.0.0",
|
|
130
130
|
"esbuild": "^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0",
|
|
131
131
|
"json5": "^2.0.0",
|
|
132
|
+
"picomatch": "^4.0.2",
|
|
132
133
|
"semver": "^7.0.0",
|
|
133
134
|
"source-map-support": "^0.5.0",
|
|
134
135
|
"tinyglobby": "^0.2.10",
|
|
@@ -246,6 +247,7 @@
|
|
|
246
247
|
"@types/estree": "^1.0.5",
|
|
247
248
|
"@types/jest": "^29.5.11",
|
|
248
249
|
"@types/node": "^20.10.5",
|
|
250
|
+
"@types/picomatch": "^3.0.2",
|
|
249
251
|
"@types/resolve": "^1.20.6",
|
|
250
252
|
"@types/semver": "^7.5.8",
|
|
251
253
|
"@types/source-map-support": "^0.5.10",
|