vike 0.4.171 → 0.4.172-commit-c1b0884
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/buildConfig.js +3 -4
- package/dist/cjs/node/plugin/plugins/config/index.js +9 -5
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -1
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +8 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +19 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +43 -85
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +5 -44
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +10 -51
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/cjs/node/plugin/resolveClientEntriesDev.js +59 -0
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +17 -2
- package/dist/cjs/node/prerender/runPrerender.js +35 -15
- package/dist/cjs/node/prerender/utils.js +1 -0
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScripts.js +2 -1
- package/dist/cjs/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- package/dist/cjs/node/runtime/html/renderHtml.js +19 -20
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/cjs/node/runtime/html/stream.js +9 -9
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -8
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +91 -282
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +30 -10
- package/dist/cjs/node/runtime/renderPage.js +24 -17
- package/dist/cjs/node/runtime/utils.js +2 -0
- package/dist/cjs/node/shared/assertV1Design.js +3 -4
- package/dist/cjs/shared/getPageContext.js +5 -0
- package/dist/cjs/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
- package/dist/cjs/shared/getPageFiles/getExports.js +49 -1
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +15 -8
- package/dist/cjs/shared/hooks/executeHook.js +22 -3
- package/dist/cjs/shared/hooks/getHook.js +2 -2
- package/dist/cjs/shared/page-configs/getConfigValue.js +14 -17
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +70 -0
- package/dist/cjs/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -18
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +110 -16
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +198 -0
- package/dist/cjs/shared/route/executeGuardHook.js +1 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/cjs/shared/route/index.js +2 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
- package/dist/cjs/shared/route/resolveRouteFunction.js +2 -2
- package/dist/cjs/shared/sortPageContext.js +4 -8
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/assert.js +3 -3
- package/dist/cjs/utils/assertNodeVersion.js +1 -1
- package/dist/cjs/utils/changeEnumerable.js +9 -0
- package/dist/cjs/utils/escapeHtml.js +14 -0
- package/dist/cjs/utils/getPropAccessNotation.js +1 -4
- package/dist/cjs/utils/hasProp.js +5 -7
- package/dist/cjs/utils/normalizeHeaders.js +13 -0
- package/dist/cjs/utils/objectAssign.js +1 -1
- package/dist/cjs/utils/objectDefineProperty.js +8 -0
- package/dist/cjs/utils/objectKeys.js +8 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +6 -4
- package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -3
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +16 -12
- package/dist/esm/client/client-routing-runtime/installClientRouter.js +18 -10
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +3 -3
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +4 -4
- package/dist/esm/client/server-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/server-routing-runtime/utils.js +1 -0
- package/dist/esm/client/shared/executeOnRenderClientHook.js +1 -1
- package/dist/esm/client/shared/getPageContextProxyForUser.d.ts +3 -2
- package/dist/esm/client/shared/getPageContextProxyForUser.js +35 -48
- package/dist/esm/client/shared/loadUserFilesClientSide.js +4 -4
- package/dist/esm/node/plugin/index.js +3 -0
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -4
- package/dist/esm/node/plugin/plugins/config/index.js +9 -5
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -1
- package/dist/esm/node/plugin/plugins/envVars.js +2 -1
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +14 -0
- package/dist/esm/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +7 -9
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- 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/loadFileAtConfigTime.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +4 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +43 -85
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +5 -44
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +10 -51
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- 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.js +14 -2
- package/dist/esm/node/prerender/runPrerender.js +37 -17
- package/dist/esm/node/prerender/utils.d.ts +1 -0
- package/dist/esm/node/prerender/utils.js +1 -0
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScripts.js +3 -2
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- package/dist/esm/node/runtime/html/renderHtml.js +19 -20
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/esm/node/runtime/html/stream.d.ts +1 -1
- package/dist/esm/node/runtime/html/stream.js +9 -9
- package/dist/esm/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -8
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- 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/loadUserFilesServerSide.d.ts +1 -6
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/esm/node/runtime/renderPage/logErrorHint.d.ts +2 -6
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +92 -283
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +65 -39
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +31 -11
- package/dist/esm/node/runtime/renderPage.js +24 -17
- package/dist/esm/node/runtime/utils.d.ts +2 -0
- package/dist/esm/node/runtime/utils.js +2 -0
- package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
- package/dist/esm/node/shared/assertV1Design.js +3 -4
- package/dist/esm/shared/ConfigVike.d.ts +7 -0
- package/dist/esm/shared/VikeNamespace.d.ts +9 -0
- package/dist/esm/shared/getPageContext.d.ts +1 -0
- package/dist/esm/shared/getPageContext.js +1 -0
- package/dist/esm/shared/{addUrlComputedProps.d.ts → getPageContextUrlComputed.d.ts} +23 -21
- package/dist/esm/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/getPageFiles/getExports.d.ts +36 -0
- package/dist/esm/shared/getPageFiles/getExports.js +50 -2
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +14 -7
- package/dist/esm/shared/hooks/executeHook.d.ts +10 -1
- package/dist/esm/shared/hooks/executeHook.js +21 -2
- package/dist/esm/shared/hooks/getHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.js +3 -3
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +2 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +14 -8
- package/dist/esm/shared/page-configs/getConfigValue.d.ts +12 -12
- package/dist/esm/shared/page-configs/getConfigValue.js +13 -16
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +9 -0
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +67 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +17 -21
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.d.ts +1 -5
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -16
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +4 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +109 -15
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +5 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +192 -0
- package/dist/esm/shared/route/executeGuardHook.js +1 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/index.js +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +3 -3
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
- package/dist/esm/shared/route/resolveRouteFunction.js +2 -2
- package/dist/esm/shared/sortPageContext.js +4 -8
- package/dist/esm/shared/types.d.ts +32 -6
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/assert.js +3 -3
- package/dist/esm/utils/assertNodeVersion.js +1 -1
- package/dist/esm/utils/changeEnumerable.d.ts +2 -0
- package/dist/esm/utils/changeEnumerable.js +5 -0
- package/dist/esm/utils/escapeHtml.d.ts +1 -0
- package/dist/esm/utils/escapeHtml.js +10 -0
- package/dist/esm/utils/getPropAccessNotation.d.ts +1 -2
- package/dist/esm/utils/getPropAccessNotation.js +2 -6
- package/dist/esm/utils/hasProp.d.ts +4 -13
- package/dist/esm/utils/hasProp.js +5 -7
- package/dist/esm/utils/normalizeHeaders.d.ts +1 -0
- package/dist/esm/utils/normalizeHeaders.js +9 -0
- package/dist/esm/utils/objectAssign.js +1 -1
- package/dist/esm/utils/objectDefineProperty.d.ts +4 -0
- package/dist/esm/utils/objectDefineProperty.js +4 -0
- package/dist/esm/utils/objectKeys.d.ts +1 -3
- package/dist/esm/utils/objectKeys.js +8 -4
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +23 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -76
- package/dist/cjs/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -14
- package/dist/cjs/node/shared/getClientEntry.js +0 -12
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +0 -85
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -24
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +0 -50
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +0 -16
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -70
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.d.ts +0 -5
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -11
- package/dist/esm/node/shared/getClientEntry.d.ts +0 -3
- package/dist/esm/node/shared/getClientEntry.js +0 -9
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +0 -82
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -21
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +0 -8
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +0 -47
|
@@ -2,7 +2,6 @@ export { determineOptimizeDeps };
|
|
|
2
2
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
3
3
|
import { assert, assertIsNpmPackageImport, createDebugger, isArray, unique } from '../../utils.js';
|
|
4
4
|
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
5
|
-
import { getConfigValueSourcesNotOverriden } from '../../shared/getConfigValueSourcesNotOverriden.js';
|
|
6
5
|
import { analyzeClientEntries } from '../buildConfig.js';
|
|
7
6
|
import { virtualFileIdImportUserCodeClientCR, virtualFileIdImportUserCodeClientSR } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
8
7
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
@@ -45,20 +44,24 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
45
44
|
// V1 design
|
|
46
45
|
{
|
|
47
46
|
pageConfigs.forEach((pageConfig) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
Object.values(pageConfig.configValueSources).forEach((sources) => {
|
|
48
|
+
sources
|
|
49
|
+
.filter((c) => !c.isOverriden)
|
|
50
|
+
.forEach((configValueSource) => {
|
|
51
|
+
if (!configValueSource.valueIsImportedAtRuntime)
|
|
52
|
+
return;
|
|
53
|
+
const { definedAtFilePath, configEnv } = configValueSource;
|
|
54
|
+
if (!configEnv.client)
|
|
55
|
+
return;
|
|
56
|
+
if (definedAtFilePath.filePathAbsoluteUserRootDir !== null) {
|
|
57
|
+
// Vite expects entries to be filesystem absolute paths (surprisingly so).
|
|
58
|
+
addEntry(definedAtFilePath.filePathAbsoluteFilesystem);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Adding definedAtFilePath.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
62
|
+
addInclude(definedAtFilePath.importPathAbsolute);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
62
65
|
});
|
|
63
66
|
});
|
|
64
67
|
}
|
|
@@ -73,7 +73,8 @@ function devConfig() {
|
|
|
73
73
|
configureServer: {
|
|
74
74
|
order: 'post',
|
|
75
75
|
handler(server) {
|
|
76
|
-
|
|
76
|
+
const hasHonoViteDevServer = !!config.plugins.find((p) => p.name === '@hono/vite-dev-server');
|
|
77
|
+
if (config.server.middlewareMode || hasHonoViteDevServer)
|
|
77
78
|
return;
|
|
78
79
|
return () => {
|
|
79
80
|
addSsrMiddleware(server.middlewares);
|
|
@@ -50,7 +50,8 @@ function envVarsPlugin() {
|
|
|
50
50
|
assertUsage(false, errMsg);
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
|
-
// Only a warning for faster development DX (e.g. when user toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`)
|
|
53
|
+
// - Only a warning for faster development DX (e.g. when user toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`).
|
|
54
|
+
// - But only showing a warning can be confusing: https://github.com/vikejs/vike/issues/1641
|
|
54
55
|
assertWarning(false, errMsg, { onlyOnce: true });
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -101,7 +101,7 @@ function extractAssetsPlugin() {
|
|
|
101
101
|
}
|
|
102
102
|
// If the import path resolves to a file in `node_modules/`, we ignore that file:
|
|
103
103
|
// - Direct CSS dependencies are included though, such as `import 'bootstrap/theme/dark.css'`. (Because the above if-branch for CSS files will add the file.)
|
|
104
|
-
// - Loading CSS from a library (living in `node_modules/`) in a non-direct way is
|
|
104
|
+
// - Loading CSS from a library (living in `node_modules/`) in a non-direct way is unconventional; we can safely not support this case. (I'm not aware of any library that does this.)
|
|
105
105
|
assertPosixPath(file);
|
|
106
106
|
if (file.includes('/node_modules/')) {
|
|
107
107
|
return emptyModule(file, importer);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { addImportStatement };
|
|
2
|
+
/**
|
|
3
|
+
* Naming:
|
|
4
|
+
* `import { someExport as someImport } from './some-file'`
|
|
5
|
+
* <=>
|
|
6
|
+
* `{`
|
|
7
|
+
* `importPath: './some-file',`
|
|
8
|
+
* `exportName: 'someExport',`
|
|
9
|
+
* `importName: 'someImport',`
|
|
10
|
+
* `}`
|
|
11
|
+
*/
|
|
12
|
+
declare function addImportStatement(importStatements: string[], importPath: string, exportName: string): {
|
|
13
|
+
importName: string;
|
|
14
|
+
};
|
package/dist/esm/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js}
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
let varCounterGlobal = 0;
|
|
1
|
+
export { addImportStatement };
|
|
3
2
|
/**
|
|
4
3
|
* Naming:
|
|
5
4
|
* `import { someExport as someImport } from './some-file'`
|
|
@@ -9,14 +8,12 @@ let varCounterGlobal = 0;
|
|
|
9
8
|
* `exportName: 'someExport',`
|
|
10
9
|
* `importName: 'someImport',`
|
|
11
10
|
* `}`
|
|
12
|
-
* We discard the information that the import variable is called `someImport` because we don't need it.
|
|
13
11
|
*/
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const importName = `import_${varCounter}`;
|
|
12
|
+
function addImportStatement(importStatements, importPath, exportName) {
|
|
13
|
+
const importCounter = importStatements.length + 1;
|
|
14
|
+
const importName = `import${importCounter}`;
|
|
18
15
|
const importLiteral = (() => {
|
|
19
|
-
if (
|
|
16
|
+
if (exportName === '*') {
|
|
20
17
|
return `* as ${importName}`;
|
|
21
18
|
}
|
|
22
19
|
if (exportName === 'default') {
|
|
@@ -25,5 +22,6 @@ function generateEagerImport(importPath, varCounter, exportName) {
|
|
|
25
22
|
return `{ ${exportName} as ${importName} }`;
|
|
26
23
|
})();
|
|
27
24
|
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
28
|
-
|
|
25
|
+
importStatements.push(importStatement);
|
|
26
|
+
return { importName };
|
|
29
27
|
}
|
|
@@ -63,7 +63,6 @@ export const pageFilesExportNamesLazy = {};
|
|
|
63
63
|
export const pageFilesExportNamesEager = {};
|
|
64
64
|
export const pageFilesList = [];
|
|
65
65
|
export const neverLoaded = {};
|
|
66
|
-
export const isGeneratedFile = true;
|
|
67
66
|
|
|
68
67
|
${await getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config)}
|
|
69
68
|
|
|
@@ -56,7 +56,8 @@ type ConfigDefinitionInternal = Omit<ConfigDefinition, 'env'> & {
|
|
|
56
56
|
_userEffectDefinedAtFilePath?: DefinedAtFilePath;
|
|
57
57
|
env: ConfigEnvInternal;
|
|
58
58
|
};
|
|
59
|
-
type ConfigDefinitions = Record<string,
|
|
59
|
+
type ConfigDefinitions = Record<string, // configName
|
|
60
|
+
ConfigDefinitionInternal>;
|
|
60
61
|
type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn, ConfigDefinitionInternal>;
|
|
61
62
|
declare const configDefinitionsBuiltIn: ConfigDefinitionsBuiltIn;
|
|
62
63
|
type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization';
|
|
@@ -21,7 +21,7 @@ const configDefinitionsBuiltIn = {
|
|
|
21
21
|
env: { server: true }
|
|
22
22
|
},
|
|
23
23
|
onBeforePrerenderStart: {
|
|
24
|
-
env: { server: true }
|
|
24
|
+
env: { server: true, production: true }
|
|
25
25
|
},
|
|
26
26
|
Page: {
|
|
27
27
|
env: { server: true, client: true }
|
|
@@ -47,7 +47,7 @@ const configDefinitionsBuiltIn = {
|
|
|
47
47
|
},
|
|
48
48
|
client: {
|
|
49
49
|
// The value of the client config is merely the file path to the client entry file, which is only needed on the sever-side
|
|
50
|
-
env: { server: true },
|
|
50
|
+
env: { server: true, config: true },
|
|
51
51
|
_valueIsFilePath: true
|
|
52
52
|
},
|
|
53
53
|
clientRouting: {
|
|
@@ -95,7 +95,7 @@ const configDefinitionsBuiltIn = {
|
|
|
95
95
|
};
|
|
96
96
|
const configDefinitionsBuiltInGlobal = {
|
|
97
97
|
onPrerenderStart: {
|
|
98
|
-
env: { server: true }
|
|
98
|
+
env: { server: true, production: true }
|
|
99
99
|
},
|
|
100
100
|
onBeforeRoute: {
|
|
101
101
|
env: { server: true, client: 'if-client-routing', eager: true }
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
declare function crawlPlusFiles(userRootDir: string, outDirAbsoluteFilesystem: string, isDev: boolean): Promise<{
|
|
2
|
+
declare function crawlPlusFiles(userRootDir: string, outDirAbsoluteFilesystem: string, isDev: boolean, crawlWithGit: null | boolean): Promise<{
|
|
3
3
|
filePathAbsoluteUserRootDir: string;
|
|
4
4
|
}[]>;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
import { assertPosixPath, assert,
|
|
2
|
+
import { assertPosixPath, assert, assertWarning, scriptFileExtensionList, scriptFileExtensions, humanizeTime, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove } from '../../../../utils.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import glob from 'fast-glob';
|
|
5
5
|
import { exec } from 'child_process';
|
|
@@ -10,7 +10,7 @@ const execA = promisify(exec);
|
|
|
10
10
|
assertIsNotProductionRuntime();
|
|
11
11
|
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
12
12
|
let gitIsNotUsable = false;
|
|
13
|
-
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
13
|
+
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, crawlWithGit) {
|
|
14
14
|
assertPosixPath(userRootDir);
|
|
15
15
|
assertPosixPath(outDirAbsoluteFilesystem);
|
|
16
16
|
let outDirRelativeFromUserRootDir = path.posix.relative(userRootDir, outDirAbsoluteFilesystem);
|
|
@@ -26,8 +26,9 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
26
26
|
//
|
|
27
27
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
28
28
|
const timeBefore = new Date().getTime();
|
|
29
|
+
// Crawl
|
|
29
30
|
let files = [];
|
|
30
|
-
const res = await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir);
|
|
31
|
+
const res = crawlWithGit !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
31
32
|
if (res &&
|
|
32
33
|
// 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`.)
|
|
33
34
|
res.length > 0) {
|
|
@@ -36,7 +37,9 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
36
37
|
else {
|
|
37
38
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
38
39
|
}
|
|
40
|
+
// Filter build files
|
|
39
41
|
files = files.filter((file) => !isTemporaryBuildFile(file));
|
|
42
|
+
// Check performance
|
|
40
43
|
{
|
|
41
44
|
const timeAfter = new Date().getTime();
|
|
42
45
|
const timeSpent = timeAfter - timeBefore;
|
|
@@ -48,10 +51,12 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
// Normalize
|
|
55
|
+
const plusFiles = files.map((filePath) => {
|
|
56
|
+
// Both `$ git-ls files` and fast-glob return posix paths
|
|
57
|
+
assertPosixPath(filePath);
|
|
58
|
+
assert(!filePath.startsWith(userRootDir));
|
|
59
|
+
const filePathAbsoluteUserRootDir = path.posix.join('/', filePath);
|
|
55
60
|
return { filePathAbsoluteUserRootDir };
|
|
56
61
|
});
|
|
57
62
|
return plusFiles;
|
|
@@ -60,10 +65,17 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
60
65
|
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
61
66
|
if (gitIsNotUsable)
|
|
62
67
|
return null;
|
|
68
|
+
// Preserve UTF-8 file paths.
|
|
69
|
+
// https://github.com/vikejs/vike/issues/1658
|
|
70
|
+
// https://stackoverflow.com/questions/22827239/how-to-make-git-properly-display-utf-8-encoded-pathnames-in-the-console-window/22828826#22828826
|
|
71
|
+
// https://stackoverflow.com/questions/15884180/how-do-i-override-git-configuration-options-by-command-line-parameters/15884261#15884261
|
|
72
|
+
const preserveUTF8 = '-c core.quotepath=off';
|
|
63
73
|
const ignoreAsPatterns = getIgnoreAsPatterns(outDirRelativeFromUserRootDir);
|
|
64
74
|
const ignoreAsFilterFn = getIgnoreAsFilterFn(outDirRelativeFromUserRootDir);
|
|
65
75
|
const cmd = [
|
|
66
|
-
'git
|
|
76
|
+
'git',
|
|
77
|
+
preserveUTF8,
|
|
78
|
+
'ls-files',
|
|
67
79
|
...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
68
80
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
69
81
|
// --others lists untracked files only (but using .gitignore because --exclude-standard)
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -10,7 +10,7 @@ import { parsePointerImportData } from './transformFileImports.js';
|
|
|
10
10
|
import { getConfigFileExport } from '../getConfigFileExport.js';
|
|
11
11
|
import { resolvePointerImport } from './resolvePointerImport.js';
|
|
12
12
|
assertIsNotProductionRuntime();
|
|
13
|
-
// Load
|
|
13
|
+
// Load pointer import
|
|
14
14
|
async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
15
15
|
const f = import_.filePathAbsoluteFilesystem;
|
|
16
16
|
if (!importedFilesLoaded[f]) {
|
|
@@ -30,7 +30,7 @@ async function loadValueFile(interfaceValueFile, configName, userRootDir) {
|
|
|
30
30
|
interfaceValueFile.fileExportsByConfigName[configName_] = { configValue };
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
// Load +config.js, including all its extends
|
|
33
|
+
// Load +config.js, including all its extends pointer imports
|
|
34
34
|
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig) {
|
|
35
35
|
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
36
36
|
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
@@ -29,6 +29,9 @@ type VikeConfigObject = {
|
|
|
29
29
|
};
|
|
30
30
|
declare const vikeConfigDependencies: Set<string>;
|
|
31
31
|
declare function reloadVikeConfig(userRootDir: string, outDirRoot: string): void;
|
|
32
|
-
declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, tolerateInvalidConfig?:
|
|
32
|
+
declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, { crawlWithGit, tolerateInvalidConfig }?: {
|
|
33
|
+
crawlWithGit?: null | boolean;
|
|
34
|
+
tolerateInvalidConfig?: true;
|
|
35
|
+
}): Promise<VikeConfigObject>;
|
|
33
36
|
declare function isV1Design(config: ResolvedConfig, isDev: boolean): Promise<boolean>;
|
|
34
37
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
@@ -14,12 +14,13 @@ import { logConfigError, logConfigErrorRecover } from '../../../shared/loggerNot
|
|
|
14
14
|
import { removeSuperfluousViteLog_enable, removeSuperfluousViteLog_disable } from '../../../shared/loggerVite/removeSuperfluousViteLog.js';
|
|
15
15
|
import pc from '@brillout/picocolors';
|
|
16
16
|
import { getConfigDefinedAt } from '../../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
17
|
-
import { assertConfigValueIsSerializable } from './getConfigValuesSerialized.js';
|
|
18
17
|
import { crawlPlusFiles } from './getVikeConfig/crawlPlusFiles.js';
|
|
19
18
|
import { getConfigFileExport } from './getConfigFileExport.js';
|
|
20
19
|
import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig/loadFileAtConfigTime.js';
|
|
21
20
|
import { clearFilesEnvMap, resolvePointerImportOfConfig } from './getVikeConfig/resolvePointerImport.js';
|
|
22
21
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
22
|
+
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
23
|
+
import { getConfigVike } from '../../../../shared/getConfigVike.js';
|
|
23
24
|
assertIsNotProductionRuntime();
|
|
24
25
|
let devServerIsCorrupt = false;
|
|
25
26
|
let wasConfigInvalid = null;
|
|
@@ -62,11 +63,12 @@ async function handleReloadSideEffects() {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
async function getVikeConfig(config, isDev, tolerateInvalidConfig) {
|
|
66
|
+
async function getVikeConfig(config, isDev, { crawlWithGit, tolerateInvalidConfig } = {}) {
|
|
66
67
|
const { outDirRoot } = getOutDirs(config);
|
|
67
68
|
const userRootDir = config.root;
|
|
68
69
|
if (!vikeConfigPromise) {
|
|
69
|
-
|
|
70
|
+
const crawlWithGit_ = crawlWithGit !== undefined ? crawlWithGit : (await getConfigVike(config)).crawl.git;
|
|
71
|
+
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit_, tolerateInvalidConfig);
|
|
70
72
|
}
|
|
71
73
|
return await vikeConfigPromise;
|
|
72
74
|
}
|
|
@@ -76,8 +78,8 @@ async function isV1Design(config, isDev) {
|
|
|
76
78
|
const isV1Design = pageConfigs.length > 0;
|
|
77
79
|
return isV1Design;
|
|
78
80
|
}
|
|
79
|
-
async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
80
|
-
const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev);
|
|
81
|
+
async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
82
|
+
const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
81
83
|
const configFiles = [];
|
|
82
84
|
const valueFiles = [];
|
|
83
85
|
plusFiles.forEach((f) => {
|
|
@@ -166,7 +168,7 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
166
168
|
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
167
169
|
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
168
170
|
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
|
|
169
|
-
if (configDef &&
|
|
171
|
+
if (configDef && isLoadableAtBuildTime(configDef)) {
|
|
170
172
|
await loadValueFile(interfaceFile, configName, userRootDir);
|
|
171
173
|
}
|
|
172
174
|
}
|
|
@@ -208,12 +210,12 @@ function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
|
|
|
208
210
|
});
|
|
209
211
|
});
|
|
210
212
|
}
|
|
211
|
-
async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, tolerateInvalidConfig) {
|
|
213
|
+
async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit, tolerateInvalidConfig) {
|
|
212
214
|
let hasError = false;
|
|
213
215
|
let ret;
|
|
214
216
|
let err;
|
|
215
217
|
try {
|
|
216
|
-
ret = await loadVikeConfig(userRootDir, outDirRoot, isDev);
|
|
218
|
+
ret = await loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
217
219
|
}
|
|
218
220
|
catch (err_) {
|
|
219
221
|
hasError = true;
|
|
@@ -241,6 +243,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
241
243
|
const dummyData = {
|
|
242
244
|
pageConfigs: [],
|
|
243
245
|
pageConfigGlobal: {
|
|
246
|
+
configDefinitions: {},
|
|
244
247
|
configValueSources: {}
|
|
245
248
|
},
|
|
246
249
|
globalVikeConfig: {}
|
|
@@ -249,8 +252,8 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
|
-
async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
253
|
-
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev);
|
|
255
|
+
async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
256
|
+
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
254
257
|
const importedFilesLoaded = {};
|
|
255
258
|
const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
|
|
256
259
|
const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
|
|
@@ -266,7 +269,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
266
269
|
if (isGlobalConfig(configName))
|
|
267
270
|
return;
|
|
268
271
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
269
|
-
if (!
|
|
272
|
+
if (!isLoadableAtBuildTime(configDef))
|
|
270
273
|
return;
|
|
271
274
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
272
275
|
if (isAlreadyLoaded)
|
|
@@ -288,14 +291,13 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
288
291
|
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
|
|
289
292
|
applyEffectsAll(configValueSources, configDefinitions);
|
|
290
293
|
const configValuesComputed = getComputed(configValueSources, configDefinitions);
|
|
291
|
-
const configValues = getConfigValues(configValueSources, configValuesComputed, configDefinitions);
|
|
292
294
|
const pageConfig = {
|
|
293
295
|
pageId: locationId,
|
|
294
296
|
isErrorPage,
|
|
295
297
|
routeFilesystem,
|
|
298
|
+
configDefinitions,
|
|
296
299
|
configValueSources,
|
|
297
|
-
configValuesComputed
|
|
298
|
-
configValues
|
|
300
|
+
configValuesComputed
|
|
299
301
|
};
|
|
300
302
|
return pageConfig;
|
|
301
303
|
}));
|
|
@@ -328,7 +330,7 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
328
330
|
if (!onBeforeRenderConfig)
|
|
329
331
|
return;
|
|
330
332
|
const onBeforeRenderEnv = onBeforeRenderConfig.configEnv;
|
|
331
|
-
const isClientRouting =
|
|
333
|
+
const isClientRouting = getConfigValueBuildTime(pageConfig, 'clientRouting', 'boolean');
|
|
332
334
|
// When using Server Routing, loading a onBeforeRender() hook on the client-side hasn't any effect (the Server Routing's client runtime never calls it); it unnecessarily bloats client bundle sizes
|
|
333
335
|
assertUsage(!(onBeforeRenderEnv.client && !isClientRouting), `Page ${pageConfig.pageId} has an onBeforeRender() hook with env ${pc.cyan(JSON.stringify(onBeforeRenderEnv))} which doesn't make sense because the page is using Server Routing: onBeforeRender() can be run in the client only when using Client Routing.`);
|
|
334
336
|
}
|
|
@@ -389,6 +391,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
389
391
|
}
|
|
390
392
|
const globalVikeConfig = {};
|
|
391
393
|
const pageConfigGlobal = {
|
|
394
|
+
configDefinitions: configDefinitionsBuiltInGlobal,
|
|
392
395
|
configValueSources: {}
|
|
393
396
|
};
|
|
394
397
|
await Promise.all(objectEntries(configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
|
|
@@ -422,7 +425,15 @@ async function resolveConfigValueSources(configName, configDef, interfaceFilesRe
|
|
|
422
425
|
const add = (interfaceFile) => {
|
|
423
426
|
assert(!visited.has(interfaceFile));
|
|
424
427
|
visited.add(interfaceFile);
|
|
425
|
-
sourcesInfo.
|
|
428
|
+
const isHighestInheritancePrecedence = sourcesInfo.length === 0;
|
|
429
|
+
sourcesInfo.push([
|
|
430
|
+
configName,
|
|
431
|
+
interfaceFile,
|
|
432
|
+
configDef,
|
|
433
|
+
userRootDir,
|
|
434
|
+
importedFilesLoaded,
|
|
435
|
+
isHighestInheritancePrecedence
|
|
436
|
+
]);
|
|
426
437
|
};
|
|
427
438
|
// Main resolution logic
|
|
428
439
|
{
|
|
@@ -493,7 +504,7 @@ function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden,
|
|
|
493
504
|
function isInterfaceFileUserLand(interfaceFile) {
|
|
494
505
|
return (interfaceFile.isConfigFile && !interfaceFile.isConfigExtend) || interfaceFile.isValueFile;
|
|
495
506
|
}
|
|
496
|
-
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded) {
|
|
507
|
+
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded, isHighestInheritancePrecedence) {
|
|
497
508
|
const conf = interfaceFile.fileExportsByConfigName[configName];
|
|
498
509
|
assert(conf);
|
|
499
510
|
const configEnv = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
|
|
@@ -502,6 +513,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
502
513
|
...interfaceFile.filePath,
|
|
503
514
|
fileExportPathToShowToUser: ['default', configName]
|
|
504
515
|
};
|
|
516
|
+
const isOverriden = configDef.cumulative ? false : !isHighestInheritancePrecedence;
|
|
505
517
|
// +client.js
|
|
506
518
|
if (configDef._valueIsFilePath) {
|
|
507
519
|
let definedAtFilePath;
|
|
@@ -528,7 +540,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
528
540
|
valueIsFilePath: true,
|
|
529
541
|
configEnv,
|
|
530
542
|
valueIsImportedAtRuntime: true,
|
|
531
|
-
|
|
543
|
+
valueIsDefinedByPlusFile: false,
|
|
544
|
+
isOverriden,
|
|
532
545
|
definedAtFilePath
|
|
533
546
|
};
|
|
534
547
|
return configValueSource;
|
|
@@ -544,11 +557,12 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
544
557
|
locationId,
|
|
545
558
|
configEnv,
|
|
546
559
|
valueIsImportedAtRuntime: true,
|
|
547
|
-
|
|
560
|
+
valueIsDefinedByPlusFile: false,
|
|
561
|
+
isOverriden,
|
|
548
562
|
definedAtFilePath: pointerImport
|
|
549
563
|
};
|
|
550
|
-
// Load
|
|
551
|
-
if (
|
|
564
|
+
// Load pointer import
|
|
565
|
+
if (isLoadableAtBuildTime(configDef) &&
|
|
552
566
|
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
553
567
|
configName !== 'extends') {
|
|
554
568
|
if (pointerImport.filePathAbsoluteFilesystem) {
|
|
@@ -568,7 +582,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
568
582
|
value: configValue,
|
|
569
583
|
configEnv,
|
|
570
584
|
valueIsImportedAtRuntime: false,
|
|
571
|
-
|
|
585
|
+
valueIsDefinedByPlusFile: false,
|
|
586
|
+
isOverriden,
|
|
572
587
|
definedAtFilePath: definedAtFilePath_
|
|
573
588
|
};
|
|
574
589
|
return configValueSource;
|
|
@@ -581,7 +596,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
581
596
|
locationId,
|
|
582
597
|
configEnv,
|
|
583
598
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
584
|
-
|
|
599
|
+
valueIsDefinedByPlusFile: true,
|
|
600
|
+
isOverriden,
|
|
585
601
|
definedAtFilePath: {
|
|
586
602
|
...interfaceFile.filePath,
|
|
587
603
|
fileExportPathToShowToUser: configName === interfaceFile.configName
|
|
@@ -751,8 +767,8 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
751
767
|
});
|
|
752
768
|
return configValuesComputed;
|
|
753
769
|
}
|
|
754
|
-
async function findPlusFiles(userRootDir, outDirRoot, isDev) {
|
|
755
|
-
const files = await crawlPlusFiles(userRootDir, outDirRoot, isDev);
|
|
770
|
+
async function findPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
771
|
+
const files = await crawlPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
756
772
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
757
773
|
return plusFiles;
|
|
758
774
|
}
|
|
@@ -876,59 +892,6 @@ function determineIsErrorPage(routeFilesystem) {
|
|
|
876
892
|
function isVikeConfigFile(filePath) {
|
|
877
893
|
return !!getConfigName(filePath);
|
|
878
894
|
}
|
|
879
|
-
function getConfigValues(configValueSources, configValuesComputed, configDefinitions) {
|
|
880
|
-
const configValues = {};
|
|
881
|
-
Object.entries(configValuesComputed).forEach(([configName, configValueComputed]) => {
|
|
882
|
-
configValues[configName] = {
|
|
883
|
-
type: 'computed',
|
|
884
|
-
value: configValueComputed.value,
|
|
885
|
-
definedAtData: null
|
|
886
|
-
};
|
|
887
|
-
});
|
|
888
|
-
Object.entries(configValueSources).forEach(([configName, sources]) => {
|
|
889
|
-
const configDef = configDefinitions[configName];
|
|
890
|
-
assert(configDef);
|
|
891
|
-
if (!configDef.cumulative) {
|
|
892
|
-
const configValueSource = sources[0];
|
|
893
|
-
if ('value' in configValueSource) {
|
|
894
|
-
configValues[configName] = {
|
|
895
|
-
type: 'classic',
|
|
896
|
-
value: configValueSource.value,
|
|
897
|
-
definedAtData: getDefinedAtFile(configValueSource)
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
else {
|
|
902
|
-
const value = mergeCumulative(configName, sources);
|
|
903
|
-
const definedAtData = sources.map((source) => getDefinedAtFile(source));
|
|
904
|
-
assert(value.length === definedAtData.length);
|
|
905
|
-
configValues[configName] = {
|
|
906
|
-
type: 'cumulative',
|
|
907
|
-
value,
|
|
908
|
-
definedAtData
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
return configValues;
|
|
913
|
-
}
|
|
914
|
-
function getDefinedAtFile(configValueSource) {
|
|
915
|
-
return {
|
|
916
|
-
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
917
|
-
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
function mergeCumulative(configName, configValueSources) {
|
|
921
|
-
const configValues = [];
|
|
922
|
-
configValueSources.forEach((configValueSource) => {
|
|
923
|
-
// We could, in principle, also support cumulative for values that aren't loaded at config-time but it isn't completely trivial to implement.
|
|
924
|
-
assert('value' in configValueSource);
|
|
925
|
-
// Make sure configValueSource.value is serializable
|
|
926
|
-
assertConfigValueIsSerializable(configValueSource.value, configName, getDefinedAtFile(configValueSource));
|
|
927
|
-
const { value } = configValueSource;
|
|
928
|
-
configValues.push(value);
|
|
929
|
-
});
|
|
930
|
-
return configValues;
|
|
931
|
-
}
|
|
932
895
|
function getConfigEnvValue(val, errMsgIntro) {
|
|
933
896
|
const errInvalidValue = `${errMsgIntro} an invalid value ${pc.cyan(JSON.stringify(val))}`;
|
|
934
897
|
// Legacy outdated values
|
|
@@ -971,13 +934,8 @@ function getConfigDefinition(configDefinitions, configName, filePathToShowToUser
|
|
|
971
934
|
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
972
935
|
return configDefinitions[configName] ?? null;
|
|
973
936
|
}
|
|
974
|
-
function
|
|
975
|
-
|
|
976
|
-
if (configDef.cumulative) {
|
|
977
|
-
// In principle we could lift that requirement (but it requires non-trivial modifications)
|
|
978
|
-
assertUsage(configEnv.config, `Config ${pc.cyan(configName)} needs its ${pc.cyan('env')} to have ${pc.cyan('{ config: true }')} (because ${pc.cyan(configName)} is a ${pc.cyan('cumulative')} config)`);
|
|
979
|
-
}
|
|
980
|
-
return !!configEnv.config;
|
|
937
|
+
function isLoadableAtBuildTime(configDef) {
|
|
938
|
+
return !!configDef.env.config && !configDef._valueIsFilePath;
|
|
981
939
|
}
|
|
982
940
|
function isGlobalConfig(configName) {
|
|
983
941
|
if (configName === 'prerender')
|