vike 0.4.168-commit-7678a7d → 0.4.168-commit-42406a9
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 +2 -2
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +19 -16
- package/dist/cjs/node/plugin/plugins/distFileNames.js +1 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +1 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +14 -11
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +11 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{resolveImportPath.js → resolvePointerImport.js} +58 -44
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +8 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +52 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +81 -106
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -2
- package/dist/cjs/node/plugin/shared/getFilePath.js +44 -48
- package/dist/cjs/node/plugin/utils.js +2 -2
- package/dist/cjs/node/prerender/runPrerender.js +6 -5
- package/dist/cjs/node/prerender/utils.js +2 -1
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/cjs/node/runtime/index-common.js +14 -3
- package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -1
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +25 -14
- package/dist/cjs/node/runtime/renderPage/log404/index.js +2 -2
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +1 -1
- package/dist/cjs/node/runtime/utils.js +2 -1
- package/dist/cjs/node/shared/assertV1Design.js +1 -1
- package/dist/cjs/node/shared/getClientEntry.js +2 -2
- package/dist/cjs/node/shared/utils.js +0 -1
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/getPageFiles/getExports.js +8 -15
- package/dist/cjs/shared/getPageFiles.js +3 -6
- package/dist/cjs/shared/hooks/getHook.js +7 -6
- package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +48 -0
- package/dist/cjs/shared/page-configs/{helpers/getConfigValue.js → getConfigValue.js} +6 -8
- package/dist/cjs/shared/page-configs/helpers.js +6 -11
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -1
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +2 -1
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +11 -6
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +4 -3
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +3 -3
- package/dist/cjs/shared/route/index.js +2 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +12 -10
- package/dist/cjs/shared/route/resolveRouteFunction.js +8 -9
- package/dist/cjs/shared/route/resolveRouteString.js +5 -16
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/utils/assertPathFilesystemAbsolute.js +39 -0
- package/dist/cjs/utils/createErrorWithCleanStackTrace.js +1 -7
- package/dist/cjs/utils/debug.js +2 -1
- package/dist/cjs/utils/findFile.js +2 -1
- package/dist/cjs/utils/hasProp.js +9 -5
- package/dist/cjs/utils/injectRollupInputs.js +2 -1
- package/dist/cjs/utils/isArray.js +8 -0
- package/dist/cjs/utils/isArrayOfStrings.js +8 -0
- package/dist/cjs/utils/isNpmPackage.js +1 -1
- package/dist/cjs/utils/isObjectOfStrings.js +8 -0
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +2 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -0
- package/dist/esm/client/shared/getPageContextSerializedInHtml.d.ts +1 -0
- package/dist/esm/client/shared/getPageContextSerializedInHtml.js +1 -0
- package/dist/esm/client/shared/loadUserFilesClientSide.js +3 -7
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +20 -17
- package/dist/esm/node/plugin/plugins/distFileNames.js +2 -2
- package/dist/esm/node/plugin/plugins/envVars.js +2 -6
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +14 -11
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +4 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +12 -15
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +12 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +123 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +8 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +7 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +53 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +81 -106
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +11 -5
- package/dist/esm/node/plugin/shared/getFilePath.js +43 -47
- package/dist/esm/node/plugin/utils.d.ts +2 -2
- package/dist/esm/node/plugin/utils.js +2 -2
- package/dist/esm/node/prerender/runPrerender.js +6 -5
- package/dist/esm/node/prerender/utils.d.ts +2 -1
- package/dist/esm/node/prerender/utils.js +2 -1
- package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +1 -0
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/esm/node/runtime/index-common.d.ts +0 -4
- package/dist/esm/node/runtime/index-common.js +14 -3
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +4 -4
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +27 -16
- package/dist/esm/node/runtime/renderPage/log404/index.js +2 -2
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -7
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +16 -16
- package/dist/esm/node/runtime/utils.d.ts +2 -1
- package/dist/esm/node/runtime/utils.js +2 -1
- package/dist/esm/node/shared/assertV1Design.js +1 -1
- package/dist/esm/node/shared/getClientEntry.js +1 -1
- package/dist/esm/node/shared/utils.d.ts +0 -1
- package/dist/esm/node/shared/utils.js +0 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/getExports.d.ts +4 -5
- package/dist/esm/shared/getPageFiles/getExports.js +9 -16
- package/dist/esm/shared/getPageFiles.d.ts +1 -2
- package/dist/esm/shared/getPageFiles.js +1 -3
- package/dist/esm/shared/hooks/getHook.js +6 -5
- package/dist/esm/shared/page-configs/Config.d.ts +2 -2
- package/dist/esm/shared/page-configs/FilePath.d.ts +32 -22
- package/dist/esm/shared/page-configs/PageConfig.d.ts +27 -15
- package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +11 -0
- package/dist/esm/shared/page-configs/getConfigDefinedAt.js +42 -0
- package/dist/esm/shared/page-configs/{helpers/getConfigValue.d.ts → getConfigValue.d.ts} +2 -2
- package/dist/esm/shared/page-configs/{helpers/getConfigValue.js → getConfigValue.js} +6 -8
- package/dist/esm/shared/page-configs/helpers.d.ts +3 -9
- package/dist/esm/shared/page-configs/helpers.js +6 -8
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +7 -4
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +2 -2
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +2 -1
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +12 -7
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +5 -4
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +3 -3
- package/dist/esm/shared/route/index.js +2 -2
- package/dist/esm/shared/route/loadPageRoutes.d.ts +3 -3
- package/dist/esm/shared/route/loadPageRoutes.js +10 -8
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +1 -1
- package/dist/esm/shared/route/resolveRouteFunction.js +9 -10
- package/dist/esm/shared/route/resolveRouteString.d.ts +0 -2
- package/dist/esm/shared/route/resolveRouteString.js +5 -16
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/shared/utils.d.ts +1 -0
- package/dist/esm/shared/utils.js +1 -0
- package/dist/esm/utils/assertPathFilesystemAbsolute.d.ts +6 -0
- package/dist/esm/utils/assertPathFilesystemAbsolute.js +33 -0
- package/dist/esm/utils/createErrorWithCleanStackTrace.js +1 -7
- package/dist/esm/utils/debug.js +2 -1
- package/dist/esm/utils/findFile.js +2 -1
- package/dist/esm/utils/hasProp.d.ts +1 -0
- package/dist/esm/utils/hasProp.js +9 -5
- package/dist/esm/utils/injectRollupInputs.js +2 -1
- package/dist/esm/utils/isArray.d.ts +1 -0
- package/dist/esm/utils/isArray.js +4 -0
- package/dist/esm/utils/isArrayOfStrings.d.ts +2 -0
- package/dist/esm/utils/isArrayOfStrings.js +5 -0
- package/dist/esm/utils/isNpmPackage.js +1 -1
- package/dist/esm/utils/isObjectOfStrings.d.ts +2 -0
- package/dist/esm/utils/isObjectOfStrings.js +5 -0
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +0 -43
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +0 -21
- package/dist/cjs/utils/isStringRecord.js +0 -7
- package/dist/cjs/utils/mergeCumulativeValues.js +0 -21
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +0 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +0 -109
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +0 -7
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +0 -37
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.d.ts +0 -3
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +0 -15
- package/dist/esm/utils/isStringRecord.d.ts +0 -1
- package/dist/esm/utils/isStringRecord.js +0 -3
- package/dist/esm/utils/mergeCumulativeValues.d.ts +0 -2
- package/dist/esm/utils/mergeCumulativeValues.js +0 -18
|
@@ -5,7 +5,8 @@ const error_page_js_1 = require("../error-page.js");
|
|
|
5
5
|
const utils_js_1 = require("./utils.js");
|
|
6
6
|
const deduceRouteStringFromFilesystemPath_js_1 = require("./deduceRouteStringFromFilesystemPath.js");
|
|
7
7
|
const utils_js_2 = require("../utils.js");
|
|
8
|
-
const
|
|
8
|
+
const getConfigValue_js_1 = require("../page-configs/getConfigValue.js");
|
|
9
|
+
const getConfigDefinedAt_js_1 = require("../page-configs/getConfigDefinedAt.js");
|
|
9
10
|
const resolveRouteFunction_js_1 = require("./resolveRouteFunction.js");
|
|
10
11
|
const getHook_js_1 = require("../hooks/getHook.js");
|
|
11
12
|
async function loadPageRoutes(
|
|
@@ -30,28 +31,29 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
30
31
|
let pageRoute = null;
|
|
31
32
|
{
|
|
32
33
|
const configName = 'route';
|
|
33
|
-
const configValue = (0,
|
|
34
|
+
const configValue = (0, getConfigValue_js_1.getConfigValue)(pageConfig, configName);
|
|
34
35
|
if (configValue) {
|
|
35
36
|
const route = configValue.value;
|
|
36
|
-
|
|
37
|
+
(0, utils_js_1.assert)(configValue.definedAtData);
|
|
38
|
+
const definedAtString = (0, getConfigDefinedAt_js_1.getDefinedAtString)(configValue.definedAtData, configName);
|
|
37
39
|
if (typeof route === 'string') {
|
|
38
40
|
pageRoute = {
|
|
39
41
|
pageId,
|
|
40
42
|
comesFromV1PageConfig,
|
|
41
43
|
routeString: route,
|
|
42
|
-
|
|
44
|
+
routeDefinedAtString: definedAtString,
|
|
43
45
|
routeType: 'STRING'
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
else {
|
|
47
49
|
(0, utils_js_1.assert)((0, utils_js_2.isCallable)(route));
|
|
48
|
-
if ((0,
|
|
50
|
+
if ((0, getConfigValue_js_1.getConfigValue)(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
|
|
49
51
|
(0, resolveRouteFunction_js_1.warnDeprecatedAllowKey)();
|
|
50
52
|
pageRoute = {
|
|
51
53
|
pageId,
|
|
52
54
|
comesFromV1PageConfig,
|
|
53
55
|
routeFunction: route,
|
|
54
|
-
|
|
56
|
+
routeDefinedAtString: definedAtString,
|
|
55
57
|
routeType: 'FUNCTION'
|
|
56
58
|
};
|
|
57
59
|
}
|
|
@@ -67,7 +69,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
67
69
|
routeFilesystemDefinedBy: definedBy,
|
|
68
70
|
comesFromV1PageConfig,
|
|
69
71
|
routeString,
|
|
70
|
-
|
|
72
|
+
routeDefinedAtString: null,
|
|
71
73
|
routeType: 'FILESYSTEM'
|
|
72
74
|
};
|
|
73
75
|
}
|
|
@@ -92,7 +94,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
92
94
|
pageId,
|
|
93
95
|
comesFromV1PageConfig,
|
|
94
96
|
routeString,
|
|
95
|
-
|
|
97
|
+
routeDefinedAtString: null,
|
|
96
98
|
routeFilesystemDefinedBy: `${pageId}.page.*`,
|
|
97
99
|
routeType: 'FILESYSTEM'
|
|
98
100
|
});
|
|
@@ -107,7 +109,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
107
109
|
pageId,
|
|
108
110
|
comesFromV1PageConfig,
|
|
109
111
|
routeString,
|
|
110
|
-
|
|
112
|
+
routeDefinedAtString: filePath,
|
|
111
113
|
routeType: 'STRING'
|
|
112
114
|
});
|
|
113
115
|
return;
|
|
@@ -124,7 +126,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
124
126
|
pageId,
|
|
125
127
|
comesFromV1PageConfig,
|
|
126
128
|
routeFunction,
|
|
127
|
-
|
|
129
|
+
routeDefinedAtString: filePath,
|
|
128
130
|
routeType: 'FUNCTION'
|
|
129
131
|
});
|
|
130
132
|
return;
|
|
@@ -7,10 +7,10 @@ exports.warnDeprecatedAllowKey = exports.assertSyncRouting = exports.assertRoute
|
|
|
7
7
|
const addUrlComputedProps_js_1 = require("../addUrlComputedProps.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
9
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
|
-
async function resolveRouteFunction(routeFunction, pageContext,
|
|
10
|
+
async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAtString) {
|
|
11
11
|
(0, addUrlComputedProps_js_1.assertPageContextUrlComputedProps)(pageContext);
|
|
12
12
|
let result = routeFunction(pageContext);
|
|
13
|
-
assertSyncRouting(result, `The Route Function ${
|
|
13
|
+
assertSyncRouting(result, `The Route Function ${routeDefinedAtString}`);
|
|
14
14
|
// TODO/v1-release: make resolveRouteFunction() and route() sync
|
|
15
15
|
//* We disallow asynchronous routing, because we need to check whether a link is a Vike link in a synchronous fashion before calling ev.preventDefault() in the 'click' event listener
|
|
16
16
|
result = await result;
|
|
@@ -21,11 +21,11 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAt)
|
|
|
21
21
|
if (result === true) {
|
|
22
22
|
result = {};
|
|
23
23
|
}
|
|
24
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isPlainObject)(result), `The Route Function ${
|
|
24
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.isPlainObject)(result), `The Route Function ${routeDefinedAtString} should return a boolean or a plain JavaScript object (but it's ${picocolors_1.default.cyan(`typeof result === ${JSON.stringify(typeof result)}`)} instead)`);
|
|
25
25
|
// AFAICT this return interface is superfluous. Should we soft-deprecate it and remove it?
|
|
26
26
|
if ('match' in result) {
|
|
27
27
|
const { match } = result;
|
|
28
|
-
(0, utils_js_1.assertUsage)(typeof match === 'boolean', `The ${picocolors_1.default.cyan('match')} value returned by the Route Function ${
|
|
28
|
+
(0, utils_js_1.assertUsage)(typeof match === 'boolean', `The ${picocolors_1.default.cyan('match')} value returned by the Route Function ${routeDefinedAtString} should be a boolean.`);
|
|
29
29
|
if (!match) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
@@ -33,14 +33,14 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAt)
|
|
|
33
33
|
let precedence = null;
|
|
34
34
|
if ('precedence' in result) {
|
|
35
35
|
precedence = result.precedence;
|
|
36
|
-
(0, utils_js_1.assertUsage)(typeof precedence === 'number', `The ${picocolors_1.default.cyan('precedence')} value returned by the Route Function ${
|
|
36
|
+
(0, utils_js_1.assertUsage)(typeof precedence === 'number', `The ${picocolors_1.default.cyan('precedence')} value returned by the Route Function ${routeDefinedAtString} should be a number.`);
|
|
37
37
|
}
|
|
38
|
-
assertRouteParams(result, `The ${picocolors_1.default.cyan('routeParams')} object returned by the Route Function ${
|
|
38
|
+
assertRouteParams(result, `The ${picocolors_1.default.cyan('routeParams')} object returned by the Route Function ${routeDefinedAtString} should`);
|
|
39
39
|
const routeParams = result.routeParams || {};
|
|
40
40
|
(0, utils_js_1.assertUsage)(!('pageContext' in result), `Providing ${picocolors_1.default.cyan('pageContext')} in Route Functions is prohibited, see https://vike.dev/route-function#cannot-provide-pagecontext`);
|
|
41
41
|
(0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(routeParams));
|
|
42
42
|
Object.keys(result).forEach((key) => {
|
|
43
|
-
(0, utils_js_1.assertUsage)(key === 'match' || key === 'routeParams' || key === 'precedence', `The Route Function ${
|
|
43
|
+
(0, utils_js_1.assertUsage)(key === 'match' || key === 'routeParams' || key === 'precedence', `The Route Function ${routeDefinedAtString} returned an object with an unknown property ${picocolors_1.default.cyan(key)} (the known properties are ${picocolors_1.default.cyan('match')}, ${picocolors_1.default.cyan('routeParams')}, and ${picocolors_1.default.cyan('precedence')})`);
|
|
44
44
|
});
|
|
45
45
|
return {
|
|
46
46
|
precedence,
|
|
@@ -65,7 +65,6 @@ function assertRouteParams(result, errPrefix) {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
(0, utils_js_1.assert)(errPrefix.endsWith(' should'));
|
|
68
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.
|
|
69
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isStringRecord)(result.routeParams), `${errPrefix} only hold string values.`);
|
|
68
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(result, 'routeParams', 'string{}'), `${errPrefix} be an object holding string values.`);
|
|
70
69
|
}
|
|
71
70
|
exports.assertRouteParams = assertRouteParams;
|
|
@@ -26,12 +26,7 @@ function resolveRouteString(routeString, urlPathname) {
|
|
|
26
26
|
return '[^/]+';
|
|
27
27
|
}
|
|
28
28
|
if (segment.glob) {
|
|
29
|
-
|
|
30
|
-
return '|/.*';
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return '.*';
|
|
34
|
-
}
|
|
29
|
+
return '.*';
|
|
35
30
|
}
|
|
36
31
|
// segment.static
|
|
37
32
|
return (0, utils_js_1.escapeRegex)(segment.static);
|
|
@@ -61,8 +56,6 @@ function resolveRouteString(routeString, urlPathname) {
|
|
|
61
56
|
}
|
|
62
57
|
if (segment.glob) {
|
|
63
58
|
const param = `*${hasMultipleGlobs ? ++globIdx : ''}`;
|
|
64
|
-
if (segment.isLastDir)
|
|
65
|
-
val = val.slice(1);
|
|
66
59
|
routeParams[param] = val;
|
|
67
60
|
}
|
|
68
61
|
});
|
|
@@ -82,21 +75,17 @@ function parseRouteString(routeString) {
|
|
|
82
75
|
};
|
|
83
76
|
const parts = routeString.split('/');
|
|
84
77
|
parts.forEach((s, i) => {
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
if (i !== 0)
|
|
79
|
+
pushStatic('/');
|
|
87
80
|
if (isParam(s)) {
|
|
88
81
|
(0, utils_js_1.assertWarning)(!s.startsWith(PARAM_TOKEN_OLD), `Outdated Route String ${highlight(routeString)}, use ${highlight(routeString.split(PARAM_TOKEN_OLD).join(PARAM_TOKEN_NEW))} instead`, { onlyOnce: true });
|
|
89
|
-
if (!isFirst)
|
|
90
|
-
pushStatic('/');
|
|
91
82
|
segments.push({ param: s.slice(1) });
|
|
92
83
|
}
|
|
93
84
|
else {
|
|
94
|
-
if (s === '*' &&
|
|
95
|
-
segments.push({ glob: true
|
|
85
|
+
if (s === '*' && i === parts.length - 1 && routeString !== '*' && routeString !== '/*') {
|
|
86
|
+
segments.push({ glob: true });
|
|
96
87
|
}
|
|
97
88
|
else {
|
|
98
|
-
if (!isFirst)
|
|
99
|
-
pushStatic('/');
|
|
100
89
|
s.split('*').forEach((s, i) => {
|
|
101
90
|
if (i !== 0)
|
|
102
91
|
segments.push({ glob: true });
|
|
@@ -31,7 +31,6 @@ __exportStar(require("../../utils/isPromise.js"), exports);
|
|
|
31
31
|
__exportStar(require("../../utils/isPlainObject.js"), exports);
|
|
32
32
|
__exportStar(require("../../utils/objectAssign.js"), exports);
|
|
33
33
|
__exportStar(require("../../utils/slice.js"), exports);
|
|
34
|
-
__exportStar(require("../../utils/isStringRecord.js"), exports);
|
|
35
34
|
__exportStar(require("../../utils/unique.js"), exports);
|
|
36
35
|
__exportStar(require("../../utils/isBrowser.js"), exports);
|
|
37
36
|
__exportStar(require("../../utils/parseUrl.js"), exports);
|
package/dist/cjs/shared/utils.js
CHANGED
|
@@ -40,3 +40,4 @@ __exportStar(require("../utils/isPromise.js"), exports);
|
|
|
40
40
|
__exportStar(require("../utils/checkType.js"), exports);
|
|
41
41
|
__exportStar(require("../utils/getValuePrintable.js"), exports);
|
|
42
42
|
__exportStar(require("../utils/escapeRegex.js"), exports);
|
|
43
|
+
__exportStar(require("../utils/isArray.js"), exports);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isPathFilesystemAbsolute = exports.assertPathFilesystemAbsolute = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const assert_js_1 = require("./assert.js");
|
|
9
|
+
const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
10
|
+
/** Assert path is absolute starting from the filesystem root. */
|
|
11
|
+
function assertPathFilesystemAbsolute(p) {
|
|
12
|
+
// The assert is "eventually reliable":
|
|
13
|
+
// - For Windows users, the assert is correct.
|
|
14
|
+
// - For Linux users assertPathFilesystemAbsolute() will erroneously succeed if `p` is a path absolute from the user root dir.
|
|
15
|
+
// - But that's okay because the assertion will eventually fail for Windows users.
|
|
16
|
+
(0, assert_js_1.assert)(isPathFilesystemAbsolute(p));
|
|
17
|
+
}
|
|
18
|
+
exports.assertPathFilesystemAbsolute = assertPathFilesystemAbsolute;
|
|
19
|
+
/** Whether path is absolute starting from the filesystem root. Isn't reliable for Linux users: isPathFilesystemAbsolute() returns `true` for paths absolute from the user root dir. */
|
|
20
|
+
function isPathFilesystemAbsolute(p) {
|
|
21
|
+
(0, filesystemPathHandling_js_1.assertPosixPath)(p);
|
|
22
|
+
(0, assert_js_1.assert)(!p.startsWith('/@fs/'));
|
|
23
|
+
if (process.platform !== 'win32') {
|
|
24
|
+
// - For linux users, there doesn't seem to be a reliable way to distinguish between:
|
|
25
|
+
// - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
|
|
26
|
+
// - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
|
|
27
|
+
// - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
|
|
28
|
+
// - Using require.resolve() would be a solution but probably too slow?
|
|
29
|
+
return p.startsWith('/');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const yes = path_1.default.win32.isAbsolute(p);
|
|
33
|
+
// Ensure isPathFilesystemAbsolute() returns `false` if path is absolute starting from the user root dir (see comments above).
|
|
34
|
+
if (yes)
|
|
35
|
+
(0, assert_js_1.assert)(!p.startsWith('/'));
|
|
36
|
+
return yes;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.isPathFilesystemAbsolute = isPathFilesystemAbsolute;
|
|
@@ -3,13 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createErrorWithCleanStackTrace = void 0;
|
|
4
4
|
const isNodeJS_js_1 = require("./isNodeJS.js");
|
|
5
5
|
function createErrorWithCleanStackTrace(errorMessage, numberOfStackTraceLinesToRemove) {
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
var stackTraceLimit__original = Error.stackTraceLimit;
|
|
9
|
-
Error.stackTraceLimit = Infinity;
|
|
10
|
-
err = new Error(errorMessage);
|
|
11
|
-
Error.stackTraceLimit = stackTraceLimit__original;
|
|
12
|
-
}
|
|
6
|
+
const err = new Error(errorMessage);
|
|
13
7
|
if ((0, isNodeJS_js_1.isNodeJS)()) {
|
|
14
8
|
err.stack = clean(err.stack, numberOfStackTraceLinesToRemove);
|
|
15
9
|
}
|
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -11,6 +11,7 @@ const assert_js_1 = require("./assert.js");
|
|
|
11
11
|
const checkType_js_1 = require("./checkType.js");
|
|
12
12
|
const getTerminWidth_js_1 = require("./getTerminWidth.js");
|
|
13
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
|
+
const isArray_js_1 = require("./isArray.js");
|
|
14
15
|
// Avoid this to be loaded in the browser. For isomorphic code: instead of `import { createDebugger } from './utils.js'`, use `globalThis.createDebugger()`.
|
|
15
16
|
(0, assert_js_1.assert)(!(0, isBrowser_js_1.isBrowser)());
|
|
16
17
|
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
@@ -87,7 +88,7 @@ function formatMsg(info, options, padding, position) {
|
|
|
87
88
|
if (typeof info === 'string') {
|
|
88
89
|
str += info;
|
|
89
90
|
}
|
|
90
|
-
else if (
|
|
91
|
+
else if ((0, isArray_js_1.isArray)(info)) {
|
|
91
92
|
if (info.length === 0) {
|
|
92
93
|
str += options.serialization?.emptyArray ?? '[]';
|
|
93
94
|
}
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.findFile = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const isArray_js_1 = require("./isArray.js");
|
|
9
10
|
function findFile(arg, cwd) {
|
|
10
|
-
const filenames =
|
|
11
|
+
const filenames = (0, isArray_js_1.isArray)(arg) ? arg : [arg];
|
|
11
12
|
let dir = cwd;
|
|
12
13
|
while (true) {
|
|
13
14
|
for (const filename of filenames) {
|
|
@@ -5,8 +5,9 @@ exports.hasProp = void 0;
|
|
|
5
5
|
// - https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABDAzgFQJ4AcCmdgAUAbgIYA2IOAXIiWBgDSJTbWIDkARnHGTnewCUNUhRzIUibr35gA3AFgAUKEiwEEzLnzFylGnUbNWNdmBABbTjgBOQkXvGpE5q7cUrw0eElRa8hKL6tPRMLLimKFA2MGAA5vaIQU6SUTHxHqreGn6sOskGocYRHOAA1mBwAO5gickSiOWVNZle6r7oeYGOhUbhbGmxcYgAvKVgFdW1wlI8fHSIAN7KiMiExeIjW+OTNeyIgksrq4g2OFAgNkjRlMcAvsdnF1cb+EmOo9v9Hg9KyhAIKK0GhNKajRAAFgATMplCQUChbFACLltIQSEwzJZrHZBIJ-oCZAA6MhwOIEEj4v6eNQ+WgIpEEAFgAAmMHaIImzTAM3hiJsUEkzLZ7SOShOa0QTIQIp8hyelzAx1WUAAFjZqi4cFVEABRGwamwEdgAQQZArpADESDAyEJlHcgA
|
|
6
6
|
const isCallable_js_1 = require("./isCallable.js");
|
|
7
7
|
const isObject_js_1 = require("./isObject.js");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const isArrayOfStrings_js_1 = require("./isArrayOfStrings.js");
|
|
9
|
+
const isObjectOfStrings_js_1 = require("./isObjectOfStrings.js");
|
|
10
|
+
const isArray_js_1 = require("./isArray.js");
|
|
10
11
|
function hasProp(obj, prop, type = 'unknown') {
|
|
11
12
|
if (!(0, isObject_js_1.isObject)(obj))
|
|
12
13
|
return false;
|
|
@@ -18,18 +19,21 @@ function hasProp(obj, prop, type = 'unknown') {
|
|
|
18
19
|
}
|
|
19
20
|
const propValue = obj[prop];
|
|
20
21
|
if (type === 'array') {
|
|
21
|
-
return
|
|
22
|
+
return (0, isArray_js_1.isArray)(propValue);
|
|
22
23
|
}
|
|
23
24
|
if (type === 'object') {
|
|
24
25
|
return (0, isObject_js_1.isObject)(propValue);
|
|
25
26
|
}
|
|
26
27
|
if (type === 'string[]') {
|
|
27
|
-
return
|
|
28
|
+
return (0, isArrayOfStrings_js_1.isArrayOfStrings)(propValue);
|
|
29
|
+
}
|
|
30
|
+
if (type === 'string{}') {
|
|
31
|
+
return (0, isObjectOfStrings_js_1.isObjectOfStrings)(propValue);
|
|
28
32
|
}
|
|
29
33
|
if (type === 'function') {
|
|
30
34
|
return (0, isCallable_js_1.isCallable)(propValue);
|
|
31
35
|
}
|
|
32
|
-
if (
|
|
36
|
+
if ((0, isArray_js_1.isArray)(type)) {
|
|
33
37
|
return typeof propValue === 'string' && type.includes(propValue);
|
|
34
38
|
}
|
|
35
39
|
if (type === 'null') {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeRollupInput = exports.injectRollupInputs = void 0;
|
|
4
4
|
const assert_js_1 = require("./assert.js");
|
|
5
5
|
const isObject_js_1 = require("./isObject.js");
|
|
6
|
+
const isArray_js_1 = require("./isArray.js");
|
|
6
7
|
function injectRollupInputs(inputsNew, config) {
|
|
7
8
|
const inputsCurrent = normalizeRollupInput(config.build.rollupOptions.input);
|
|
8
9
|
const input = {
|
|
@@ -20,7 +21,7 @@ function normalizeRollupInput(input) {
|
|
|
20
21
|
if (typeof input === 'string') {
|
|
21
22
|
input = [input];
|
|
22
23
|
}
|
|
23
|
-
if (
|
|
24
|
+
if ((0, isArray_js_1.isArray)(input)) {
|
|
24
25
|
return Object.fromEntries(input.map((input) => [input, input]));
|
|
25
26
|
}
|
|
26
27
|
(0, assert_js_1.assert)((0, isObject_js_1.isObject)(input));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isArray = void 0;
|
|
4
|
+
// Typesafe Array.isArray() — asserting unknown[] instead of any[]
|
|
5
|
+
function isArray(value) {
|
|
6
|
+
return Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
exports.isArray = isArray;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isArrayOfStrings = void 0;
|
|
4
|
+
const isArray_js_1 = require("./isArray.js");
|
|
5
|
+
function isArrayOfStrings(val) {
|
|
6
|
+
return (0, isArray_js_1.isArray)(val) && val.every((v) => typeof v === 'string');
|
|
7
|
+
}
|
|
8
|
+
exports.isArrayOfStrings = isArrayOfStrings;
|
|
@@ -15,7 +15,7 @@ function assertIsNpmPackageImport(str) {
|
|
|
15
15
|
(0, assert_js_1.assert)(isNpmPackageImport(str, {
|
|
16
16
|
// If `str` is a path alias that looks like an npm package => assertIsNpmPackageImport() is erroneous but that's okay because the assertion will eventually fail for some other user using a disambiguated path alias.
|
|
17
17
|
cannotBePathAlias: true
|
|
18
|
-
}));
|
|
18
|
+
}), str);
|
|
19
19
|
}
|
|
20
20
|
exports.assertIsNpmPackageImport = assertIsNpmPackageImport;
|
|
21
21
|
function isNpmPackageName(str) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObjectOfStrings = void 0;
|
|
4
|
+
const isObject_js_1 = require("./isObject.js");
|
|
5
|
+
function isObjectOfStrings(val) {
|
|
6
|
+
return (0, isObject_js_1.isObject)(val) && Object.values(val).every((v) => typeof v === 'string');
|
|
7
|
+
}
|
|
8
|
+
exports.isObjectOfStrings = isObjectOfStrings;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const PROJECT_VERSION = '0.4.168-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.168-commit-42406a9';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -13,7 +13,9 @@ type PageContextSerialized = {
|
|
|
13
13
|
_pageId: string;
|
|
14
14
|
_hasPageContextFromServer: true;
|
|
15
15
|
};
|
|
16
|
-
declare function getPageContextFromHooks_serialized(): PageContextSerialized
|
|
16
|
+
declare function getPageContextFromHooks_serialized(): PageContextSerialized & {
|
|
17
|
+
routeParams: Record<string, string>;
|
|
18
|
+
};
|
|
17
19
|
declare function getPageContextFromHooks_isHydration(pageContext: PageContextSerialized & PageContext & PageContextExports): Promise<{
|
|
18
20
|
isHydration: true;
|
|
19
21
|
_hasPageContextFromClient: false;
|
|
@@ -9,7 +9,8 @@ import { getHook } from '../../shared/hooks/getHook.js';
|
|
|
9
9
|
import { preparePageContextForUserConsumptionClientSide } from '../shared/preparePageContextForUserConsumptionClientSide.js';
|
|
10
10
|
import { removeBuiltInOverrides } from './getPageContext/removeBuiltInOverrides.js';
|
|
11
11
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
12
|
-
import {
|
|
12
|
+
import { getPageConfig } from '../../shared/page-configs/helpers.js';
|
|
13
|
+
import { getConfigValue } from '../../shared/page-configs/getConfigValue.js';
|
|
13
14
|
import { assertOnBeforeRenderHookReturn } from '../../shared/assertOnBeforeRenderHookReturn.js';
|
|
14
15
|
import { executeGuardHook } from '../../shared/route/executeGuardHook.js';
|
|
15
16
|
import { AbortRender, isAbortPageContext } from '../../shared/route/abort.js';
|
|
@@ -15,5 +15,6 @@ function getPageContextSerializedInHtml() {
|
|
|
15
15
|
assert(pageContextJson);
|
|
16
16
|
const pageContextSerializedInHtml = parse(pageContextJson);
|
|
17
17
|
assert(hasProp(pageContextSerializedInHtml, '_pageId', 'string'));
|
|
18
|
+
assert(hasProp(pageContextSerializedInHtml, 'routeParams', 'string{}'));
|
|
18
19
|
return pageContextSerializedInHtml;
|
|
19
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { loadUserFilesClientSide };
|
|
2
2
|
export { isErrorFetchingStaticAssets };
|
|
3
|
-
import { getPageFilesClientSide,
|
|
3
|
+
import { getPageFilesClientSide, getPageContextExports } from '../../shared/getPageFiles.js';
|
|
4
4
|
import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
|
|
5
5
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
6
6
|
const stamp = '__whileFetchingAssets';
|
|
@@ -28,13 +28,9 @@ async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
|
|
|
28
28
|
}
|
|
29
29
|
throw err;
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const pageContextExports = getPageContextExports(pageFilesClientSide, pageConfigLoaded);
|
|
32
32
|
const pageContextAddendum = {
|
|
33
|
-
|
|
34
|
-
configEntries,
|
|
35
|
-
exports,
|
|
36
|
-
exportsAll,
|
|
37
|
-
pageExports,
|
|
33
|
+
...pageContextExports,
|
|
38
34
|
_pageFilesLoaded: pageFilesClientSide
|
|
39
35
|
};
|
|
40
36
|
return pageContextAddendum;
|
|
@@ -4,7 +4,7 @@ export { analyzeClientEntries };
|
|
|
4
4
|
export { manifestTempFile };
|
|
5
5
|
import { assert, resolveOutDir, viteIsSSR, addOnBeforeLogHook, removeFileExtention, unique, assertUsage, injectRollupInputs, normalizeRollupInput, getOutDirs, assertNodeEnv_build, assertIsNpmPackageImport } from '../utils.js';
|
|
6
6
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
-
import { getConfigValue } from '../../../shared/page-configs/
|
|
7
|
+
import { getConfigValue } from '../../../shared/page-configs/getConfigValue.js';
|
|
8
8
|
import { findPageFiles } from '../shared/findPageFiles.js';
|
|
9
9
|
import { getConfigVike } from '../../shared/getConfigVike.js';
|
|
10
10
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { assertResolveAlias };
|
|
2
|
-
import { assert, assertUsage, assertWarning, isValidPathAlias } from '../../utils.js';
|
|
2
|
+
import { assert, assertUsage, assertWarning, isArray, isValidPathAlias } from '../../utils.js';
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
// Recommend users to avoid un-distinguishable path aliases.
|
|
5
5
|
// There are a lot of libraries that don't or cannot follow that recommendation, for example:
|
|
@@ -74,7 +74,7 @@ function assertResolveAlias(config) {
|
|
|
74
74
|
}
|
|
75
75
|
function getAliases(config) {
|
|
76
76
|
const { alias } = config.resolve;
|
|
77
|
-
if (!
|
|
77
|
+
if (!isArray(alias)) {
|
|
78
78
|
return [alias];
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { determineOptimizeDeps };
|
|
2
2
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
3
|
-
import { assert, assertIsNpmPackageImport, createDebugger, unique } from '../../utils.js';
|
|
3
|
+
import { assert, assertIsNpmPackageImport, createDebugger, isArray, unique } from '../../utils.js';
|
|
4
4
|
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
5
5
|
import { getConfigValueSourcesNotOverriden } from '../../shared/getConfigValueSourcesNotOverriden.js';
|
|
6
6
|
import { analyzeClientEntries } from '../buildConfig.js';
|
|
@@ -32,28 +32,32 @@ async function determineOptimizeDeps(config, isDev) {
|
|
|
32
32
|
async function getPageDeps(config, pageConfigs, isDev) {
|
|
33
33
|
let entries = [];
|
|
34
34
|
let include = [];
|
|
35
|
+
const addEntry = (e) => {
|
|
36
|
+
assert(e);
|
|
37
|
+
entries.push(e);
|
|
38
|
+
};
|
|
39
|
+
const addInclude = (e) => {
|
|
40
|
+
assert(e);
|
|
41
|
+
// Shouldn't be a path alias, as path aliases would need to be added to config.optimizeDeps.entries instead of config.optimizeDeps.include
|
|
42
|
+
assertIsNpmPackageImport(e);
|
|
43
|
+
include.push(e);
|
|
44
|
+
};
|
|
35
45
|
// V1 design
|
|
36
46
|
{
|
|
37
47
|
pageConfigs.forEach((pageConfig) => {
|
|
38
48
|
getConfigValueSourcesNotOverriden(pageConfig).forEach((configValueSource) => {
|
|
39
49
|
if (!configValueSource.valueIsImportedAtRuntime)
|
|
40
50
|
return;
|
|
41
|
-
const {
|
|
51
|
+
const { definedAtFilePath, configEnv } = configValueSource;
|
|
42
52
|
if (!configEnv.client)
|
|
43
53
|
return;
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Surprisingly Vite expects entries to be absolute paths
|
|
48
|
-
entries.push(filePathAbsoluteFilesystem);
|
|
54
|
+
if (definedAtFilePath.filePathAbsoluteUserRootDir !== null) {
|
|
55
|
+
// Vite expects entries to be filesystem absolute paths (surprisingly so).
|
|
56
|
+
addEntry(definedAtFilePath.filePathAbsoluteFilesystem);
|
|
49
57
|
}
|
|
50
58
|
else {
|
|
51
|
-
// Adding
|
|
52
|
-
|
|
53
|
-
assert(importPathAbsolute); // Help TS
|
|
54
|
-
// Shouldn't be a path alias, as path aliases would need to be added to config.optimizeDeps.entries instead of config.optimizeDeps.include
|
|
55
|
-
assertIsNpmPackageImport(importPathAbsolute);
|
|
56
|
-
include.push(importPathAbsolute);
|
|
59
|
+
// Adding definedAtFilePath.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
60
|
+
addInclude(definedAtFilePath.importPathAbsolute);
|
|
57
61
|
}
|
|
58
62
|
});
|
|
59
63
|
});
|
|
@@ -65,8 +69,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
65
69
|
pageFiles.forEach((filePathAbsoluteUserRootDir) => {
|
|
66
70
|
const entry = getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir });
|
|
67
71
|
const { filePathAbsoluteFilesystem } = entry;
|
|
68
|
-
|
|
69
|
-
entries.push(filePathAbsoluteFilesystem);
|
|
72
|
+
addEntry(filePathAbsoluteFilesystem);
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
entries = unique(entries);
|
|
@@ -83,7 +86,7 @@ function getVirtualFiles(config, pageConfigs) {
|
|
|
83
86
|
return entriesVirtualFiles;
|
|
84
87
|
}
|
|
85
88
|
function normalizeEntries(entries) {
|
|
86
|
-
if (
|
|
89
|
+
if (isArray(entries))
|
|
87
90
|
return entries;
|
|
88
91
|
if (typeof entries === 'string')
|
|
89
92
|
return [entries];
|
|
@@ -92,7 +95,7 @@ function normalizeEntries(entries) {
|
|
|
92
95
|
assert(false);
|
|
93
96
|
}
|
|
94
97
|
function normalizeInclude(include) {
|
|
95
|
-
if (
|
|
98
|
+
if (isArray(include))
|
|
96
99
|
return include;
|
|
97
100
|
if (include === undefined)
|
|
98
101
|
return [];
|
|
@@ -2,7 +2,7 @@ export { distFileNames };
|
|
|
2
2
|
// Attempt to preserve file structure of `.page.js` files:
|
|
3
3
|
// - https://github.com/vikejs/vike/commit/11a4c49e5403aa7c37c8020c462b499425b41854
|
|
4
4
|
// - Blocker: https://github.com/rollup/rollup/issues/4724
|
|
5
|
-
import { assertPosixPath, assert, assertUsage } from '../utils.js';
|
|
5
|
+
import { assertPosixPath, assert, assertUsage, isArray } from '../utils.js';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { getAssetsDir } from '../shared/getAssetsDir.js';
|
|
8
8
|
function distFileNames() {
|
|
@@ -165,7 +165,7 @@ function getRollupOutputs(config) {
|
|
|
165
165
|
(_a = config.build).rollupOptions ?? (_a.rollupOptions = {});
|
|
166
166
|
(_b = config.build.rollupOptions).output ?? (_b.output = {});
|
|
167
167
|
const { output } = config.build.rollupOptions;
|
|
168
|
-
if (!
|
|
168
|
+
if (!isArray(output)) {
|
|
169
169
|
return [output];
|
|
170
170
|
}
|
|
171
171
|
return output;
|
|
@@ -2,7 +2,7 @@ export { envVarsPlugin };
|
|
|
2
2
|
// For ./envVars.spec.ts
|
|
3
3
|
export { applyEnvVar };
|
|
4
4
|
import { loadEnv } from 'vite';
|
|
5
|
-
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, lowerFirst } from '../utils.js';
|
|
5
|
+
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, lowerFirst } from '../utils.js';
|
|
6
6
|
import { sourceMapPassthrough } from '../shared/rollupSourceMap.js';
|
|
7
7
|
import { getModuleFilePath } from '../shared/getFilePath.js';
|
|
8
8
|
function envVarsPlugin() {
|
|
@@ -30,11 +30,7 @@ function envVarsPlugin() {
|
|
|
30
30
|
Object.entries(envsAll)
|
|
31
31
|
.filter(([key]) => {
|
|
32
32
|
// Already handled by Vite
|
|
33
|
-
const envPrefix = !config.envPrefix
|
|
34
|
-
? []
|
|
35
|
-
: Array.isArray(config.envPrefix)
|
|
36
|
-
? config.envPrefix
|
|
37
|
-
: [config.envPrefix];
|
|
33
|
+
const envPrefix = !config.envPrefix ? [] : isArray(config.envPrefix) ? config.envPrefix : [config.envPrefix];
|
|
38
34
|
return !envPrefix.some((prefix) => key.startsWith(prefix));
|
|
39
35
|
})
|
|
40
36
|
.forEach(([envName, envVal]) => {
|