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
|
@@ -28,9 +28,12 @@ const baseUrls_js_1 = require("./plugins/baseUrls.js");
|
|
|
28
28
|
const envVars_js_1 = require("./plugins/envVars.js");
|
|
29
29
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
30
30
|
const fileEnv_js_1 = require("./plugins/fileEnv.js");
|
|
31
|
+
const getPageAssets_js_1 = require("../runtime/renderPage/getPageAssets.js");
|
|
32
|
+
const resolveClientEntriesDev_js_1 = require("./resolveClientEntriesDev.js");
|
|
31
33
|
(0, utils_js_2.assertNodeEnv_onVikePluginLoad)();
|
|
32
34
|
(0, utils_js_2.markEnvAsVikePluginLoaded)();
|
|
33
35
|
assertViteVersion();
|
|
36
|
+
(0, getPageAssets_js_1.setResolveClientEntriesDev)(resolveClientEntriesDev_js_1.resolveClientEntriesDev);
|
|
34
37
|
// Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
|
|
35
38
|
function plugin(vikeConfig) {
|
|
36
39
|
const plugins = [
|
|
@@ -6,19 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.manifestTempFile = exports.analyzeClientEntries = exports.assertRollupInput = exports.buildConfig = void 0;
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
8
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
9
|
-
const getConfigValue_js_1 = require("../../../shared/page-configs/getConfigValue.js");
|
|
10
9
|
const findPageFiles_js_1 = require("../shared/findPageFiles.js");
|
|
11
10
|
const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
12
11
|
const virtualFilePageConfigValuesAll_js_1 = require("../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
13
12
|
const extractAssetsQuery_js_1 = require("../../shared/extractAssetsQuery.js");
|
|
14
13
|
const module_1 = require("module");
|
|
15
|
-
const getClientEntry_js_1 = require("../../shared/getClientEntry.js");
|
|
16
14
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
15
|
const path_1 = __importDefault(require("path"));
|
|
18
16
|
const fixServerAssets_js_1 = require("./buildConfig/fixServerAssets.js");
|
|
19
17
|
const index_js_1 = require("./importBuild/index.js");
|
|
20
18
|
const prependEntriesDir_js_1 = require("../../shared/prependEntriesDir.js");
|
|
21
19
|
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
20
|
+
const getConfigValueBuildTime_js_1 = require("../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
22
21
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
23
22
|
const importMetaUrl = `file://${__filename}`;
|
|
24
23
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
@@ -156,7 +155,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
156
155
|
let clientEntries = {};
|
|
157
156
|
let clientEntryList = [];
|
|
158
157
|
pageConfigs.forEach((pageConfig) => {
|
|
159
|
-
const configValue = (0,
|
|
158
|
+
const configValue = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'clientRouting', 'boolean');
|
|
160
159
|
if (configValue?.value) {
|
|
161
160
|
hasClientRouting = true;
|
|
162
161
|
}
|
|
@@ -169,7 +168,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
169
168
|
clientEntries[entryName] = entryTarget;
|
|
170
169
|
}
|
|
171
170
|
{
|
|
172
|
-
const clientEntry = (0,
|
|
171
|
+
const clientEntry = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'client', 'string')?.value ?? null;
|
|
173
172
|
if (clientEntry) {
|
|
174
173
|
clientEntryList.push(clientEntry);
|
|
175
174
|
}
|
|
@@ -26,15 +26,16 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
26
26
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
27
27
|
const fromViteConfig = (config.vike ?? {});
|
|
28
28
|
const configs = [fromPluginOptions, fromViteConfig];
|
|
29
|
-
|
|
29
|
+
(0, assertVikeConfig_js_1.assertVikeConfig)(fromViteConfig, ({ prop, errMsg }) => `vite.config.js#vike.${prop} ${errMsg}`);
|
|
30
|
+
// TODO/v1-release: deprecate this
|
|
31
|
+
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
32
|
+
const crawlWithGit = fromPluginOptions.crawl?.git ?? null;
|
|
33
|
+
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config), { crawlWithGit });
|
|
30
34
|
configs.push(fromPlusConfigFile);
|
|
31
35
|
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
32
36
|
// TODO: add config file path ?
|
|
33
37
|
return `config ${picocolors_1.default.cyan(prop)} ${errMsg}`;
|
|
34
38
|
});
|
|
35
|
-
(0, assertVikeConfig_js_1.assertVikeConfig)(fromViteConfig, ({ prop, errMsg }) => `vite.config.js#vike.${prop} ${errMsg}`);
|
|
36
|
-
// TODO/v1-release: deprecate this
|
|
37
|
-
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
38
39
|
const { baseServer, baseAssets } = (0, resolveBase_js_1.resolveBase)(configs, config);
|
|
39
40
|
const configVike = {
|
|
40
41
|
disableAutoFullBuild: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
@@ -44,7 +45,10 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
44
45
|
baseAssets,
|
|
45
46
|
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
46
47
|
disableUrlNormalization: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
47
|
-
trailingSlash: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.trailingSlash)) ?? false
|
|
48
|
+
trailingSlash: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.trailingSlash)) ?? false,
|
|
49
|
+
crawl: {
|
|
50
|
+
git: crawlWithGit
|
|
51
|
+
}
|
|
48
52
|
};
|
|
49
53
|
return configVike;
|
|
50
54
|
}
|
|
@@ -4,7 +4,6 @@ exports.determineOptimizeDeps = void 0;
|
|
|
4
4
|
const findPageFiles_js_1 = require("../../shared/findPageFiles.js");
|
|
5
5
|
const utils_js_1 = require("../../utils.js");
|
|
6
6
|
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
7
|
-
const getConfigValueSourcesNotOverriden_js_1 = require("../../shared/getConfigValueSourcesNotOverriden.js");
|
|
8
7
|
const buildConfig_js_1 = require("../buildConfig.js");
|
|
9
8
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
10
9
|
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
@@ -48,20 +47,24 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
48
47
|
// V1 design
|
|
49
48
|
{
|
|
50
49
|
pageConfigs.forEach((pageConfig) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
Object.values(pageConfig.configValueSources).forEach((sources) => {
|
|
51
|
+
sources
|
|
52
|
+
.filter((c) => !c.isOverriden)
|
|
53
|
+
.forEach((configValueSource) => {
|
|
54
|
+
if (!configValueSource.valueIsImportedAtRuntime)
|
|
55
|
+
return;
|
|
56
|
+
const { definedAtFilePath, configEnv } = configValueSource;
|
|
57
|
+
if (!configEnv.client)
|
|
58
|
+
return;
|
|
59
|
+
if (definedAtFilePath.filePathAbsoluteUserRootDir !== null) {
|
|
60
|
+
// Vite expects entries to be filesystem absolute paths (surprisingly so).
|
|
61
|
+
addEntry(definedAtFilePath.filePathAbsoluteFilesystem);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Adding definedAtFilePath.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
65
|
+
addInclude(definedAtFilePath.importPathAbsolute);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
65
68
|
});
|
|
66
69
|
});
|
|
67
70
|
}
|
|
@@ -75,7 +75,8 @@ function devConfig() {
|
|
|
75
75
|
configureServer: {
|
|
76
76
|
order: 'post',
|
|
77
77
|
handler(server) {
|
|
78
|
-
|
|
78
|
+
const hasHonoViteDevServer = !!config.plugins.find((p) => p.name === '@hono/vite-dev-server');
|
|
79
|
+
if (config.server.middlewareMode || hasHonoViteDevServer)
|
|
79
80
|
return;
|
|
80
81
|
return () => {
|
|
81
82
|
(0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares);
|
|
@@ -50,7 +50,8 @@ function envVarsPlugin() {
|
|
|
50
50
|
(0, utils_js_1.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
|
(0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -102,7 +102,7 @@ function extractAssetsPlugin() {
|
|
|
102
102
|
}
|
|
103
103
|
// If the import path resolves to a file in `node_modules/`, we ignore that file:
|
|
104
104
|
// - 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.)
|
|
105
|
-
// - Loading CSS from a library (living in `node_modules/`) in a non-direct way is
|
|
105
|
+
// - 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.)
|
|
106
106
|
(0, utils_js_1.assertPosixPath)(file);
|
|
107
107
|
if (file.includes('/node_modules/')) {
|
|
108
108
|
return emptyModule(file, importer);
|
package/dist/cjs/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js}
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
let varCounterGlobal = 0;
|
|
3
|
+
exports.addImportStatement = void 0;
|
|
5
4
|
/**
|
|
6
5
|
* Naming:
|
|
7
6
|
* `import { someExport as someImport } from './some-file'`
|
|
@@ -11,14 +10,12 @@ let varCounterGlobal = 0;
|
|
|
11
10
|
* `exportName: 'someExport',`
|
|
12
11
|
* `importName: 'someImport',`
|
|
13
12
|
* `}`
|
|
14
|
-
* We discard the information that the import variable is called `someImport` because we don't need it.
|
|
15
13
|
*/
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const importName = `import_${varCounter}`;
|
|
14
|
+
function addImportStatement(importStatements, importPath, exportName) {
|
|
15
|
+
const importCounter = importStatements.length + 1;
|
|
16
|
+
const importName = `import${importCounter}`;
|
|
20
17
|
const importLiteral = (() => {
|
|
21
|
-
if (
|
|
18
|
+
if (exportName === '*') {
|
|
22
19
|
return `* as ${importName}`;
|
|
23
20
|
}
|
|
24
21
|
if (exportName === 'default') {
|
|
@@ -27,6 +24,7 @@ function generateEagerImport(importPath, varCounter, exportName) {
|
|
|
27
24
|
return `{ ${exportName} as ${importName} }`;
|
|
28
25
|
})();
|
|
29
26
|
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
30
|
-
|
|
27
|
+
importStatements.push(importStatement);
|
|
28
|
+
return { importName };
|
|
31
29
|
}
|
|
32
|
-
exports.
|
|
30
|
+
exports.addImportStatement = addImportStatement;
|
|
@@ -69,7 +69,6 @@ export const pageFilesExportNamesLazy = {};
|
|
|
69
69
|
export const pageFilesExportNamesEager = {};
|
|
70
70
|
export const pageFilesList = [];
|
|
71
71
|
export const neverLoaded = {};
|
|
72
|
-
export const isGeneratedFile = true;
|
|
73
72
|
|
|
74
73
|
${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClientSide, isDev, id, isClientRouting, config)}
|
|
75
74
|
|
|
@@ -22,7 +22,7 @@ const configDefinitionsBuiltIn = {
|
|
|
22
22
|
env: { server: true }
|
|
23
23
|
},
|
|
24
24
|
onBeforePrerenderStart: {
|
|
25
|
-
env: { server: true }
|
|
25
|
+
env: { server: true, production: true }
|
|
26
26
|
},
|
|
27
27
|
Page: {
|
|
28
28
|
env: { server: true, client: true }
|
|
@@ -48,7 +48,7 @@ const configDefinitionsBuiltIn = {
|
|
|
48
48
|
},
|
|
49
49
|
client: {
|
|
50
50
|
// The value of the client config is merely the file path to the client entry file, which is only needed on the sever-side
|
|
51
|
-
env: { server: true },
|
|
51
|
+
env: { server: true, config: true },
|
|
52
52
|
_valueIsFilePath: true
|
|
53
53
|
},
|
|
54
54
|
clientRouting: {
|
|
@@ -97,7 +97,7 @@ const configDefinitionsBuiltIn = {
|
|
|
97
97
|
exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
|
|
98
98
|
const configDefinitionsBuiltInGlobal = {
|
|
99
99
|
onPrerenderStart: {
|
|
100
|
-
env: { server: true }
|
|
100
|
+
env: { server: true, production: true }
|
|
101
101
|
},
|
|
102
102
|
onBeforeRoute: {
|
|
103
103
|
env: { server: true, client: 'if-client-routing', eager: true }
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -15,7 +15,7 @@ const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
|
15
15
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
16
16
|
(0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
|
|
17
17
|
let gitIsNotUsable = false;
|
|
18
|
-
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
18
|
+
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, crawlWithGit) {
|
|
19
19
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
20
20
|
(0, utils_js_1.assertPosixPath)(outDirAbsoluteFilesystem);
|
|
21
21
|
let outDirRelativeFromUserRootDir = path_1.default.posix.relative(userRootDir, outDirAbsoluteFilesystem);
|
|
@@ -31,8 +31,9 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
31
31
|
//
|
|
32
32
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
33
33
|
const timeBefore = new Date().getTime();
|
|
34
|
+
// Crawl
|
|
34
35
|
let files = [];
|
|
35
|
-
const res = await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir);
|
|
36
|
+
const res = crawlWithGit !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
36
37
|
if (res &&
|
|
37
38
|
// Fallback to fast-glob for users that dynamically generate plus files. (Assuming all (generetad) plus files to be skipped because users usually included them in `.gitignore`.)
|
|
38
39
|
res.length > 0) {
|
|
@@ -41,7 +42,9 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
41
42
|
else {
|
|
42
43
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
43
44
|
}
|
|
45
|
+
// Filter build files
|
|
44
46
|
files = files.filter((file) => !(0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(file));
|
|
47
|
+
// Check performance
|
|
45
48
|
{
|
|
46
49
|
const timeAfter = new Date().getTime();
|
|
47
50
|
const timeSpent = timeAfter - timeBefore;
|
|
@@ -53,10 +56,12 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
// Normalize
|
|
60
|
+
const plusFiles = files.map((filePath) => {
|
|
61
|
+
// Both `$ git-ls files` and fast-glob return posix paths
|
|
62
|
+
(0, utils_js_1.assertPosixPath)(filePath);
|
|
63
|
+
(0, utils_js_1.assert)(!filePath.startsWith(userRootDir));
|
|
64
|
+
const filePathAbsoluteUserRootDir = path_1.default.posix.join('/', filePath);
|
|
60
65
|
return { filePathAbsoluteUserRootDir };
|
|
61
66
|
});
|
|
62
67
|
return plusFiles;
|
|
@@ -66,10 +71,17 @@ exports.crawlPlusFiles = crawlPlusFiles;
|
|
|
66
71
|
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
67
72
|
if (gitIsNotUsable)
|
|
68
73
|
return null;
|
|
74
|
+
// Preserve UTF-8 file paths.
|
|
75
|
+
// https://github.com/vikejs/vike/issues/1658
|
|
76
|
+
// https://stackoverflow.com/questions/22827239/how-to-make-git-properly-display-utf-8-encoded-pathnames-in-the-console-window/22828826#22828826
|
|
77
|
+
// https://stackoverflow.com/questions/15884180/how-do-i-override-git-configuration-options-by-command-line-parameters/15884261#15884261
|
|
78
|
+
const preserveUTF8 = '-c core.quotepath=off';
|
|
69
79
|
const ignoreAsPatterns = getIgnoreAsPatterns(outDirRelativeFromUserRootDir);
|
|
70
80
|
const ignoreAsFilterFn = getIgnoreAsFilterFn(outDirRelativeFromUserRootDir);
|
|
71
81
|
const cmd = [
|
|
72
|
-
'git
|
|
82
|
+
'git',
|
|
83
|
+
preserveUTF8,
|
|
84
|
+
'ls-files',
|
|
73
85
|
...utils_js_1.scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
74
86
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
75
87
|
// --others lists untracked files only (but using .gitignore because --exclude-standard)
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -13,7 +13,7 @@ const transformFileImports_js_1 = require("./transformFileImports.js");
|
|
|
13
13
|
const getConfigFileExport_js_1 = require("../getConfigFileExport.js");
|
|
14
14
|
const resolvePointerImport_js_1 = require("./resolvePointerImport.js");
|
|
15
15
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
16
|
-
// Load
|
|
16
|
+
// Load pointer import
|
|
17
17
|
async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
18
18
|
const f = import_.filePathAbsoluteFilesystem;
|
|
19
19
|
if (!importedFilesLoaded[f]) {
|
|
@@ -35,7 +35,7 @@ async function loadValueFile(interfaceValueFile, configName, userRootDir) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
exports.loadValueFile = loadValueFile;
|
|
38
|
-
// Load +config.js, including all its extends
|
|
38
|
+
// Load +config.js, including all its extends pointer imports
|
|
39
39
|
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig) {
|
|
40
40
|
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
41
41
|
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
@@ -15,12 +15,13 @@ const loggerNotProd_js_1 = require("../../../shared/loggerNotProd.js");
|
|
|
15
15
|
const removeSuperfluousViteLog_js_1 = require("../../../shared/loggerVite/removeSuperfluousViteLog.js");
|
|
16
16
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
17
17
|
const getConfigDefinedAt_js_1 = require("../../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
18
|
-
const getConfigValuesSerialized_js_1 = require("./getConfigValuesSerialized.js");
|
|
19
18
|
const crawlPlusFiles_js_1 = require("./getVikeConfig/crawlPlusFiles.js");
|
|
20
19
|
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
21
20
|
const loadFileAtConfigTime_js_1 = require("./getVikeConfig/loadFileAtConfigTime.js");
|
|
22
21
|
const resolvePointerImport_js_1 = require("./getVikeConfig/resolvePointerImport.js");
|
|
23
22
|
const getFilePath_js_1 = require("../../../shared/getFilePath.js");
|
|
23
|
+
const getConfigValueBuildTime_js_1 = require("../../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
24
|
+
const getConfigVike_js_1 = require("../../../../shared/getConfigVike.js");
|
|
24
25
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
25
26
|
let devServerIsCorrupt = false;
|
|
26
27
|
let wasConfigInvalid = null;
|
|
@@ -65,11 +66,12 @@ async function handleReloadSideEffects() {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
async function getVikeConfig(config, isDev, tolerateInvalidConfig) {
|
|
69
|
+
async function getVikeConfig(config, isDev, { crawlWithGit, tolerateInvalidConfig } = {}) {
|
|
69
70
|
const { outDirRoot } = (0, utils_js_1.getOutDirs)(config);
|
|
70
71
|
const userRootDir = config.root;
|
|
71
72
|
if (!vikeConfigPromise) {
|
|
72
|
-
|
|
73
|
+
const crawlWithGit_ = crawlWithGit !== undefined ? crawlWithGit : (await (0, getConfigVike_js_1.getConfigVike)(config)).crawl.git;
|
|
74
|
+
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit_, tolerateInvalidConfig);
|
|
73
75
|
}
|
|
74
76
|
return await vikeConfigPromise;
|
|
75
77
|
}
|
|
@@ -81,8 +83,8 @@ async function isV1Design(config, isDev) {
|
|
|
81
83
|
return isV1Design;
|
|
82
84
|
}
|
|
83
85
|
exports.isV1Design = isV1Design;
|
|
84
|
-
async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
85
|
-
const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev);
|
|
86
|
+
async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
87
|
+
const plusFiles = await findPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
86
88
|
const configFiles = [];
|
|
87
89
|
const valueFiles = [];
|
|
88
90
|
plusFiles.forEach((f) => {
|
|
@@ -171,7 +173,7 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
171
173
|
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
172
174
|
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
173
175
|
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn, configName);
|
|
174
|
-
if (configDef &&
|
|
176
|
+
if (configDef && isLoadableAtBuildTime(configDef)) {
|
|
175
177
|
await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
|
|
176
178
|
}
|
|
177
179
|
}
|
|
@@ -213,12 +215,12 @@ function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
|
|
|
213
215
|
});
|
|
214
216
|
});
|
|
215
217
|
}
|
|
216
|
-
async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, tolerateInvalidConfig) {
|
|
218
|
+
async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit, tolerateInvalidConfig) {
|
|
217
219
|
let hasError = false;
|
|
218
220
|
let ret;
|
|
219
221
|
let err;
|
|
220
222
|
try {
|
|
221
|
-
ret = await loadVikeConfig(userRootDir, outDirRoot, isDev);
|
|
223
|
+
ret = await loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
222
224
|
}
|
|
223
225
|
catch (err_) {
|
|
224
226
|
hasError = true;
|
|
@@ -246,6 +248,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
246
248
|
const dummyData = {
|
|
247
249
|
pageConfigs: [],
|
|
248
250
|
pageConfigGlobal: {
|
|
251
|
+
configDefinitions: {},
|
|
249
252
|
configValueSources: {}
|
|
250
253
|
},
|
|
251
254
|
globalVikeConfig: {}
|
|
@@ -254,8 +257,8 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
254
257
|
}
|
|
255
258
|
}
|
|
256
259
|
}
|
|
257
|
-
async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
258
|
-
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev);
|
|
260
|
+
async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
261
|
+
const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
259
262
|
const importedFilesLoaded = {};
|
|
260
263
|
const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
|
|
261
264
|
const pageConfigs = await Promise.all((0, utils_js_1.objectEntries)(interfaceFilesByLocationId)
|
|
@@ -271,7 +274,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
271
274
|
if (isGlobalConfig(configName))
|
|
272
275
|
return;
|
|
273
276
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
274
|
-
if (!
|
|
277
|
+
if (!isLoadableAtBuildTime(configDef))
|
|
275
278
|
return;
|
|
276
279
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
277
280
|
if (isAlreadyLoaded)
|
|
@@ -293,14 +296,13 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
293
296
|
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
|
|
294
297
|
applyEffectsAll(configValueSources, configDefinitions);
|
|
295
298
|
const configValuesComputed = getComputed(configValueSources, configDefinitions);
|
|
296
|
-
const configValues = getConfigValues(configValueSources, configValuesComputed, configDefinitions);
|
|
297
299
|
const pageConfig = {
|
|
298
300
|
pageId: locationId,
|
|
299
301
|
isErrorPage,
|
|
300
302
|
routeFilesystem,
|
|
303
|
+
configDefinitions,
|
|
301
304
|
configValueSources,
|
|
302
|
-
configValuesComputed
|
|
303
|
-
configValues
|
|
305
|
+
configValuesComputed
|
|
304
306
|
};
|
|
305
307
|
return pageConfig;
|
|
306
308
|
}));
|
|
@@ -333,7 +335,7 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
333
335
|
if (!onBeforeRenderConfig)
|
|
334
336
|
return;
|
|
335
337
|
const onBeforeRenderEnv = onBeforeRenderConfig.configEnv;
|
|
336
|
-
const isClientRouting =
|
|
338
|
+
const isClientRouting = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'clientRouting', 'boolean');
|
|
337
339
|
// 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
|
|
338
340
|
(0, utils_js_1.assertUsage)(!(onBeforeRenderEnv.client && !isClientRouting), `Page ${pageConfig.pageId} has an onBeforeRender() hook with env ${picocolors_1.default.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.`);
|
|
339
341
|
}
|
|
@@ -394,6 +396,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
394
396
|
}
|
|
395
397
|
const globalVikeConfig = {};
|
|
396
398
|
const pageConfigGlobal = {
|
|
399
|
+
configDefinitions: configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal,
|
|
397
400
|
configValueSources: {}
|
|
398
401
|
};
|
|
399
402
|
await Promise.all((0, utils_js_1.objectEntries)(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
|
|
@@ -427,7 +430,15 @@ async function resolveConfigValueSources(configName, configDef, interfaceFilesRe
|
|
|
427
430
|
const add = (interfaceFile) => {
|
|
428
431
|
(0, utils_js_1.assert)(!visited.has(interfaceFile));
|
|
429
432
|
visited.add(interfaceFile);
|
|
430
|
-
sourcesInfo.
|
|
433
|
+
const isHighestInheritancePrecedence = sourcesInfo.length === 0;
|
|
434
|
+
sourcesInfo.push([
|
|
435
|
+
configName,
|
|
436
|
+
interfaceFile,
|
|
437
|
+
configDef,
|
|
438
|
+
userRootDir,
|
|
439
|
+
importedFilesLoaded,
|
|
440
|
+
isHighestInheritancePrecedence
|
|
441
|
+
]);
|
|
431
442
|
};
|
|
432
443
|
// Main resolution logic
|
|
433
444
|
{
|
|
@@ -498,7 +509,7 @@ function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden,
|
|
|
498
509
|
function isInterfaceFileUserLand(interfaceFile) {
|
|
499
510
|
return (interfaceFile.isConfigFile && !interfaceFile.isConfigExtend) || interfaceFile.isValueFile;
|
|
500
511
|
}
|
|
501
|
-
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded) {
|
|
512
|
+
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded, isHighestInheritancePrecedence) {
|
|
502
513
|
const conf = interfaceFile.fileExportsByConfigName[configName];
|
|
503
514
|
(0, utils_js_1.assert)(conf);
|
|
504
515
|
const configEnv = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
|
|
@@ -507,6 +518,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
507
518
|
...interfaceFile.filePath,
|
|
508
519
|
fileExportPathToShowToUser: ['default', configName]
|
|
509
520
|
};
|
|
521
|
+
const isOverriden = configDef.cumulative ? false : !isHighestInheritancePrecedence;
|
|
510
522
|
// +client.js
|
|
511
523
|
if (configDef._valueIsFilePath) {
|
|
512
524
|
let definedAtFilePath;
|
|
@@ -533,7 +545,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
533
545
|
valueIsFilePath: true,
|
|
534
546
|
configEnv,
|
|
535
547
|
valueIsImportedAtRuntime: true,
|
|
536
|
-
|
|
548
|
+
valueIsDefinedByPlusFile: false,
|
|
549
|
+
isOverriden,
|
|
537
550
|
definedAtFilePath
|
|
538
551
|
};
|
|
539
552
|
return configValueSource;
|
|
@@ -549,11 +562,12 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
549
562
|
locationId,
|
|
550
563
|
configEnv,
|
|
551
564
|
valueIsImportedAtRuntime: true,
|
|
552
|
-
|
|
565
|
+
valueIsDefinedByPlusFile: false,
|
|
566
|
+
isOverriden,
|
|
553
567
|
definedAtFilePath: pointerImport
|
|
554
568
|
};
|
|
555
|
-
// Load
|
|
556
|
-
if (
|
|
569
|
+
// Load pointer import
|
|
570
|
+
if (isLoadableAtBuildTime(configDef) &&
|
|
557
571
|
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
558
572
|
configName !== 'extends') {
|
|
559
573
|
if (pointerImport.filePathAbsoluteFilesystem) {
|
|
@@ -573,7 +587,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
573
587
|
value: configValue,
|
|
574
588
|
configEnv,
|
|
575
589
|
valueIsImportedAtRuntime: false,
|
|
576
|
-
|
|
590
|
+
valueIsDefinedByPlusFile: false,
|
|
591
|
+
isOverriden,
|
|
577
592
|
definedAtFilePath: definedAtFilePath_
|
|
578
593
|
};
|
|
579
594
|
return configValueSource;
|
|
@@ -586,7 +601,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
586
601
|
locationId,
|
|
587
602
|
configEnv,
|
|
588
603
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
589
|
-
|
|
604
|
+
valueIsDefinedByPlusFile: true,
|
|
605
|
+
isOverriden,
|
|
590
606
|
definedAtFilePath: {
|
|
591
607
|
...interfaceFile.filePath,
|
|
592
608
|
fileExportPathToShowToUser: configName === interfaceFile.configName
|
|
@@ -756,8 +772,8 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
756
772
|
});
|
|
757
773
|
return configValuesComputed;
|
|
758
774
|
}
|
|
759
|
-
async function findPlusFiles(userRootDir, outDirRoot, isDev) {
|
|
760
|
-
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot, isDev);
|
|
775
|
+
async function findPlusFiles(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
776
|
+
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot, isDev, crawlWithGit);
|
|
761
777
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
762
778
|
return plusFiles;
|
|
763
779
|
}
|
|
@@ -882,59 +898,6 @@ function isVikeConfigFile(filePath) {
|
|
|
882
898
|
return !!getConfigName(filePath);
|
|
883
899
|
}
|
|
884
900
|
exports.isVikeConfigFile = isVikeConfigFile;
|
|
885
|
-
function getConfigValues(configValueSources, configValuesComputed, configDefinitions) {
|
|
886
|
-
const configValues = {};
|
|
887
|
-
Object.entries(configValuesComputed).forEach(([configName, configValueComputed]) => {
|
|
888
|
-
configValues[configName] = {
|
|
889
|
-
type: 'computed',
|
|
890
|
-
value: configValueComputed.value,
|
|
891
|
-
definedAtData: null
|
|
892
|
-
};
|
|
893
|
-
});
|
|
894
|
-
Object.entries(configValueSources).forEach(([configName, sources]) => {
|
|
895
|
-
const configDef = configDefinitions[configName];
|
|
896
|
-
(0, utils_js_1.assert)(configDef);
|
|
897
|
-
if (!configDef.cumulative) {
|
|
898
|
-
const configValueSource = sources[0];
|
|
899
|
-
if ('value' in configValueSource) {
|
|
900
|
-
configValues[configName] = {
|
|
901
|
-
type: 'classic',
|
|
902
|
-
value: configValueSource.value,
|
|
903
|
-
definedAtData: getDefinedAtFile(configValueSource)
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
else {
|
|
908
|
-
const value = mergeCumulative(configName, sources);
|
|
909
|
-
const definedAtData = sources.map((source) => getDefinedAtFile(source));
|
|
910
|
-
(0, utils_js_1.assert)(value.length === definedAtData.length);
|
|
911
|
-
configValues[configName] = {
|
|
912
|
-
type: 'cumulative',
|
|
913
|
-
value,
|
|
914
|
-
definedAtData
|
|
915
|
-
};
|
|
916
|
-
}
|
|
917
|
-
});
|
|
918
|
-
return configValues;
|
|
919
|
-
}
|
|
920
|
-
function getDefinedAtFile(configValueSource) {
|
|
921
|
-
return {
|
|
922
|
-
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
923
|
-
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
function mergeCumulative(configName, configValueSources) {
|
|
927
|
-
const configValues = [];
|
|
928
|
-
configValueSources.forEach((configValueSource) => {
|
|
929
|
-
// We could, in principle, also support cumulative for values that aren't loaded at config-time but it isn't completely trivial to implement.
|
|
930
|
-
(0, utils_js_1.assert)('value' in configValueSource);
|
|
931
|
-
// Make sure configValueSource.value is serializable
|
|
932
|
-
(0, getConfigValuesSerialized_js_1.assertConfigValueIsSerializable)(configValueSource.value, configName, getDefinedAtFile(configValueSource));
|
|
933
|
-
const { value } = configValueSource;
|
|
934
|
-
configValues.push(value);
|
|
935
|
-
});
|
|
936
|
-
return configValues;
|
|
937
|
-
}
|
|
938
901
|
function getConfigEnvValue(val, errMsgIntro) {
|
|
939
902
|
const errInvalidValue = `${errMsgIntro} an invalid value ${picocolors_1.default.cyan(JSON.stringify(val))}`;
|
|
940
903
|
// Legacy outdated values
|
|
@@ -977,13 +940,8 @@ function getConfigDefinition(configDefinitions, configName, filePathToShowToUser
|
|
|
977
940
|
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
978
941
|
return configDefinitions[configName] ?? null;
|
|
979
942
|
}
|
|
980
|
-
function
|
|
981
|
-
|
|
982
|
-
if (configDef.cumulative) {
|
|
983
|
-
// In principle we could lift that requirement (but it requires non-trivial modifications)
|
|
984
|
-
(0, utils_js_1.assertUsage)(configEnv.config, `Config ${picocolors_1.default.cyan(configName)} needs its ${picocolors_1.default.cyan('env')} to have ${picocolors_1.default.cyan('{ config: true }')} (because ${picocolors_1.default.cyan(configName)} is a ${picocolors_1.default.cyan('cumulative')} config)`);
|
|
985
|
-
}
|
|
986
|
-
return !!configEnv.config;
|
|
943
|
+
function isLoadableAtBuildTime(configDef) {
|
|
944
|
+
return !!configDef.env.config && !configDef._valueIsFilePath;
|
|
987
945
|
}
|
|
988
946
|
function isGlobalConfig(configName) {
|
|
989
947
|
if (configName === 'prerender')
|