vike 0.4.220-commit-af5c91f → 0.4.221-commit-8577456
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/__internal/index.js +5 -23
- package/dist/cjs/node/api/build.js +55 -11
- package/dist/cjs/node/api/prepareViteApiCall.js +20 -17
- package/dist/cjs/node/api/prerender.js +1 -0
- package/dist/cjs/node/api/utils.js +1 -0
- package/dist/cjs/node/plugin/index.js +2 -0
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +9 -20
- package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildApp.js +72 -0
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +8 -10
- package/dist/cjs/node/plugin/plugins/buildConfig.js +5 -5
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +8 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{assertExtensions.js → getVikeConfig/assertExtensions.js} +31 -31
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +53 -21
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.js → getVikeConfig/getConfigFileExport.js} +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +159 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +205 -343
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{debug.js → virtual-files/debug.js} +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.js → virtual-files/getVirtualFilePageConfigValuesAll.js} +7 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.js → virtual-files/getVirtualFilePageConfigs.js} +3 -3
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -4
- package/dist/cjs/node/plugin/shared/getFullBuildInlineConfig.js +20 -0
- package/dist/cjs/node/plugin/shared/getOutDirs.js +50 -38
- package/dist/cjs/node/prerender/runPrerender.js +29 -30
- package/dist/cjs/node/runtime/globalContext.js +186 -100
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -3
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +2 -3
- package/dist/cjs/node/runtime/html/injectAssets.js +4 -4
- package/dist/cjs/node/runtime/html/renderHtml.js +4 -5
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -3
- package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +2 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +4 -4
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +3 -5
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +5 -4
- package/dist/cjs/node/runtime/renderPage/log404/index.js +1 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +10 -9
- package/dist/cjs/node/runtime/renderPage.js +27 -30
- package/dist/cjs/node/runtime/utils.js +1 -0
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +5 -3
- package/dist/cjs/node/shared/resolveBase.js +3 -5
- package/dist/cjs/shared/getPageConfigsRuntime.js +20 -0
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +4 -3
- package/dist/cjs/shared/getPageFiles.js +1 -3
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +13 -4
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +1 -1
- package/dist/cjs/utils/debug.js +8 -6
- package/dist/cjs/utils/findFile.js +1 -0
- package/dist/cjs/utils/objectAssignSafe.js +7 -0
- package/dist/esm/__internal/index.d.ts +2 -2
- package/dist/esm/__internal/index.js +7 -26
- package/dist/esm/client/client-routing-runtime/createPageContext.js +5 -9
- package/dist/esm/client/server-routing-runtime/getPageContext.js +3 -4
- package/dist/esm/client/shared/loadUserFilesClientSide.js +3 -2
- package/dist/esm/node/api/build.js +23 -12
- package/dist/esm/node/api/prepareViteApiCall.d.ts +4 -2
- package/dist/esm/node/api/prepareViteApiCall.js +20 -17
- package/dist/esm/node/api/prerender.js +1 -0
- package/dist/esm/node/api/utils.d.ts +1 -0
- package/dist/esm/node/api/utils.js +1 -0
- package/dist/esm/node/plugin/index.js +2 -0
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +10 -21
- package/dist/esm/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/esm/node/plugin/plugins/buildApp.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/buildApp.js +70 -0
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +8 -10
- package/dist/esm/node/plugin/plugins/buildConfig.js +6 -6
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +2 -2
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +8 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.d.ts +6 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{assertExtensions.js → getVikeConfig/assertExtensions.js} +31 -31
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +52 -20
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.js → getVikeConfig/getConfigFileExport.js} +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.d.ts +39 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +154 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -38
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +208 -346
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{debug.js → virtual-files/debug.js} +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.js → virtual-files/getVirtualFilePageConfigValuesAll.js} +7 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.js → virtual-files/getVirtualFilePageConfigs.js} +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.d.ts → virtual-files/isRuntimeEnvMatch.d.ts} +1 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +2 -5
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.d.ts +2 -0
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.js +17 -0
- package/dist/esm/node/plugin/shared/getOutDirs.d.ts +1 -1
- package/dist/esm/node/plugin/shared/getOutDirs.js +50 -38
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +2 -5
- package/dist/esm/node/prerender/runPrerender.d.ts +2 -2
- package/dist/esm/node/prerender/runPrerender.js +30 -31
- package/dist/esm/node/runtime/globalContext.d.ts +31 -29
- package/dist/esm/node/runtime/globalContext.js +186 -100
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -3
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +4 -1
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +2 -3
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -0
- package/dist/esm/node/runtime/html/injectAssets.js +4 -4
- package/dist/esm/node/runtime/html/renderHtml.js +4 -5
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -3
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +2 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +4 -4
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +3 -5
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +6 -5
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/log404/index.js +1 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +21 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +10 -9
- package/dist/esm/node/runtime/renderPage.js +28 -31
- package/dist/esm/node/runtime/utils.d.ts +1 -0
- package/dist/esm/node/runtime/utils.js +1 -0
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +5 -3
- package/dist/esm/node/shared/resolveBase.d.ts +2 -1
- package/dist/esm/node/shared/resolveBase.js +3 -5
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +13 -0
- package/dist/esm/shared/getPageConfigsRuntime.js +18 -0
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +4 -3
- package/dist/esm/shared/getPageFiles.d.ts +0 -1
- package/dist/esm/shared/getPageFiles.js +0 -1
- package/dist/esm/shared/page-configs/Config.d.ts +7 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +9 -5
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +5 -7
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +13 -4
- package/dist/esm/shared/route/loadPageRoutes.js +1 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSetup.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +8 -6
- package/dist/esm/utils/findFile.js +1 -0
- package/dist/esm/utils/objectAssignSafe.d.ts +1 -0
- package/dist/esm/utils/objectAssignSafe.js +4 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/shared/getPageFiles/getPageFiles.js +0 -48
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +0 -6
- package/dist/esm/shared/getPageFiles/getPageFiles.d.ts +0 -15
- package/dist/esm/shared/getPageFiles/getPageFiles.js +0 -46
- /package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.js → virtual-files/isRuntimeEnvMatch.js} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.d.ts → getVikeConfig/getConfigFileExport.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{debug.d.ts → virtual-files/debug.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.d.ts → virtual-files/getVirtualFilePageConfigValuesAll.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.d.ts → virtual-files/getVirtualFilePageConfigs.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.js → virtual-files/isRuntimeEnvMatch.js} +0 -0
|
@@ -6,51 +6,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.assertExtensionsConventions = assertExtensionsConventions;
|
|
7
7
|
exports.assertExtensionsRequire = assertExtensionsRequire;
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
-
const isObjectOfStrings_js_1 = require("
|
|
10
|
-
const utils_js_1 = require("
|
|
11
|
-
const getVikeConfig_js_1 = require("
|
|
9
|
+
const isObjectOfStrings_js_1 = require("../../../../../../utils/isObjectOfStrings.js");
|
|
10
|
+
const utils_js_1 = require("../../../../utils.js");
|
|
11
|
+
const getVikeConfig_js_1 = require("../getVikeConfig.js");
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const semver_1 = __importDefault(require("semver"));
|
|
14
|
-
function assertExtensionsConventions(
|
|
15
|
-
assertExtensionName(
|
|
16
|
-
assertConfigExportPath(
|
|
14
|
+
function assertExtensionsConventions(plusFile) {
|
|
15
|
+
assertExtensionName(plusFile);
|
|
16
|
+
assertConfigExportPath(plusFile);
|
|
17
17
|
}
|
|
18
|
-
function assertConfigExportPath(
|
|
19
|
-
const { importPathAbsolute, filePathAbsoluteFilesystem } =
|
|
18
|
+
function assertConfigExportPath(plusFile) {
|
|
19
|
+
const { importPathAbsolute, filePathAbsoluteFilesystem } = plusFile.filePath;
|
|
20
20
|
// Ejected Vike extension
|
|
21
21
|
if (!importPathAbsolute) {
|
|
22
22
|
const p = filePathAbsoluteFilesystem;
|
|
23
23
|
(0, utils_js_1.assert)(!p.includes('node_modules'));
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const name = getNameValue(
|
|
26
|
+
const name = getNameValue(plusFile);
|
|
27
27
|
(0, utils_js_1.assert)(name); // already asserted in assertExtensionName()
|
|
28
28
|
const importPathAbsoluteExpected = `${name}/config`;
|
|
29
29
|
(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 });
|
|
30
30
|
}
|
|
31
|
-
function assertExtensionName(
|
|
32
|
-
const filePathToShowToUser = getFilePathToShowToUser(
|
|
33
|
-
const name = getNameValue(
|
|
31
|
+
function assertExtensionName(plusFile) {
|
|
32
|
+
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
33
|
+
const name = getNameValue(plusFile);
|
|
34
34
|
(0, utils_js_1.assertUsage)(name, `Vike extension name missing: the config ${filePathToShowToUser} must define the setting ${picocolors_1.default.cyan('name')}`);
|
|
35
35
|
}
|
|
36
36
|
function assertExtensionsRequire(pageConfig) {
|
|
37
|
-
const
|
|
37
|
+
const plusFilesRelevantList = Object.values(pageConfig.plusFiles).flat(1);
|
|
38
38
|
// Collect extensions
|
|
39
39
|
const extensions = {};
|
|
40
|
-
|
|
41
|
-
const name = getNameValue(
|
|
40
|
+
plusFilesRelevantList.forEach((plusFile) => {
|
|
41
|
+
const name = getNameValue(plusFile);
|
|
42
42
|
if (name) {
|
|
43
|
-
const version = getExtensionVersion(name,
|
|
43
|
+
const version = getExtensionVersion(name, plusFile);
|
|
44
44
|
extensions[name] = version;
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
// Enforce `require`
|
|
48
|
-
|
|
49
|
-
const require = getConfigRequireValue(
|
|
48
|
+
plusFilesRelevantList.forEach((plusFile) => {
|
|
49
|
+
const require = getConfigRequireValue(plusFile);
|
|
50
50
|
if (!require)
|
|
51
51
|
return;
|
|
52
|
-
const name = getNameValue(
|
|
53
|
-
const filePathToShowToUser = getFilePathToShowToUser(
|
|
52
|
+
const name = getNameValue(plusFile);
|
|
53
|
+
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
54
54
|
(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}.`);
|
|
55
55
|
Object.entries(require).forEach(([reqName, reqVersion]) => {
|
|
56
56
|
const errBase = `${picocolors_1.default.bold(name)} requires ${picocolors_1.default.bold(reqName)}`;
|
|
@@ -64,36 +64,36 @@ function assertExtensionsRequire(pageConfig) {
|
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
function getConfigRequireValue(
|
|
68
|
-
const confVal = (0, getVikeConfig_js_1.getConfVal)(
|
|
67
|
+
function getConfigRequireValue(plusFile) {
|
|
68
|
+
const confVal = (0, getVikeConfig_js_1.getConfVal)(plusFile, 'require');
|
|
69
69
|
if (!confVal)
|
|
70
70
|
return null;
|
|
71
71
|
(0, utils_js_1.assert)(confVal.configValueLoaded);
|
|
72
72
|
const require = confVal.configValue;
|
|
73
|
-
const { filePathToShowToUserResolved } =
|
|
73
|
+
const { filePathToShowToUserResolved } = plusFile.filePath;
|
|
74
74
|
(0, utils_js_1.assert)(filePathToShowToUserResolved);
|
|
75
75
|
(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>')}).`);
|
|
76
76
|
return require;
|
|
77
77
|
}
|
|
78
|
-
function getNameValue(
|
|
79
|
-
const confVal = (0, getVikeConfig_js_1.getConfVal)(
|
|
78
|
+
function getNameValue(plusFile) {
|
|
79
|
+
const confVal = (0, getVikeConfig_js_1.getConfVal)(plusFile, 'name');
|
|
80
80
|
if (!confVal)
|
|
81
81
|
return null;
|
|
82
82
|
(0, utils_js_1.assert)(confVal.configValueLoaded);
|
|
83
83
|
const name = confVal.configValue;
|
|
84
|
-
const filePathToShowToUser = getFilePathToShowToUser(
|
|
84
|
+
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
85
85
|
(0, utils_js_1.assertUsage)(typeof name === 'string', `The setting ${picocolors_1.default.bold('name')} defined at ${filePathToShowToUser} should be a string.`);
|
|
86
86
|
return name;
|
|
87
87
|
}
|
|
88
88
|
// 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).
|
|
89
89
|
const extensionsVersion = {};
|
|
90
|
-
function getExtensionVersion(name,
|
|
90
|
+
function getExtensionVersion(name, plusFile) {
|
|
91
91
|
if (!extensionsVersion[name]) {
|
|
92
|
-
const extensionConfigFilePath =
|
|
92
|
+
const extensionConfigFilePath = plusFile.filePath.filePathAbsoluteFilesystem;
|
|
93
93
|
const found = (0, utils_js_1.findPackageJson)(path_1.default.posix.dirname(extensionConfigFilePath));
|
|
94
94
|
(0, utils_js_1.assert)(found);
|
|
95
95
|
const { packageJson, packageJsonPath } = found;
|
|
96
|
-
const filePathToShowToUser = getFilePathToShowToUser(
|
|
96
|
+
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
97
97
|
const nameExpected = packageJson.name;
|
|
98
98
|
(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 });
|
|
99
99
|
const { version } = packageJson;
|
|
@@ -102,8 +102,8 @@ function getExtensionVersion(name, interfaceFile) {
|
|
|
102
102
|
}
|
|
103
103
|
return extensionsVersion[name];
|
|
104
104
|
}
|
|
105
|
-
function getFilePathToShowToUser(
|
|
106
|
-
const { filePathToShowToUserResolved } =
|
|
105
|
+
function getFilePathToShowToUser(plusFile) {
|
|
106
|
+
const { filePathToShowToUserResolved } = plusFile.filePath;
|
|
107
107
|
(0, utils_js_1.assert)(filePathToShowToUserResolved);
|
|
108
108
|
return filePathToShowToUserResolved;
|
|
109
109
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.configDefinitionsBuiltIn = void 0;
|
|
4
4
|
const utils_js_1 = require("../../../../utils.js");
|
|
5
5
|
const getConfigDefinedAt_js_1 = require("../../../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
6
|
-
const
|
|
6
|
+
const configDefinitionsBuiltIn = {
|
|
7
7
|
onRenderHtml: {
|
|
8
8
|
env: { server: true }
|
|
9
9
|
},
|
|
@@ -89,11 +89,14 @@ const configDefinitionsBuiltInAll = {
|
|
|
89
89
|
_computed: (configValueSources) => {
|
|
90
90
|
{
|
|
91
91
|
const source = getConfigValueSource(configValueSources, 'clientHooks');
|
|
92
|
-
if (source
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
if (source) {
|
|
93
|
+
(0, utils_js_1.assert)(source.valueIsLoaded);
|
|
94
|
+
if (source.value !== null) {
|
|
95
|
+
const { value } = source;
|
|
96
|
+
const definedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', source.definedAtFilePath);
|
|
97
|
+
(0, utils_js_1.assertUsage)(typeof value === 'boolean', `${definedAt} should be a boolean`);
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
return (isConfigSet(configValueSources, 'onRenderClient') &&
|
|
@@ -129,8 +132,7 @@ const configDefinitionsBuiltInAll = {
|
|
|
129
132
|
keepScrollPosition: {
|
|
130
133
|
env: { client: true }
|
|
131
134
|
},
|
|
132
|
-
|
|
133
|
-
middleware: { env: { server: true }, cumulative: true, eager: true },
|
|
135
|
+
middleware: { env: { server: true }, cumulative: true, eager: true, global: true },
|
|
134
136
|
onPrerenderStart: {
|
|
135
137
|
env: { server: true, production: true },
|
|
136
138
|
eager: true,
|
|
@@ -157,14 +159,44 @@ const configDefinitionsBuiltInAll = {
|
|
|
157
159
|
'string'
|
|
158
160
|
]
|
|
159
161
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
viteEnvironmentAPI: {
|
|
163
|
+
env: { config: true },
|
|
164
|
+
global: true,
|
|
165
|
+
type: 'boolean'
|
|
166
|
+
},
|
|
167
|
+
includeAssetsImportedByServer: {
|
|
168
|
+
env: { config: true },
|
|
169
|
+
global: true,
|
|
170
|
+
type: 'boolean'
|
|
171
|
+
},
|
|
172
|
+
baseAssets: {
|
|
173
|
+
env: { config: true, server: true },
|
|
174
|
+
global: true,
|
|
175
|
+
type: 'string'
|
|
176
|
+
},
|
|
177
|
+
baseServer: {
|
|
178
|
+
env: { config: true, server: true },
|
|
179
|
+
global: true,
|
|
180
|
+
type: 'string'
|
|
181
|
+
},
|
|
182
|
+
redirects: {
|
|
183
|
+
env: { server: true },
|
|
184
|
+
global: true,
|
|
185
|
+
type: 'string{}',
|
|
186
|
+
cumulative: true
|
|
187
|
+
},
|
|
188
|
+
trailingSlash: {
|
|
189
|
+
env: { server: true },
|
|
190
|
+
global: true,
|
|
191
|
+
type: 'boolean'
|
|
192
|
+
},
|
|
193
|
+
disableUrlNormalization: {
|
|
194
|
+
env: { server: true },
|
|
195
|
+
global: true,
|
|
196
|
+
type: 'boolean'
|
|
197
|
+
}
|
|
166
198
|
};
|
|
167
|
-
exports.
|
|
199
|
+
exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
|
|
168
200
|
function getConfigEnv(configValueSources, configName) {
|
|
169
201
|
const configValueSource = getConfigValueSource(configValueSources, configName);
|
|
170
202
|
if (!configValueSource)
|
|
@@ -178,11 +210,11 @@ function getConfigEnv(configValueSources, configName) {
|
|
|
178
210
|
return env;
|
|
179
211
|
}
|
|
180
212
|
function isConfigSet(configValueSources, configName) {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
213
|
+
const source = getConfigValueSource(configValueSources, configName);
|
|
214
|
+
return (!!source &&
|
|
215
|
+
!(source.valueIsLoaded &&
|
|
216
|
+
// Enable users to suppress inherited config by overriding it with `null`
|
|
217
|
+
source.value === null));
|
|
186
218
|
}
|
|
187
219
|
function getConfigValueSource(configValueSources, configName) {
|
|
188
220
|
const sources = configValueSources[configName];
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getConfigFileExport = getConfigFileExport;
|
|
7
7
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
|
-
const assertPlusFileExport_js_1 = require("
|
|
9
|
-
const utils_js_1 = require("
|
|
8
|
+
const assertPlusFileExport_js_1 = require("../../../../../../shared/page-configs/assertPlusFileExport.js");
|
|
9
|
+
const utils_js_1 = require("../../../../utils.js");
|
|
10
10
|
function getConfigFileExport(fileExports, filePathToShowToUser) {
|
|
11
11
|
(0, assertPlusFileExport_js_1.assertPlusFileExport)(fileExports, filePathToShowToUser, 'config');
|
|
12
12
|
const usesNamedExport = !!fileExports.config;
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
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.getPlusFilesAll = getPlusFilesAll;
|
|
7
|
+
exports.getPlusFileValueConfigName = getPlusFileValueConfigName;
|
|
8
|
+
const utils_js_1 = require("../../../../utils.js");
|
|
9
|
+
const configDefinitionsBuiltIn_js_1 = require("./configDefinitionsBuiltIn.js");
|
|
10
|
+
const filesystemRouting_js_1 = require("./filesystemRouting.js");
|
|
11
|
+
const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
|
|
12
|
+
const crawlPlusFiles_js_1 = require("./crawlPlusFiles.js");
|
|
13
|
+
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
14
|
+
const loadFileAtConfigTime_js_1 = require("./loadFileAtConfigTime.js");
|
|
15
|
+
const resolvePointerImport_js_1 = require("./resolvePointerImport.js");
|
|
16
|
+
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
17
|
+
const assertExtensions_js_1 = require("./assertExtensions.js");
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
19
|
+
async function getPlusFilesAll(userRootDir, esbuildCache) {
|
|
20
|
+
const plusFiles = await findPlusFiles(userRootDir, null);
|
|
21
|
+
const configFiles = [];
|
|
22
|
+
const valueFiles = [];
|
|
23
|
+
plusFiles.forEach((f) => {
|
|
24
|
+
if (getPlusFileValueConfigName(f.filePathAbsoluteFilesystem) === 'config') {
|
|
25
|
+
configFiles.push(f);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
valueFiles.push(f);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
let plusFilesAll = {};
|
|
32
|
+
await Promise.all([
|
|
33
|
+
// Config files
|
|
34
|
+
...configFiles.map(async (filePath) => {
|
|
35
|
+
const { filePathAbsoluteUserRootDir } = filePath;
|
|
36
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
37
|
+
const { configFile, extendsConfigs } = await (0, loadFileAtConfigTime_js_1.loadConfigFile)(filePath, userRootDir, [], false, esbuildCache);
|
|
38
|
+
(0, utils_js_1.assert)(filePath.filePathAbsoluteUserRootDir);
|
|
39
|
+
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir);
|
|
40
|
+
const plusFile = getPlusFileFromConfigFile(configFile, false, locationId, userRootDir);
|
|
41
|
+
plusFilesAll[locationId] = plusFilesAll[locationId] ?? [];
|
|
42
|
+
plusFilesAll[locationId].push(plusFile);
|
|
43
|
+
extendsConfigs.forEach((extendsConfig) => {
|
|
44
|
+
/* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
|
|
45
|
+
```js
|
|
46
|
+
// /pages/admin/+config.js
|
|
47
|
+
|
|
48
|
+
import vikeVue from 'vike-vue/config'
|
|
49
|
+
// Should only apply to /pages/admin/**
|
|
50
|
+
export default { extends: [vikeVue] }
|
|
51
|
+
```
|
|
52
|
+
```js
|
|
53
|
+
// /pages/marketing/+config.js
|
|
54
|
+
|
|
55
|
+
import vikeReact from 'vike-react/config'
|
|
56
|
+
// Should only apply to /pages/marketing/**
|
|
57
|
+
export default { extends: [vikeReact] }
|
|
58
|
+
```
|
|
59
|
+
*/
|
|
60
|
+
const plusFile = getPlusFileFromConfigFile(extendsConfig, true, locationId, userRootDir);
|
|
61
|
+
(0, assertExtensions_js_1.assertExtensionsConventions)(plusFile);
|
|
62
|
+
plusFilesAll[locationId].push(plusFile);
|
|
63
|
+
});
|
|
64
|
+
}),
|
|
65
|
+
// Value files
|
|
66
|
+
...valueFiles.map(async (filePath) => {
|
|
67
|
+
const { filePathAbsoluteUserRootDir } = filePath;
|
|
68
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
69
|
+
const configName = getPlusFileValueConfigName(filePathAbsoluteUserRootDir);
|
|
70
|
+
(0, utils_js_1.assert)(configName);
|
|
71
|
+
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir);
|
|
72
|
+
const plusFile = {
|
|
73
|
+
locationId,
|
|
74
|
+
filePath,
|
|
75
|
+
isConfigFile: false,
|
|
76
|
+
isNotLoaded: true,
|
|
77
|
+
configName
|
|
78
|
+
};
|
|
79
|
+
plusFilesAll[locationId] = plusFilesAll[locationId] ?? [];
|
|
80
|
+
plusFilesAll[locationId].push(plusFile);
|
|
81
|
+
// We don't have access to the custom config definitions defined by the user yet.
|
|
82
|
+
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
83
|
+
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
84
|
+
await (0, loadFileAtConfigTime_js_1.loadValueFile)(plusFile, configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn, userRootDir, esbuildCache);
|
|
85
|
+
})
|
|
86
|
+
]);
|
|
87
|
+
// Make lists element order deterministic
|
|
88
|
+
Object.entries(plusFilesAll).forEach(([_locationId, plusFiles]) => {
|
|
89
|
+
plusFiles.sort(sortMakeDeterministic);
|
|
90
|
+
});
|
|
91
|
+
return plusFilesAll;
|
|
92
|
+
}
|
|
93
|
+
function getPlusFileFromConfigFile(configFile, isExtensionConfig, locationId, userRootDir) {
|
|
94
|
+
const { fileExports, filePath, extendsFilePaths } = configFile;
|
|
95
|
+
const fileExportsByConfigName = {};
|
|
96
|
+
const pointerImportsByConfigName = {};
|
|
97
|
+
const fileExport = (0, getConfigFileExport_js_1.getConfigFileExport)(fileExports, filePath.filePathToShowToUser);
|
|
98
|
+
Object.entries(fileExport).forEach(([configName, configValue]) => {
|
|
99
|
+
fileExportsByConfigName[configName] = configValue;
|
|
100
|
+
const pointerImport = (0, resolvePointerImport_js_1.resolvePointerImport)(configValue, configFile.filePath, userRootDir, configName);
|
|
101
|
+
if (pointerImport) {
|
|
102
|
+
pointerImportsByConfigName[configName] = {
|
|
103
|
+
...pointerImport,
|
|
104
|
+
fileExportValueLoaded: false
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const plusFile = {
|
|
109
|
+
locationId,
|
|
110
|
+
filePath,
|
|
111
|
+
fileExportsByConfigName,
|
|
112
|
+
pointerImportsByConfigName,
|
|
113
|
+
isConfigFile: true,
|
|
114
|
+
isExtensionConfig,
|
|
115
|
+
extendsFilePaths
|
|
116
|
+
};
|
|
117
|
+
return plusFile;
|
|
118
|
+
}
|
|
119
|
+
// Make order deterministic (no other purpose)
|
|
120
|
+
function sortMakeDeterministic(plusFile1, plusFile2) {
|
|
121
|
+
return plusFile1.filePath.filePathAbsoluteVite < plusFile2.filePath.filePathAbsoluteVite ? -1 : 1;
|
|
122
|
+
}
|
|
123
|
+
async function findPlusFiles(userRootDir, outDirRoot) {
|
|
124
|
+
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot);
|
|
125
|
+
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
126
|
+
return plusFiles;
|
|
127
|
+
}
|
|
128
|
+
function getPlusFileValueConfigName(filePath) {
|
|
129
|
+
(0, utils_js_1.assertPosixPath)(filePath);
|
|
130
|
+
if ((0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath))
|
|
131
|
+
return null;
|
|
132
|
+
const fileName = node_path_1.default.posix.basename(filePath);
|
|
133
|
+
// assertNoUnexpectedPlusSign(filePath, fileName)
|
|
134
|
+
const basename = fileName.split('.')[0];
|
|
135
|
+
if (!basename.startsWith('+')) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const configName = basename.slice(1);
|
|
140
|
+
(0, utils_js_1.assertUsage)(configName !== '', `${filePath} Invalid filename ${fileName}`);
|
|
141
|
+
return configName;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/* https://github.com/vikejs/vike/issues/1407
|
|
145
|
+
function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
146
|
+
const dirs = path.posix.dirname(filePath).split('/')
|
|
147
|
+
dirs.forEach((dir, i) => {
|
|
148
|
+
const dirPath = dirs.slice(0, i + 1).join('/')
|
|
149
|
+
assertUsage(
|
|
150
|
+
!dir.includes('+'),
|
|
151
|
+
`Character '+' is a reserved character: remove '+' from the directory name ${dirPath}/`
|
|
152
|
+
)
|
|
153
|
+
})
|
|
154
|
+
assertUsage(
|
|
155
|
+
!fileName.slice(1).includes('+'),
|
|
156
|
+
`Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
*/
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -13,7 +13,7 @@ const getVikeConfig_js_1 = require("../getVikeConfig.js");
|
|
|
13
13
|
const assertPlusFileExport_js_1 = require("../../../../../../shared/page-configs/assertPlusFileExport.js");
|
|
14
14
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
15
|
const transformPointerImports_js_1 = require("./transformPointerImports.js");
|
|
16
|
-
const getConfigFileExport_js_1 = require("
|
|
16
|
+
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
17
17
|
const resolvePointerImport_js_1 = require("./resolvePointerImport.js");
|
|
18
18
|
const getConfigDefinedAt_js_1 = require("../../../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
19
19
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
@@ -41,8 +41,8 @@ async function loadValueFile(interfaceValueFile, configDefinitions, userRootDir,
|
|
|
41
41
|
// Only load value files with `env.config===true`
|
|
42
42
|
if (!configDef || !shouldBeLoadableAtBuildTime(configDef))
|
|
43
43
|
return;
|
|
44
|
-
interfaceValueFile.
|
|
45
|
-
(0, utils_js_1.assert)(interfaceValueFile.
|
|
44
|
+
interfaceValueFile.isNotLoaded = false;
|
|
45
|
+
(0, utils_js_1.assert)(!interfaceValueFile.isNotLoaded);
|
|
46
46
|
interfaceValueFile.fileExportsByConfigName = {};
|
|
47
47
|
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(interfaceValueFile.filePath, userRootDir, false, esbuildCache);
|
|
48
48
|
const { filePathToShowToUser } = interfaceValueFile.filePath;
|