vike 0.4.165-commit-b3cc3cb → 0.4.165-commit-8eba585
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/baseUrls.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +12 -0
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -2
- package/dist/cjs/node/plugin/plugins/envVars.js +1 -1
- package/dist/cjs/node/plugin/plugins/fileEnv.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +0 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +53 -24
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getFilePath.js +90 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -24
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +15 -22
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -20
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +21 -20
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +1 -1
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +26 -24
- package/dist/cjs/node/runtime/renderPage.js +34 -21
- package/dist/cjs/shared/page-configs/FilePath.js +2 -0
- package/dist/cjs/utils/assert.js +2 -0
- package/dist/cjs/utils/assertSingleInstance.js +6 -5
- package/dist/cjs/utils/assertVersion.js +4 -1
- package/dist/cjs/utils/getFilePathAbsolute.js +11 -11
- package/dist/cjs/utils/getGlobalObject.js +21 -6
- package/dist/cjs/utils/isNpmPackage.js +1 -4
- package/dist/cjs/utils/parseUrl.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -4
- package/dist/esm/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +12 -0
- package/dist/esm/node/plugin/plugins/config/index.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +3 -3
- package/dist/esm/node/plugin/plugins/envVars.js +2 -2
- package/dist/esm/node/plugin/plugins/fileEnv.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +0 -1
- 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 +54 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +6 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getFilePath.d.ts +20 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getFilePath.js +84 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +6 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +15 -22
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -20
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +21 -20
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +2 -2
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +26 -24
- package/dist/esm/node/runtime/renderPage.js +34 -21
- package/dist/esm/shared/page-configs/FilePath.d.ts +52 -0
- package/dist/esm/shared/page-configs/FilePath.js +1 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +1 -42
- package/dist/esm/utils/assert.js +2 -0
- package/dist/esm/utils/assertSingleInstance.d.ts +2 -2
- package/dist/esm/utils/assertSingleInstance.js +5 -4
- package/dist/esm/utils/assertVersion.js +4 -1
- package/dist/esm/utils/getFilePathAbsolute.d.ts +4 -4
- package/dist/esm/utils/getFilePathAbsolute.js +10 -10
- package/dist/esm/utils/getGlobalObject.d.ts +6 -1
- package/dist/esm/utils/getGlobalObject.js +22 -6
- package/dist/esm/utils/isNpmPackage.d.ts +0 -6
- package/dist/esm/utils/isNpmPackage.js +5 -3
- package/dist/esm/utils/parseUrl.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -4
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -33
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -27
|
@@ -10,7 +10,7 @@ function baseUrls(configVike) {
|
|
|
10
10
|
return {
|
|
11
11
|
name: 'vike:baseUrls',
|
|
12
12
|
enforce: 'post',
|
|
13
|
-
config
|
|
13
|
+
async config(config) {
|
|
14
14
|
const bases = (0, resolveBase_js_1.resolveBaseFromUserConfig)(config, configVike);
|
|
15
15
|
baseServer = bases.baseServer;
|
|
16
16
|
baseAssets = bases.baseAssets;
|
|
@@ -49,10 +49,14 @@ async function copyAssets(filesToCopy, config) {
|
|
|
49
49
|
return;
|
|
50
50
|
(0, utils_js_1.assert)((0, fs_1.existsSync)(assetsDirServer));
|
|
51
51
|
const concurrencyLimit = (0, utils_js_1.pLimit)(10);
|
|
52
|
-
await Promise.all(filesToCopy.map((file) => concurrencyLimit(() =>
|
|
52
|
+
await Promise.all(filesToCopy.map((file) => concurrencyLimit(() =>
|
|
53
|
+
// TODO: move instead of copying
|
|
54
|
+
promises_1.default.cp(path_1.default.posix.join(outDirServer, file), path_1.default.posix.join(outDirClient, file), {
|
|
53
55
|
recursive: true
|
|
54
56
|
}))));
|
|
55
|
-
|
|
57
|
+
/* We cannot do that because, with some edge case Rollup settings (outputing JavaScript chunks and static assets to the same directoy), this removes JavaScript chunks, see https://github.com/vikejs/vike/issues/1154#issuecomment-1975762404
|
|
58
|
+
await fs.rm(assetsDirServer, { recursive: true })
|
|
59
|
+
*/
|
|
56
60
|
}
|
|
57
61
|
// Add serverManifest resources to clientManifest
|
|
58
62
|
function addServerAssets(clientManifest, serverManifest) {
|
|
@@ -213,7 +213,7 @@ function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
|
213
213
|
const filePath = clientEntry;
|
|
214
214
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
215
215
|
(0, utils_js_1.assert)(filePath.startsWith('/'));
|
|
216
|
-
let entryTarget = (0, utils_js_1.
|
|
216
|
+
let entryTarget = (0, utils_js_1.getFilePathAbsoluteFilesystem)(filePath, config);
|
|
217
217
|
if (addExtractAssetsQuery)
|
|
218
218
|
entryTarget = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(entryTarget);
|
|
219
219
|
let entryName = filePath;
|
|
@@ -6,6 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.assertResolveAlias = void 0;
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
+
// Recommend users to avoid un-distinguishable path aliases.
|
|
10
|
+
// There are a lot of libraries that don't or cannot follow that recommendation, for example:
|
|
11
|
+
// - Nx
|
|
12
|
+
// - Not sure why, but Nx seems to add a path alias for each monorepo package
|
|
13
|
+
// - https://github.com/vikejs/vike/discussions/1134
|
|
14
|
+
// - MUI
|
|
15
|
+
// - https://mui.com/material-ui/guides/minimizing-bundle-size/#how-to-use-custom-bundles
|
|
16
|
+
// - https://github.com/vikejs/vike/discussions/1549#discussioncomment-8789002
|
|
17
|
+
// - @preact/preset-vite
|
|
18
|
+
// - Aliases react imports
|
|
19
|
+
// - @vitejs/plugin-vue2
|
|
20
|
+
// - https://github.com/vikejs/vike/issues/1329
|
|
9
21
|
// TODO/v1-release: replace assertWarning() with assertUsage()
|
|
10
22
|
function assertResolveAlias(config) {
|
|
11
23
|
const aliases = getAliases(config);
|
|
@@ -26,7 +26,7 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
26
26
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
27
27
|
const fromViteConfig = (config.vike ?? {});
|
|
28
28
|
const configs = [fromPluginOptions, fromViteConfig];
|
|
29
|
-
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config)
|
|
29
|
+
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config));
|
|
30
30
|
configs.push(fromPlusConfigFile);
|
|
31
31
|
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
32
32
|
// TODO: add config file path ?
|
|
@@ -38,7 +38,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
38
38
|
const { definedAt, configEnv } = configValueSource;
|
|
39
39
|
if (!configEnv.client)
|
|
40
40
|
return;
|
|
41
|
-
if (definedAt.
|
|
41
|
+
if (definedAt.filePathAbsoluteUserRootDir !== null) {
|
|
42
42
|
const { filePathAbsoluteFilesystem } = definedAt;
|
|
43
43
|
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
44
44
|
// Surprisingly Vite expects entries to be absolute paths
|
|
@@ -73,7 +73,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
73
73
|
{
|
|
74
74
|
const pageFiles = await (0, findPageFiles_js_1.findPageFiles)(config, ['.page', '.page.client'], isDev);
|
|
75
75
|
pageFiles.forEach((filePath) => {
|
|
76
|
-
const entry = (0, utils_js_1.
|
|
76
|
+
const entry = (0, utils_js_1.getFilePathAbsoluteFilesystem)(filePath, config);
|
|
77
77
|
entries.push(entry);
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -45,7 +45,7 @@ function envVarsPlugin() {
|
|
|
45
45
|
if (isPrivate && isClientSide) {
|
|
46
46
|
if (!code.includes(envStatement))
|
|
47
47
|
return;
|
|
48
|
-
const filePathToShowToUser = (0, utils_js_1.
|
|
48
|
+
const filePathToShowToUser = (0, utils_js_1.getFilePathAbsoluteUserRootDir)(id, config.root);
|
|
49
49
|
const errMsgAddendum = isBuild ? '' : ' (Vike will prevent your app from building for production)';
|
|
50
50
|
const keyPublic = `${publicPrefix}${envName}`;
|
|
51
51
|
const errMsg = `${envStatement} is used in client-side file ${filePathToShowToUser} which means that the environment variable ${envName} will be included in client-side bundles and, therefore, ${envName} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${envStatement} only in server-side files, or rename ${envName} to ${keyPublic}, see https://vike.dev/env`;
|
|
@@ -60,7 +60,7 @@ function fileEnv() {
|
|
|
60
60
|
return;
|
|
61
61
|
// Show error message
|
|
62
62
|
let errMsg;
|
|
63
|
-
let modulePathPretty = (0, utils_js_1.
|
|
63
|
+
let modulePathPretty = (0, utils_js_1.getFilePathAbsoluteUserRootDir)(modulePath, config.root);
|
|
64
64
|
modulePathPretty = modulePathPretty.replaceAll(suffix, picocolors_1.default.bold(suffix));
|
|
65
65
|
errMsg = `${(0, utils_js_1.capitalizeFirstLetter)(envExpect)}-only module ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
|
|
66
66
|
if (importer &&
|
|
@@ -68,7 +68,7 @@ function fileEnv() {
|
|
|
68
68
|
!importer.includes('virtual:vike:') &&
|
|
69
69
|
// I don't know why and who sets importer to '<stdin>' (I guess Vite?)
|
|
70
70
|
importer !== '<stdin>') {
|
|
71
|
-
const importerPath = (0, utils_js_1.
|
|
71
|
+
const importerPath = (0, utils_js_1.getFilePathAbsoluteUserRootDir)(importer.split('?')[0], config.root);
|
|
72
72
|
errMsg += ` by ${importerPath}`;
|
|
73
73
|
}
|
|
74
74
|
if (isDev) {
|
|
@@ -124,7 +124,7 @@ function isVikeConfigModule(filePathAbsoluteFilesystem) {
|
|
|
124
124
|
}
|
|
125
125
|
function reloadConfig(filePath, config, op) {
|
|
126
126
|
{
|
|
127
|
-
const filePathToShowToUser = picocolors_1.default.dim((0, utils_js_1.
|
|
127
|
+
const filePathToShowToUser = picocolors_1.default.dim((0, utils_js_1.getFilePathAbsoluteUserRootDir)(filePath, config.root, true));
|
|
128
128
|
const msg = `${op} ${filePathToShowToUser}`;
|
|
129
129
|
(0, loggerNotProd_js_1.logConfigInfo)(msg, 'info');
|
|
130
130
|
}
|
|
@@ -105,7 +105,6 @@ const configDefinitionsBuiltInGlobal = {
|
|
|
105
105
|
prerender: {
|
|
106
106
|
env: { config: true }
|
|
107
107
|
},
|
|
108
|
-
extensions: { env: { config: true } },
|
|
109
108
|
disableAutoFullBuild: { env: { config: true } },
|
|
110
109
|
includeAssetsImportedByServer: { env: { config: true } },
|
|
111
110
|
baseAssets: { env: { config: true } },
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -11,9 +11,9 @@ const child_process_1 = require("child_process");
|
|
|
11
11
|
const util_1 = require("util");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
13
|
const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
15
|
+
(0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
|
|
16
|
+
let gitIsNotUsable = false;
|
|
17
17
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
18
18
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
19
19
|
(0, utils_js_1.assertPosixPath)(outDirAbsoluteFilesystem);
|
|
@@ -48,15 +48,15 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
48
48
|
const plusFiles = files.map((p) => {
|
|
49
49
|
p = (0, utils_js_1.toPosixPath)(p);
|
|
50
50
|
(0, utils_js_1.assert)(!p.startsWith(userRootDir));
|
|
51
|
-
const
|
|
52
|
-
return {
|
|
51
|
+
const filePathAbsoluteUserRootDir = path_1.default.posix.join('/', p);
|
|
52
|
+
return { filePathAbsoluteUserRootDir };
|
|
53
53
|
});
|
|
54
54
|
return plusFiles;
|
|
55
55
|
}
|
|
56
56
|
exports.crawlPlusFiles = crawlPlusFiles;
|
|
57
57
|
// Same as fastGlob() but using `$ git ls-files`
|
|
58
58
|
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
59
|
-
if (
|
|
59
|
+
if (gitIsNotUsable)
|
|
60
60
|
return null;
|
|
61
61
|
const ignoreAsPatterns = getIgnoreAsPatterns(outDirRelativeFromUserRootDir);
|
|
62
62
|
const ignoreAsFilterFn = getIgnoreAsFilterFn(outDirRelativeFromUserRootDir);
|
|
@@ -74,14 +74,14 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
74
74
|
;
|
|
75
75
|
[files, filesDeleted] = await Promise.all([
|
|
76
76
|
// Main command
|
|
77
|
-
|
|
77
|
+
runCmd1(cmd, userRootDir),
|
|
78
78
|
// Get tracked by deleted files
|
|
79
|
-
|
|
79
|
+
runCmd1('git ls-files --deleted', userRootDir)
|
|
80
80
|
]);
|
|
81
81
|
}
|
|
82
82
|
catch (err) {
|
|
83
|
-
if (await
|
|
84
|
-
|
|
83
|
+
if (await isGitNotUsable(userRootDir)) {
|
|
84
|
+
gitIsNotUsable = true;
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
87
87
|
throw err;
|
|
@@ -125,24 +125,53 @@ function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
|
125
125
|
!file.includes('.telefunc.') &&
|
|
126
126
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
127
127
|
}
|
|
128
|
-
// Whether Git is installed and whether
|
|
129
|
-
async function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
res = await
|
|
128
|
+
// Whether Git is installed and whether we can use it
|
|
129
|
+
async function isGitNotUsable(userRootDir) {
|
|
130
|
+
// Check Git version
|
|
131
|
+
{
|
|
132
|
+
const res = await runCmd2('git --version', userRootDir);
|
|
133
|
+
if ('err' in res)
|
|
134
|
+
return true;
|
|
135
|
+
let { stdout, stderr } = res;
|
|
136
|
+
(0, utils_js_1.assert)(stderr === '');
|
|
137
|
+
const prefix = 'git version ';
|
|
138
|
+
(0, utils_js_1.assert)(stdout.startsWith(prefix));
|
|
139
|
+
const gitVersion = stdout.slice(prefix.length);
|
|
140
|
+
// - Works with Git 2.43.1 but also (most certainly) with earlier versions.
|
|
141
|
+
// - We didn't bother test which is the earliest verision that works.
|
|
142
|
+
// - Git 2.32.0 doesn't seem to work: https://github.com/vikejs/vike/discussions/1549
|
|
143
|
+
// - Maybe it's because of StackBlitz: looking at the release notes, Git 2.32.0 should be working.
|
|
144
|
+
if (!(0, utils_js_1.isVersionOrAbove)(gitVersion, '2.43.1'))
|
|
145
|
+
return true;
|
|
133
146
|
}
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
// Is userRootDir inside a Git repository?
|
|
148
|
+
{
|
|
149
|
+
const res = await runCmd2('git rev-parse --is-inside-work-tree', userRootDir);
|
|
150
|
+
if ('err' in res)
|
|
151
|
+
return true;
|
|
152
|
+
let { stdout, stderr } = res;
|
|
153
|
+
(0, utils_js_1.assert)(stderr === '');
|
|
154
|
+
(0, utils_js_1.assert)(stdout === 'true');
|
|
155
|
+
return false;
|
|
136
156
|
}
|
|
137
|
-
const { stdout, stderr } = res;
|
|
138
|
-
(0, utils_js_1.assert)(stderr.toString().trim() === '');
|
|
139
|
-
(0, utils_js_1.assert)(stdout.toString().trim() === 'true');
|
|
140
|
-
return false;
|
|
141
157
|
}
|
|
142
|
-
async function
|
|
143
|
-
const
|
|
158
|
+
async function runCmd1(cmd, cwd) {
|
|
159
|
+
const { stdout } = await execA(cmd, { cwd });
|
|
144
160
|
/* Not always true: https://github.com/vikejs/vike/issues/1440#issuecomment-1892831303
|
|
145
161
|
assert(res.stderr === '')
|
|
146
162
|
*/
|
|
147
|
-
return
|
|
163
|
+
return stdout.toString().split('\n').filter(Boolean);
|
|
164
|
+
}
|
|
165
|
+
async function runCmd2(cmd, cwd) {
|
|
166
|
+
let res;
|
|
167
|
+
try {
|
|
168
|
+
res = await execA(cmd, { cwd });
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
return { err };
|
|
172
|
+
}
|
|
173
|
+
let { stdout, stderr } = res;
|
|
174
|
+
stdout = stdout.toString().trim();
|
|
175
|
+
stderr = stderr.toString().trim();
|
|
176
|
+
return { stdout, stderr };
|
|
148
177
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -10,10 +10,10 @@ const utils_js_1 = require("../../../../utils.js");
|
|
|
10
10
|
*/
|
|
11
11
|
function getLocationId(
|
|
12
12
|
// We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.js` that extends the Vike extension.
|
|
13
|
-
|
|
14
|
-
(0, utils_js_1.assertPosixPath)(
|
|
15
|
-
(0, utils_js_1.assert)(
|
|
16
|
-
const locationId = removeFilename(
|
|
13
|
+
filePathAbsoluteUserRootDir) {
|
|
14
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
|
|
15
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
16
|
+
const locationId = removeFilename(filePathAbsoluteUserRootDir);
|
|
17
17
|
assertLocationId(locationId);
|
|
18
18
|
return locationId;
|
|
19
19
|
}
|
|
@@ -96,8 +96,8 @@ function removeDirectories(somePath, removeDirs) {
|
|
|
96
96
|
somePath = '/';
|
|
97
97
|
return somePath;
|
|
98
98
|
}
|
|
99
|
-
function removeFilename(
|
|
100
|
-
const filePathParts =
|
|
99
|
+
function removeFilename(filePathAbsoluteUserRootDir) {
|
|
100
|
+
const filePathParts = filePathAbsoluteUserRootDir.split('/');
|
|
101
101
|
{
|
|
102
102
|
const filename = filePathParts.slice(-1)[0];
|
|
103
103
|
(0, utils_js_1.assert)(filename.includes('.'));
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getFilePathUnresolved = exports.getFilePathResolved = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const utils_js_1 = require("../../../../utils.js");
|
|
9
|
+
function getFilePathUnresolved(args) {
|
|
10
|
+
const { filePathAbsoluteFilesystem, filePathAbsoluteUserRootDir } = args;
|
|
11
|
+
let filePathAbsoluteVite;
|
|
12
|
+
if (args.filePathAbsoluteUserRootDir !== null) {
|
|
13
|
+
filePathAbsoluteVite = args.filePathAbsoluteUserRootDir;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
(0, utils_js_1.assert)(args.importPathAbsolute !== null); // Help TS
|
|
17
|
+
filePathAbsoluteVite = args.importPathAbsolute;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
...args,
|
|
21
|
+
filePathAbsoluteVite,
|
|
22
|
+
filePathToShowToUser: filePathAbsoluteVite,
|
|
23
|
+
filePathToShowToUserResolved: filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.getFilePathUnresolved = getFilePathUnresolved;
|
|
27
|
+
function getFilePathResolved(args) {
|
|
28
|
+
const { userRootDir, importPathAbsolute } = args;
|
|
29
|
+
let filePathAbsoluteFilesystem;
|
|
30
|
+
let filePathAbsoluteUserRootDir;
|
|
31
|
+
if ('filePathAbsoluteFilesystem' in args) {
|
|
32
|
+
filePathAbsoluteFilesystem = args.filePathAbsoluteFilesystem;
|
|
33
|
+
filePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
filePathAbsoluteUserRootDir = args.filePathAbsoluteUserRootDir;
|
|
37
|
+
filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
|
|
38
|
+
}
|
|
39
|
+
let filePathResolved;
|
|
40
|
+
const common = {
|
|
41
|
+
filePathAbsoluteUserRootDir,
|
|
42
|
+
filePathAbsoluteFilesystem,
|
|
43
|
+
importPathAbsolute,
|
|
44
|
+
userRootDir
|
|
45
|
+
};
|
|
46
|
+
if (importPathAbsolute) {
|
|
47
|
+
filePathResolved = getFilePathUnresolved({
|
|
48
|
+
...common,
|
|
49
|
+
importPathAbsolute
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
54
|
+
filePathResolved = getFilePathUnresolved({
|
|
55
|
+
...common,
|
|
56
|
+
filePathAbsoluteUserRootDir
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
60
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(filePathResolved, 'filePathAbsoluteFilesystem', 'string'));
|
|
61
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(filePathResolved, 'filePathToShowToUserResolved', 'string'));
|
|
62
|
+
return filePathResolved;
|
|
63
|
+
}
|
|
64
|
+
exports.getFilePathResolved = getFilePathResolved;
|
|
65
|
+
function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
|
|
66
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
|
|
67
|
+
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
68
|
+
const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathAbsoluteUserRootDir);
|
|
69
|
+
return filePathAbsoluteFilesystem;
|
|
70
|
+
}
|
|
71
|
+
function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
|
|
72
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
73
|
+
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
74
|
+
let filePathAbsoluteUserRootDir = null;
|
|
75
|
+
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
76
|
+
{
|
|
77
|
+
let filePathAbsoluteUserRootDir1 = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
78
|
+
if (!filePathAbsoluteUserRootDir1.startsWith('/'))
|
|
79
|
+
filePathAbsoluteUserRootDir1 = '/' + filePathAbsoluteUserRootDir1;
|
|
80
|
+
filePathAbsoluteUserRootDir = filePathAbsoluteUserRootDir1;
|
|
81
|
+
}
|
|
82
|
+
{
|
|
83
|
+
let filePathAbsoluteUserRootDir2 = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
84
|
+
(0, utils_js_1.assert)(!filePathAbsoluteUserRootDir2.startsWith('.') && !filePathAbsoluteUserRootDir2.startsWith('/'));
|
|
85
|
+
filePathAbsoluteUserRootDir2 = '/' + filePathAbsoluteUserRootDir2;
|
|
86
|
+
(0, utils_js_1.assert)(filePathAbsoluteFilesystem === filePathAbsoluteUserRootDir2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return filePathAbsoluteUserRootDir;
|
|
90
|
+
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -12,6 +12,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
12
12
|
const transformFileImports_js_1 = require("./transformFileImports.js");
|
|
13
13
|
const getConfigFileExport_js_1 = require("../getConfigFileExport.js");
|
|
14
14
|
const resolveImportPath_js_1 = require("./resolveImportPath.js");
|
|
15
|
+
const getFilePath_js_1 = require("./getFilePath.js");
|
|
15
16
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
16
17
|
// Load fake import
|
|
17
18
|
async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
@@ -64,21 +65,12 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
64
65
|
const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
|
|
65
66
|
const extendsConfigFiles = [];
|
|
66
67
|
extendsImportData.map((importData) => {
|
|
67
|
-
const { importPath:
|
|
68
|
+
const { importPath: importPathAbsolute } = importData;
|
|
68
69
|
const filePathAbsoluteFilesystem = (0, resolveImportPath_js_1.resolveImportPath)(importData, configFilePath);
|
|
69
70
|
(0, resolveImportPath_js_1.assertImportPath)(filePathAbsoluteFilesystem, importData, configFilePath);
|
|
70
|
-
warnUserLandExtension(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
|
|
74
|
-
const filePathAbsoluteVite = filePathRelativeToUserRootDir ?? importPath;
|
|
75
|
-
extendsConfigFiles.push({
|
|
76
|
-
filePathAbsoluteFilesystem,
|
|
77
|
-
filePathAbsoluteVite,
|
|
78
|
-
filePathRelativeToUserRootDir,
|
|
79
|
-
filePathToShowToUser: filePathAbsoluteVite,
|
|
80
|
-
importPathAbsolute: importPath
|
|
81
|
-
});
|
|
71
|
+
warnUserLandExtension(importPathAbsolute, configFilePath);
|
|
72
|
+
const filePath = (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteFilesystem, userRootDir, importPathAbsolute });
|
|
73
|
+
extendsConfigFiles.push(filePath);
|
|
82
74
|
});
|
|
83
75
|
const extendsConfigs = [];
|
|
84
76
|
await Promise.all(extendsConfigFiles.map(async (configFilePath) => {
|
|
@@ -89,17 +81,6 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
89
81
|
const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
|
|
90
82
|
return { extendsConfigs, extendsFilePaths };
|
|
91
83
|
}
|
|
92
|
-
function determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir) {
|
|
93
|
-
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
94
|
-
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
95
|
-
if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
let filePathRelativeToUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
99
|
-
if (!filePathRelativeToUserRootDir.startsWith('/'))
|
|
100
|
-
filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir;
|
|
101
|
-
return filePathRelativeToUserRootDir;
|
|
102
|
-
}
|
|
103
84
|
function warnUserLandExtension(importPath, configFilePath) {
|
|
104
85
|
(0, utils_js_1.assertWarning)((0, utils_js_1.isNpmPackageImport)(importPath), `${configFilePath.filePathToShowToUser} uses ${picocolors_1.default.cyan('extends')} to inherit from ${picocolors_1.default.cyan(importPath)} which is a user-land file: this is experimental and may be remove at any time. Reach out to a maintainer if you need this.`, { onlyOnce: true });
|
|
105
86
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js
CHANGED
|
@@ -8,6 +8,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
8
8
|
const utils_js_1 = require("../../../../utils.js");
|
|
9
9
|
const transformFileImports_js_1 = require("./transformFileImports.js");
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const getFilePath_js_1 = require("./getFilePath.js");
|
|
11
12
|
const filesEnvMap = new Map();
|
|
12
13
|
function resolveImport(configValue, importerFilePath, userRootDir, configEnv, configName) {
|
|
13
14
|
if (typeof configValue !== 'string')
|
|
@@ -25,14 +26,8 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
25
26
|
// [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
|
|
26
27
|
// ```
|
|
27
28
|
assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
|
|
28
|
-
const
|
|
29
|
-
const filePath = {
|
|
30
|
-
filePathAbsoluteFilesystem,
|
|
31
|
-
filePathRelativeToUserRootDir,
|
|
32
|
-
filePathAbsoluteVite: filePathRelativeToUserRootDir,
|
|
33
|
-
filePathToShowToUser: filePathRelativeToUserRootDir,
|
|
34
|
-
importPathAbsolute: null
|
|
35
|
-
};
|
|
29
|
+
const filePathAbsoluteUserRootDir = resolveImportPath_absoluteUserRootDir(filePathAbsoluteFilesystem, importData, importerFilePath, userRootDir);
|
|
30
|
+
const filePath = (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir, importPathAbsolute: null });
|
|
36
31
|
return {
|
|
37
32
|
...filePath,
|
|
38
33
|
fileExportName: exportName,
|
|
@@ -43,13 +38,11 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
43
38
|
// importPath can be:
|
|
44
39
|
// - an npm package import
|
|
45
40
|
// - a path alias
|
|
46
|
-
const filePath = {
|
|
41
|
+
const filePath = (0, getFilePath_js_1.getFilePathUnresolved)({
|
|
47
42
|
filePathAbsoluteFilesystem,
|
|
48
|
-
|
|
49
|
-
filePathAbsoluteVite: importPath,
|
|
50
|
-
filePathToShowToUser: importPath,
|
|
43
|
+
filePathAbsoluteUserRootDir: null,
|
|
51
44
|
importPathAbsolute: importPath
|
|
52
|
-
};
|
|
45
|
+
});
|
|
53
46
|
return {
|
|
54
47
|
...filePath,
|
|
55
48
|
fileExportName: exportName,
|
|
@@ -58,11 +51,11 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
58
51
|
}
|
|
59
52
|
}
|
|
60
53
|
exports.resolveImport = resolveImport;
|
|
61
|
-
function
|
|
54
|
+
function resolveImportPath_absoluteUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
|
|
62
55
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
63
|
-
let
|
|
56
|
+
let filePathAbsoluteUserRootDir;
|
|
64
57
|
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
65
|
-
|
|
58
|
+
filePathAbsoluteUserRootDir = getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, userRootDir);
|
|
66
59
|
}
|
|
67
60
|
else {
|
|
68
61
|
(0, utils_js_1.assertUsage)(false, `${configFilePath.filePathToShowToUser} imports from a relative path ${picocolors_1.default.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
|
|
@@ -71,14 +64,14 @@ function resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, imp
|
|
|
71
64
|
// assert(filePathAbsoluteFilesystem.startsWith('/'))
|
|
72
65
|
// filePath = `/@fs${filePathAbsoluteFilesystem}`
|
|
73
66
|
// /*/
|
|
74
|
-
//
|
|
75
|
-
// assert(
|
|
76
|
-
//
|
|
67
|
+
// filePathAbsoluteUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem)
|
|
68
|
+
// assert(filePathAbsoluteUserRootDir.startsWith('../'))
|
|
69
|
+
// filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir
|
|
77
70
|
// //*/
|
|
78
71
|
}
|
|
79
|
-
(0, utils_js_1.assertPosixPath)(
|
|
80
|
-
(0, utils_js_1.assert)(
|
|
81
|
-
return
|
|
72
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
|
|
73
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
74
|
+
return filePathAbsoluteUserRootDir;
|
|
82
75
|
}
|
|
83
76
|
function resolveImportPath(importData, importerFilePath) {
|
|
84
77
|
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
@@ -16,13 +16,12 @@ require("source-map-support/register.js");
|
|
|
16
16
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
17
17
|
const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
18
18
|
async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
19
|
-
const { filePathAbsoluteFilesystem } = filePath;
|
|
19
|
+
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
20
20
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
21
|
-
|
|
22
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isJavaScriptFile)(filePathAbsoluteFilesystem), `${filePathToShowToUser2} has file extension .${fileExtension} but a config file can only be a JavaScript/TypeScript file`);
|
|
21
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.isJavaScriptFile)(filePathAbsoluteFilesystem), `${filePathToShowToUserResolved} has file extension .${fileExtension} but a config file can only be a JavaScript/TypeScript file`);
|
|
23
22
|
const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
|
|
24
23
|
if (isHeader) {
|
|
25
|
-
(0, utils_js_1.assertWarning)(false, `${picocolors_1.default.cyan('.h.js')} files are deprecated: simply renaming ${
|
|
24
|
+
(0, utils_js_1.assertWarning)(false, `${picocolors_1.default.cyan('.h.js')} files are deprecated: simply renaming ${filePathToShowToUserResolved} to ${removeHeaderFileExtension(filePathToShowToUserResolved)} is usually enough, although you may occasionally need to use ${picocolors_1.default.cyan("with { type: 'pointer' }")} as explained at https://vike.dev/config#pointer-imports`, { onlyOnce: true });
|
|
26
25
|
}
|
|
27
26
|
if (isConfigFile === 'is-extension-config' && !isHeader && fileExtension.endsWith('js')) {
|
|
28
27
|
// This doesn't track dependencies => we should never use this for user land configs
|
|
@@ -38,28 +37,27 @@ async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
|
38
37
|
}
|
|
39
38
|
exports.transpileAndExecuteFile = transpileAndExecuteFile;
|
|
40
39
|
async function transpileFile(filePath, transformImports, userRootDir) {
|
|
41
|
-
const
|
|
42
|
-
const { filePathAbsoluteFilesystem } = filePath;
|
|
40
|
+
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
43
41
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
44
42
|
getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
45
43
|
if (debug.isEnabled)
|
|
46
|
-
debug('transpile',
|
|
44
|
+
debug('transpile', filePathToShowToUserResolved);
|
|
47
45
|
let { code, pointerImports } = await transpileWithEsbuild(filePath, userRootDir, transformImports);
|
|
48
46
|
if (debug.isEnabled)
|
|
49
|
-
debug(`code, post esbuild (${
|
|
47
|
+
debug(`code, post esbuild (${filePathToShowToUserResolved})`, code);
|
|
50
48
|
let isImportTransformed = false;
|
|
51
49
|
if (transformImports) {
|
|
52
|
-
const codeMod = (0, transformFileImports_js_1.transformFileImports)(code,
|
|
50
|
+
const codeMod = (0, transformFileImports_js_1.transformFileImports)(code, filePathToShowToUserResolved, pointerImports);
|
|
53
51
|
if (codeMod) {
|
|
54
52
|
code = codeMod;
|
|
55
53
|
isImportTransformed = true;
|
|
56
54
|
if (debug.isEnabled)
|
|
57
|
-
debug(`code, post transformImports() (${
|
|
55
|
+
debug(`code, post transformImports() (${filePathToShowToUserResolved})`, code);
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
if (!isImportTransformed) {
|
|
61
59
|
if (debug.isEnabled)
|
|
62
|
-
debug(`code, no transformImports() (${
|
|
60
|
+
debug(`code, no transformImports() (${filePathToShowToUserResolved})`);
|
|
63
61
|
}
|
|
64
62
|
return code;
|
|
65
63
|
}
|
|
@@ -298,19 +296,12 @@ function triggerPrepareStackTrace(err) {
|
|
|
298
296
|
}
|
|
299
297
|
}
|
|
300
298
|
function getErrIntroMsg(operation, filePath) {
|
|
301
|
-
const
|
|
299
|
+
const { filePathToShowToUserResolved } = filePath;
|
|
302
300
|
const msg = [
|
|
303
301
|
// prettier ignore
|
|
304
302
|
picocolors_1.default.red(`Failed to ${operation}`),
|
|
305
|
-
picocolors_1.default.bold(picocolors_1.default.red(
|
|
303
|
+
picocolors_1.default.bold(picocolors_1.default.red(filePathToShowToUserResolved)),
|
|
306
304
|
picocolors_1.default.red(`because:`)
|
|
307
305
|
].join(' ');
|
|
308
306
|
return msg;
|
|
309
307
|
}
|
|
310
|
-
/** `filePath.filePathToShowToUser` may show the import path of a package, use `filePathToShowToUser2` instead always show a file path instead. */
|
|
311
|
-
function getFilePathToShowToUser2(filePath) {
|
|
312
|
-
const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
|
|
313
|
-
const filePathToShowToUser2 = filePathRelativeToUserRootDir || filePathAbsoluteFilesystem;
|
|
314
|
-
(0, utils_js_1.assert)(filePathToShowToUser2);
|
|
315
|
-
return filePathToShowToUser2;
|
|
316
|
-
}
|