vike 0.4.144-commit-756f5d7 → 0.4.144-commit-f7ab002
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/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +152 -152
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +13 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -4
- package/dist/cjs/node/plugin/plugins/previewConfig.js +6 -2
- package/dist/cjs/node/prerender/runPrerender.js +8 -8
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +19 -6
- package/dist/cjs/node/runtime/renderPage/log404/index.js +27 -17
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
- package/dist/cjs/node/shared/getClientEntryFilePath.js +2 -2
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +4 -6
- package/dist/cjs/shared/getPageFiles/getExports.js +3 -3
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/getExportPath.js +3 -3
- package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +43 -0
- package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +44 -0
- package/dist/cjs/shared/page-configs/helpers.js +33 -0
- package/dist/cjs/shared/page-configs/loadConfigValues.js +2 -2
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +6 -8
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +9 -10
- package/dist/cjs/shared/route/abort.js +1 -1
- package/dist/cjs/shared/route/loadPageRoutes.js +11 -10
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/truncateString.js +12 -7
- package/dist/esm/client/client-routing-runtime/getPageContext.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/esm/node/plugin/plugins/importBuild/index.js +3 -3
- 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 +4 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +152 -152
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +14 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +1 -14
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -4
- package/dist/esm/node/plugin/plugins/previewConfig.js +6 -2
- package/dist/esm/node/prerender/runPrerender.js +2 -2
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +20 -7
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.js +27 -16
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -1
- package/dist/esm/node/shared/getClientEntryFilePath.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +2 -4
- package/dist/esm/shared/getPageFiles/getExports.js +2 -2
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +53 -31
- package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
- package/dist/esm/shared/page-configs/getExportPath.js +3 -3
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +7 -0
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +37 -0
- package/dist/esm/shared/page-configs/helpers/getConfigValue.d.ts +14 -0
- package/dist/esm/shared/page-configs/helpers/getConfigValue.js +38 -0
- package/dist/esm/shared/page-configs/helpers.d.ts +13 -0
- package/dist/esm/shared/page-configs/helpers.js +27 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +2 -2
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +4 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +6 -8
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +9 -10
- package/dist/esm/shared/route/abort.js +1 -1
- package/dist/esm/shared/route/loadPageRoutes.js +8 -7
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/truncateString.d.ts +2 -1
- package/dist/esm/utils/truncateString.js +10 -7
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -16
- package/dist/cjs/shared/page-configs/utils.js +0 -103
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +0 -24
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -13
- package/dist/esm/shared/page-configs/utils.d.ts +0 -35
- package/dist/esm/shared/page-configs/utils.js +0 -97
|
@@ -28,29 +28,28 @@ exports.serializeConfigValue = serializeConfigValue;
|
|
|
28
28
|
function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
|
|
29
29
|
(0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
|
|
30
30
|
(0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
|
|
31
|
-
const { valueIsImportedAtRuntime,
|
|
31
|
+
const { valueIsImportedAtRuntime, definedAt } = configValueSource;
|
|
32
32
|
(0, utils_js_1.assert)(valueIsImportedAtRuntime);
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const fileName = path_1.default.posix.basename(importPath);
|
|
33
|
+
const { filePathAbsoluteVite, fileExportName } = definedAt;
|
|
34
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteVite);
|
|
35
|
+
const fileName = path_1.default.posix.basename(filePathAbsoluteVite);
|
|
37
36
|
const isValueFile = fileName.startsWith('+');
|
|
38
37
|
if (isValueFile)
|
|
39
|
-
(0, utils_js_1.assert)(
|
|
40
|
-
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(
|
|
38
|
+
(0, utils_js_1.assert)(fileExportName === undefined);
|
|
39
|
+
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(filePathAbsoluteVite, varCounterContainer.varCounter++, fileExportName);
|
|
41
40
|
importStatements.push(importStatement);
|
|
42
41
|
const lines = [];
|
|
43
42
|
lines.push(` {`);
|
|
44
43
|
lines.push(` configName: '${configName}',`);
|
|
45
|
-
lines.push(` importPath: '${
|
|
44
|
+
lines.push(` importPath: '${filePathAbsoluteVite}',`);
|
|
46
45
|
lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
|
|
47
46
|
if (isValueFile) {
|
|
48
47
|
lines.push(` exportValues: ${importName},`);
|
|
49
48
|
}
|
|
50
49
|
else {
|
|
51
50
|
lines.push(` exportValue: ${importName},`);
|
|
52
|
-
(0, utils_js_1.assert)(
|
|
53
|
-
lines.push(` exportName: ${JSON.stringify(
|
|
51
|
+
(0, utils_js_1.assert)(fileExportName);
|
|
52
|
+
lines.push(` exportName: ${JSON.stringify(fileExportName)},`);
|
|
54
53
|
}
|
|
55
54
|
lines.push(` },`);
|
|
56
55
|
return lines;
|
|
@@ -39,7 +39,7 @@ exports.redirect = redirect;
|
|
|
39
39
|
function render(value, abortReason) {
|
|
40
40
|
const args = [typeof value === 'number' ? String(value) : JSON.stringify(value)];
|
|
41
41
|
if (abortReason !== undefined)
|
|
42
|
-
args.push((0, utils_js_1.truncateString)(JSON.stringify(abortReason), 30
|
|
42
|
+
args.push((0, utils_js_1.truncateString)(JSON.stringify(abortReason), 30));
|
|
43
43
|
const abortCaller = 'throw render()';
|
|
44
44
|
const abortCall = `throw render(${args.join(', ')})`;
|
|
45
45
|
return render_(value, abortReason, abortCall, abortCaller);
|
|
@@ -5,10 +5,10 @@ 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 helpers_js_1 = require("../page-configs/helpers.js");
|
|
9
9
|
const resolveRouteFunction_js_1 = require("./resolveRouteFunction.js");
|
|
10
10
|
async function loadPageRoutes(
|
|
11
|
-
//
|
|
11
|
+
// Remove all arguments and use GlobalContext instead?
|
|
12
12
|
pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
|
|
13
13
|
await Promise.all(pageFilesAll.filter((p) => p.fileType === '.page.route').map((p) => p.loadFile?.()));
|
|
14
14
|
const { onBeforeRouteHook, filesystemRoots } = getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal);
|
|
@@ -31,10 +31,10 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
31
31
|
let pageRoute = null;
|
|
32
32
|
{
|
|
33
33
|
const configName = 'route';
|
|
34
|
-
const configValue = (0,
|
|
34
|
+
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, configName);
|
|
35
35
|
if (configValue) {
|
|
36
36
|
const route = configValue.value;
|
|
37
|
-
const definedAt = (0,
|
|
37
|
+
const definedAt = (0, helpers_js_1.getDefinedAtString)(configValue.definedAt, configName);
|
|
38
38
|
if (typeof route === 'string') {
|
|
39
39
|
pageRoute = {
|
|
40
40
|
pageId,
|
|
@@ -46,7 +46,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
(0, utils_js_1.assert)((0, utils_js_2.isCallable)(route));
|
|
49
|
-
if ((0,
|
|
49
|
+
if ((0, helpers_js_1.getConfigValue)(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
|
|
50
50
|
(0, resolveRouteFunction_js_1.warnDeprecatedAllowKey)();
|
|
51
51
|
pageRoute = {
|
|
52
52
|
pageId,
|
|
@@ -139,12 +139,13 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
139
139
|
function getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal) {
|
|
140
140
|
// V1 Design
|
|
141
141
|
if (pageConfigs.length > 0) {
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
const hookName = 'onBeforeRoute';
|
|
143
|
+
if (pageConfigGlobal.configValues[hookName]?.value) {
|
|
144
|
+
const configValue = pageConfigGlobal.configValues[hookName];
|
|
144
145
|
const { value: hookFn } = configValue;
|
|
145
|
-
const hookFilePath = (0,
|
|
146
|
-
|
|
147
|
-
(0, utils_js_1.assertUsage)((0, utils_js_2.isCallable)(hookFn),
|
|
146
|
+
const hookFilePath = (0, helpers_js_1.getHookFilePathToShowToUser)(configValue);
|
|
147
|
+
const hookDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Hook', hookName, configValue);
|
|
148
|
+
(0, utils_js_1.assertUsage)((0, utils_js_2.isCallable)(hookFn), `${hookDefinedAt} should be a function.`);
|
|
148
149
|
const onBeforeRouteHook = {
|
|
149
150
|
hookFilePath: hookFilePath,
|
|
150
151
|
onBeforeRoute: hookFn
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectInfo = void 0;
|
|
4
4
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
5
|
-
const PROJECT_VERSION = '0.4.144-commit-
|
|
5
|
+
const PROJECT_VERSION = '0.4.144-commit-f7ab002';
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
8
8
|
projectVersion: PROJECT_VERSION,
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.truncateString = void 0;
|
|
4
|
-
|
|
7
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
|
+
const assert_js_1 = require("./assert.js");
|
|
9
|
+
function truncateString(str, lenMax) {
|
|
10
|
+
const lenMaxReal = lenMax - 3;
|
|
11
|
+
(0, assert_js_1.assert)(lenMaxReal >= 1); // Show at least one character before the ellipsis
|
|
5
12
|
if (str.length < lenMax) {
|
|
6
13
|
return str;
|
|
7
14
|
}
|
|
8
15
|
else {
|
|
9
|
-
//
|
|
10
|
-
// - So far, the str we pass to truncateString(str)
|
|
11
|
-
str = str.substring(0,
|
|
12
|
-
|
|
13
|
-
if (dim)
|
|
14
|
-
ellipsis = dim(ellipsis);
|
|
16
|
+
// Breaks ANSI codes.
|
|
17
|
+
// - So far, the `str` we pass to truncateString(str) is always expected to not contain any ANSI code
|
|
18
|
+
str = str.substring(0, lenMaxReal);
|
|
19
|
+
const ellipsis = picocolors_1.default.dim('...');
|
|
15
20
|
str = str + ellipsis;
|
|
16
21
|
return str;
|
|
17
22
|
}
|
|
@@ -14,7 +14,7 @@ import { preparePageContextForUserConsumptionClientSide } from '../shared/prepar
|
|
|
14
14
|
import { loadPageFilesClientSide } from '../shared/loadPageFilesClientSide.js';
|
|
15
15
|
import { removeBuiltInOverrides } from './getPageContext/removeBuiltInOverrides.js';
|
|
16
16
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
17
|
-
import { getConfigValue, getPageConfig } from '../../shared/page-configs/
|
|
17
|
+
import { getConfigValue, getPageConfig } from '../../shared/page-configs/helpers.js';
|
|
18
18
|
import { assertOnBeforeRenderHookReturn } from '../../shared/assertOnBeforeRenderHookReturn.js';
|
|
19
19
|
import { executeGuardHook } from '../../shared/route/executeGuardHook.js';
|
|
20
20
|
import { AbortRender, isAbortPageContext } from '../../shared/route/abort.js';
|
|
@@ -4,7 +4,7 @@ export { analyzeClientEntries };
|
|
|
4
4
|
import { assert, resolveOutDir, isObject, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, getOutDirs } from '../utils.js';
|
|
5
5
|
import { virtualFileIdImportUserCodeServer } from '../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
6
6
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
-
import { getConfigValue } from '../../../shared/page-configs/
|
|
7
|
+
import { getConfigValue } from '../../../shared/page-configs/helpers.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';
|
|
@@ -34,18 +34,18 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
34
34
|
configValueSourcesRelevant.forEach((configValueSource) => {
|
|
35
35
|
if (!configValueSource.valueIsImportedAtRuntime)
|
|
36
36
|
return;
|
|
37
|
-
const {
|
|
37
|
+
const { definedAt, configEnv } = configValueSource;
|
|
38
38
|
if (configEnv !== 'client-only' && configEnv !== 'server-and-client')
|
|
39
39
|
return;
|
|
40
|
-
if (
|
|
41
|
-
const { filePathAbsoluteFilesystem } =
|
|
40
|
+
if (definedAt.filePathRelativeToUserRootDir !== null) {
|
|
41
|
+
const { filePathAbsoluteFilesystem } = definedAt;
|
|
42
42
|
assert(filePathAbsoluteFilesystem);
|
|
43
43
|
// Surprisingly Vite expects entries to be absolute paths
|
|
44
44
|
entries.push(filePathAbsoluteFilesystem);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
// Adding
|
|
48
|
-
const { importPathAbsolute } =
|
|
47
|
+
// Adding definedAt.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
48
|
+
const { importPathAbsolute } = definedAt;
|
|
49
49
|
assert(importPathAbsolute);
|
|
50
50
|
// We need to differentiate between npm package imports and path aliases.
|
|
51
51
|
// There are path aliases that cannot be distinguished from npm package names.
|
|
@@ -26,15 +26,15 @@ function importBuild() {
|
|
|
26
26
|
];
|
|
27
27
|
}
|
|
28
28
|
function getImporterCode(config, pageFilesEntry) {
|
|
29
|
-
const
|
|
29
|
+
const filePathAbsolute = toPosixPath(
|
|
30
30
|
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/importBuild/index.js
|
|
31
31
|
require_.resolve(`../../../../../../dist/esm/node/runtime/globalContext/loadImportBuild.js`));
|
|
32
32
|
const { outDirServer } = getOutDirs(config);
|
|
33
|
-
const
|
|
33
|
+
const filePathRelative = path.posix.relative(outDirServer, filePathAbsolute);
|
|
34
34
|
// The only reason we went for using CJS require() instead of ESM import() is because import() doesn't support .json files
|
|
35
35
|
const importerCode = [
|
|
36
36
|
'(async () => {',
|
|
37
|
-
` const { setImportBuildGetters } = await import('${
|
|
37
|
+
` const { setImportBuildGetters } = await import('${filePathRelative}');`,
|
|
38
38
|
' setImportBuildGetters({',
|
|
39
39
|
` pageFiles: () => import('./${pageFilesEntry}'),`,
|
|
40
40
|
" clientManifest: () => require('../assets.json'),",
|
|
@@ -4,7 +4,7 @@ export type { ConfigDefinition };
|
|
|
4
4
|
export type { ConfigDefinitionInternal };
|
|
5
5
|
export type { ConfigNameGlobal };
|
|
6
6
|
export type { ConfigEffect };
|
|
7
|
-
import type { ConfigEnvInternal, ConfigEnv, ConfigValueSources } from '../../../../../../shared/page-configs/PageConfig.js';
|
|
7
|
+
import type { ConfigEnvInternal, ConfigEnv, ConfigValueSources, DefinedAtFileFullInfo } from '../../../../../../shared/page-configs/PageConfig.js';
|
|
8
8
|
import type { Config, ConfigNameBuiltIn } from '../../../../../../shared/page-configs/Config.js';
|
|
9
9
|
/** The meta definition of a config.
|
|
10
10
|
*
|
|
@@ -46,6 +46,7 @@ type ConfigEffect = (config: {
|
|
|
46
46
|
type ConfigDefinitionInternal = Omit<ConfigDefinition, 'env'> & {
|
|
47
47
|
_computed?: (configValueSources: ConfigValueSources) => unknown;
|
|
48
48
|
_valueIsFilePath?: true;
|
|
49
|
+
_userEffectDefinedAt?: DefinedAtFileFullInfo;
|
|
49
50
|
env: ConfigEnvInternal;
|
|
50
51
|
};
|
|
51
52
|
type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn, ConfigDefinitionInternal>;
|
|
@@ -48,16 +48,17 @@ const configDefinitionsBuiltIn = {
|
|
|
48
48
|
_valueIsFilePath: true
|
|
49
49
|
},
|
|
50
50
|
clientRouting: {
|
|
51
|
-
|
|
51
|
+
// We could make it 'server-only' (we don't yet because of some legacy V0.4 design code)
|
|
52
|
+
env: 'server-and-client'
|
|
52
53
|
},
|
|
53
54
|
prerender: {
|
|
54
55
|
env: 'server-only'
|
|
55
56
|
},
|
|
56
57
|
hydrationCanBeAborted: {
|
|
57
|
-
env: 'client-only'
|
|
58
|
+
env: 'client-only'
|
|
58
59
|
},
|
|
59
60
|
prefetchStaticAssets: {
|
|
60
|
-
env: 'client-only'
|
|
61
|
+
env: 'client-only'
|
|
61
62
|
},
|
|
62
63
|
extends: {
|
|
63
64
|
env: 'config-only'
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { getLogicalPath };
|
|
|
11
11
|
* getLocationId('/pages/some-page') => '/pages/some-page'
|
|
12
12
|
* getLocationId('/renderer/+config.js') => '/renderer'
|
|
13
13
|
*/
|
|
14
|
-
declare function getLocationId(
|
|
14
|
+
declare function getLocationId(filePathAbsoluteVite: string): string;
|
|
15
15
|
/** Get URL determined by filesystem path */
|
|
16
16
|
declare function getFilesystemRouteString(locationId: string): string;
|
|
17
17
|
/**
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -13,8 +13,8 @@ import { assert, assertPosixPath, getNpmPackageImportPath, isNpmPackageImport, h
|
|
|
13
13
|
* getLocationId('/pages/some-page') => '/pages/some-page'
|
|
14
14
|
* getLocationId('/renderer/+config.js') => '/renderer'
|
|
15
15
|
*/
|
|
16
|
-
function getLocationId(
|
|
17
|
-
const locationId = removeFilename(
|
|
16
|
+
function getLocationId(filePathAbsoluteVite) {
|
|
17
|
+
const locationId = removeFilename(filePathAbsoluteVite, true);
|
|
18
18
|
assertLocationId(locationId);
|
|
19
19
|
return locationId;
|
|
20
20
|
}
|
|
@@ -110,21 +110,21 @@ function removeDirectories(somePath, removeDirs) {
|
|
|
110
110
|
somePath = '/';
|
|
111
111
|
return somePath;
|
|
112
112
|
}
|
|
113
|
-
function removeFilename(
|
|
114
|
-
assertPosixPath(
|
|
115
|
-
assert(
|
|
113
|
+
function removeFilename(filePathAbsoluteVite, optional) {
|
|
114
|
+
assertPosixPath(filePathAbsoluteVite);
|
|
115
|
+
assert(filePathAbsoluteVite.startsWith('/') || isNpmPackageImport(filePathAbsoluteVite));
|
|
116
116
|
{
|
|
117
|
-
const filename =
|
|
117
|
+
const filename = filePathAbsoluteVite.split('/').slice(-1)[0];
|
|
118
118
|
if (!filename.includes('.')) {
|
|
119
119
|
assert(optional);
|
|
120
|
-
return
|
|
120
|
+
return filePathAbsoluteVite;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
assertLocationId(
|
|
127
|
-
return
|
|
123
|
+
let locationId = filePathAbsoluteVite.split('/').slice(0, -1).join('/');
|
|
124
|
+
if (locationId === '')
|
|
125
|
+
locationId = '/';
|
|
126
|
+
assertLocationId(locationId);
|
|
127
|
+
return locationId;
|
|
128
128
|
}
|
|
129
129
|
function getFilesystemRouteDefinedBy(locationId) {
|
|
130
130
|
if (locationId === '/')
|