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
|
@@ -4,7 +4,7 @@ import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/vir
|
|
|
4
4
|
import { version as viteVersion } from 'vite';
|
|
5
5
|
import { fileTypes } from '../../../../shared/getPageFiles/fileTypes.js';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import { getVirtualFilePageConfigs } from './v1-design/getVirtualFilePageConfigs.js';
|
|
7
|
+
import { getVirtualFilePageConfigs } from './v1-design/virtual-files/getVirtualFilePageConfigs.js';
|
|
8
8
|
import { isV1Design as isV1Design_ } from './v1-design/getVikeConfig.js';
|
|
9
9
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
10
10
|
import { viteIsSSR_options } from '../../shared/viteIsSSR.js';
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export { importUserCode };
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
|
-
import { getVirtualFilePageConfigValuesAll } from './v1-design/getVirtualFilePageConfigValuesAll.js';
|
|
3
|
+
import { getVirtualFilePageConfigValuesAll } from './v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js';
|
|
4
4
|
import { getVirtualFileImportUserCode } from './getVirtualFileImportUserCode.js';
|
|
5
5
|
import { assert, assertPosixPath } from '../../utils.js';
|
|
6
6
|
import { resolveVirtualFileId, isVirtualFileId, getVirtualFileId } from '../../../shared/virtual-files.js';
|
|
7
7
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
8
8
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
9
|
-
import { vikeConfigDependencies, reloadVikeConfig,
|
|
9
|
+
import { vikeConfigDependencies, reloadVikeConfig, isV1Design, getVikeConfig } from './v1-design/getVikeConfig.js';
|
|
10
10
|
import pc from '@brillout/picocolors';
|
|
11
11
|
import { logConfigInfo } from '../../shared/loggerNotProd.js';
|
|
12
12
|
import { getModuleFilePathAbsolute } from '../../shared/getFilePath.js';
|
|
13
|
+
import { getPlusFileValueConfigName } from './v1-design/getVikeConfig/getPlusFilesAll.js';
|
|
14
|
+
import { updateUserFiles } from '../../../runtime/globalContext.js';
|
|
13
15
|
function importUserCode() {
|
|
14
16
|
let config;
|
|
15
17
|
let vikeConfig;
|
|
@@ -118,6 +120,7 @@ function reloadConfig(filePath, config, op) {
|
|
|
118
120
|
logConfigInfo(msg, 'info');
|
|
119
121
|
}
|
|
120
122
|
reloadVikeConfig(config);
|
|
123
|
+
updateUserFiles();
|
|
121
124
|
}
|
|
122
125
|
function getVirtualModules(server) {
|
|
123
126
|
const virtualModules = Array.from(server.moduleGraph.urlToModuleMap.keys())
|
|
@@ -129,3 +132,6 @@ function getVirtualModules(server) {
|
|
|
129
132
|
});
|
|
130
133
|
return virtualModules;
|
|
131
134
|
}
|
|
135
|
+
function isVikeConfigFile(filePath) {
|
|
136
|
+
return !!getPlusFileValueConfigName(filePath);
|
|
137
|
+
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { assertExtensionsConventions };
|
|
2
|
+
export { assertExtensionsRequire };
|
|
3
|
+
import type { PlusFile } from './getPlusFilesAll.js';
|
|
4
|
+
import { PageConfigBuildTime } from '../../../../../../shared/page-configs/PageConfig.js';
|
|
5
|
+
declare function assertExtensionsConventions(plusFile: PlusFile): void;
|
|
6
|
+
declare function assertExtensionsRequire(pageConfig: PageConfigBuildTime): void;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
export { assertExtensionsConventions };
|
|
2
2
|
export { assertExtensionsRequire };
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
|
-
import { isObjectOfStrings } from '
|
|
5
|
-
import { PROJECT_VERSION, assert, assertUsage, assertWarning, findPackageJson } from '
|
|
6
|
-
import { getConfVal } from '
|
|
4
|
+
import { isObjectOfStrings } from '../../../../../../utils/isObjectOfStrings.js';
|
|
5
|
+
import { PROJECT_VERSION, assert, assertUsage, assertWarning, findPackageJson } from '../../../../utils.js';
|
|
6
|
+
import { getConfVal } from '../getVikeConfig.js';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import semver from 'semver';
|
|
9
|
-
function assertExtensionsConventions(
|
|
10
|
-
assertExtensionName(
|
|
11
|
-
assertConfigExportPath(
|
|
9
|
+
function assertExtensionsConventions(plusFile) {
|
|
10
|
+
assertExtensionName(plusFile);
|
|
11
|
+
assertConfigExportPath(plusFile);
|
|
12
12
|
}
|
|
13
|
-
function assertConfigExportPath(
|
|
14
|
-
const { importPathAbsolute, filePathAbsoluteFilesystem } =
|
|
13
|
+
function assertConfigExportPath(plusFile) {
|
|
14
|
+
const { importPathAbsolute, filePathAbsoluteFilesystem } = plusFile.filePath;
|
|
15
15
|
// Ejected Vike extension
|
|
16
16
|
if (!importPathAbsolute) {
|
|
17
17
|
const p = filePathAbsoluteFilesystem;
|
|
18
18
|
assert(!p.includes('node_modules'));
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const name = getNameValue(
|
|
21
|
+
const name = getNameValue(plusFile);
|
|
22
22
|
assert(name); // already asserted in assertExtensionName()
|
|
23
23
|
const importPathAbsoluteExpected = `${name}/config`;
|
|
24
24
|
assertWarning(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${pc.bold(name)} is exported at ${pc.bold(importPathAbsolute)}, but it should be exported at ${pc.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
25
25
|
}
|
|
26
|
-
function assertExtensionName(
|
|
27
|
-
const filePathToShowToUser = getFilePathToShowToUser(
|
|
28
|
-
const name = getNameValue(
|
|
26
|
+
function assertExtensionName(plusFile) {
|
|
27
|
+
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
28
|
+
const name = getNameValue(plusFile);
|
|
29
29
|
assertUsage(name, `Vike extension name missing: the config ${filePathToShowToUser} must define the setting ${pc.cyan('name')}`);
|
|
30
30
|
}
|
|
31
31
|
function assertExtensionsRequire(pageConfig) {
|
|
32
|
-
const
|
|
32
|
+
const plusFilesRelevantList = Object.values(pageConfig.plusFiles).flat(1);
|
|
33
33
|
// Collect extensions
|
|
34
34
|
const extensions = {};
|
|
35
|
-
|
|
36
|
-
const name = getNameValue(
|
|
35
|
+
plusFilesRelevantList.forEach((plusFile) => {
|
|
36
|
+
const name = getNameValue(plusFile);
|
|
37
37
|
if (name) {
|
|
38
|
-
const version = getExtensionVersion(name,
|
|
38
|
+
const version = getExtensionVersion(name, plusFile);
|
|
39
39
|
extensions[name] = version;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
// Enforce `require`
|
|
43
|
-
|
|
44
|
-
const require = getConfigRequireValue(
|
|
43
|
+
plusFilesRelevantList.forEach((plusFile) => {
|
|
44
|
+
const require = getConfigRequireValue(plusFile);
|
|
45
45
|
if (!require)
|
|
46
46
|
return;
|
|
47
|
-
const name = getNameValue(
|
|
48
|
-
const filePathToShowToUser = getFilePathToShowToUser(
|
|
47
|
+
const name = getNameValue(plusFile);
|
|
48
|
+
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
49
49
|
assertUsage(name, `Setting ${pc.bold('name')} is required for being able to use setting ${pc.bold('require')} in ${filePathToShowToUser}.`);
|
|
50
50
|
Object.entries(require).forEach(([reqName, reqVersion]) => {
|
|
51
51
|
const errBase = `${pc.bold(name)} requires ${pc.bold(reqName)}`;
|
|
@@ -59,36 +59,36 @@ function assertExtensionsRequire(pageConfig) {
|
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
function getConfigRequireValue(
|
|
63
|
-
const confVal = getConfVal(
|
|
62
|
+
function getConfigRequireValue(plusFile) {
|
|
63
|
+
const confVal = getConfVal(plusFile, 'require');
|
|
64
64
|
if (!confVal)
|
|
65
65
|
return null;
|
|
66
66
|
assert(confVal.configValueLoaded);
|
|
67
67
|
const require = confVal.configValue;
|
|
68
|
-
const { filePathToShowToUserResolved } =
|
|
68
|
+
const { filePathToShowToUserResolved } = plusFile.filePath;
|
|
69
69
|
assert(filePathToShowToUserResolved);
|
|
70
70
|
assertUsage(isObjectOfStrings(require), `The setting ${pc.bold('require')} defined at ${filePathToShowToUserResolved} should be an object with string values (${pc.bold('Record<string, string>')}).`);
|
|
71
71
|
return require;
|
|
72
72
|
}
|
|
73
|
-
function getNameValue(
|
|
74
|
-
const confVal = getConfVal(
|
|
73
|
+
function getNameValue(plusFile) {
|
|
74
|
+
const confVal = getConfVal(plusFile, 'name');
|
|
75
75
|
if (!confVal)
|
|
76
76
|
return null;
|
|
77
77
|
assert(confVal.configValueLoaded);
|
|
78
78
|
const name = confVal.configValue;
|
|
79
|
-
const filePathToShowToUser = getFilePathToShowToUser(
|
|
79
|
+
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
80
80
|
assertUsage(typeof name === 'string', `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} should be a string.`);
|
|
81
81
|
return name;
|
|
82
82
|
}
|
|
83
83
|
// 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).
|
|
84
84
|
const extensionsVersion = {};
|
|
85
|
-
function getExtensionVersion(name,
|
|
85
|
+
function getExtensionVersion(name, plusFile) {
|
|
86
86
|
if (!extensionsVersion[name]) {
|
|
87
|
-
const extensionConfigFilePath =
|
|
87
|
+
const extensionConfigFilePath = plusFile.filePath.filePathAbsoluteFilesystem;
|
|
88
88
|
const found = findPackageJson(path.posix.dirname(extensionConfigFilePath));
|
|
89
89
|
assert(found);
|
|
90
90
|
const { packageJson, packageJsonPath } = found;
|
|
91
|
-
const filePathToShowToUser = getFilePathToShowToUser(
|
|
91
|
+
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
92
92
|
const nameExpected = packageJson.name;
|
|
93
93
|
assertWarning(name === nameExpected, `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} is ${pc.bold(JSON.stringify(name))}, but it should be equal to ${pc.bold(JSON.stringify(nameExpected))} (the value of ${packageJsonPath}${pc.dim('#')}${pc.bold('name')})`, { onlyOnce: true });
|
|
94
94
|
const { version } = packageJson;
|
|
@@ -97,8 +97,8 @@ function getExtensionVersion(name, interfaceFile) {
|
|
|
97
97
|
}
|
|
98
98
|
return extensionsVersion[name];
|
|
99
99
|
}
|
|
100
|
-
function getFilePathToShowToUser(
|
|
101
|
-
const { filePathToShowToUserResolved } =
|
|
100
|
+
function getFilePathToShowToUser(plusFile) {
|
|
101
|
+
const { filePathToShowToUserResolved } = plusFile.filePath;
|
|
102
102
|
assert(filePathToShowToUserResolved);
|
|
103
103
|
return filePathToShowToUserResolved;
|
|
104
104
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { configDefinitionsBuiltIn };
|
|
2
2
|
export type { ConfigDefinition };
|
|
3
3
|
export type { ConfigDefinitions };
|
|
4
4
|
export type { ConfigDefinitionInternal };
|
|
@@ -74,4 +74,4 @@ type ConfigDefinitionInternal = Omit<ConfigDefinition, 'env'> & {
|
|
|
74
74
|
type ConfigDefinitions = Record<string, // configName
|
|
75
75
|
ConfigDefinitionInternal>;
|
|
76
76
|
type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn | ConfigNameGlobal, ConfigDefinitionInternal>;
|
|
77
|
-
declare const
|
|
77
|
+
declare const configDefinitionsBuiltIn: ConfigDefinitionsBuiltIn;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { configDefinitionsBuiltIn };
|
|
2
2
|
import { assert, assertUsage } from '../../../../utils.js';
|
|
3
3
|
import { getConfigDefinedAt } from '../../../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
4
|
-
const
|
|
4
|
+
const configDefinitionsBuiltIn = {
|
|
5
5
|
onRenderHtml: {
|
|
6
6
|
env: { server: true }
|
|
7
7
|
},
|
|
@@ -87,11 +87,14 @@ const configDefinitionsBuiltInAll = {
|
|
|
87
87
|
_computed: (configValueSources) => {
|
|
88
88
|
{
|
|
89
89
|
const source = getConfigValueSource(configValueSources, 'clientHooks');
|
|
90
|
-
if (source
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
if (source) {
|
|
91
|
+
assert(source.valueIsLoaded);
|
|
92
|
+
if (source.value !== null) {
|
|
93
|
+
const { value } = source;
|
|
94
|
+
const definedAt = getConfigDefinedAt('Config', 'clientHooks', source.definedAtFilePath);
|
|
95
|
+
assertUsage(typeof value === 'boolean', `${definedAt} should be a boolean`);
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
return (isConfigSet(configValueSources, 'onRenderClient') &&
|
|
@@ -127,8 +130,7 @@ const configDefinitionsBuiltInAll = {
|
|
|
127
130
|
keepScrollPosition: {
|
|
128
131
|
env: { client: true }
|
|
129
132
|
},
|
|
130
|
-
|
|
131
|
-
middleware: { env: { server: true }, cumulative: true, eager: true },
|
|
133
|
+
middleware: { env: { server: true }, cumulative: true, eager: true, global: true },
|
|
132
134
|
onPrerenderStart: {
|
|
133
135
|
env: { server: true, production: true },
|
|
134
136
|
eager: true,
|
|
@@ -155,12 +157,42 @@ const configDefinitionsBuiltInAll = {
|
|
|
155
157
|
'string'
|
|
156
158
|
]
|
|
157
159
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
viteEnvironmentAPI: {
|
|
161
|
+
env: { config: true },
|
|
162
|
+
global: true,
|
|
163
|
+
type: 'boolean'
|
|
164
|
+
},
|
|
165
|
+
includeAssetsImportedByServer: {
|
|
166
|
+
env: { config: true },
|
|
167
|
+
global: true,
|
|
168
|
+
type: 'boolean'
|
|
169
|
+
},
|
|
170
|
+
baseAssets: {
|
|
171
|
+
env: { config: true, server: true },
|
|
172
|
+
global: true,
|
|
173
|
+
type: 'string'
|
|
174
|
+
},
|
|
175
|
+
baseServer: {
|
|
176
|
+
env: { config: true, server: true },
|
|
177
|
+
global: true,
|
|
178
|
+
type: 'string'
|
|
179
|
+
},
|
|
180
|
+
redirects: {
|
|
181
|
+
env: { server: true },
|
|
182
|
+
global: true,
|
|
183
|
+
type: 'string{}',
|
|
184
|
+
cumulative: true
|
|
185
|
+
},
|
|
186
|
+
trailingSlash: {
|
|
187
|
+
env: { server: true },
|
|
188
|
+
global: true,
|
|
189
|
+
type: 'boolean'
|
|
190
|
+
},
|
|
191
|
+
disableUrlNormalization: {
|
|
192
|
+
env: { server: true },
|
|
193
|
+
global: true,
|
|
194
|
+
type: 'boolean'
|
|
195
|
+
}
|
|
164
196
|
};
|
|
165
197
|
function getConfigEnv(configValueSources, configName) {
|
|
166
198
|
const configValueSource = getConfigValueSource(configValueSources, configName);
|
|
@@ -175,11 +207,11 @@ function getConfigEnv(configValueSources, configName) {
|
|
|
175
207
|
return env;
|
|
176
208
|
}
|
|
177
209
|
function isConfigSet(configValueSources, configName) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
210
|
+
const source = getConfigValueSource(configValueSources, configName);
|
|
211
|
+
return (!!source &&
|
|
212
|
+
!(source.valueIsLoaded &&
|
|
213
|
+
// Enable users to suppress inherited config by overriding it with `null`
|
|
214
|
+
source.value === null));
|
|
183
215
|
}
|
|
184
216
|
function getConfigValueSource(configValueSources, configName) {
|
|
185
217
|
const sources = configValueSources[configName];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getConfigFileExport };
|
|
2
2
|
import pc from '@brillout/picocolors';
|
|
3
|
-
import { assertPlusFileExport } from '
|
|
4
|
-
import { assertUsage, isObject } from '
|
|
3
|
+
import { assertPlusFileExport } from '../../../../../../shared/page-configs/assertPlusFileExport.js';
|
|
4
|
+
import { assertUsage, isObject } from '../../../../utils.js';
|
|
5
5
|
function getConfigFileExport(fileExports, filePathToShowToUser) {
|
|
6
6
|
assertPlusFileExport(fileExports, filePathToShowToUser, 'config');
|
|
7
7
|
const usesNamedExport = !!fileExports.config;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export { getPlusFilesAll };
|
|
2
|
+
export { getPlusFileValueConfigName };
|
|
3
|
+
export type { PlusFileValue };
|
|
4
|
+
export type { PlusFile };
|
|
5
|
+
export type { PlusFilesByLocationId };
|
|
6
|
+
import { type LocationId } from './filesystemRouting.js';
|
|
7
|
+
import { type EsbuildCache } from './transpileAndExecuteFile.js';
|
|
8
|
+
import { PointerImportLoaded } from './loadFileAtConfigTime.js';
|
|
9
|
+
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
10
|
+
type PlusFile = PlusFileConfig | PlusFileValue;
|
|
11
|
+
type PlusFileCommons = {
|
|
12
|
+
locationId: LocationId;
|
|
13
|
+
filePath: FilePathResolved;
|
|
14
|
+
};
|
|
15
|
+
type PlusFileConfig = PlusFileCommons & {
|
|
16
|
+
isConfigFile: true;
|
|
17
|
+
fileExportsByConfigName: Record<string, // configName
|
|
18
|
+
unknown>;
|
|
19
|
+
pointerImportsByConfigName: Record<string, // configName
|
|
20
|
+
PointerImportLoaded>;
|
|
21
|
+
isExtensionConfig: boolean;
|
|
22
|
+
extendsFilePaths: string[];
|
|
23
|
+
isNotLoaded?: undefined;
|
|
24
|
+
};
|
|
25
|
+
type PlusFileValue = PlusFileCommons & {
|
|
26
|
+
isConfigFile: false;
|
|
27
|
+
configName: string;
|
|
28
|
+
} & ({
|
|
29
|
+
isNotLoaded: false;
|
|
30
|
+
fileExportsByConfigName: Record<string, // configName
|
|
31
|
+
unknown>;
|
|
32
|
+
} | {
|
|
33
|
+
isNotLoaded: true;
|
|
34
|
+
}) & {
|
|
35
|
+
isExtensionConfig?: undefined;
|
|
36
|
+
};
|
|
37
|
+
type PlusFilesByLocationId = Record<LocationId, PlusFile[]>;
|
|
38
|
+
declare function getPlusFilesAll(userRootDir: string, esbuildCache: EsbuildCache): Promise<PlusFilesByLocationId>;
|
|
39
|
+
declare function getPlusFileValueConfigName(filePath: string): string | null;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export { getPlusFilesAll };
|
|
2
|
+
export { getPlusFileValueConfigName };
|
|
3
|
+
import { assert, assertPosixPath, assertUsage } from '../../../../utils.js';
|
|
4
|
+
import { configDefinitionsBuiltIn } from './configDefinitionsBuiltIn.js';
|
|
5
|
+
import { getLocationId } from './filesystemRouting.js';
|
|
6
|
+
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
7
|
+
import { crawlPlusFiles } from './crawlPlusFiles.js';
|
|
8
|
+
import { getConfigFileExport } from './getConfigFileExport.js';
|
|
9
|
+
import { loadConfigFile, loadValueFile } from './loadFileAtConfigTime.js';
|
|
10
|
+
import { resolvePointerImport } from './resolvePointerImport.js';
|
|
11
|
+
import { getFilePathResolved } from '../../../../shared/getFilePath.js';
|
|
12
|
+
import { assertExtensionsConventions } from './assertExtensions.js';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
async function getPlusFilesAll(userRootDir, esbuildCache) {
|
|
15
|
+
const plusFiles = await findPlusFiles(userRootDir, null);
|
|
16
|
+
const configFiles = [];
|
|
17
|
+
const valueFiles = [];
|
|
18
|
+
plusFiles.forEach((f) => {
|
|
19
|
+
if (getPlusFileValueConfigName(f.filePathAbsoluteFilesystem) === 'config') {
|
|
20
|
+
configFiles.push(f);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
valueFiles.push(f);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
let plusFilesAll = {};
|
|
27
|
+
await Promise.all([
|
|
28
|
+
// Config files
|
|
29
|
+
...configFiles.map(async (filePath) => {
|
|
30
|
+
const { filePathAbsoluteUserRootDir } = filePath;
|
|
31
|
+
assert(filePathAbsoluteUserRootDir);
|
|
32
|
+
const { configFile, extendsConfigs } = await loadConfigFile(filePath, userRootDir, [], false, esbuildCache);
|
|
33
|
+
assert(filePath.filePathAbsoluteUserRootDir);
|
|
34
|
+
const locationId = getLocationId(filePathAbsoluteUserRootDir);
|
|
35
|
+
const plusFile = getPlusFileFromConfigFile(configFile, false, locationId, userRootDir);
|
|
36
|
+
plusFilesAll[locationId] = plusFilesAll[locationId] ?? [];
|
|
37
|
+
plusFilesAll[locationId].push(plusFile);
|
|
38
|
+
extendsConfigs.forEach((extendsConfig) => {
|
|
39
|
+
/* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
|
|
40
|
+
```js
|
|
41
|
+
// /pages/admin/+config.js
|
|
42
|
+
|
|
43
|
+
import vikeVue from 'vike-vue/config'
|
|
44
|
+
// Should only apply to /pages/admin/**
|
|
45
|
+
export default { extends: [vikeVue] }
|
|
46
|
+
```
|
|
47
|
+
```js
|
|
48
|
+
// /pages/marketing/+config.js
|
|
49
|
+
|
|
50
|
+
import vikeReact from 'vike-react/config'
|
|
51
|
+
// Should only apply to /pages/marketing/**
|
|
52
|
+
export default { extends: [vikeReact] }
|
|
53
|
+
```
|
|
54
|
+
*/
|
|
55
|
+
const plusFile = getPlusFileFromConfigFile(extendsConfig, true, locationId, userRootDir);
|
|
56
|
+
assertExtensionsConventions(plusFile);
|
|
57
|
+
plusFilesAll[locationId].push(plusFile);
|
|
58
|
+
});
|
|
59
|
+
}),
|
|
60
|
+
// Value files
|
|
61
|
+
...valueFiles.map(async (filePath) => {
|
|
62
|
+
const { filePathAbsoluteUserRootDir } = filePath;
|
|
63
|
+
assert(filePathAbsoluteUserRootDir);
|
|
64
|
+
const configName = getPlusFileValueConfigName(filePathAbsoluteUserRootDir);
|
|
65
|
+
assert(configName);
|
|
66
|
+
const locationId = getLocationId(filePathAbsoluteUserRootDir);
|
|
67
|
+
const plusFile = {
|
|
68
|
+
locationId,
|
|
69
|
+
filePath,
|
|
70
|
+
isConfigFile: false,
|
|
71
|
+
isNotLoaded: true,
|
|
72
|
+
configName
|
|
73
|
+
};
|
|
74
|
+
plusFilesAll[locationId] = plusFilesAll[locationId] ?? [];
|
|
75
|
+
plusFilesAll[locationId].push(plusFile);
|
|
76
|
+
// We don't have access to the custom config definitions defined by the user yet.
|
|
77
|
+
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
78
|
+
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
79
|
+
await loadValueFile(plusFile, configDefinitionsBuiltIn, userRootDir, esbuildCache);
|
|
80
|
+
})
|
|
81
|
+
]);
|
|
82
|
+
// Make lists element order deterministic
|
|
83
|
+
Object.entries(plusFilesAll).forEach(([_locationId, plusFiles]) => {
|
|
84
|
+
plusFiles.sort(sortMakeDeterministic);
|
|
85
|
+
});
|
|
86
|
+
return plusFilesAll;
|
|
87
|
+
}
|
|
88
|
+
function getPlusFileFromConfigFile(configFile, isExtensionConfig, locationId, userRootDir) {
|
|
89
|
+
const { fileExports, filePath, extendsFilePaths } = configFile;
|
|
90
|
+
const fileExportsByConfigName = {};
|
|
91
|
+
const pointerImportsByConfigName = {};
|
|
92
|
+
const fileExport = getConfigFileExport(fileExports, filePath.filePathToShowToUser);
|
|
93
|
+
Object.entries(fileExport).forEach(([configName, configValue]) => {
|
|
94
|
+
fileExportsByConfigName[configName] = configValue;
|
|
95
|
+
const pointerImport = resolvePointerImport(configValue, configFile.filePath, userRootDir, configName);
|
|
96
|
+
if (pointerImport) {
|
|
97
|
+
pointerImportsByConfigName[configName] = {
|
|
98
|
+
...pointerImport,
|
|
99
|
+
fileExportValueLoaded: false
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const plusFile = {
|
|
104
|
+
locationId,
|
|
105
|
+
filePath,
|
|
106
|
+
fileExportsByConfigName,
|
|
107
|
+
pointerImportsByConfigName,
|
|
108
|
+
isConfigFile: true,
|
|
109
|
+
isExtensionConfig,
|
|
110
|
+
extendsFilePaths
|
|
111
|
+
};
|
|
112
|
+
return plusFile;
|
|
113
|
+
}
|
|
114
|
+
// Make order deterministic (no other purpose)
|
|
115
|
+
function sortMakeDeterministic(plusFile1, plusFile2) {
|
|
116
|
+
return plusFile1.filePath.filePathAbsoluteVite < plusFile2.filePath.filePathAbsoluteVite ? -1 : 1;
|
|
117
|
+
}
|
|
118
|
+
async function findPlusFiles(userRootDir, outDirRoot) {
|
|
119
|
+
const files = await crawlPlusFiles(userRootDir, outDirRoot);
|
|
120
|
+
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
121
|
+
return plusFiles;
|
|
122
|
+
}
|
|
123
|
+
function getPlusFileValueConfigName(filePath) {
|
|
124
|
+
assertPosixPath(filePath);
|
|
125
|
+
if (isTemporaryBuildFile(filePath))
|
|
126
|
+
return null;
|
|
127
|
+
const fileName = path.posix.basename(filePath);
|
|
128
|
+
// assertNoUnexpectedPlusSign(filePath, fileName)
|
|
129
|
+
const basename = fileName.split('.')[0];
|
|
130
|
+
if (!basename.startsWith('+')) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const configName = basename.slice(1);
|
|
135
|
+
assertUsage(configName !== '', `${filePath} Invalid filename ${fileName}`);
|
|
136
|
+
return configName;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/* https://github.com/vikejs/vike/issues/1407
|
|
140
|
+
function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
141
|
+
const dirs = path.posix.dirname(filePath).split('/')
|
|
142
|
+
dirs.forEach((dir, i) => {
|
|
143
|
+
const dirPath = dirs.slice(0, i + 1).join('/')
|
|
144
|
+
assertUsage(
|
|
145
|
+
!dir.includes('+'),
|
|
146
|
+
`Character '+' is a reserved character: remove '+' from the directory name ${dirPath}/`
|
|
147
|
+
)
|
|
148
|
+
})
|
|
149
|
+
assertUsage(
|
|
150
|
+
!fileName.slice(1).includes('+'),
|
|
151
|
+
`Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
*/
|
|
@@ -5,7 +5,7 @@ export type { ConfigFile };
|
|
|
5
5
|
export type { PointerImportLoaded };
|
|
6
6
|
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
7
7
|
import { type EsbuildCache } from './transpileAndExecuteFile.js';
|
|
8
|
-
import {
|
|
8
|
+
import type { PlusFileValue } from './getPlusFilesAll.js';
|
|
9
9
|
import { PointerImport } from './resolvePointerImport.js';
|
|
10
10
|
import type { ConfigDefinitions } from './configDefinitionsBuiltIn.js';
|
|
11
11
|
type ConfigFile = {
|
|
@@ -20,7 +20,7 @@ type PointerImportLoaded = PointerImport & ({
|
|
|
20
20
|
} | {
|
|
21
21
|
fileExportValueLoaded: false;
|
|
22
22
|
});
|
|
23
|
-
declare function loadValueFile(interfaceValueFile:
|
|
23
|
+
declare function loadValueFile(interfaceValueFile: PlusFileValue, configDefinitions: ConfigDefinitions, userRootDir: string, esbuildCache: EsbuildCache): Promise<void>;
|
|
24
24
|
declare function loadConfigFile(configFilePath: FilePathResolved, userRootDir: string, visited: string[], isExtensionConfig: boolean, esbuildCache: EsbuildCache): Promise<{
|
|
25
25
|
configFile: ConfigFile;
|
|
26
26
|
extendsConfigs: ConfigFile[];
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -8,7 +8,7 @@ import { getConfigDefinitionOptional } from '../getVikeConfig.js';
|
|
|
8
8
|
import { assertPlusFileExport } from '../../../../../../shared/page-configs/assertPlusFileExport.js';
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
10
|
import { parsePointerImportData } from './transformPointerImports.js';
|
|
11
|
-
import { getConfigFileExport } from '
|
|
11
|
+
import { getConfigFileExport } from './getConfigFileExport.js';
|
|
12
12
|
import { resolvePointerImportData } from './resolvePointerImport.js';
|
|
13
13
|
import { getConfigDefinedAt } from '../../../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
14
14
|
assertIsNotProductionRuntime();
|
|
@@ -36,8 +36,8 @@ async function loadValueFile(interfaceValueFile, configDefinitions, userRootDir,
|
|
|
36
36
|
// Only load value files with `env.config===true`
|
|
37
37
|
if (!configDef || !shouldBeLoadableAtBuildTime(configDef))
|
|
38
38
|
return;
|
|
39
|
-
interfaceValueFile.
|
|
40
|
-
assert(interfaceValueFile.
|
|
39
|
+
interfaceValueFile.isNotLoaded = false;
|
|
40
|
+
assert(!interfaceValueFile.isNotLoaded);
|
|
41
41
|
interfaceValueFile.fileExportsByConfigName = {};
|
|
42
42
|
const { fileExports } = await transpileAndExecuteFile(interfaceValueFile.filePath, userRootDir, false, esbuildCache);
|
|
43
43
|
const { filePathToShowToUser } = interfaceValueFile.filePath;
|
|
@@ -2,50 +2,15 @@ export { getVikeConfig };
|
|
|
2
2
|
export { getVikeConfig2 };
|
|
3
3
|
export { reloadVikeConfig };
|
|
4
4
|
export { vikeConfigDependencies };
|
|
5
|
-
export { isVikeConfigFile };
|
|
6
5
|
export { isV1Design };
|
|
7
6
|
export { getConfVal };
|
|
8
7
|
export { getConfigDefinitionOptional };
|
|
9
8
|
export type { VikeConfigObject };
|
|
10
|
-
export type { InterfaceValueFile };
|
|
11
|
-
export type { InterfaceFile };
|
|
12
|
-
export type { InterfaceFilesByLocationId };
|
|
13
9
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
14
10
|
import { type ConfigDefinitions, type ConfigDefinitionInternal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
15
|
-
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
16
11
|
import type { ResolvedConfig } from 'vite';
|
|
17
|
-
import { type PointerImportLoaded } from './getVikeConfig/loadFileAtConfigTime.js';
|
|
18
|
-
import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
|
|
19
12
|
import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
20
|
-
type
|
|
21
|
-
type InterfaceFileCommons = {
|
|
22
|
-
locationId: LocationId;
|
|
23
|
-
filePath: FilePathResolved;
|
|
24
|
-
};
|
|
25
|
-
type InterfaceConfigFile = InterfaceFileCommons & {
|
|
26
|
-
isConfigFile: true;
|
|
27
|
-
isValueFile: false;
|
|
28
|
-
extendsFilePaths: string[];
|
|
29
|
-
isConfigExtension: boolean;
|
|
30
|
-
isValueFileLoaded: true;
|
|
31
|
-
fileExportsByConfigName: Record<string, // configName
|
|
32
|
-
unknown>;
|
|
33
|
-
pointerImportsByConfigName: Record<string, // configValue
|
|
34
|
-
PointerImportLoaded>;
|
|
35
|
-
};
|
|
36
|
-
type InterfaceValueFile = InterfaceFileCommons & {
|
|
37
|
-
isConfigFile: false;
|
|
38
|
-
isValueFile: true;
|
|
39
|
-
isConfigExtension?: undefined;
|
|
40
|
-
configName: string;
|
|
41
|
-
} & ({
|
|
42
|
-
isValueFileLoaded: true;
|
|
43
|
-
fileExportsByConfigName: Record<string, // configName
|
|
44
|
-
unknown>;
|
|
45
|
-
} | {
|
|
46
|
-
isValueFileLoaded: false;
|
|
47
|
-
});
|
|
48
|
-
type InterfaceFilesByLocationId = Record<LocationId, InterfaceFile[]>;
|
|
13
|
+
import { type PlusFile } from './getVikeConfig/getPlusFilesAll.js';
|
|
49
14
|
type VikeConfigObject = {
|
|
50
15
|
pageConfigs: PageConfigBuildTime[];
|
|
51
16
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
@@ -58,9 +23,8 @@ declare function getVikeConfig(config: ResolvedConfig, { doNotRestartViteOnError
|
|
|
58
23
|
}): Promise<VikeConfigObject>;
|
|
59
24
|
declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePluginOptions: unknown): Promise<VikeConfigObject>;
|
|
60
25
|
declare function isV1Design(config: ResolvedConfig): Promise<boolean>;
|
|
61
|
-
declare function isVikeConfigFile(filePath: string): boolean;
|
|
62
26
|
declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitions, configName: string): ConfigDefinitionInternal | null;
|
|
63
|
-
declare function getConfVal(
|
|
27
|
+
declare function getConfVal(plusFile: PlusFile, configName: string): null | {
|
|
64
28
|
configValue: unknown;
|
|
65
29
|
configValueLoaded: true;
|
|
66
30
|
} | {
|