vike 0.4.159-commit-0424983 → 0.4.159-commit-a6bc208
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/importUserCode/v1-design/getVikeConfig.js +3 -15
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transformImports.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +40 -26
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +3 -15
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transformImports.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +40 -26
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
|
@@ -875,7 +875,7 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
875
875
|
const { importPath: importPath } = importData;
|
|
876
876
|
const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
|
|
877
877
|
assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
|
|
878
|
-
|
|
878
|
+
warnUserLandExtension(importPath, configFilePath);
|
|
879
879
|
// - filePathRelativeToUserRootDir has no functionality beyond nicer error messages for user
|
|
880
880
|
// - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsoluteFilesystem for added clarity
|
|
881
881
|
const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
|
|
@@ -908,20 +908,8 @@ function determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRoot
|
|
|
908
908
|
filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir;
|
|
909
909
|
return filePathRelativeToUserRootDir;
|
|
910
910
|
}
|
|
911
|
-
function
|
|
912
|
-
|
|
913
|
-
const fileDir = path_1.default.posix.dirname(filePath) + '/';
|
|
914
|
-
const fileName = path_1.default.posix.basename(filePath);
|
|
915
|
-
const fileNameBaseCorrect = '+config';
|
|
916
|
-
const [fileNameBase, ...fileNameRest] = fileName.split('.');
|
|
917
|
-
const fileNameCorrect = [fileNameBaseCorrect, ...fileNameRest].join('.');
|
|
918
|
-
(0, utils_js_1.assertWarning)(fileNameBase === fileNameBaseCorrect, `Rename ${fileName} to ${fileNameCorrect} in ${fileDir}`, {
|
|
919
|
-
onlyOnce: true
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
else {
|
|
923
|
-
(0, utils_js_1.assertWarning)(false, `${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 feature.`, { onlyOnce: true });
|
|
924
|
-
}
|
|
911
|
+
function warnUserLandExtension(importPath, configFilePath) {
|
|
912
|
+
(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 });
|
|
925
913
|
}
|
|
926
914
|
function getExtendsImportData(configFileExports, configFilePath) {
|
|
927
915
|
const { filePathToShowToUser } = configFilePath;
|
|
@@ -26,13 +26,13 @@ skipWarnings) {
|
|
|
26
26
|
return;
|
|
27
27
|
const importPath = node.source.value;
|
|
28
28
|
(0, utils_js_1.assert)(typeof importPath === 'string');
|
|
29
|
-
// - This doesn't work
|
|
29
|
+
// - This doesn't work. To make it work we would need to run esbuild twice: esbuild for TypeScript to JavaScript => transformImports() => esbuild for bundling.
|
|
30
30
|
// - Or we use an esbuild plugin to apply transformImports(). Maybe we can completely skip the need for acorn?
|
|
31
31
|
// - ?real breaks TypeScript, and TypeScript isn't working on supporting query params: https://github.com/microsoft/TypeScript/issues/10988#issuecomment-867135453
|
|
32
32
|
// - Import attributes would be the best.
|
|
33
33
|
// - But it only works with Node.js >=21: https://nodejs.org/api/esm.html#import-attributes
|
|
34
34
|
// - But it's probably ok to tell users "to use real imports you need Node.js 21 or above".
|
|
35
|
-
// - It
|
|
35
|
+
// - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
36
36
|
// - Esbuid seems to support it: https://esbuild.github.io/plugins/#on-load-arguments:~:text=This%20contains%20a%20map%20of%20the%20import%20attributes%20that
|
|
37
37
|
// - acorn supports it over an acorn plugin: https://github.com/acornjs/acorn/issues/983
|
|
38
38
|
// - Maybe we can use an esbuild plugin instead of acorn to apply transformImports()?
|
|
@@ -16,17 +16,27 @@ require("source-map-support/register.js");
|
|
|
16
16
|
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
17
17
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
18
18
|
async function transpileAndExecuteFile(filePath, isValueFile, userRootDir, isConfigOfExtension = false) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
async function transpileFile(filePath, isValueFile, userRootDir
|
|
34
|
+
async function transpileFile(filePath, isValueFile, userRootDir) {
|
|
25
35
|
const { filePathAbsoluteFilesystem } = filePath;
|
|
26
36
|
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
27
37
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
28
38
|
getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
29
|
-
const importsAreTransformed = !
|
|
39
|
+
const importsAreTransformed = !isValueFile;
|
|
30
40
|
let code = await transpileWithEsbuild(filePath, userRootDir, importsAreTransformed, isValueFile);
|
|
31
41
|
let fileImportsTransformed = null;
|
|
32
42
|
if (importsAreTransformed) {
|
|
@@ -41,9 +51,6 @@ async function transpileFile(filePath, isValueFile, userRootDir, isConfigOfExten
|
|
|
41
51
|
if (isValueFile) {
|
|
42
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 });
|
|
43
53
|
}
|
|
44
|
-
else if (isConfigOfExtension) {
|
|
45
|
-
(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 });
|
|
46
|
-
}
|
|
47
54
|
else {
|
|
48
55
|
(0, utils_js_1.assert)(false);
|
|
49
56
|
}
|
|
@@ -143,7 +150,7 @@ async function transpileWithEsbuild(filePath, userRootDir, importsAreTransformed
|
|
|
143
150
|
(0, utils_js_1.assert)(typeof code === 'string');
|
|
144
151
|
return code;
|
|
145
152
|
}
|
|
146
|
-
async function
|
|
153
|
+
async function executeTranspiledFile(filePath, code, fileImportsTransformed, isValueFile) {
|
|
147
154
|
const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
|
|
148
155
|
// Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
|
|
149
156
|
// - But seems to break source maps, so I don't think it's worth it
|
|
@@ -152,28 +159,35 @@ async function executeFile(filePath, code, fileImportsTransformed, isValueFile)
|
|
|
152
159
|
const clean = () => fs_1.default.unlinkSync(filePathTmp);
|
|
153
160
|
let fileExports = {};
|
|
154
161
|
try {
|
|
155
|
-
fileExports = await (
|
|
156
|
-
}
|
|
157
|
-
catch (err) {
|
|
158
|
-
triggerPrepareStackTrace(err);
|
|
159
|
-
const errIntroMsg = getErrIntroMsg('execute', filePath);
|
|
160
|
-
(0, utils_js_1.assert)((0, utils_js_1.isObject)(err));
|
|
161
|
-
execErrIntroMsg.set(err, errIntroMsg);
|
|
162
|
-
throw err;
|
|
162
|
+
fileExports = await executeFile(filePathTmp, filePath);
|
|
163
163
|
}
|
|
164
164
|
finally {
|
|
165
165
|
clean();
|
|
166
166
|
}
|
|
167
|
-
// Return a plain JavaScript object
|
|
168
|
-
// - import() returns `[Module: null prototype] { default: { onRenderClient: '...' }}`
|
|
169
|
-
// - We don't need this special object
|
|
170
|
-
fileExports = { ...fileExports };
|
|
171
167
|
if (fileImportsTransformed && !isValueFile) {
|
|
172
168
|
(0, utils_js_1.assert)(filePathRelativeToUserRootDir !== undefined);
|
|
173
169
|
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
174
170
|
assertImportsAreReExported(fileImportsTransformed, fileExports, filePathToShowToUser2);
|
|
175
171
|
}
|
|
176
|
-
return
|
|
172
|
+
return fileExports;
|
|
173
|
+
}
|
|
174
|
+
async function executeFile(filePathToExecuteAbsoluteFilesystem, filePathSourceFile) {
|
|
175
|
+
let fileExports = {};
|
|
176
|
+
try {
|
|
177
|
+
fileExports = await (0, import_1.import_)(filePathToExecuteAbsoluteFilesystem);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
triggerPrepareStackTrace(err);
|
|
181
|
+
const errIntroMsg = getErrIntroMsg('execute', filePathSourceFile);
|
|
182
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(err));
|
|
183
|
+
execErrIntroMsg.set(err, errIntroMsg);
|
|
184
|
+
throw err;
|
|
185
|
+
}
|
|
186
|
+
// Return a plain JavaScript object:
|
|
187
|
+
// - import() returns `[Module: null prototype] { default: { onRenderClient: '...' }}`
|
|
188
|
+
// - We don't need this special object.
|
|
189
|
+
fileExports = { ...fileExports };
|
|
190
|
+
return fileExports;
|
|
177
191
|
}
|
|
178
192
|
const formatted = '_formatted';
|
|
179
193
|
function getConfigBuildErrorFormatted(err) {
|
|
@@ -205,10 +219,10 @@ function getConfigExecutionErrorIntroMsg(err) {
|
|
|
205
219
|
}
|
|
206
220
|
exports.getConfigExecutionErrorIntroMsg = getConfigExecutionErrorIntroMsg;
|
|
207
221
|
const tmpPrefix = `[build-`;
|
|
208
|
-
function getFilePathTmp(
|
|
209
|
-
(0, utils_js_1.assertPosixPath)(
|
|
210
|
-
const dirname = path_1.default.posix.dirname(
|
|
211
|
-
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);
|
|
212
226
|
// Syntax with semicolon `[build:${/*...*/}]` doesn't work on Windows: https://github.com/vikejs/vike/issues/800#issuecomment-1517329455
|
|
213
227
|
const tag = `${tmpPrefix}${(0, utils_js_1.getRandomId)(12)}]`;
|
|
214
228
|
const filePathTmp = path_1.default.posix.join(dirname, `${tag}${filename}.mjs`);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
4
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
5
|
-
const PROJECT_VERSION = '0.4.159-commit-
|
|
5
|
+
const PROJECT_VERSION = '0.4.159-commit-a6bc208';
|
|
6
6
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
7
7
|
const projectInfo = {
|
|
8
8
|
projectName: 'Vike',
|
|
@@ -870,7 +870,7 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
870
870
|
const { importPath: importPath } = importData;
|
|
871
871
|
const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
|
|
872
872
|
assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
|
|
873
|
-
|
|
873
|
+
warnUserLandExtension(importPath, configFilePath);
|
|
874
874
|
// - filePathRelativeToUserRootDir has no functionality beyond nicer error messages for user
|
|
875
875
|
// - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsoluteFilesystem for added clarity
|
|
876
876
|
const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
|
|
@@ -903,20 +903,8 @@ function determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRoot
|
|
|
903
903
|
filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir;
|
|
904
904
|
return filePathRelativeToUserRootDir;
|
|
905
905
|
}
|
|
906
|
-
function
|
|
907
|
-
|
|
908
|
-
const fileDir = path.posix.dirname(filePath) + '/';
|
|
909
|
-
const fileName = path.posix.basename(filePath);
|
|
910
|
-
const fileNameBaseCorrect = '+config';
|
|
911
|
-
const [fileNameBase, ...fileNameRest] = fileName.split('.');
|
|
912
|
-
const fileNameCorrect = [fileNameBaseCorrect, ...fileNameRest].join('.');
|
|
913
|
-
assertWarning(fileNameBase === fileNameBaseCorrect, `Rename ${fileName} to ${fileNameCorrect} in ${fileDir}`, {
|
|
914
|
-
onlyOnce: true
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
else {
|
|
918
|
-
assertWarning(false, `${configFilePath.filePathToShowToUser} uses ${pc.cyan('extends')} to inherit from ${pc.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 feature.`, { onlyOnce: true });
|
|
919
|
-
}
|
|
906
|
+
function warnUserLandExtension(importPath, configFilePath) {
|
|
907
|
+
assertWarning(isNpmPackageImport(importPath), `${configFilePath.filePathToShowToUser} uses ${pc.cyan('extends')} to inherit from ${pc.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 });
|
|
920
908
|
}
|
|
921
909
|
function getExtendsImportData(configFileExports, configFilePath) {
|
|
922
910
|
const { filePathToShowToUser } = configFilePath;
|
|
@@ -23,13 +23,13 @@ skipWarnings) {
|
|
|
23
23
|
return;
|
|
24
24
|
const importPath = node.source.value;
|
|
25
25
|
assert(typeof importPath === 'string');
|
|
26
|
-
// - This doesn't work
|
|
26
|
+
// - This doesn't work. To make it work we would need to run esbuild twice: esbuild for TypeScript to JavaScript => transformImports() => esbuild for bundling.
|
|
27
27
|
// - Or we use an esbuild plugin to apply transformImports(). Maybe we can completely skip the need for acorn?
|
|
28
28
|
// - ?real breaks TypeScript, and TypeScript isn't working on supporting query params: https://github.com/microsoft/TypeScript/issues/10988#issuecomment-867135453
|
|
29
29
|
// - Import attributes would be the best.
|
|
30
30
|
// - But it only works with Node.js >=21: https://nodejs.org/api/esm.html#import-attributes
|
|
31
31
|
// - But it's probably ok to tell users "to use real imports you need Node.js 21 or above".
|
|
32
|
-
// - It
|
|
32
|
+
// - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
33
33
|
// - Esbuid seems to support it: https://esbuild.github.io/plugins/#on-load-arguments:~:text=This%20contains%20a%20map%20of%20the%20import%20attributes%20that
|
|
34
34
|
// - acorn supports it over an acorn plugin: https://github.com/acornjs/acorn/issues/983
|
|
35
35
|
// - Maybe we can use an esbuild plugin instead of acorn to apply transformImports()?
|
|
@@ -14,16 +14,26 @@ import 'source-map-support/register.js';
|
|
|
14
14
|
import { getConfigFileExport } from './getConfigFileExport.js';
|
|
15
15
|
assertIsNotProductionRuntime();
|
|
16
16
|
async function transpileAndExecuteFile(filePath, isValueFile, userRootDir, isConfigOfExtension = false) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (isConfigOfExtension) {
|
|
18
|
+
const fileExports = await executeFile(filePath.filePathAbsoluteFilesystem, filePath);
|
|
19
|
+
if (isHeaderFile(filePath.filePathAbsoluteFilesystem)) {
|
|
20
|
+
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
21
|
+
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 });
|
|
22
|
+
}
|
|
23
|
+
return { fileExports };
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const { code, fileImportsTransformed } = await transpileFile(filePath, isValueFile, userRootDir);
|
|
27
|
+
const fileExports = await executeTranspiledFile(filePath, code, fileImportsTransformed, isValueFile);
|
|
28
|
+
return { fileExports };
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
|
-
async function transpileFile(filePath, isValueFile, userRootDir
|
|
31
|
+
async function transpileFile(filePath, isValueFile, userRootDir) {
|
|
22
32
|
const { filePathAbsoluteFilesystem } = filePath;
|
|
23
33
|
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
24
34
|
assertPosixPath(filePathAbsoluteFilesystem);
|
|
25
35
|
vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
26
|
-
const importsAreTransformed = !
|
|
36
|
+
const importsAreTransformed = !isValueFile;
|
|
27
37
|
let code = await transpileWithEsbuild(filePath, userRootDir, importsAreTransformed, isValueFile);
|
|
28
38
|
let fileImportsTransformed = null;
|
|
29
39
|
if (importsAreTransformed) {
|
|
@@ -38,9 +48,6 @@ async function transpileFile(filePath, isValueFile, userRootDir, isConfigOfExten
|
|
|
38
48
|
if (isValueFile) {
|
|
39
49
|
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 });
|
|
40
50
|
}
|
|
41
|
-
else if (isConfigOfExtension) {
|
|
42
|
-
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 });
|
|
43
|
-
}
|
|
44
51
|
else {
|
|
45
52
|
assert(false);
|
|
46
53
|
}
|
|
@@ -140,7 +147,7 @@ async function transpileWithEsbuild(filePath, userRootDir, importsAreTransformed
|
|
|
140
147
|
assert(typeof code === 'string');
|
|
141
148
|
return code;
|
|
142
149
|
}
|
|
143
|
-
async function
|
|
150
|
+
async function executeTranspiledFile(filePath, code, fileImportsTransformed, isValueFile) {
|
|
144
151
|
const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
|
|
145
152
|
// Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
|
|
146
153
|
// - But seems to break source maps, so I don't think it's worth it
|
|
@@ -149,28 +156,35 @@ async function executeFile(filePath, code, fileImportsTransformed, isValueFile)
|
|
|
149
156
|
const clean = () => fs.unlinkSync(filePathTmp);
|
|
150
157
|
let fileExports = {};
|
|
151
158
|
try {
|
|
152
|
-
fileExports = await
|
|
153
|
-
}
|
|
154
|
-
catch (err) {
|
|
155
|
-
triggerPrepareStackTrace(err);
|
|
156
|
-
const errIntroMsg = getErrIntroMsg('execute', filePath);
|
|
157
|
-
assert(isObject(err));
|
|
158
|
-
execErrIntroMsg.set(err, errIntroMsg);
|
|
159
|
-
throw err;
|
|
159
|
+
fileExports = await executeFile(filePathTmp, filePath);
|
|
160
160
|
}
|
|
161
161
|
finally {
|
|
162
162
|
clean();
|
|
163
163
|
}
|
|
164
|
-
// Return a plain JavaScript object
|
|
165
|
-
// - import() returns `[Module: null prototype] { default: { onRenderClient: '...' }}`
|
|
166
|
-
// - We don't need this special object
|
|
167
|
-
fileExports = { ...fileExports };
|
|
168
164
|
if (fileImportsTransformed && !isValueFile) {
|
|
169
165
|
assert(filePathRelativeToUserRootDir !== undefined);
|
|
170
166
|
const filePathToShowToUser2 = getFilePathToShowToUser2(filePath);
|
|
171
167
|
assertImportsAreReExported(fileImportsTransformed, fileExports, filePathToShowToUser2);
|
|
172
168
|
}
|
|
173
|
-
return
|
|
169
|
+
return fileExports;
|
|
170
|
+
}
|
|
171
|
+
async function executeFile(filePathToExecuteAbsoluteFilesystem, filePathSourceFile) {
|
|
172
|
+
let fileExports = {};
|
|
173
|
+
try {
|
|
174
|
+
fileExports = await import_(filePathToExecuteAbsoluteFilesystem);
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
triggerPrepareStackTrace(err);
|
|
178
|
+
const errIntroMsg = getErrIntroMsg('execute', filePathSourceFile);
|
|
179
|
+
assert(isObject(err));
|
|
180
|
+
execErrIntroMsg.set(err, errIntroMsg);
|
|
181
|
+
throw err;
|
|
182
|
+
}
|
|
183
|
+
// Return a plain JavaScript object:
|
|
184
|
+
// - import() returns `[Module: null prototype] { default: { onRenderClient: '...' }}`
|
|
185
|
+
// - We don't need this special object.
|
|
186
|
+
fileExports = { ...fileExports };
|
|
187
|
+
return fileExports;
|
|
174
188
|
}
|
|
175
189
|
const formatted = '_formatted';
|
|
176
190
|
function getConfigBuildErrorFormatted(err) {
|
|
@@ -200,10 +214,10 @@ function getConfigExecutionErrorIntroMsg(err) {
|
|
|
200
214
|
return errIntroMsg ?? null;
|
|
201
215
|
}
|
|
202
216
|
const tmpPrefix = `[build-`;
|
|
203
|
-
function getFilePathTmp(
|
|
204
|
-
assertPosixPath(
|
|
205
|
-
const dirname = path.posix.dirname(
|
|
206
|
-
const filename = path.posix.basename(
|
|
217
|
+
function getFilePathTmp(filePathAbsoluteFilesystem) {
|
|
218
|
+
assertPosixPath(filePathAbsoluteFilesystem);
|
|
219
|
+
const dirname = path.posix.dirname(filePathAbsoluteFilesystem);
|
|
220
|
+
const filename = path.posix.basename(filePathAbsoluteFilesystem);
|
|
207
221
|
// Syntax with semicolon `[build:${/*...*/}]` doesn't work on Windows: https://github.com/vikejs/vike/issues/800#issuecomment-1517329455
|
|
208
222
|
const tag = `${tmpPrefix}${getRandomId(12)}]`;
|
|
209
223
|
const filePathTmp = path.posix.join(dirname, `${tag}${filename}.mjs`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.159-commit-
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.159-commit-a6bc208";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.159-commit-
|
|
6
|
+
projectVersion: "0.4.159-commit-a6bc208";
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
3
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
4
|
-
const PROJECT_VERSION = '0.4.159-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.159-commit-a6bc208';
|
|
5
5
|
const projectInfo = {
|
|
6
6
|
projectName: 'Vike',
|
|
7
7
|
projectVersion: PROJECT_VERSION
|