vike 0.4.159 → 0.4.160-commit-a1101c1
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/index.js +20 -1
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +18 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileConfigEnv.js +129 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +139 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{replaceImportStatements.js → getVikeConfig/transformImports.js} +44 -13
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{transpileAndExecuteFile.js → getVikeConfig/transpileAndExecuteFile.js} +110 -77
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +58 -279
- package/dist/cjs/node/plugin/plugins/previewConfig.js +1 -1
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +3 -3
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +4 -3
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/html/renderHtml.js +1 -1
- package/dist/cjs/node/runtime/html/stream.js +2 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +1 -1
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +44 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +2 -2
- package/dist/cjs/shared/route/abort.js +1 -1
- package/dist/cjs/utils/assert.js +5 -6
- package/dist/cjs/utils/assertIsNotProductionRuntime.js +35 -17
- package/dist/cjs/utils/nodeEnv.js +11 -1
- package/dist/cjs/utils/projectInfo.js +2 -4
- package/dist/esm/node/plugin/index.js +21 -2
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.d.ts +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +12 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +6 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileConfigEnv.d.ts +21 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileConfigEnv.js +123 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +12 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +133 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{replaceImportStatements.d.ts → getVikeConfig/transformImports.d.ts} +5 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{replaceImportStatements.js → getVikeConfig/transformImports.js} +43 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{transpileAndExecuteFile.d.ts → getVikeConfig/transpileAndExecuteFile.d.ts} +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{transpileAndExecuteFile.js → getVikeConfig/transpileAndExecuteFile.js} +110 -77
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +14 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +55 -276
- package/dist/esm/node/plugin/plugins/previewConfig.js +2 -2
- package/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js +1 -1
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +3 -3
- package/dist/esm/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/runtime/globalContext.js +5 -4
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/html/renderHtml.js +1 -1
- package/dist/esm/node/runtime/html/stream.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/esm/shared/page-configs/Config.d.ts +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +4 -0
- package/dist/esm/shared/page-configs/assertPlusFileExport.d.ts +2 -0
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +38 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +2 -2
- package/dist/esm/shared/route/abort.js +2 -2
- package/dist/esm/utils/assert.js +5 -6
- package/dist/esm/utils/assertIsNotProductionRuntime.d.ts +8 -6
- package/dist/esm/utils/assertIsNotProductionRuntime.js +35 -17
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/nodeEnv.d.ts +2 -0
- package/dist/esm/utils/nodeEnv.js +10 -0
- package/dist/esm/utils/projectInfo.d.ts +2 -8
- package/dist/esm/utils/projectInfo.js +2 -4
- package/package.json +1 -1
- package/dist/cjs/shared/page-configs/assertExports.js +0 -67
- package/dist/esm/shared/page-configs/assertExports.d.ts +0 -6
- package/dist/esm/shared/page-configs/assertExports.js +0 -61
|
@@ -9,58 +9,74 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
11
|
const import_1 = require("@brillout/import");
|
|
12
|
-
const utils_js_1 = require("
|
|
13
|
-
const
|
|
14
|
-
const getVikeConfig_js_1 = require("
|
|
12
|
+
const utils_js_1 = require("../../../../utils.js");
|
|
13
|
+
const transformImports_js_1 = require("./transformImports.js");
|
|
14
|
+
const getVikeConfig_js_1 = require("../getVikeConfig.js");
|
|
15
15
|
require("source-map-support/register.js");
|
|
16
|
-
const
|
|
16
|
+
const getConfigFileExport_js_1 = require("../getConfigFileExport.js");
|
|
17
17
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
18
|
-
async function transpileAndExecuteFile(filePath, isValueFile, userRootDir) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
async function transpileAndExecuteFile(filePath, isValueFile, userRootDir, isConfigOfExtension = false) {
|
|
19
|
+
if (isConfigOfExtension) {
|
|
20
|
+
const fileExports = await executeFile(filePath.filePathAbsoluteFilesystem, filePath);
|
|
21
|
+
if (isHeaderFile(filePath.filePathAbsoluteFilesystem)) {
|
|
22
|
+
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
23
|
+
(0, utils_js_1.assertWarning)(false, `${filePathToShowToUser2} is a JavaScript header file (.h.js), but JavaScript header files don't apply to the config files of extensions`, { onlyOnce: true });
|
|
24
|
+
}
|
|
25
|
+
return { fileExports };
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const { code, fileImportsTransformed } = await transpileFile(filePath, isValueFile, userRootDir);
|
|
29
|
+
const fileExports = await executeTranspiledFile(filePath, code, fileImportsTransformed, isValueFile);
|
|
30
|
+
return { fileExports };
|
|
31
|
+
}
|
|
22
32
|
}
|
|
23
33
|
exports.transpileAndExecuteFile = transpileAndExecuteFile;
|
|
24
34
|
async function transpileFile(filePath, isValueFile, userRootDir) {
|
|
25
35
|
const { filePathAbsoluteFilesystem } = filePath;
|
|
36
|
+
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
26
37
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
27
38
|
getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
28
|
-
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
const importsAreTransformed = !isValueFile;
|
|
40
|
+
let code = await transpileWithEsbuild(filePath, userRootDir, importsAreTransformed, isValueFile);
|
|
41
|
+
let fileImportsTransformed = null;
|
|
42
|
+
if (importsAreTransformed) {
|
|
43
|
+
const res = transformImports_(code, filePath);
|
|
32
44
|
if (res) {
|
|
33
45
|
code = res.code;
|
|
34
|
-
|
|
46
|
+
fileImportsTransformed = res.fileImportsTransformed;
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return null;
|
|
49
|
+
else {
|
|
50
|
+
if (isHeaderFile(filePathAbsoluteFilesystem)) {
|
|
51
|
+
if (isValueFile) {
|
|
52
|
+
(0, utils_js_1.assertWarning)(false, `${filePathToShowToUser2} is a JavaScript header file (.h.js), but JavaScript header files only apply to +config.h.js, see https://vike.dev/header-file`, { onlyOnce: true });
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
(0, utils_js_1.assert)(false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
return { code, fileImportsTransformed };
|
|
60
|
+
}
|
|
61
|
+
function transformImports_(codeOriginal, filePath) {
|
|
62
|
+
const { filePathAbsoluteFilesystem } = filePath;
|
|
63
|
+
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
64
|
+
// Replace import statements with import strings
|
|
65
|
+
const res = (0, transformImports_js_1.transformImports)(codeOriginal, filePathToShowToUser2);
|
|
66
|
+
if (res.noTransformation) {
|
|
52
67
|
return null;
|
|
53
68
|
}
|
|
54
|
-
const { code,
|
|
55
|
-
if (!
|
|
56
|
-
const filePathCorrect = appendHeaderFileExtension(
|
|
57
|
-
(0, utils_js_1.assertWarning)(false, `Rename ${
|
|
69
|
+
const { code, fileImportsTransformed } = res;
|
|
70
|
+
if (!isHeaderFile(filePathAbsoluteFilesystem)) {
|
|
71
|
+
const filePathCorrect = appendHeaderFileExtension(filePathToShowToUser2);
|
|
72
|
+
(0, utils_js_1.assertWarning)(false, `Rename ${filePathToShowToUser2} to ${filePathCorrect}, see https://vike.dev/header-file`, {
|
|
58
73
|
onlyOnce: true
|
|
59
74
|
});
|
|
60
75
|
}
|
|
61
|
-
return { code,
|
|
76
|
+
return { code, fileImportsTransformed };
|
|
62
77
|
}
|
|
63
|
-
async function transpileWithEsbuild(filePath,
|
|
78
|
+
async function transpileWithEsbuild(filePath, userRootDir, importsAreTransformed, isValueFile) {
|
|
79
|
+
const isConfigFile = !isValueFile;
|
|
64
80
|
const entryFilePath = filePath.filePathAbsoluteFilesystem;
|
|
65
81
|
const entryFileDir = path_1.default.posix.dirname(entryFilePath);
|
|
66
82
|
const options = {
|
|
@@ -76,22 +92,26 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
76
92
|
'NEVER_EMITTED.js'),
|
|
77
93
|
logLevel: 'silent',
|
|
78
94
|
format: 'esm',
|
|
79
|
-
|
|
95
|
+
absWorkingDir: userRootDir,
|
|
96
|
+
// Disable tree-shaking to avoid dead-code elimination, so that unused imports aren't removed.
|
|
97
|
+
// Esbuild still sometimes removes unused imports because of TypeScript: https://github.com/evanw/esbuild/issues/3034
|
|
98
|
+
treeShaking: false,
|
|
80
99
|
minify: false,
|
|
81
|
-
metafile:
|
|
82
|
-
|
|
100
|
+
metafile: isConfigFile,
|
|
101
|
+
// We cannot bundle imports that are meant to be transformed
|
|
102
|
+
bundle: !importsAreTransformed
|
|
83
103
|
};
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
// Track dependencies
|
|
105
|
+
if (isConfigFile) {
|
|
86
106
|
options.packages = 'external';
|
|
87
107
|
options.plugins = [
|
|
88
108
|
{
|
|
89
|
-
name: 'vike:
|
|
109
|
+
name: 'vike:dependency-tracker',
|
|
90
110
|
setup(b) {
|
|
91
111
|
b.onLoad({ filter: /./ }, (args) => {
|
|
112
|
+
// We collect the dependency `args.path` in case the bulid fails (upon build error => error is thrown => no metafile)
|
|
92
113
|
let { path } = args;
|
|
93
114
|
path = (0, utils_js_1.toPosixPath)(path);
|
|
94
|
-
// We collect the dependency args.path in case it fails to build (upon build error => error is thrown => no metafile)
|
|
95
115
|
getVikeConfig_js_1.vikeConfigDependencies.add(path);
|
|
96
116
|
return undefined;
|
|
97
117
|
});
|
|
@@ -108,11 +128,6 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
108
128
|
}
|
|
109
129
|
];
|
|
110
130
|
}
|
|
111
|
-
else {
|
|
112
|
-
// Avoid dead-code elimination to ensure unused imports aren't removed.
|
|
113
|
-
// Esbuild still sometimes removes unused imports because of TypeScript: https://github.com/evanw/esbuild/issues/3034
|
|
114
|
-
options.treeShaking = false;
|
|
115
|
-
}
|
|
116
131
|
let result;
|
|
117
132
|
try {
|
|
118
133
|
result = await (0, esbuild_1.build)(options);
|
|
@@ -121,7 +136,8 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
121
136
|
await formatBuildErr(err, filePath);
|
|
122
137
|
throw err;
|
|
123
138
|
}
|
|
124
|
-
|
|
139
|
+
// Track dependencies
|
|
140
|
+
if (isConfigFile) {
|
|
125
141
|
(0, utils_js_1.assert)(result.metafile);
|
|
126
142
|
Object.keys(result.metafile.inputs).forEach((filePathRelative) => {
|
|
127
143
|
filePathRelative = (0, utils_js_1.toPosixPath)(filePathRelative);
|
|
@@ -134,7 +150,7 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
134
150
|
(0, utils_js_1.assert)(typeof code === 'string');
|
|
135
151
|
return code;
|
|
136
152
|
}
|
|
137
|
-
async function
|
|
153
|
+
async function executeTranspiledFile(filePath, code, fileImportsTransformed, isValueFile) {
|
|
138
154
|
const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
|
|
139
155
|
// Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
|
|
140
156
|
// - But seems to break source maps, so I don't think it's worth it
|
|
@@ -143,28 +159,35 @@ async function executeFile(filePath, code, fileImports, isValueFile) {
|
|
|
143
159
|
const clean = () => fs_1.default.unlinkSync(filePathTmp);
|
|
144
160
|
let fileExports = {};
|
|
145
161
|
try {
|
|
146
|
-
fileExports = await (
|
|
162
|
+
fileExports = await executeFile(filePathTmp, filePath);
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
clean();
|
|
166
|
+
}
|
|
167
|
+
if (fileImportsTransformed && !isValueFile) {
|
|
168
|
+
(0, utils_js_1.assert)(filePathRelativeToUserRootDir !== undefined);
|
|
169
|
+
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
170
|
+
assertImportsAreReExported(fileImportsTransformed, fileExports, filePathToShowToUser2);
|
|
171
|
+
}
|
|
172
|
+
return fileExports;
|
|
173
|
+
}
|
|
174
|
+
async function executeFile(filePathToExecuteAbsoluteFilesystem, filePathSourceFile) {
|
|
175
|
+
let fileExports = {};
|
|
176
|
+
try {
|
|
177
|
+
fileExports = await (0, import_1.import_)(filePathToExecuteAbsoluteFilesystem);
|
|
147
178
|
}
|
|
148
179
|
catch (err) {
|
|
149
180
|
triggerPrepareStackTrace(err);
|
|
150
|
-
const errIntroMsg = getErrIntroMsg('execute',
|
|
181
|
+
const errIntroMsg = getErrIntroMsg('execute', filePathSourceFile);
|
|
151
182
|
(0, utils_js_1.assert)((0, utils_js_1.isObject)(err));
|
|
152
183
|
execErrIntroMsg.set(err, errIntroMsg);
|
|
153
184
|
throw err;
|
|
154
185
|
}
|
|
155
|
-
|
|
156
|
-
clean();
|
|
157
|
-
}
|
|
158
|
-
// Return a plain JavaScript object
|
|
186
|
+
// Return a plain JavaScript object:
|
|
159
187
|
// - import() returns `[Module: null prototype] { default: { onRenderClient: '...' }}`
|
|
160
|
-
// - We don't need this special object
|
|
188
|
+
// - We don't need this special object.
|
|
161
189
|
fileExports = { ...fileExports };
|
|
162
|
-
|
|
163
|
-
(0, utils_js_1.assert)(filePathRelativeToUserRootDir !== undefined);
|
|
164
|
-
const filePathToShowToUser = filePathRelativeToUserRootDir ?? filePathAbsoluteFilesystem;
|
|
165
|
-
assertImportsAreReExported(fileImports, fileExports, filePathToShowToUser);
|
|
166
|
-
}
|
|
167
|
-
return { fileExports };
|
|
190
|
+
return fileExports;
|
|
168
191
|
}
|
|
169
192
|
const formatted = '_formatted';
|
|
170
193
|
function getConfigBuildErrorFormatted(err) {
|
|
@@ -196,10 +219,10 @@ function getConfigExecutionErrorIntroMsg(err) {
|
|
|
196
219
|
}
|
|
197
220
|
exports.getConfigExecutionErrorIntroMsg = getConfigExecutionErrorIntroMsg;
|
|
198
221
|
const tmpPrefix = `[build-`;
|
|
199
|
-
function getFilePathTmp(
|
|
200
|
-
(0, utils_js_1.assertPosixPath)(
|
|
201
|
-
const dirname = path_1.default.posix.dirname(
|
|
202
|
-
const filename = path_1.default.posix.basename(
|
|
222
|
+
function getFilePathTmp(filePathAbsoluteFilesystem) {
|
|
223
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
224
|
+
const dirname = path_1.default.posix.dirname(filePathAbsoluteFilesystem);
|
|
225
|
+
const filename = path_1.default.posix.basename(filePathAbsoluteFilesystem);
|
|
203
226
|
// Syntax with semicolon `[build:${/*...*/}]` doesn't work on Windows: https://github.com/vikejs/vike/issues/800#issuecomment-1517329455
|
|
204
227
|
const tag = `${tmpPrefix}${(0, utils_js_1.getRandomId)(12)}]`;
|
|
205
228
|
const filePathTmp = path_1.default.posix.join(dirname, `${tag}${filename}.mjs`);
|
|
@@ -211,29 +234,29 @@ function isTmpFile(filePath) {
|
|
|
211
234
|
return fileName.startsWith(tmpPrefix);
|
|
212
235
|
}
|
|
213
236
|
exports.isTmpFile = isTmpFile;
|
|
214
|
-
function assertImportsAreReExported(
|
|
215
|
-
(0,
|
|
216
|
-
const exportedStrings = getExportedStrings(
|
|
237
|
+
function assertImportsAreReExported(fileImportsTransformed, fileExports, filePathToShowToUser2) {
|
|
238
|
+
const fileExport = (0, getConfigFileExport_js_1.getConfigFileExport)(fileExports, filePathToShowToUser2);
|
|
239
|
+
const exportedStrings = getExportedStrings(fileExport);
|
|
217
240
|
Object.values(exportedStrings).forEach((exportVal) => {
|
|
218
241
|
if (typeof exportVal !== 'string')
|
|
219
242
|
return;
|
|
220
|
-
if (!(0,
|
|
243
|
+
if (!(0, transformImports_js_1.isImportData)(exportVal))
|
|
221
244
|
return;
|
|
222
245
|
const importString = exportVal;
|
|
223
|
-
|
|
246
|
+
fileImportsTransformed.forEach((fileImport) => {
|
|
224
247
|
if (fileImport.importString === importString) {
|
|
225
248
|
fileImport.isReExported = true;
|
|
226
249
|
}
|
|
227
250
|
});
|
|
228
251
|
});
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
252
|
+
const fileImportsTransformedUnused = fileImportsTransformed.filter((fi) => !fi.isReExported);
|
|
253
|
+
if (fileImportsTransformedUnused.length === 0)
|
|
231
254
|
return;
|
|
232
|
-
const importStatements = (0, utils_js_1.unique)(
|
|
233
|
-
const importNamesUnused =
|
|
234
|
-
const singular =
|
|
235
|
-
(0, utils_js_1.assertWarning)(
|
|
236
|
-
`${
|
|
255
|
+
const importStatements = (0, utils_js_1.unique)(fileImportsTransformedUnused.map((fi) => fi.importStatementCode));
|
|
256
|
+
const importNamesUnused = fileImportsTransformedUnused.map((fi) => picocolors_1.default.cyan(fi.importLocalName)).join(', ');
|
|
257
|
+
const singular = fileImportsTransformedUnused.length === 1;
|
|
258
|
+
(0, utils_js_1.assertWarning)(fileImportsTransformedUnused.length === 0, [
|
|
259
|
+
`${filePathToShowToUser2} imports the following:`,
|
|
237
260
|
...importStatements.map((s) => picocolors_1.default.cyan(` ${s}`)),
|
|
238
261
|
`But the import${singular ? '' : 's'} ${importNamesUnused} ${singular ? "isn't" : "aren't"} re-exported at ${picocolors_1.default.cyan('export default { ... }')} and therefore ${singular ? 'has' : 'have'} no effect, see explanation at https://vike.dev/header-file`
|
|
239
262
|
].join('\n'), { onlyOnce: true });
|
|
@@ -255,6 +278,7 @@ function getExportedStrings(obj) {
|
|
|
255
278
|
return exportedStrings;
|
|
256
279
|
}
|
|
257
280
|
function isHeaderFile(filePath) {
|
|
281
|
+
(0, utils_js_1.assertPosixPath)(filePath);
|
|
258
282
|
const basenameParts = path_1.default.posix.basename(filePath).split('.');
|
|
259
283
|
return basenameParts.includes('h');
|
|
260
284
|
}
|
|
@@ -275,10 +299,19 @@ function triggerPrepareStackTrace(err) {
|
|
|
275
299
|
}
|
|
276
300
|
}
|
|
277
301
|
function getErrIntroMsg(operation, filePath) {
|
|
302
|
+
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
278
303
|
const msg = [
|
|
304
|
+
// prettier ignore
|
|
279
305
|
picocolors_1.default.red(`Failed to ${operation}`),
|
|
280
|
-
picocolors_1.default.bold(picocolors_1.default.red(
|
|
306
|
+
picocolors_1.default.bold(picocolors_1.default.red(filePathToShowToUser2)),
|
|
281
307
|
picocolors_1.default.red(`because:`)
|
|
282
308
|
].join(' ');
|
|
283
309
|
return msg;
|
|
284
310
|
}
|
|
311
|
+
/** `filePath.filePathToShowToUser` may show the import path of a package, use `filePathToShowToUser2` instead always show a file path instead. */
|
|
312
|
+
function getFilePathToShowToUser2(filePath) {
|
|
313
|
+
const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
|
|
314
|
+
const filePathToShowToUser2 = filePathRelativeToUserRootDir || filePathAbsoluteFilesystem;
|
|
315
|
+
(0, utils_js_1.assert)(filePathToShowToUser2);
|
|
316
|
+
return filePathToShowToUser2;
|
|
317
|
+
}
|