vike 0.4.166 → 0.4.167-commit-c08a6bb
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/buildConfig.js +11 -6
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +17 -22
- package/dist/cjs/node/plugin/plugins/envVars.js +3 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +11 -13
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -4
- package/dist/cjs/node/plugin/plugins/fileEnv.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +21 -17
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +34 -23
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +33 -10
- package/dist/cjs/node/plugin/shared/getFilePath.js +83 -29
- package/dist/cjs/node/plugin/shared/isErrorDebug.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +3 -8
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +6 -7
- package/dist/cjs/node/prerender/utils.js +2 -1
- package/dist/cjs/node/runtime/html/stream.js +5 -5
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -9
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +6 -12
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +13 -1
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -3
- package/dist/cjs/shared/route/abort.js +2 -1
- package/dist/cjs/shared/route/executeGuardHook.js +2 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/cjs/shared/route/index.js +2 -3
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/utils/assertIsNotProductionRuntime.js +5 -5
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/cjs/utils/debug.js +48 -14
- package/dist/cjs/utils/isNpmPackage.js +11 -2
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/trackLogs.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +31 -24
- package/dist/esm/node/plugin/plugins/buildConfig.js +12 -7
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -23
- package/dist/esm/node/plugin/plugins/envVars.js +4 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +12 -14
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +3 -5
- package/dist/esm/node/plugin/plugins/fileEnv.js +7 -4
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +7 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/debug.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +21 -17
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +33 -22
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +34 -11
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +10 -9
- package/dist/esm/node/plugin/shared/getFilePath.js +83 -29
- package/dist/esm/node/plugin/shared/isErrorDebug.js +2 -2
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/runPrerender.js +2 -3
- package/dist/esm/node/prerender/utils.d.ts +2 -1
- package/dist/esm/node/prerender/utils.js +2 -1
- package/dist/esm/node/runtime/html/stream.js +5 -5
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -10
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +7 -13
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +13 -1
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/shared/addUrlComputedProps.d.ts +2 -2
- package/dist/esm/shared/page-configs/FilePath.d.ts +41 -29
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +1 -3
- package/dist/esm/shared/route/abort.js +2 -1
- package/dist/esm/shared/route/executeGuardHook.js +2 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/esm/shared/route/index.js +2 -3
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/utils/assertIsNotProductionRuntime.js +5 -5
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/esm/utils/debug.d.ts +5 -4
- package/dist/esm/utils/debug.js +45 -14
- package/dist/esm/utils/debugGlob.d.ts +1 -1
- package/dist/esm/utils/isNpmPackage.d.ts +5 -1
- package/dist/esm/utils/isNpmPackage.js +10 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/trackLogs.js +2 -2
- package/package.json +1 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -19
- package/dist/cjs/utils/getFilePathAbsolute.js +0 -70
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.d.ts +0 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -16
- package/dist/esm/utils/getFilePathAbsolute.d.ts +0 -5
- package/dist/esm/utils/getFilePathAbsolute.js +0 -64
|
@@ -3,29 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getFilePathUnresolved = exports.getFilePathResolved = void 0;
|
|
6
|
+
exports.cleanFilePathUnkown = exports.getFilePathToShowToUserFromUnkown = exports.getModuleFilePath = exports.getFilePathUnresolved = exports.getFilePathResolved = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
|
-
function getFilePathUnresolved(
|
|
10
|
-
|
|
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
|
-
};
|
|
9
|
+
function getFilePathUnresolved({ importPathAbsolute }) {
|
|
10
|
+
return getFilePath({ importPathAbsolute, filePathAbsoluteUserRootDir: null });
|
|
25
11
|
}
|
|
26
12
|
exports.getFilePathUnresolved = getFilePathUnresolved;
|
|
27
13
|
function getFilePathResolved(args) {
|
|
28
|
-
const { userRootDir
|
|
14
|
+
const { userRootDir } = args;
|
|
15
|
+
const importPathAbsolute = args.importPathAbsolute ?? null;
|
|
29
16
|
let filePathAbsoluteFilesystem;
|
|
30
17
|
let filePathAbsoluteUserRootDir;
|
|
31
18
|
if ('filePathAbsoluteFilesystem' in args) {
|
|
@@ -36,41 +23,68 @@ function getFilePathResolved(args) {
|
|
|
36
23
|
filePathAbsoluteUserRootDir = args.filePathAbsoluteUserRootDir;
|
|
37
24
|
filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
|
|
38
25
|
}
|
|
39
|
-
let
|
|
26
|
+
let filePath;
|
|
40
27
|
const common = {
|
|
41
28
|
filePathAbsoluteUserRootDir,
|
|
42
|
-
filePathAbsoluteFilesystem,
|
|
43
29
|
importPathAbsolute,
|
|
44
30
|
userRootDir
|
|
45
31
|
};
|
|
46
32
|
if (importPathAbsolute) {
|
|
47
|
-
|
|
33
|
+
filePath = getFilePath({
|
|
48
34
|
...common,
|
|
49
35
|
importPathAbsolute
|
|
50
36
|
});
|
|
51
37
|
}
|
|
52
38
|
else {
|
|
53
39
|
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
54
|
-
|
|
40
|
+
filePath = getFilePath({
|
|
55
41
|
...common,
|
|
56
42
|
filePathAbsoluteUserRootDir
|
|
57
43
|
});
|
|
58
44
|
}
|
|
59
45
|
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
60
|
-
(0, utils_js_1.
|
|
61
|
-
|
|
46
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
47
|
+
const filePathToShowToUserResolved = filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem;
|
|
48
|
+
(0, utils_js_1.assert)(filePathToShowToUserResolved);
|
|
49
|
+
const filePathResolved = {
|
|
50
|
+
...filePath,
|
|
51
|
+
filePathAbsoluteFilesystem,
|
|
52
|
+
filePathToShowToUserResolved
|
|
53
|
+
};
|
|
62
54
|
return filePathResolved;
|
|
63
55
|
}
|
|
64
56
|
exports.getFilePathResolved = getFilePathResolved;
|
|
57
|
+
function getFilePath(args) {
|
|
58
|
+
let filePathAbsoluteVite;
|
|
59
|
+
if (args.filePathAbsoluteUserRootDir !== null) {
|
|
60
|
+
filePathAbsoluteVite = args.filePathAbsoluteUserRootDir;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
(0, utils_js_1.assert)(args.importPathAbsolute !== null); // Help TS
|
|
64
|
+
filePathAbsoluteVite = args.importPathAbsolute;
|
|
65
|
+
}
|
|
66
|
+
const filePathToShowToUser = filePathAbsoluteVite;
|
|
67
|
+
(0, utils_js_1.assert)(filePathToShowToUser);
|
|
68
|
+
return {
|
|
69
|
+
...args,
|
|
70
|
+
filePathAbsoluteFilesystem: null,
|
|
71
|
+
filePathAbsoluteVite,
|
|
72
|
+
filePathToShowToUser
|
|
73
|
+
};
|
|
74
|
+
}
|
|
65
75
|
function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
|
|
66
76
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
|
|
67
77
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
78
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(userRootDir);
|
|
68
79
|
const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathAbsoluteUserRootDir);
|
|
80
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(userRootDir);
|
|
69
81
|
return filePathAbsoluteFilesystem;
|
|
70
82
|
}
|
|
71
83
|
function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
|
|
72
84
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
73
85
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
86
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
87
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(userRootDir);
|
|
74
88
|
const filePathRelative = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
75
89
|
if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
76
90
|
(0, utils_js_1.assert)(filePathRelative.startsWith('../'));
|
|
@@ -78,11 +92,51 @@ function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDi
|
|
|
78
92
|
}
|
|
79
93
|
(0, utils_js_1.assert)(!filePathRelative.startsWith('.') && !filePathRelative.startsWith('/'));
|
|
80
94
|
const filePathAbsoluteUserRootDir = `/${filePathRelative}`;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir === getFilePathAbsoluteUserRootDir2(filePathAbsoluteFilesystem, userRootDir));
|
|
96
|
+
return filePathAbsoluteUserRootDir;
|
|
97
|
+
}
|
|
98
|
+
function getModuleFilePath(moduleId, config) {
|
|
99
|
+
const userRootDir = config.root;
|
|
100
|
+
(0, utils_js_1.assertPosixPath)(moduleId);
|
|
101
|
+
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
102
|
+
const filePathAbsoluteFilesystem = cleanModuleId(moduleId);
|
|
103
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
104
|
+
const filePath = getFilePathResolved({ filePathAbsoluteFilesystem, userRootDir });
|
|
105
|
+
return filePath.filePathToShowToUserResolved;
|
|
106
|
+
}
|
|
107
|
+
exports.getModuleFilePath = getModuleFilePath;
|
|
108
|
+
function getFilePathToShowToUserFromUnkown(
|
|
109
|
+
// We don't have any guarentee about filePath, e.g. about whether is filePathAbsoluteFilesystem or filePathAbsoluteUserRootDir
|
|
110
|
+
filePathUnkown, userRootDir) {
|
|
111
|
+
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
112
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(userRootDir);
|
|
113
|
+
filePathUnkown = cleanFilePathUnkown(filePathUnkown);
|
|
114
|
+
if (!filePathUnkown.startsWith(userRootDir)) {
|
|
115
|
+
return filePathUnkown;
|
|
86
116
|
}
|
|
117
|
+
else {
|
|
118
|
+
return getFilePathAbsoluteUserRootDir2(filePathUnkown, userRootDir);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.getFilePathToShowToUserFromUnkown = getFilePathToShowToUserFromUnkown;
|
|
122
|
+
function getFilePathAbsoluteUserRootDir2(filePathAbsoluteFilesystem, userRootDir) {
|
|
123
|
+
(0, utils_js_1.assert)(filePathAbsoluteFilesystem.startsWith(userRootDir));
|
|
124
|
+
let filePathAbsoluteUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
125
|
+
if (!filePathAbsoluteUserRootDir.startsWith('/'))
|
|
126
|
+
filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir;
|
|
87
127
|
return filePathAbsoluteUserRootDir;
|
|
88
128
|
}
|
|
129
|
+
function cleanFilePathUnkown(filePathUnknown) {
|
|
130
|
+
filePathUnknown = (0, utils_js_1.toPosixPath)(filePathUnknown);
|
|
131
|
+
filePathUnknown = cleanModuleId(filePathUnknown);
|
|
132
|
+
return filePathUnknown;
|
|
133
|
+
}
|
|
134
|
+
exports.cleanFilePathUnkown = cleanFilePathUnkown;
|
|
135
|
+
function cleanModuleId(moduleId) {
|
|
136
|
+
// remove query
|
|
137
|
+
const parts = moduleId.split('?');
|
|
138
|
+
if (parts.length > 1)
|
|
139
|
+
parts.pop();
|
|
140
|
+
(0, utils_js_1.assert)(parts.length >= 1);
|
|
141
|
+
return parts.join('?');
|
|
142
|
+
}
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isErrorDebug = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
function isErrorDebug() {
|
|
6
|
-
return (0, utils_js_1.
|
|
6
|
+
return (0, utils_js_1.isDebugActivated)('vike:error');
|
|
7
7
|
}
|
|
8
8
|
exports.isErrorDebug = isErrorDebug;
|
|
@@ -9,6 +9,7 @@ exports.getPrettyErrMessage = exports.isEquivalentErrorWithCodeSnippet = exports
|
|
|
9
9
|
// Copied & adapted from https://github.com/vitejs/vite/blob/9c114c5c72a6af87e3330d5573362554b4511265/packages/vite/src/node/server/middlewares/error.ts
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
11
|
const utils_js_1 = require("../../utils.js");
|
|
12
|
+
const getFilePath_js_1 = require("../getFilePath.js");
|
|
12
13
|
function isErrorWithCodeSnippet(err) {
|
|
13
14
|
if (!(0, utils_js_1.isObject)(err)) {
|
|
14
15
|
return false;
|
|
@@ -48,7 +49,7 @@ function getPrettyErrorWithCodeSnippet(err, userRootDir) {
|
|
|
48
49
|
let { id, frame } = err;
|
|
49
50
|
const msgFirstLine = [
|
|
50
51
|
picocolors_1.default.red('Failed to transpile'),
|
|
51
|
-
picocolors_1.default.bold(picocolors_1.default.red((0,
|
|
52
|
+
picocolors_1.default.bold(picocolors_1.default.red((0, getFilePath_js_1.getFilePathToShowToUserFromUnkown)(id, userRootDir))),
|
|
52
53
|
picocolors_1.default.red('because:')
|
|
53
54
|
].join(' ');
|
|
54
55
|
const errMsg = getPrettyErrMessage(err);
|
|
@@ -88,7 +89,7 @@ function getPrettyErrMessage(err) {
|
|
|
88
89
|
// Remove "/home/rom/code/vike/examples/react-full/components/Counter.tsx:1:8:" (redundant since we already print the filename)
|
|
89
90
|
const pos = /(?:\:\d+|)/;
|
|
90
91
|
errMsg = errMsg.split(reg([id, pos, pos, trail], 'gi')).join('');
|
|
91
|
-
errMsg = errMsg.split(reg([
|
|
92
|
+
errMsg = errMsg.split(reg([(0, getFilePath_js_1.cleanFilePathUnkown)(id), pos, pos, trail], 'gi')).join('');
|
|
92
93
|
// Remove "ERROR:" (useless)
|
|
93
94
|
errMsg = errMsg.split(reg(['ERROR:', trail])).join('');
|
|
94
95
|
// Remove "Internal server error:" (useless)
|
|
@@ -160,9 +161,3 @@ exports.isEquivalentErrorWithCodeSnippet = isEquivalentErrorWithCodeSnippet;
|
|
|
160
161
|
function isDefinedAndSame(val1, val2) {
|
|
161
162
|
return val1 && val1 === val2;
|
|
162
163
|
}
|
|
163
|
-
function normalizeId(id) {
|
|
164
|
-
id = (0, utils_js_1.toPosixPath)(id);
|
|
165
|
-
// remove query
|
|
166
|
-
id = id.split('?')[0];
|
|
167
|
-
return id;
|
|
168
|
-
}
|
|
@@ -23,6 +23,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
23
23
|
const isNewError_js_1 = require("../../runtime/renderPage/isNewError.js");
|
|
24
24
|
const isConfigInvalid_js_1 = require("../../runtime/renderPage/isConfigInvalid.js");
|
|
25
25
|
const loggerProd_js_1 = require("../../runtime/renderPage/loggerProd.js");
|
|
26
|
+
const executeHook_js_1 = require("../../../shared/hooks/executeHook.js");
|
|
26
27
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
27
28
|
(0, loggerRuntime_js_1.overwriteRuntimeProductionLogger)(logRuntimeError, logRuntimeInfo);
|
|
28
29
|
(0, utils_js_1.overwriteAssertProductionLogger)(assertLogger);
|
|
@@ -99,7 +100,7 @@ function logErr(err, httpRequestId = null, errorComesFromVite) {
|
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
// Needs to be after assertion messages handling, because user hooks may throw an assertion error
|
|
102
|
-
const hook = (0,
|
|
103
|
+
const hook = (0, executeHook_js_1.isUserHookError)(err);
|
|
103
104
|
if (hook) {
|
|
104
105
|
const { hookName, hookFilePath } = hook;
|
|
105
106
|
(0, log_js_1.logWithVikeTag)(picocolors_1.default.red(`Following error was thrown by the ${hookName}() hook defined at ${hookFilePath}`), 'error', category);
|
|
@@ -22,7 +22,6 @@ const onLoad_js_1 = require("./onLoad.js");
|
|
|
22
22
|
__exportStar(require("../runtime/utils.js"), exports);
|
|
23
23
|
// Utils only needed by `plugin/*`
|
|
24
24
|
__exportStar(require("../../utils/viteIsSSR.js"), exports);
|
|
25
|
-
__exportStar(require("../../utils/getFilePathAbsolute.js"), exports);
|
|
26
25
|
__exportStar(require("../../utils/requireResolve.js"), exports);
|
|
27
26
|
__exportStar(require("../../utils/arrayIncludes.js"), exports);
|
|
28
27
|
__exportStar(require("../../utils/isDev.js"), exports);
|
|
@@ -42,3 +41,4 @@ __exportStar(require("../../utils/injectRollupInputs.js"), exports);
|
|
|
42
41
|
__exportStar(require("../../utils/humanizeTime.js"), exports);
|
|
43
42
|
__exportStar(require("../../utils/pLimit.js"), exports);
|
|
44
43
|
__exportStar(require("../../utils/assertVersion.js"), exports);
|
|
44
|
+
__exportStar(require("../../utils/assertPathIsFilesystemAbsolute.js"), exports);
|
|
@@ -31,7 +31,6 @@ require("../runtime/page-files/setup.js");
|
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const index_js_1 = require("../../shared/route/index.js");
|
|
33
33
|
const utils_js_1 = require("./utils.js");
|
|
34
|
-
const pLimit_js_1 = require("../../utils/pLimit.js");
|
|
35
34
|
const renderPageAlreadyRouted_js_1 = require("../runtime/renderPage/renderPageAlreadyRouted.js");
|
|
36
35
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
37
36
|
const os_1 = require("os");
|
|
@@ -45,13 +44,13 @@ const helpers_js_1 = require("../../shared/page-configs/helpers.js");
|
|
|
45
44
|
const loadConfigValues_js_1 = require("../../shared/page-configs/loadConfigValues.js");
|
|
46
45
|
const error_page_js_1 = require("../../shared/error-page.js");
|
|
47
46
|
const addUrlComputedProps_js_1 = require("../../shared/addUrlComputedProps.js");
|
|
48
|
-
const assertPathIsFilesystemAbsolute_js_1 = require("../../utils/assertPathIsFilesystemAbsolute.js");
|
|
49
47
|
const abort_js_1 = require("../../shared/route/abort.js");
|
|
50
48
|
const loadUserFilesServerSide_js_1 = require("../runtime/renderPage/loadUserFilesServerSide.js");
|
|
51
49
|
const getHook_js_1 = require("../../shared/hooks/getHook.js");
|
|
52
50
|
const noRouteMatch_js_1 = require("../../shared/route/noRouteMatch.js");
|
|
53
51
|
const getVikeConfig_js_1 = require("../plugin/plugins/importUserCode/v1-design/getVikeConfig.js");
|
|
54
52
|
const logErrorHint_js_1 = require("../runtime/renderPage/logErrorHint.js");
|
|
53
|
+
const executeHook_js_1 = require("../../shared/hooks/executeHook.js");
|
|
55
54
|
async function runPrerenderFromAPI(options = {}) {
|
|
56
55
|
await runPrerender(options, 'prerender()');
|
|
57
56
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
@@ -103,8 +102,8 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
103
102
|
});
|
|
104
103
|
}
|
|
105
104
|
const { partial = false, noExtraDir = false, parallel = true } = prerenderConfig || {};
|
|
106
|
-
const concurrencyLimit = (0,
|
|
107
|
-
(0,
|
|
105
|
+
const concurrencyLimit = (0, utils_js_1.pLimit)(parallel === false || parallel === 0 ? 1 : parallel === true || parallel === undefined ? (0, os_1.cpus)().length : parallel);
|
|
106
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
|
|
108
107
|
await (0, globalContext_js_1.initGlobalContext)(true, outDirRoot);
|
|
109
108
|
const renderContext = await (0, renderPageAlreadyRouted_js_1.getRenderContext)();
|
|
110
109
|
renderContext.pageFilesAll.forEach(assertExportNames);
|
|
@@ -245,7 +244,7 @@ async function callOnBeforePrerenderStartHooks(prerenderContext, renderContext,
|
|
|
245
244
|
if (doNotPrerenderList.find((p) => p.pageId === pageId)) {
|
|
246
245
|
return;
|
|
247
246
|
}
|
|
248
|
-
const prerenderResult = await (0,
|
|
247
|
+
const prerenderResult = await (0, executeHook_js_1.executeHook)(() => hookFn(), { hookName, hookFilePath, hookTimeout });
|
|
249
248
|
const result = normalizeOnPrerenderHookResult(prerenderResult, hookFilePath, hookName);
|
|
250
249
|
result.forEach(({ url, pageContext }) => {
|
|
251
250
|
{
|
|
@@ -410,7 +409,7 @@ async function callOnPrerenderStartHook(prerenderContext, renderContext) {
|
|
|
410
409
|
pageContext._urlOriginalBeforeHook = pageContext.urlOriginal;
|
|
411
410
|
});
|
|
412
411
|
const docLink = 'https://vike.dev/i18n#pre-rendering';
|
|
413
|
-
let result = await (0,
|
|
412
|
+
let result = await (0, executeHook_js_1.executeHook)(() => hookFn({
|
|
414
413
|
pageContexts: prerenderContext.pageContexts,
|
|
415
414
|
// TODO/v1-release: remove warning
|
|
416
415
|
get prerenderPageContexts() {
|
|
@@ -734,7 +733,7 @@ function assertIsNotAbort(err, urlOr404) {
|
|
|
734
733
|
if (!(0, abort_js_1.isAbortError)(err))
|
|
735
734
|
return;
|
|
736
735
|
const pageContextAbort = err._pageContextAbort;
|
|
737
|
-
const hookLoc = (0,
|
|
736
|
+
const hookLoc = (0, executeHook_js_1.isUserHookError)(err);
|
|
738
737
|
(0, utils_js_1.assert)(hookLoc);
|
|
739
738
|
const thrownBy = ` by ${picocolors_1.default.cyan(`${hookLoc.hookName}()`)} hook defined at ${hookLoc.hookFilePath}`;
|
|
740
739
|
const abortCaller = pageContextAbort._abortCaller;
|
|
@@ -26,6 +26,7 @@ __exportStar(require("../../utils/getOutDirs.js"), exports);
|
|
|
26
26
|
__exportStar(require("../../utils/isPropertyGetter.js"), exports);
|
|
27
27
|
__exportStar(require("../../utils/filesystemPathHandling.js"), exports);
|
|
28
28
|
__exportStar(require("../../utils/urlToFile.js"), exports);
|
|
29
|
-
__exportStar(require("../../shared/hooks/executeHook.js"), exports);
|
|
30
29
|
__exportStar(require("../../utils/isPlainObject.js"), exports);
|
|
31
30
|
__exportStar(require("../../utils/assertNodeEnv.js"), exports);
|
|
31
|
+
__exportStar(require("../../utils/pLimit.js"), exports);
|
|
32
|
+
__exportStar(require("../../utils/assertPathIsFilesystemAbsolute.js"), exports);
|
|
@@ -375,7 +375,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
375
375
|
const writeChunk = (chunk) => {
|
|
376
376
|
(0, utils_js_1.assert)(writableOriginal);
|
|
377
377
|
writableOriginal.write(chunk);
|
|
378
|
-
if (debug.
|
|
378
|
+
if (debug.isActivated) {
|
|
379
379
|
debug('data written (Node.js Writable)', String(chunk));
|
|
380
380
|
}
|
|
381
381
|
};
|
|
@@ -448,7 +448,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
448
448
|
const writeChunk = (chunk) => {
|
|
449
449
|
(0, utils_js_1.assert)(writerOriginal);
|
|
450
450
|
writerOriginal.write(encodeForWebStream(chunk));
|
|
451
|
-
if (debug.
|
|
451
|
+
if (debug.isActivated) {
|
|
452
452
|
debug('data written (Web Writable)', String(chunk));
|
|
453
453
|
}
|
|
454
454
|
};
|
|
@@ -541,12 +541,12 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
541
541
|
// If readableOriginal doesn't implement readableOriginal.cancel() then it may still emit data after we close the stream. We therefore need to check whether we closed `controllerProxy`.
|
|
542
542
|
!controllerProxyIsClosed) {
|
|
543
543
|
controllerProxy.enqueue(encodeForWebStream(chunk));
|
|
544
|
-
if (debug.
|
|
544
|
+
if (debug.isActivated) {
|
|
545
545
|
debug('data written (Web Readable)', String(chunk));
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
else {
|
|
549
|
-
if (debug.
|
|
549
|
+
if (debug.isActivated) {
|
|
550
550
|
debug('data emitted but not written (Web Readable)', String(chunk));
|
|
551
551
|
}
|
|
552
552
|
}
|
|
@@ -568,7 +568,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
|
|
|
568
568
|
}
|
|
569
569
|
const writeChunk = (chunk) => {
|
|
570
570
|
readableProxy.push(chunk);
|
|
571
|
-
if (debug.
|
|
571
|
+
if (debug.isActivated) {
|
|
572
572
|
debug('data written (Node.js Readable)', String(chunk));
|
|
573
573
|
}
|
|
574
574
|
};
|
|
@@ -15,7 +15,7 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
|
15
15
|
const clientDependencies = [];
|
|
16
16
|
clientDependencies.push({
|
|
17
17
|
id: (0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageConfig.pageId, true),
|
|
18
|
-
onlyAssets: false,
|
|
18
|
+
onlyAssets: isClientSideRenderable ? false : true,
|
|
19
19
|
eagerlyImported: false
|
|
20
20
|
});
|
|
21
21
|
// In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.executeOnBeforeRenderAndDataHooks = void 0;
|
|
4
4
|
const getHook_js_1 = require("../../../shared/hooks/getHook.js");
|
|
5
5
|
const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePageContextForUserConsumptionServerSide.js");
|
|
6
|
-
const utils_js_1 = require("../utils.js");
|
|
7
6
|
const assertOnBeforeRenderHookReturn_js_1 = require("../../../shared/assertOnBeforeRenderHookReturn.js");
|
|
7
|
+
const executeHook_js_1 = require("../../../shared/hooks/executeHook.js");
|
|
8
8
|
async function executeOnBeforeRenderAndDataHooks(pageContext) {
|
|
9
9
|
if (pageContext._pageContextAlreadyProvidedByOnPrerenderHook) {
|
|
10
10
|
return;
|
|
@@ -16,7 +16,7 @@ async function executeOnBeforeRenderAndDataHooks(pageContext) {
|
|
|
16
16
|
}
|
|
17
17
|
(0, preparePageContextForUserConsumptionServerSide_js_1.preparePageContextForUserConsumptionServerSide)(pageContext);
|
|
18
18
|
if (dataHook) {
|
|
19
|
-
const hookResult = await (0,
|
|
19
|
+
const hookResult = await (0, executeHook_js_1.executeHook)(() => dataHook.hookFn(pageContext), dataHook);
|
|
20
20
|
// Note: hookResult can be anything (e.g. an object) and is to be assigned to pageContext.data
|
|
21
21
|
const pageContextFromHook = {
|
|
22
22
|
data: hookResult
|
|
@@ -24,7 +24,7 @@ async function executeOnBeforeRenderAndDataHooks(pageContext) {
|
|
|
24
24
|
Object.assign(pageContext, pageContextFromHook);
|
|
25
25
|
}
|
|
26
26
|
if (onBeforeRenderHook) {
|
|
27
|
-
const hookResult = await (0,
|
|
27
|
+
const hookResult = await (0, executeHook_js_1.executeHook)(() => onBeforeRenderHook.hookFn(pageContext), onBeforeRenderHook);
|
|
28
28
|
(0, assertOnBeforeRenderHookReturn_js_1.assertOnBeforeRenderHookReturn)(hookResult, onBeforeRenderHook.hookFilePath);
|
|
29
29
|
const pageContextFromHook = hookResult?.pageContext;
|
|
30
30
|
Object.assign(pageContext, pageContextFromHook);
|
|
@@ -13,11 +13,12 @@ const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePa
|
|
|
13
13
|
const assertHookReturnedObject_js_1 = require("../../../shared/assertHookReturnedObject.js");
|
|
14
14
|
const loggerRuntime_js_1 = require("./loggerRuntime.js");
|
|
15
15
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
16
|
+
const executeHook_js_1 = require("../../../shared/hooks/executeHook.js");
|
|
16
17
|
async function executeOnRenderHtmlHook(pageContext) {
|
|
17
18
|
const { renderHook, hookFn } = getRenderHook(pageContext);
|
|
18
19
|
(0, utils_js_1.objectAssign)(pageContext, { _renderHook: renderHook });
|
|
19
20
|
(0, preparePageContextForUserConsumptionServerSide_js_1.preparePageContextForUserConsumptionServerSide)(pageContext);
|
|
20
|
-
const hookReturnValue = await (0,
|
|
21
|
+
const hookReturnValue = await (0, executeHook_js_1.executeHook)(() => hookFn(pageContext), renderHook);
|
|
21
22
|
const { documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter } = processHookReturnValue(hookReturnValue, renderHook);
|
|
22
23
|
Object.assign(pageContext, pageContextProvidedByRenderHook);
|
|
23
24
|
(0, utils_js_1.objectAssign)(pageContext, { _pageContextPromise: pageContextPromise });
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getManifestEntry = void 0;
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
const assertClientEntryId_js_1 = require("./assertClientEntryId.js");
|
|
6
5
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
7
6
|
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
8
7
|
function getManifestEntry(id, assetsManifest) {
|
|
9
|
-
(0, assertClientEntryId_js_1.assertClientEntryId)(id);
|
|
10
8
|
const debugInfo = getDebugInfo(id, assetsManifest);
|
|
11
9
|
// Vike client entry
|
|
12
10
|
if (id.startsWith('@@vike/')) {
|
|
@@ -44,12 +42,11 @@ function getManifestEntry(id, assetsManifest) {
|
|
|
44
42
|
return { manifestEntry, manifestKey };
|
|
45
43
|
}
|
|
46
44
|
// npm package import
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
45
|
+
(0, utils_js_1.assertIsNpmPackageImport)(id);
|
|
46
|
+
const found = Object.entries(assetsManifest).find(([, e]) => e.name === (0, prependEntriesDir_js_1.prependEntriesDir)(id));
|
|
47
|
+
(0, utils_js_1.assert)(found);
|
|
48
|
+
const [manifestKey, manifestEntry] = found;
|
|
49
|
+
return { manifestEntry, manifestKey };
|
|
53
50
|
/* Can we remove this?
|
|
54
51
|
// extensions[number].pageConfigsSrcDir
|
|
55
52
|
if (id.startsWith('/node_modules/') || id.startsWith('/../')) {
|
|
@@ -81,7 +78,6 @@ function getManifestEntry(id, assetsManifest) {
|
|
|
81
78
|
assert(false, debugInfo)
|
|
82
79
|
}
|
|
83
80
|
*/
|
|
84
|
-
(0, utils_js_1.assert)(false, debugInfo);
|
|
85
81
|
}
|
|
86
82
|
exports.getManifestEntry = getManifestEntry;
|
|
87
83
|
function findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id) {
|
|
@@ -11,15 +11,16 @@ function retrieveAssetsProd(clientDependencies, assetsManifest, includeAssetsImp
|
|
|
11
11
|
clientDependencies.forEach(({ id, onlyAssets, eagerlyImported }) => {
|
|
12
12
|
if (eagerlyImported)
|
|
13
13
|
return; // Eagerly imported assets aren't imported with import() and therefore don't create a new Rollup entry and aren't listed in the manifest file
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// TODO/v1-release: remove
|
|
15
|
+
if (includeAssetsImportedByServer &&
|
|
16
|
+
onlyAssets &&
|
|
17
|
+
id.includes('.page.server.') &&
|
|
17
18
|
// We assume that all npm packages have already built their files: bundlers (Rollup, esbuild, tsup, ...) extract the CSS out of JavaScript => we can assume JavaScript to not import any CSS/assets.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
!(0, utils_js_1.isNpmPackageImport)(id, {
|
|
20
|
+
// I presume Vite already resolves path aliases when Vite sets the module's id
|
|
21
|
+
cannotBePathAlias: true
|
|
22
|
+
})) {
|
|
23
|
+
id = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(id);
|
|
23
24
|
}
|
|
24
25
|
const { manifestKey } = (0, getManifestEntry_js_1.getManifestEntry)(id, assetsManifest);
|
|
25
26
|
collectAssets(manifestKey, assetUrls, visistedAssets, assetsManifest, onlyAssets);
|
|
@@ -8,7 +8,6 @@ const inferMediaType_js_1 = require("./inferMediaType.js");
|
|
|
8
8
|
const getManifestEntry_js_1 = require("./getPageAssets/getManifestEntry.js");
|
|
9
9
|
const sortPageAssetsForEarlyHintsHeader_js_1 = require("./getPageAssets/sortPageAssetsForEarlyHintsHeader.js");
|
|
10
10
|
const globalContext_js_1 = require("../globalContext.js");
|
|
11
|
-
const assertClientEntryId_js_1 = require("./getPageAssets/assertClientEntryId.js");
|
|
12
11
|
const import_1 = require("@brillout/import");
|
|
13
12
|
async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
14
13
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
@@ -59,7 +58,6 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
59
58
|
}
|
|
60
59
|
exports.getPageAssets = getPageAssets;
|
|
61
60
|
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
62
|
-
(0, assertClientEntryId_js_1.assertClientEntryId)(clientEntry);
|
|
63
61
|
let root = viteDevServer.config.root;
|
|
64
62
|
(0, utils_js_1.assert)(root);
|
|
65
63
|
root = (0, utils_js_1.toPosixPath)(root);
|
|
@@ -76,11 +74,9 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
76
74
|
(0, utils_js_1.assertPosixPath)(clientEntry);
|
|
77
75
|
let filePath;
|
|
78
76
|
if (clientEntry.startsWith('/')) {
|
|
79
|
-
// User files
|
|
80
77
|
filePath = (0, utils_js_1.pathJoin)(root, clientEntry);
|
|
81
78
|
}
|
|
82
|
-
else
|
|
83
|
-
// Vike client entry
|
|
79
|
+
else {
|
|
84
80
|
const { createRequire } = (await (0, import_1.import_)('module')).default;
|
|
85
81
|
const { dirname } = (await (0, import_1.import_)('path')).default;
|
|
86
82
|
const { fileURLToPath } = (await (0, import_1.import_)('url')).default;
|
|
@@ -91,10 +87,7 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
91
87
|
// @ts-expect-error
|
|
92
88
|
// Bun workaround https://github.com/vikejs/vike/pull/1048
|
|
93
89
|
const res = typeof Bun !== 'undefined' ? (toPath) => Bun.resolveSync(toPath, __dirname_) : require_.resolve;
|
|
94
|
-
if (
|
|
95
|
-
filePath = res(clientEntry);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
90
|
+
if (clientEntry.startsWith('@@vike/')) {
|
|
98
91
|
(0, utils_js_1.assert)(clientEntry.endsWith('.js'));
|
|
99
92
|
try {
|
|
100
93
|
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
@@ -107,9 +100,10 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
107
100
|
filePath = (0, utils_js_1.toPosixPath)(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
108
101
|
}
|
|
109
102
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
else {
|
|
104
|
+
(0, utils_js_1.assertIsNpmPackageImport)(clientEntry);
|
|
105
|
+
filePath = res(clientEntry);
|
|
106
|
+
}
|
|
113
107
|
}
|
|
114
108
|
if (!filePath.startsWith('/')) {
|
|
115
109
|
(0, utils_js_1.assert)(process.platform === 'win32');
|
|
@@ -21,6 +21,10 @@ const knownErrors = [
|
|
|
21
21
|
// ```
|
|
22
22
|
errMsg: 'assets.json',
|
|
23
23
|
link: 'https://vike.dev/getGlobalContext'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
errMsg: /Named export.*not found/i,
|
|
27
|
+
link: 'https://vike.dev/broken-npm-package#named-export-not-found'
|
|
24
28
|
}
|
|
25
29
|
];
|
|
26
30
|
function logErrorHint(error) {
|
|
@@ -290,7 +294,15 @@ function extractFromNodeModulesPath(str) {
|
|
|
290
294
|
return packageName;
|
|
291
295
|
}
|
|
292
296
|
function includes(str1, str2) {
|
|
293
|
-
|
|
297
|
+
if (!str1)
|
|
298
|
+
return false;
|
|
299
|
+
if (str2 instanceof RegExp) {
|
|
300
|
+
return str2.test(str1.toLowerCase());
|
|
301
|
+
}
|
|
302
|
+
if (typeof str2 === 'string') {
|
|
303
|
+
return str1.toLowerCase().includes(str2.toLowerCase());
|
|
304
|
+
}
|
|
305
|
+
return false;
|
|
294
306
|
}
|
|
295
307
|
function includesNodeModules(str) {
|
|
296
308
|
if (!str)
|
|
@@ -48,7 +48,6 @@ __exportStar(require("../../utils/isPropertyGetter.js"), exports);
|
|
|
48
48
|
__exportStar(require("../../utils/debug.js"), exports);
|
|
49
49
|
__exportStar(require("../../utils/urlToFile.js"), exports);
|
|
50
50
|
__exportStar(require("../../utils/getGlobalObject.js"), exports);
|
|
51
|
-
__exportStar(require("../../shared/hooks/executeHook.js"), exports);
|
|
52
51
|
__exportStar(require("../../utils/freezePartial.js"), exports);
|
|
53
52
|
__exportStar(require("../../utils/isNpmPackage.js"), exports);
|
|
54
53
|
__exportStar(require("../../utils/isNotNullish.js"), exports);
|
|
@@ -28,9 +28,7 @@ function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
30
|
(0, utils_js_1.assert)(exportsAll.length === 2); // because `exportsInvalid.length === 0`
|
|
31
|
-
(0, utils_js_1.assertWarning)(false,
|
|
32
|
-
onlyOnce: true
|
|
33
|
-
});
|
|
31
|
+
(0, utils_js_1.assertWarning)(false, `The exports of ${filePathToShowToUser} are ambiguous: remove ${exportDefault} or ${exportNamed}`, { onlyOnce: true });
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
else {
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.assertNoInfiniteAbortLoop = exports.AbortRender = exports.getPageContextFromAllRewrites = exports.logAbortErrorHandled = exports.isAbortPageContext = exports.isAbortError = exports.RenderErrorPage = exports.render = exports.redirect = void 0;
|
|
7
|
+
const executeHook_js_1 = require("../hooks/executeHook.js");
|
|
7
8
|
const utils_js_1 = require("./utils.js");
|
|
8
9
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
10
|
/**
|
|
@@ -121,7 +122,7 @@ function logAbortErrorHandled(err, isProduction, pageContext) {
|
|
|
121
122
|
(0, utils_js_1.assert)(urlCurrent);
|
|
122
123
|
const abortCall = err._pageContextAbort._abortCall;
|
|
123
124
|
(0, utils_js_1.assert)(abortCall);
|
|
124
|
-
const hookLoc = (0,
|
|
125
|
+
const hookLoc = (0, executeHook_js_1.isUserHookError)(err);
|
|
125
126
|
let thrownBy = '';
|
|
126
127
|
if (hookLoc) {
|
|
127
128
|
thrownBy = ` by ${picocolors_1.default.cyan(`${hookLoc.hookName}()`)} hook defined at ${hookLoc.hookFilePath}`;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.executeGuardHook = void 0;
|
|
4
4
|
const getHook_js_1 = require("../hooks/getHook.js");
|
|
5
5
|
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const executeHook_js_1 = require("../hooks/executeHook.js");
|
|
6
7
|
const errIntro = 'The guard() hook defined by';
|
|
7
8
|
async function executeGuardHook(pageContext, prepareForUserConsumption) {
|
|
8
9
|
let hook;
|
|
@@ -22,7 +23,7 @@ async function executeGuardHook(pageContext, prepareForUserConsumption) {
|
|
|
22
23
|
const res = prepareForUserConsumption(pageContext);
|
|
23
24
|
if (res)
|
|
24
25
|
pageContextForUserConsumption = res;
|
|
25
|
-
const hookResult = await (0,
|
|
26
|
+
const hookResult = await (0, executeHook_js_1.executeHook)(() => guard(pageContextForUserConsumption), hook);
|
|
26
27
|
(0, utils_js_1.assertUsage)(hookResult === undefined, `${errIntro} ${hook.hookFilePath} returns a value, but guard() shouldn't return any value`);
|
|
27
28
|
}
|
|
28
29
|
exports.executeGuardHook = executeGuardHook;
|
|
@@ -8,6 +8,7 @@ const assertPageContextProvidedByUser_js_1 = require("../assertPageContextProvid
|
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
9
|
const resolveRouteFunction_js_1 = require("./resolveRouteFunction.js");
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
|
+
const executeHook_js_1 = require("../hooks/executeHook.js");
|
|
11
12
|
async function executeOnBeforeRouteHook(pageContext) {
|
|
12
13
|
const pageContextFromOnBeforeRouteHook = {};
|
|
13
14
|
if (!pageContext._onBeforeRouteHook)
|
|
@@ -41,7 +42,7 @@ async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
|
|
|
41
42
|
let hookReturn = onBeforeRouteHook.hookFn(pageContext);
|
|
42
43
|
(0, resolveRouteFunction_js_1.assertSyncRouting)(hookReturn, `The onBeforeRoute() hook ${onBeforeRouteHook.hookFilePath}`);
|
|
43
44
|
// TODO/v1-release: make executeOnBeforeRouteHook() and route() sync
|
|
44
|
-
hookReturn = await (0,
|
|
45
|
+
hookReturn = await (0, executeHook_js_1.executeHook)(() => hookReturn, onBeforeRouteHook);
|
|
45
46
|
const errPrefix = `The onBeforeRoute() hook defined by ${onBeforeRouteHook.hookFilePath}`;
|
|
46
47
|
(0, utils_js_1.assertUsage)(hookReturn === null ||
|
|
47
48
|
hookReturn === undefined ||
|