vike 0.4.172 → 0.4.173
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 +3 -0
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -8
- package/dist/cjs/node/plugin/plugins/config/index.js +9 -5
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +135 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +22 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +19 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +22 -42
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
- package/dist/cjs/node/plugin/plugins/previewConfig.js +2 -2
- package/dist/cjs/node/plugin/resolveClientEntriesDev.js +59 -0
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +7 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerVite.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/cjs/node/runtime/onLoad.js +4 -0
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/cjs/node/runtime/renderPage.js +7 -4
- package/dist/cjs/node/{plugin/shared → shared}/isErrorDebug.js +1 -1
- package/dist/cjs/node/shared/utils.js +1 -0
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/utils/assert.js +9 -3
- package/dist/cjs/utils/findFile.js +5 -3
- package/dist/cjs/utils/findPackageJson.js +19 -0
- package/dist/cjs/utils/joinEnglish.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +2 -2
- package/dist/esm/node/plugin/index.js +3 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +5 -9
- package/dist/esm/node/plugin/plugins/config/index.js +9 -5
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +129 -0
- 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 +23 -5
- 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 +20 -8
- 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 +21 -41
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +2 -2
- package/dist/esm/node/plugin/resolveClientEntriesDev.d.ts +4 -0
- package/dist/esm/node/plugin/resolveClientEntriesDev.js +56 -0
- package/dist/esm/node/plugin/shared/addSsrMiddleware.d.ts +2 -2
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +7 -1
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/esm/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/plugin/shared/loggerVite.js +1 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/esm/node/runtime/onLoad.js +4 -0
- package/dist/esm/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/esm/node/runtime/renderPage.js +7 -4
- package/dist/esm/node/{plugin/shared → shared}/isErrorDebug.js +1 -1
- package/dist/esm/node/shared/utils.d.ts +1 -0
- package/dist/esm/node/shared/utils.js +1 -0
- package/dist/esm/shared/ConfigVike.d.ts +7 -0
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +5 -2
- package/dist/esm/shared/page-configs/Config.d.ts +13 -1
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/assert.d.ts +2 -0
- package/dist/esm/utils/assert.js +8 -2
- package/dist/esm/utils/findFile.js +5 -3
- package/dist/esm/utils/findPackageJson.d.ts +5 -0
- package/dist/esm/utils/findPackageJson.js +16 -0
- package/dist/esm/utils/joinEnglish.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +4 -4
- /package/dist/esm/node/{plugin/shared → shared}/isErrorDebug.d.ts +0 -0
|
@@ -28,9 +28,12 @@ const baseUrls_js_1 = require("./plugins/baseUrls.js");
|
|
|
28
28
|
const envVars_js_1 = require("./plugins/envVars.js");
|
|
29
29
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
30
30
|
const fileEnv_js_1 = require("./plugins/fileEnv.js");
|
|
31
|
+
const getPageAssets_js_1 = require("../runtime/renderPage/getPageAssets.js");
|
|
32
|
+
const resolveClientEntriesDev_js_1 = require("./resolveClientEntriesDev.js");
|
|
31
33
|
(0, utils_js_2.assertNodeEnv_onVikePluginLoad)();
|
|
32
34
|
(0, utils_js_2.markEnvAsVikePluginLoaded)();
|
|
33
35
|
assertViteVersion();
|
|
36
|
+
(0, getPageAssets_js_1.setResolveClientEntriesDev)(resolveClientEntriesDev_js_1.resolveClientEntriesDev);
|
|
34
37
|
// Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
|
|
35
38
|
function plugin(vikeConfig) {
|
|
36
39
|
const plugins = [
|
|
@@ -9,11 +9,7 @@ const buildConfig_js_1 = require("./buildConfig.js");
|
|
|
9
9
|
const require_shim_1 = require("@brillout/require-shim");
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const module_1 = require("module");
|
|
13
12
|
const assertResolveAlias_js_1 = require("./commonConfig/assertResolveAlias.js");
|
|
14
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
15
|
-
const importMetaUrl = `file://${__filename}`;
|
|
16
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
17
13
|
const pluginName = 'vike:commonConfig-1';
|
|
18
14
|
function commonConfig() {
|
|
19
15
|
return [
|
|
@@ -70,11 +66,11 @@ function workaroundCI(config) {
|
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
68
|
function assertEsm(userViteRoot) {
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
69
|
+
const found = (0, utils_js_1.findPackageJson)(userViteRoot);
|
|
70
|
+
if (!found)
|
|
75
71
|
return;
|
|
76
|
-
const packageJson =
|
|
77
|
-
let dir = path_1.default.dirname(packageJsonPath);
|
|
72
|
+
const { packageJson, packageJsonPath } = found;
|
|
73
|
+
let dir = path_1.default.posix.dirname(packageJsonPath);
|
|
78
74
|
if (dir !== '/') {
|
|
79
75
|
(0, utils_js_1.assert)(!dir.endsWith('/'));
|
|
80
76
|
dir = dir + '/';
|
|
@@ -26,15 +26,16 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
26
26
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
27
27
|
const fromViteConfig = (config.vike ?? {});
|
|
28
28
|
const configs = [fromPluginOptions, fromViteConfig];
|
|
29
|
-
|
|
29
|
+
(0, assertVikeConfig_js_1.assertVikeConfig)(fromViteConfig, ({ prop, errMsg }) => `vite.config.js#vike.${prop} ${errMsg}`);
|
|
30
|
+
// TODO/v1-release: deprecate this
|
|
31
|
+
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
32
|
+
const crawlWithGit = fromPluginOptions.crawl?.git ?? null;
|
|
33
|
+
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config), { crawlWithGit });
|
|
30
34
|
configs.push(fromPlusConfigFile);
|
|
31
35
|
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
32
36
|
// TODO: add config file path ?
|
|
33
37
|
return `config ${picocolors_1.default.cyan(prop)} ${errMsg}`;
|
|
34
38
|
});
|
|
35
|
-
(0, assertVikeConfig_js_1.assertVikeConfig)(fromViteConfig, ({ prop, errMsg }) => `vite.config.js#vike.${prop} ${errMsg}`);
|
|
36
|
-
// TODO/v1-release: deprecate this
|
|
37
|
-
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
38
39
|
const { baseServer, baseAssets } = (0, resolveBase_js_1.resolveBase)(configs, config);
|
|
39
40
|
const configVike = {
|
|
40
41
|
disableAutoFullBuild: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
@@ -44,7 +45,10 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
44
45
|
baseAssets,
|
|
45
46
|
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
46
47
|
disableUrlNormalization: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
47
|
-
trailingSlash: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.trailingSlash)) ?? false
|
|
48
|
+
trailingSlash: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.trailingSlash)) ?? false,
|
|
49
|
+
crawl: {
|
|
50
|
+
git: crawlWithGit
|
|
51
|
+
}
|
|
48
52
|
};
|
|
49
53
|
return configVike;
|
|
50
54
|
}
|
|
@@ -6,7 +6,7 @@ const determineFsAllowList_js_1 = require("./determineFsAllowList.js");
|
|
|
6
6
|
const addSsrMiddleware_js_1 = require("../../shared/addSsrMiddleware.js");
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const loggerVite_js_1 = require("../../shared/loggerVite.js");
|
|
9
|
-
const isErrorDebug_js_1 = require("
|
|
9
|
+
const isErrorDebug_js_1 = require("../../../shared/isErrorDebug.js");
|
|
10
10
|
const getHttpRequestAsyncStore_js_1 = require("../../shared/getHttpRequestAsyncStore.js");
|
|
11
11
|
if ((0, isErrorDebug_js_1.isErrorDebug)()) {
|
|
12
12
|
Error.stackTraceLimit = Infinity;
|
|
@@ -79,7 +79,7 @@ function devConfig() {
|
|
|
79
79
|
if (config.server.middlewareMode || hasHonoViteDevServer)
|
|
80
80
|
return;
|
|
81
81
|
return () => {
|
|
82
|
-
(0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares);
|
|
82
|
+
(0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares, config, false);
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
},
|
|
@@ -0,0 +1,135 @@
|
|
|
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.assertExtensionsPeerDependencies = exports.assertExtensionsConventions = void 0;
|
|
7
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
|
+
const isObjectOfStrings_js_1 = require("../../../../../utils/isObjectOfStrings.js");
|
|
9
|
+
const utils_js_1 = require("../../../utils.js");
|
|
10
|
+
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const semver_1 = __importDefault(require("semver"));
|
|
13
|
+
function assertExtensionsConventions(interfaceFile) {
|
|
14
|
+
assertExtensionName(interfaceFile);
|
|
15
|
+
assertConfigExportPath(interfaceFile);
|
|
16
|
+
}
|
|
17
|
+
exports.assertExtensionsConventions = assertExtensionsConventions;
|
|
18
|
+
function assertConfigExportPath(interfaceFile) {
|
|
19
|
+
const { importPathAbsolute } = interfaceFile.filePath;
|
|
20
|
+
(0, utils_js_1.assert)(importPathAbsolute);
|
|
21
|
+
const name = getConfigNameValue(interfaceFile);
|
|
22
|
+
(0, utils_js_1.assert)(name); // already asserted in assertExtensionName()
|
|
23
|
+
const importPathAbsoluteExpected = `${name}/config`;
|
|
24
|
+
(0, utils_js_1.assertWarning)(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${picocolors_1.default.bold(name)} is exported at ${picocolors_1.default.bold(importPathAbsolute)}, but it should be exported at ${picocolors_1.default.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
25
|
+
}
|
|
26
|
+
function assertExtensionName(interfaceFile) {
|
|
27
|
+
let nameDeduced;
|
|
28
|
+
{
|
|
29
|
+
const { importPathAbsolute } = interfaceFile.filePath;
|
|
30
|
+
(0, utils_js_1.assert)(importPathAbsolute);
|
|
31
|
+
nameDeduced = importPathAbsolute
|
|
32
|
+
.split('/')
|
|
33
|
+
.slice(0, importPathAbsolute.startsWith('@') ? 2 : 1)
|
|
34
|
+
.join('/');
|
|
35
|
+
}
|
|
36
|
+
const name = getConfigNameValue(interfaceFile);
|
|
37
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
38
|
+
if (name) {
|
|
39
|
+
(0, utils_js_1.assertWarning)(name === nameDeduced, `The setting ${picocolors_1.default.bold('name')} defined at ${filePathToShowToUser} is ${picocolors_1.default.bold(name)}, but it should be ${picocolors_1.default.bold(nameDeduced)} instead (the name of the npm package).`, { onlyOnce: true });
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (
|
|
43
|
+
// Let's eventually remove this
|
|
44
|
+
[
|
|
45
|
+
'vike-react',
|
|
46
|
+
'vike-react-query',
|
|
47
|
+
'vike-react-zustand',
|
|
48
|
+
'vike-vue',
|
|
49
|
+
'vike-vue-query',
|
|
50
|
+
'vike-vue-pinia',
|
|
51
|
+
'vike-pinia',
|
|
52
|
+
'vike-solid'
|
|
53
|
+
].includes(nameDeduced)) {
|
|
54
|
+
(0, utils_js_1.assertUsage)(false, `Update ${nameDeduced} to its latest version.`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
(0, utils_js_1.assertUsage)(false, `The setting ${picocolors_1.default.bold('name')} is missing: it should be set by the config ${filePathToShowToUser} of ${picocolors_1.default.bold(nameDeduced)}.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function assertExtensionsPeerDependencies(interfaceFilesRelevantList) {
|
|
62
|
+
// Get installed extensions
|
|
63
|
+
const extensions = {};
|
|
64
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
65
|
+
const name = getConfigNameValue(interfaceFile);
|
|
66
|
+
if (name) {
|
|
67
|
+
const version = getExtensionVersion(name, interfaceFile);
|
|
68
|
+
extensions[name] = version;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
// Enforce peer dependencies
|
|
72
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
73
|
+
const require = getConfigRequireValue(interfaceFile);
|
|
74
|
+
if (!require)
|
|
75
|
+
return;
|
|
76
|
+
const name = getConfigNameValue(interfaceFile);
|
|
77
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
78
|
+
(0, utils_js_1.assertUsage)(name, `Setting ${picocolors_1.default.bold('name')} is required for being able to use setting ${picocolors_1.default.bold('require')} in ${filePathToShowToUser}.`);
|
|
79
|
+
Object.entries(require).forEach(([reqName, reqVersion]) => {
|
|
80
|
+
const errBase = `${picocolors_1.default.bold(name)} requires ${picocolors_1.default.bold(reqName)}`;
|
|
81
|
+
if (reqName === 'vike') {
|
|
82
|
+
(0, utils_js_1.assertUsage)(isVersionRange(utils_js_1.PROJECT_VERSION, reqVersion), `${errBase} version ${picocolors_1.default.bold(reqVersion)}, but ${picocolors_1.default.bold(utils_js_1.PROJECT_VERSION)} is installed.`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const extensionVersion = extensions[reqName];
|
|
86
|
+
(0, utils_js_1.assertUsage)(extensionVersion, `${errBase}.`);
|
|
87
|
+
(0, utils_js_1.assertUsage)(isVersionRange(extensionVersion, reqVersion), `${errBase} version ${picocolors_1.default.bold(reqVersion)}, but ${picocolors_1.default.bold(extensionVersion)} is installed.`);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
exports.assertExtensionsPeerDependencies = assertExtensionsPeerDependencies;
|
|
92
|
+
function getConfigRequireValue(interfaceFile) {
|
|
93
|
+
const require = (0, getVikeConfig_js_1.getConfigValueInterfaceFile)(interfaceFile, 'require');
|
|
94
|
+
if (!require)
|
|
95
|
+
return null;
|
|
96
|
+
const { filePathToShowToUserResolved } = interfaceFile.filePath;
|
|
97
|
+
(0, utils_js_1.assert)(filePathToShowToUserResolved);
|
|
98
|
+
(0, utils_js_1.assertUsage)((0, isObjectOfStrings_js_1.isObjectOfStrings)(require), `The setting ${picocolors_1.default.bold('require')} defined at ${filePathToShowToUserResolved} should be an object with string values (${picocolors_1.default.bold('Record<string, string>')}).`);
|
|
99
|
+
return require;
|
|
100
|
+
}
|
|
101
|
+
function getConfigNameValue(interfaceFile) {
|
|
102
|
+
const name = (0, getVikeConfig_js_1.getConfigValueInterfaceFile)(interfaceFile, 'name');
|
|
103
|
+
if (!name)
|
|
104
|
+
return null;
|
|
105
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
106
|
+
(0, utils_js_1.assertUsage)(typeof name === 'string', `The setting ${picocolors_1.default.bold('name')} defined at ${filePathToShowToUser} should be a string.`);
|
|
107
|
+
return name;
|
|
108
|
+
}
|
|
109
|
+
// We use a forever cache: users need to restart the dev server anyways when touching node_modules/**/* (I presume Vite doesn't pick up node_modules/**/* changes).
|
|
110
|
+
const extensionsVersion = {};
|
|
111
|
+
function getExtensionVersion(name, interfaceFile) {
|
|
112
|
+
if (!extensionsVersion[name]) {
|
|
113
|
+
const extensionConfigFilePath = interfaceFile.filePath.filePathAbsoluteFilesystem;
|
|
114
|
+
const found = (0, utils_js_1.findPackageJson)(path_1.default.posix.dirname(extensionConfigFilePath));
|
|
115
|
+
(0, utils_js_1.assert)(found);
|
|
116
|
+
const { packageJson, packageJsonPath } = found;
|
|
117
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
118
|
+
const nameExpected = packageJson.name;
|
|
119
|
+
(0, utils_js_1.assertWarning)(name === nameExpected, `The setting ${picocolors_1.default.bold('name')} defined at ${filePathToShowToUser} is ${picocolors_1.default.bold(JSON.stringify(name))}, but it should be equal to ${picocolors_1.default.bold(JSON.stringify(nameExpected))} (the value of ${packageJsonPath}${picocolors_1.default.dim('#')}${picocolors_1.default.bold('name')})`, { onlyOnce: true });
|
|
120
|
+
const { version } = packageJson;
|
|
121
|
+
(0, utils_js_1.assert)(typeof version === 'string');
|
|
122
|
+
extensionsVersion[name] = version;
|
|
123
|
+
}
|
|
124
|
+
return extensionsVersion[name];
|
|
125
|
+
}
|
|
126
|
+
function getFilePathToShowToUser(interfaceFile) {
|
|
127
|
+
const { filePathToShowToUserResolved } = interfaceFile.filePath;
|
|
128
|
+
(0, utils_js_1.assert)(filePathToShowToUserResolved);
|
|
129
|
+
return filePathToShowToUserResolved;
|
|
130
|
+
}
|
|
131
|
+
function isVersionRange(version, range) {
|
|
132
|
+
// Remove pre-release tag
|
|
133
|
+
version = version.split('-')[0];
|
|
134
|
+
return semver_1.default.satisfies(version, range);
|
|
135
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configDefinitionsBuiltInGlobal = exports.configDefinitionsBuiltIn = void 0;
|
|
4
4
|
const utils_js_1 = require("../../../../utils.js");
|
|
5
|
+
const getConfigDefinedAt_js_1 = require("../../../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
5
6
|
const configDefinitionsBuiltIn = {
|
|
6
7
|
onRenderHtml: {
|
|
7
8
|
env: { server: true }
|
|
@@ -55,6 +56,9 @@ const configDefinitionsBuiltIn = {
|
|
|
55
56
|
// We could make it { client: false } but we don't yet because of some legacy V0.4 design code
|
|
56
57
|
env: { server: true, client: true, config: true, eager: true }
|
|
57
58
|
},
|
|
59
|
+
clientHooks: {
|
|
60
|
+
env: { config: true }
|
|
61
|
+
},
|
|
58
62
|
prerender: {
|
|
59
63
|
env: { config: true }
|
|
60
64
|
},
|
|
@@ -70,11 +74,22 @@ const configDefinitionsBuiltIn = {
|
|
|
70
74
|
meta: {
|
|
71
75
|
env: { config: true }
|
|
72
76
|
},
|
|
73
|
-
|
|
77
|
+
clientEntryLoaded: {
|
|
74
78
|
env: { server: true, client: true, eager: true },
|
|
75
|
-
_computed: (configValueSources) =>
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
_computed: (configValueSources) => {
|
|
80
|
+
{
|
|
81
|
+
const source = getConfigValueSource(configValueSources, 'clientHooks');
|
|
82
|
+
if (source && source.value !== null) {
|
|
83
|
+
const { value } = source;
|
|
84
|
+
const definedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', source.definedAtFilePath);
|
|
85
|
+
(0, utils_js_1.assertUsage)(typeof value === 'boolean', `${definedAt} should be a boolean`);
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return (isConfigSet(configValueSources, 'onRenderClient') &&
|
|
90
|
+
isConfigSet(configValueSources, 'Page') &&
|
|
91
|
+
!!getConfigEnv(configValueSources, 'Page')?.client);
|
|
92
|
+
}
|
|
78
93
|
},
|
|
79
94
|
onBeforeRenderEnv: {
|
|
80
95
|
env: { client: true },
|
|
@@ -92,6 +107,9 @@ const configDefinitionsBuiltIn = {
|
|
|
92
107
|
},
|
|
93
108
|
name: {
|
|
94
109
|
env: { config: true }
|
|
110
|
+
},
|
|
111
|
+
require: {
|
|
112
|
+
env: { config: true }
|
|
95
113
|
}
|
|
96
114
|
};
|
|
97
115
|
exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -15,7 +15,7 @@ const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
|
15
15
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
16
16
|
(0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
|
|
17
17
|
let gitIsNotUsable = false;
|
|
18
|
-
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
18
|
+
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, crawlWithGit) {
|
|
19
19
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
20
20
|
(0, utils_js_1.assertPosixPath)(outDirAbsoluteFilesystem);
|
|
21
21
|
let outDirRelativeFromUserRootDir = path_1.default.posix.relative(userRootDir, outDirAbsoluteFilesystem);
|
|
@@ -31,8 +31,9 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
31
31
|
//
|
|
32
32
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
33
33
|
const timeBefore = new Date().getTime();
|
|
34
|
+
// Crawl
|
|
34
35
|
let files = [];
|
|
35
|
-
const res = await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir);
|
|
36
|
+
const res = crawlWithGit !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
36
37
|
if (res &&
|
|
37
38
|
// Fallback to fast-glob for users that dynamically generate plus files. (Assuming all (generetad) plus files to be skipped because users usually included them in `.gitignore`.)
|
|
38
39
|
res.length > 0) {
|
|
@@ -41,7 +42,9 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
41
42
|
else {
|
|
42
43
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
43
44
|
}
|
|
45
|
+
// Filter build files
|
|
44
46
|
files = files.filter((file) => !(0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(file));
|
|
47
|
+
// Check performance
|
|
45
48
|
{
|
|
46
49
|
const timeAfter = new Date().getTime();
|
|
47
50
|
const timeSpent = timeAfter - timeBefore;
|
|
@@ -53,10 +56,12 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
// Normalize
|
|
60
|
+
const plusFiles = files.map((filePath) => {
|
|
61
|
+
// Both `$ git-ls files` and fast-glob return posix paths
|
|
62
|
+
(0, utils_js_1.assertPosixPath)(filePath);
|
|
63
|
+
(0, utils_js_1.assert)(!filePath.startsWith(userRootDir));
|
|
64
|
+
const filePathAbsoluteUserRootDir = path_1.default.posix.join('/', filePath);
|
|
60
65
|
return { filePathAbsoluteUserRootDir };
|
|
61
66
|
});
|
|
62
67
|
return plusFiles;
|
|
@@ -66,10 +71,17 @@ exports.crawlPlusFiles = crawlPlusFiles;
|
|
|
66
71
|
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
67
72
|
if (gitIsNotUsable)
|
|
68
73
|
return null;
|
|
74
|
+
// Preserve UTF-8 file paths.
|
|
75
|
+
// https://github.com/vikejs/vike/issues/1658
|
|
76
|
+
// https://stackoverflow.com/questions/22827239/how-to-make-git-properly-display-utf-8-encoded-pathnames-in-the-console-window/22828826#22828826
|
|
77
|
+
// https://stackoverflow.com/questions/15884180/how-do-i-override-git-configuration-options-by-command-line-parameters/15884261#15884261
|
|
78
|
+
const preserveUTF8 = '-c core.quotepath=off';
|
|
69
79
|
const ignoreAsPatterns = getIgnoreAsPatterns(outDirRelativeFromUserRootDir);
|
|
70
80
|
const ignoreAsFilterFn = getIgnoreAsFilterFn(outDirRelativeFromUserRootDir);
|
|
71
81
|
const cmd = [
|
|
72
|
-
'git
|
|
82
|
+
'git',
|
|
83
|
+
preserveUTF8,
|
|
84
|
+
'ls-files',
|
|
73
85
|
...utils_js_1.scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
74
86
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
75
87
|
// --others lists untracked files only (but using .gitignore because --exclude-standard)
|
|
@@ -3,7 +3,7 @@ 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.isV1Design = exports.isVikeConfigFile = exports.vikeConfigDependencies = exports.reloadVikeConfig = exports.getVikeConfig = void 0;
|
|
6
|
+
exports.getConfigValueInterfaceFile = exports.isV1Design = exports.isVikeConfigFile = exports.vikeConfigDependencies = exports.reloadVikeConfig = exports.getVikeConfig = void 0;
|
|
7
7
|
const utils_js_1 = require("../../../utils.js");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const configDefinitionsBuiltIn_js_1 = require("./getVikeConfig/configDefinitionsBuiltIn.js");
|
|
@@ -21,6 +21,8 @@ const loadFileAtConfigTime_js_1 = require("./getVikeConfig/loadFileAtConfigTime.
|
|
|
21
21
|
const resolvePointerImport_js_1 = require("./getVikeConfig/resolvePointerImport.js");
|
|
22
22
|
const getFilePath_js_1 = require("../../../shared/getFilePath.js");
|
|
23
23
|
const getConfigValueBuildTime_js_1 = require("../../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
24
|
+
const getConfigVike_js_1 = require("../../../../shared/getConfigVike.js");
|
|
25
|
+
const assertExtensions_js_1 = require("./assertExtensions.js");
|
|
24
26
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
25
27
|
let devServerIsCorrupt = false;
|
|
26
28
|
let wasConfigInvalid = null;
|
|
@@ -65,11 +67,12 @@ async function handleReloadSideEffects() {
|
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
|
-
async function getVikeConfig(config, isDev, tolerateInvalidConfig) {
|
|
70
|
+
async function getVikeConfig(config, isDev, { crawlWithGit, tolerateInvalidConfig } = {}) {
|
|
69
71
|
const { outDirRoot } = (0, utils_js_1.getOutDirs)(config);
|
|
70
72
|
const userRootDir = config.root;
|
|
71
73
|
if (!vikeConfigPromise) {
|
|
72
|
-
|
|
74
|
+
const crawlWithGit_ = crawlWithGit !== undefined ? crawlWithGit : (await (0, getConfigVike_js_1.getConfigVike)(config)).crawl.git;
|
|
75
|
+
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit_, tolerateInvalidConfig);
|
|
73
76
|
}
|
|
74
77
|
return await vikeConfigPromise;
|
|
75
78
|
}
|
|
@@ -81,8 +84,8 @@ async function isV1Design(config, isDev) {
|
|
|
81
84
|
return isV1Design;
|
|
82
85
|
}
|
|
83
86
|
exports.isV1Design = isV1Design;
|
|
84
|
-
async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
85
|
-
const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev);
|
|
87
|
+
async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
88
|
+
const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
86
89
|
const configFiles = [];
|
|
87
90
|
const valueFiles = [];
|
|
88
91
|
plusFiles.forEach((f) => {
|
|
@@ -123,29 +126,7 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
123
126
|
```
|
|
124
127
|
*/
|
|
125
128
|
const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true, locationId);
|
|
126
|
-
|
|
127
|
-
const alreadyMigrated = [
|
|
128
|
-
'vike-react',
|
|
129
|
-
'vike-react-query',
|
|
130
|
-
'vike-react-zustand',
|
|
131
|
-
'vike-vue',
|
|
132
|
-
'vike-pinia',
|
|
133
|
-
'vike-solid'
|
|
134
|
-
];
|
|
135
|
-
(0, utils_js_1.assert)(extendsConfig.filePath.importPathAbsolute);
|
|
136
|
-
const extensionName = extendsConfig.filePath.importPathAbsolute.split('/')[0];
|
|
137
|
-
const warnMsg = alreadyMigrated.includes(extensionName)
|
|
138
|
-
? `You're using a deprecated version of the Vike extension ${extensionName}, update ${extensionName} to its latest version.`
|
|
139
|
-
: `The config of the Vike extension ${extensionName} should set a ${picocolors_1.default.cyan('name')} value`;
|
|
140
|
-
const isNameDefined = interfaceFile.fileExportsByConfigName.name?.configValue;
|
|
141
|
-
if (alreadyMigrated) {
|
|
142
|
-
// Eventually always make it a assertUsage()
|
|
143
|
-
(0, utils_js_1.assertWarning)(isNameDefined, warnMsg, { onlyOnce: true });
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
(0, utils_js_1.assertUsage)(isNameDefined, warnMsg);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
129
|
+
(0, assertExtensions_js_1.assertExtensionsConventions)(interfaceFile);
|
|
149
130
|
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
150
131
|
});
|
|
151
132
|
}),
|
|
@@ -213,12 +194,12 @@ function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
|
|
|
213
194
|
});
|
|
214
195
|
});
|
|
215
196
|
}
|
|
216
|
-
async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, tolerateInvalidConfig) {
|
|
197
|
+
async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit, tolerateInvalidConfig) {
|
|
217
198
|
let hasError = false;
|
|
218
199
|
let ret;
|
|
219
200
|
let err;
|
|
220
201
|
try {
|
|
221
|
-
ret = await loadVikeConfig(userRootDir, outDirRoot, isDev);
|
|
202
|
+
ret = await loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
222
203
|
}
|
|
223
204
|
catch (err_) {
|
|
224
205
|
hasError = true;
|
|
@@ -255,17 +236,19 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
255
236
|
}
|
|
256
237
|
}
|
|
257
238
|
}
|
|
258
|
-
async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
259
|
-
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev);
|
|
239
|
+
async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
240
|
+
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
260
241
|
const importedFilesLoaded = {};
|
|
261
242
|
const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
|
|
262
243
|
const pageConfigs = await Promise.all((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
|
|
263
244
|
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
264
245
|
.map(async ([locationId]) => {
|
|
265
246
|
const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
|
|
247
|
+
const interfaceFilesRelevantList = Object.values(interfaceFilesByLocationId).flat(1);
|
|
248
|
+
(0, assertExtensions_js_1.assertExtensionsPeerDependencies)(interfaceFilesRelevantList);
|
|
266
249
|
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
|
|
267
250
|
// Load value files of custom config-only configs
|
|
268
|
-
await Promise.all(
|
|
251
|
+
await Promise.all(interfaceFilesRelevantList.map(async (interfaceFile) => {
|
|
269
252
|
if (!interfaceFile.isValueFile)
|
|
270
253
|
return;
|
|
271
254
|
const { configName } = interfaceFile;
|
|
@@ -353,13 +336,6 @@ function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
|
|
|
353
336
|
.sort(([locationId1], [locationId2]) => (0, filesystemRouting_js_1.sortAfterInheritanceOrder)(locationId1, locationId2, locationIdPage)));
|
|
354
337
|
return interfaceFilesRelevant;
|
|
355
338
|
}
|
|
356
|
-
function getInterfaceFileList(interfaceFilesByLocationId) {
|
|
357
|
-
const interfaceFiles = [];
|
|
358
|
-
Object.values(interfaceFilesByLocationId).forEach((interfaceFiles_) => {
|
|
359
|
-
interfaceFiles.push(...interfaceFiles_);
|
|
360
|
-
});
|
|
361
|
-
return interfaceFiles;
|
|
362
|
-
}
|
|
363
339
|
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
|
|
364
340
|
const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
|
|
365
341
|
const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
@@ -770,8 +746,8 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
770
746
|
});
|
|
771
747
|
return configValuesComputed;
|
|
772
748
|
}
|
|
773
|
-
async function findPlusFiles(userRootDir, outDirRoot, isDev) {
|
|
774
|
-
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot, isDev);
|
|
749
|
+
async function findPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
750
|
+
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
775
751
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
776
752
|
return plusFiles;
|
|
777
753
|
}
|
|
@@ -973,3 +949,7 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
973
949
|
// Sort after the filesystem inheritance of the config value
|
|
974
950
|
.sort(([, [source1]], [, [source2]]) => (0, utils_js_1.reverse)((0, filesystemRouting_js_1.sortAfterInheritanceOrder)(source1.locationId, source2.locationId, locationIdPage))));
|
|
975
951
|
}
|
|
952
|
+
function getConfigValueInterfaceFile(interfaceFile, configName) {
|
|
953
|
+
return interfaceFile.fileExportsByConfigName[configName]?.configValue;
|
|
954
|
+
}
|
|
955
|
+
exports.getConfigValueInterfaceFile = getConfigValueInterfaceFile;
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -21,7 +21,7 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
21
21
|
}
|
|
22
22
|
*/
|
|
23
23
|
const { pageId, isForClientSide } = result;
|
|
24
|
-
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev, true);
|
|
24
|
+
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev, { tolerateInvalidConfig: true });
|
|
25
25
|
const pageConfig = pageConfigs.find((pageConfig) => pageConfig.pageId === pageId);
|
|
26
26
|
(0, utils_js_1.assert)(pageConfig);
|
|
27
27
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
@@ -7,7 +7,7 @@ const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
|
7
7
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
8
8
|
const serializeConfigValues_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValues.js");
|
|
9
9
|
async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
|
|
10
|
-
const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev, true);
|
|
10
|
+
const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev, { tolerateInvalidConfig: true });
|
|
11
11
|
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
12
12
|
}
|
|
13
13
|
exports.getVirtualFilePageConfigs = getVirtualFilePageConfigs;
|
|
@@ -38,10 +38,10 @@ function previewConfig() {
|
|
|
38
38
|
assertDist();
|
|
39
39
|
/* We don't use this condition (we wrongfully always use the SSR middleware) because of the regression introduced by https://github.com/vitejs/vite/pull/14756 which stops servering .html files when `appType: 'custom'`.
|
|
40
40
|
if (!configVike.prerender || configVike.prerender.partial) {
|
|
41
|
-
addSsrMiddleware(server.middlewares)
|
|
41
|
+
addSsrMiddleware(server.middlewares, config, true)
|
|
42
42
|
}
|
|
43
43
|
/*/
|
|
44
|
-
(0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares);
|
|
44
|
+
(0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares, config, true);
|
|
45
45
|
//*/
|
|
46
46
|
addStatic404Middleware(server.middlewares);
|
|
47
47
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveClientEntriesDev = void 0;
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
|
+
const module_1 = require("module");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const url_1 = require("url");
|
|
8
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
9
|
+
const importMetaUrl = `file://${__filename}`;
|
|
10
|
+
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
11
|
+
const __dirname_ = (0, path_1.dirname)((0, url_1.fileURLToPath)(importMetaUrl));
|
|
12
|
+
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
13
|
+
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
14
|
+
let root = viteDevServer.config.root;
|
|
15
|
+
(0, utils_js_1.assert)(root);
|
|
16
|
+
root = (0, utils_js_1.toPosixPath)(root);
|
|
17
|
+
// The `?import` suffix is needed for MDX to be transpiled:
|
|
18
|
+
// - Not transpiled: `/pages/markdown.page.mdx`
|
|
19
|
+
// - Transpiled: `/pages/markdown.page.mdx?import`
|
|
20
|
+
// But `?import` doesn't work with `/@fs/`:
|
|
21
|
+
// - Not transpiled: /@fs/home/runner/work/vike/vike/examples/react-full/pages/markdown.page.mdx
|
|
22
|
+
// - Not transpiled: /@fs/home/runner/work/vike/vike/examples/react-full/pages/markdown.page.mdx?import
|
|
23
|
+
if (clientEntry.endsWith('?import')) {
|
|
24
|
+
(0, utils_js_1.assert)(clientEntry.startsWith('/'));
|
|
25
|
+
return clientEntry;
|
|
26
|
+
}
|
|
27
|
+
(0, utils_js_1.assertPosixPath)(clientEntry);
|
|
28
|
+
let filePath;
|
|
29
|
+
if (clientEntry.startsWith('/')) {
|
|
30
|
+
filePath = (0, utils_js_1.pathJoin)(root, clientEntry);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (clientEntry.startsWith('@@vike/')) {
|
|
34
|
+
(0, utils_js_1.assert)(clientEntry.endsWith('.js'));
|
|
35
|
+
try {
|
|
36
|
+
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
37
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/plugin/resolveClientEntriesDev.js
|
|
38
|
+
filePath = (0, utils_js_1.toPosixPath)(require_.resolve(clientEntry.replace('@@vike/dist/esm/client/', '../../client/').replace('.js', '.ts')));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// For users
|
|
42
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/resolveClientEntriesDev.js
|
|
43
|
+
filePath = (0, utils_js_1.toPosixPath)(require_.resolve(clientEntry.replace('@@vike/dist/esm/client/', '../../../../dist/esm/client/')));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
(0, utils_js_1.assertIsNpmPackageImport)(clientEntry);
|
|
48
|
+
filePath = require_.resolve(clientEntry);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!filePath.startsWith('/')) {
|
|
52
|
+
(0, utils_js_1.assert)(process.platform === 'win32');
|
|
53
|
+
filePath = '/' + filePath;
|
|
54
|
+
}
|
|
55
|
+
filePath = '/@fs' + filePath;
|
|
56
|
+
(0, utils_js_1.assertPosixPath)(filePath);
|
|
57
|
+
return filePath;
|
|
58
|
+
}
|
|
59
|
+
exports.resolveClientEntriesDev = resolveClientEntriesDev;
|
|
@@ -7,7 +7,7 @@ exports.addSsrMiddleware = void 0;
|
|
|
7
7
|
const renderPage_js_1 = require("../../runtime/renderPage.js");
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
9
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
|
-
function addSsrMiddleware(middlewares) {
|
|
10
|
+
function addSsrMiddleware(middlewares, config, isPreview) {
|
|
11
11
|
middlewares.use(async (req, res, next) => {
|
|
12
12
|
if (res.headersSent)
|
|
13
13
|
return next();
|
|
@@ -42,6 +42,12 @@ function addSsrMiddleware(middlewares) {
|
|
|
42
42
|
// - We purposely don't use next(err) to align behavior: we use our own/copied implementation of buildErrorMessage() regardless of whether the user uses Vite's dev middleware or Vite's standalone dev server
|
|
43
43
|
return next();
|
|
44
44
|
}
|
|
45
|
+
const configHeaders = (isPreview && config?.preview?.headers) || config?.server?.headers;
|
|
46
|
+
if (configHeaders) {
|
|
47
|
+
for (const [name, value] of Object.entries(configHeaders))
|
|
48
|
+
if (value)
|
|
49
|
+
res.setHeader(name, value);
|
|
50
|
+
}
|
|
45
51
|
if (!pageContext.httpResponse) {
|
|
46
52
|
return next();
|
|
47
53
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.applyViteSourceMapToStackTrace = exports.screenHasErrors = exports.clearScreen = exports.isFirstLog = exports.logDirectly = exports.logWithVikeTag = exports.logWithViteTag = void 0;
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
-
const isErrorDebug_js_1 = require("
|
|
9
|
+
const isErrorDebug_js_1 = require("../../../shared/isErrorDebug.js");
|
|
10
10
|
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
11
11
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
12
12
|
let isFirstLog = true;
|
|
@@ -15,7 +15,7 @@ const globalContext_js_1 = require("../../runtime/globalContext.js");
|
|
|
15
15
|
const loggerRuntime_js_1 = require("../../runtime/renderPage/loggerRuntime.js");
|
|
16
16
|
const utils_js_1 = require("../utils.js");
|
|
17
17
|
const getHttpRequestAsyncStore_js_1 = require("./getHttpRequestAsyncStore.js");
|
|
18
|
-
const isErrorDebug_js_1 = require("
|
|
18
|
+
const isErrorDebug_js_1 = require("../../shared/isErrorDebug.js");
|
|
19
19
|
const errorWithCodeSnippet_js_1 = require("./loggerNotProd/errorWithCodeSnippet.js");
|
|
20
20
|
const transpileAndExecuteFile_js_1 = require("../plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js");
|
|
21
21
|
const log_js_1 = require("./loggerNotProd/log.js");
|
|
@@ -5,7 +5,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
5
5
|
const loggerNotProd_js_1 = require("./loggerNotProd.js");
|
|
6
6
|
const getHttpRequestAsyncStore_js_1 = require("./getHttpRequestAsyncStore.js");
|
|
7
7
|
const removeSuperfluousViteLog_js_1 = require("./loggerVite/removeSuperfluousViteLog.js");
|
|
8
|
-
const isErrorDebug_js_1 = require("
|
|
8
|
+
const isErrorDebug_js_1 = require("../../shared/isErrorDebug.js");
|
|
9
9
|
function improveViteLogs(config) {
|
|
10
10
|
intercept('info', config);
|
|
11
11
|
intercept('warn', config);
|