vike 0.4.171 → 0.4.172
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/plugins/buildConfig.js +3 -4
- 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/loadFileAtConfigTime.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +31 -75
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -43
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -50
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -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/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/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 +17 -13
- 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 +1 -1
- 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/plugins/buildConfig.js +3 -4
- 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/loadFileAtConfigTime.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +31 -75
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +4 -43
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +9 -50
- 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/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/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/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 +17 -13
- 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/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 +1 -1
- 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 +21 -12
- 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
|
@@ -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
|
}
|
|
@@ -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/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,12 @@ 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
24
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
25
25
|
let devServerIsCorrupt = false;
|
|
26
26
|
let wasConfigInvalid = null;
|
|
@@ -171,7 +171,7 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
171
171
|
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
172
172
|
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
173
173
|
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn, configName);
|
|
174
|
-
if (configDef &&
|
|
174
|
+
if (configDef && isLoadableAtBuildTime(configDef)) {
|
|
175
175
|
await (0, loadFileAtConfigTime_js_1.loadValueFile)(interfaceFile, configName, userRootDir);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -246,6 +246,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
246
246
|
const dummyData = {
|
|
247
247
|
pageConfigs: [],
|
|
248
248
|
pageConfigGlobal: {
|
|
249
|
+
configDefinitions: {},
|
|
249
250
|
configValueSources: {}
|
|
250
251
|
},
|
|
251
252
|
globalVikeConfig: {}
|
|
@@ -271,7 +272,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
271
272
|
if (isGlobalConfig(configName))
|
|
272
273
|
return;
|
|
273
274
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
274
|
-
if (!
|
|
275
|
+
if (!isLoadableAtBuildTime(configDef))
|
|
275
276
|
return;
|
|
276
277
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
277
278
|
if (isAlreadyLoaded)
|
|
@@ -293,14 +294,13 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
293
294
|
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
|
|
294
295
|
applyEffectsAll(configValueSources, configDefinitions);
|
|
295
296
|
const configValuesComputed = getComputed(configValueSources, configDefinitions);
|
|
296
|
-
const configValues = getConfigValues(configValueSources, configValuesComputed, configDefinitions);
|
|
297
297
|
const pageConfig = {
|
|
298
298
|
pageId: locationId,
|
|
299
299
|
isErrorPage,
|
|
300
300
|
routeFilesystem,
|
|
301
|
+
configDefinitions,
|
|
301
302
|
configValueSources,
|
|
302
|
-
configValuesComputed
|
|
303
|
-
configValues
|
|
303
|
+
configValuesComputed
|
|
304
304
|
};
|
|
305
305
|
return pageConfig;
|
|
306
306
|
}));
|
|
@@ -333,7 +333,7 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
333
333
|
if (!onBeforeRenderConfig)
|
|
334
334
|
return;
|
|
335
335
|
const onBeforeRenderEnv = onBeforeRenderConfig.configEnv;
|
|
336
|
-
const isClientRouting =
|
|
336
|
+
const isClientRouting = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'clientRouting', 'boolean');
|
|
337
337
|
// 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
338
|
(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
339
|
}
|
|
@@ -394,6 +394,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
394
394
|
}
|
|
395
395
|
const globalVikeConfig = {};
|
|
396
396
|
const pageConfigGlobal = {
|
|
397
|
+
configDefinitions: configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal,
|
|
397
398
|
configValueSources: {}
|
|
398
399
|
};
|
|
399
400
|
await Promise.all((0, utils_js_1.objectEntries)(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal).map(async ([configName, configDef]) => {
|
|
@@ -427,7 +428,15 @@ async function resolveConfigValueSources(configName, configDef, interfaceFilesRe
|
|
|
427
428
|
const add = (interfaceFile) => {
|
|
428
429
|
(0, utils_js_1.assert)(!visited.has(interfaceFile));
|
|
429
430
|
visited.add(interfaceFile);
|
|
430
|
-
sourcesInfo.
|
|
431
|
+
const isHighestInheritancePrecedence = sourcesInfo.length === 0;
|
|
432
|
+
sourcesInfo.push([
|
|
433
|
+
configName,
|
|
434
|
+
interfaceFile,
|
|
435
|
+
configDef,
|
|
436
|
+
userRootDir,
|
|
437
|
+
importedFilesLoaded,
|
|
438
|
+
isHighestInheritancePrecedence
|
|
439
|
+
]);
|
|
431
440
|
};
|
|
432
441
|
// Main resolution logic
|
|
433
442
|
{
|
|
@@ -498,7 +507,7 @@ function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden,
|
|
|
498
507
|
function isInterfaceFileUserLand(interfaceFile) {
|
|
499
508
|
return (interfaceFile.isConfigFile && !interfaceFile.isConfigExtend) || interfaceFile.isValueFile;
|
|
500
509
|
}
|
|
501
|
-
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded) {
|
|
510
|
+
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded, isHighestInheritancePrecedence) {
|
|
502
511
|
const conf = interfaceFile.fileExportsByConfigName[configName];
|
|
503
512
|
(0, utils_js_1.assert)(conf);
|
|
504
513
|
const configEnv = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
|
|
@@ -507,6 +516,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
507
516
|
...interfaceFile.filePath,
|
|
508
517
|
fileExportPathToShowToUser: ['default', configName]
|
|
509
518
|
};
|
|
519
|
+
const isOverriden = configDef.cumulative ? false : !isHighestInheritancePrecedence;
|
|
510
520
|
// +client.js
|
|
511
521
|
if (configDef._valueIsFilePath) {
|
|
512
522
|
let definedAtFilePath;
|
|
@@ -533,7 +543,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
533
543
|
valueIsFilePath: true,
|
|
534
544
|
configEnv,
|
|
535
545
|
valueIsImportedAtRuntime: true,
|
|
536
|
-
|
|
546
|
+
valueIsDefinedByPlusFile: false,
|
|
547
|
+
isOverriden,
|
|
537
548
|
definedAtFilePath
|
|
538
549
|
};
|
|
539
550
|
return configValueSource;
|
|
@@ -549,11 +560,12 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
549
560
|
locationId,
|
|
550
561
|
configEnv,
|
|
551
562
|
valueIsImportedAtRuntime: true,
|
|
552
|
-
|
|
563
|
+
valueIsDefinedByPlusFile: false,
|
|
564
|
+
isOverriden,
|
|
553
565
|
definedAtFilePath: pointerImport
|
|
554
566
|
};
|
|
555
|
-
// Load
|
|
556
|
-
if (
|
|
567
|
+
// Load pointer import
|
|
568
|
+
if (isLoadableAtBuildTime(configDef) &&
|
|
557
569
|
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
558
570
|
configName !== 'extends') {
|
|
559
571
|
if (pointerImport.filePathAbsoluteFilesystem) {
|
|
@@ -573,7 +585,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
573
585
|
value: configValue,
|
|
574
586
|
configEnv,
|
|
575
587
|
valueIsImportedAtRuntime: false,
|
|
576
|
-
|
|
588
|
+
valueIsDefinedByPlusFile: false,
|
|
589
|
+
isOverriden,
|
|
577
590
|
definedAtFilePath: definedAtFilePath_
|
|
578
591
|
};
|
|
579
592
|
return configValueSource;
|
|
@@ -586,7 +599,8 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
586
599
|
locationId,
|
|
587
600
|
configEnv,
|
|
588
601
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
589
|
-
|
|
602
|
+
valueIsDefinedByPlusFile: true,
|
|
603
|
+
isOverriden,
|
|
590
604
|
definedAtFilePath: {
|
|
591
605
|
...interfaceFile.filePath,
|
|
592
606
|
fileExportPathToShowToUser: configName === interfaceFile.configName
|
|
@@ -882,59 +896,6 @@ function isVikeConfigFile(filePath) {
|
|
|
882
896
|
return !!getConfigName(filePath);
|
|
883
897
|
}
|
|
884
898
|
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
899
|
function getConfigEnvValue(val, errMsgIntro) {
|
|
939
900
|
const errInvalidValue = `${errMsgIntro} an invalid value ${picocolors_1.default.cyan(JSON.stringify(val))}`;
|
|
940
901
|
// Legacy outdated values
|
|
@@ -977,13 +938,8 @@ function getConfigDefinition(configDefinitions, configName, filePathToShowToUser
|
|
|
977
938
|
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
978
939
|
return configDefinitions[configName] ?? null;
|
|
979
940
|
}
|
|
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;
|
|
941
|
+
function isLoadableAtBuildTime(configDef) {
|
|
942
|
+
return !!configDef.env.config && !configDef._valueIsFilePath;
|
|
987
943
|
}
|
|
988
944
|
function isGlobalConfig(configName) {
|
|
989
945
|
if (configName === 'prerender')
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -6,13 +6,11 @@ const virtualFilePageConfigValuesAll_js_1 = require("../../../../shared/virtual-
|
|
|
6
6
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
7
7
|
const extractAssetsQuery_js_1 = require("../../../../shared/extractAssetsQuery.js");
|
|
8
8
|
const debug_js_1 = require("./debug.js");
|
|
9
|
-
const getConfigValue_js_1 = require("../../../../../shared/page-configs/getConfigValue.js");
|
|
10
|
-
const getConfigValueSourcesNotOverriden_js_1 = require("../../../shared/getConfigValueSourcesNotOverriden.js");
|
|
11
9
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
12
|
-
const
|
|
10
|
+
const serializeConfigValues_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValues.js");
|
|
13
11
|
const getConfigVike_js_1 = require("../../../../shared/getConfigVike.js");
|
|
14
|
-
const getConfigValuesSerialized_js_1 = require("./getConfigValuesSerialized.js");
|
|
15
12
|
const fixServerAssets_js_1 = require("../../buildConfig/fixServerAssets.js");
|
|
13
|
+
const getConfigValueBuildTime_js_1 = require("../../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
16
14
|
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
17
15
|
const result = (0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id);
|
|
18
16
|
(0, utils_js_1.assert)(result);
|
|
@@ -35,16 +33,9 @@ exports.getVirtualFilePageConfigValuesAll = getVirtualFilePageConfigValuesAll;
|
|
|
35
33
|
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
36
34
|
const lines = [];
|
|
37
35
|
const importStatements = [];
|
|
38
|
-
const isClientRouting = (0,
|
|
39
|
-
lines.push('export const configValuesImported = [');
|
|
40
|
-
lines.push(getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements));
|
|
41
|
-
lines.push('];');
|
|
36
|
+
const isClientRouting = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
42
37
|
lines.push('export const configValuesSerialized = {');
|
|
43
|
-
lines.push((0,
|
|
44
|
-
isImport: false,
|
|
45
|
-
isForClientSide,
|
|
46
|
-
isClientRouting
|
|
47
|
-
})));
|
|
38
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: false, isDev }), ''));
|
|
48
39
|
lines.push('};');
|
|
49
40
|
if (!(0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
50
41
|
importStatements.push(`import '${(0, extractAssetsQuery_js_1.extractAssetsAddQuery)((0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, false))}'`);
|
|
@@ -52,33 +43,3 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
52
43
|
const code = [...importStatements, ...lines].join('\n');
|
|
53
44
|
return code;
|
|
54
45
|
}
|
|
55
|
-
function getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements) {
|
|
56
|
-
const lines = [];
|
|
57
|
-
const varCounterContainer = { varCounter: 0 };
|
|
58
|
-
(0, getConfigValueSourcesNotOverriden_js_1.getConfigValueSourcesNotOverriden)(pageConfig).forEach((configValueSource) => {
|
|
59
|
-
if (!isEnvMatch(configValueSource.configEnv, checkWhetherIsImport(configValueSource), {
|
|
60
|
-
isImport: true,
|
|
61
|
-
isForClientSide,
|
|
62
|
-
isClientRouting
|
|
63
|
-
}))
|
|
64
|
-
return;
|
|
65
|
-
const whitespace = ' ';
|
|
66
|
-
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configValueSource.configName, whitespace, varCounterContainer, importStatements));
|
|
67
|
-
});
|
|
68
|
-
const code = lines.join('\n');
|
|
69
|
-
return code;
|
|
70
|
-
}
|
|
71
|
-
function checkWhetherIsImport(configValueSource) {
|
|
72
|
-
const { valueIsImportedAtRuntime, valueIsFilePath } = configValueSource;
|
|
73
|
-
return valueIsImportedAtRuntime && !valueIsFilePath;
|
|
74
|
-
}
|
|
75
|
-
function isEnvMatch(configEnv, isImport, runtime) {
|
|
76
|
-
// Whether config value is imported or serialized
|
|
77
|
-
if (isImport !== runtime.isImport)
|
|
78
|
-
return false;
|
|
79
|
-
// Runtime match
|
|
80
|
-
const { isForClientSide, isClientRouting } = runtime;
|
|
81
|
-
if (!(0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: false }))
|
|
82
|
-
return false;
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVirtualFilePageConfigs = void 0;
|
|
4
|
-
const utils_js_1 = require("../../../utils.js");
|
|
5
4
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
6
5
|
const debug_js_1 = require("./debug.js");
|
|
7
6
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
8
7
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
9
|
-
const
|
|
10
|
-
const getConfigValuesSerialized_js_1 = require("./getConfigValuesSerialized.js");
|
|
8
|
+
const serializeConfigValues_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValues.js");
|
|
11
9
|
async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
|
|
12
10
|
const { pageConfigs, pageConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev, true);
|
|
13
11
|
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
@@ -16,18 +14,17 @@ exports.getVirtualFilePageConfigs = getVirtualFilePageConfigs;
|
|
|
16
14
|
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
17
15
|
const lines = [];
|
|
18
16
|
const importStatements = [];
|
|
19
|
-
const varCounterContainer = { varCounter: 0 };
|
|
20
17
|
lines.push('export const pageConfigsSerialized = [');
|
|
21
|
-
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting,
|
|
18
|
+
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements));
|
|
22
19
|
lines.push('];');
|
|
23
20
|
lines.push('export const pageConfigGlobalSerialized = {');
|
|
24
|
-
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements
|
|
21
|
+
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements));
|
|
25
22
|
lines.push('};');
|
|
26
23
|
const code = [...importStatements, ...lines].join('\n');
|
|
27
24
|
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
28
25
|
return code;
|
|
29
26
|
}
|
|
30
|
-
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting,
|
|
27
|
+
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
31
28
|
const lines = [];
|
|
32
29
|
pageConfigs.forEach((pageConfig) => {
|
|
33
30
|
const { pageId, routeFilesystem, isErrorPage } = pageConfig;
|
|
@@ -37,57 +34,19 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
37
34
|
lines.push(` isErrorPage: ${JSON.stringify(isErrorPage)},`);
|
|
38
35
|
lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
|
|
39
36
|
lines.push(` loadConfigValuesAll: () => import(${JSON.stringify(virtualFileIdPageConfigValuesAll)}),`);
|
|
40
|
-
// Serialized config values
|
|
41
37
|
lines.push(` configValuesSerialized: {`);
|
|
42
|
-
lines.push((0,
|
|
38
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true, isDev }), ' '));
|
|
43
39
|
lines.push(` },`);
|
|
44
|
-
// Imported config values
|
|
45
|
-
const whitespace = ' ';
|
|
46
|
-
lines.push(`${whitespace}configValuesImported: [`);
|
|
47
|
-
Object.entries(pageConfig.configValueSources).forEach(([configName, sources]) => {
|
|
48
|
-
const configValue = pageConfig.configValues[configName];
|
|
49
|
-
if (configValue)
|
|
50
|
-
return;
|
|
51
|
-
const configValueSource = sources[0];
|
|
52
|
-
(0, utils_js_1.assert)(configValueSource);
|
|
53
|
-
if (!configValueSource.configEnv.eager)
|
|
54
|
-
return;
|
|
55
|
-
if (!(0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configValueSource.configEnv, { isForClientSide, isClientRouting, isEager: true }))
|
|
56
|
-
return;
|
|
57
|
-
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, varCounterContainer, importStatements));
|
|
58
|
-
});
|
|
59
|
-
lines.push(`${whitespace}],`);
|
|
60
40
|
lines.push(` },`);
|
|
61
41
|
});
|
|
62
42
|
const code = lines.join('\n');
|
|
63
43
|
return code;
|
|
64
44
|
}
|
|
65
|
-
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements
|
|
45
|
+
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isClientRouting, isDev, importStatements) {
|
|
66
46
|
const lines = [];
|
|
67
|
-
|
|
68
|
-
lines.push(
|
|
69
|
-
lines.push(` },`)
|
|
70
|
-
*/
|
|
71
|
-
lines.push(` configValuesImported: [`);
|
|
72
|
-
(0, utils_js_1.objectEntries)(pageConfigGlobal.configValueSources).forEach(([configName, sources]) => {
|
|
73
|
-
if (configName === 'onBeforeRoute') {
|
|
74
|
-
// if( isForClientSide && !isClientRouting ) return
|
|
75
|
-
}
|
|
76
|
-
else if (configName === 'onPrerenderStart') {
|
|
77
|
-
if (isDev || isForClientSide) {
|
|
78
|
-
// Only load onPrerenderStart() in server production runtime
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
(0, utils_js_1.assert)(false);
|
|
84
|
-
}
|
|
85
|
-
const configValueSource = sources[0];
|
|
86
|
-
(0, utils_js_1.assert)(configValueSource);
|
|
87
|
-
const whitespace = ' ';
|
|
88
|
-
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, varCounterContainer, importStatements));
|
|
89
|
-
});
|
|
90
|
-
lines.push(` ],`);
|
|
47
|
+
lines.push(` configValuesSerialized: {`);
|
|
48
|
+
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfigGlobal, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true, isDev }), ' '));
|
|
49
|
+
lines.push(` },`);
|
|
91
50
|
const code = lines.join('\n');
|
|
92
51
|
return code;
|
|
93
52
|
}
|
|
@@ -16,6 +16,12 @@ function isRuntimeEnvMatch(configEnv, runtime) {
|
|
|
16
16
|
// Eager
|
|
17
17
|
if (runtime.isEager !== !!configEnv.eager)
|
|
18
18
|
return false;
|
|
19
|
+
// Production/development
|
|
20
|
+
if (
|
|
21
|
+
//
|
|
22
|
+
(configEnv.production === true && runtime.isDev) ||
|
|
23
|
+
(configEnv.production === false && !runtime.isDev))
|
|
24
|
+
return false;
|
|
19
25
|
return true;
|
|
20
26
|
}
|
|
21
27
|
exports.isRuntimeEnvMatch = isRuntimeEnvMatch;
|