vike 0.4.220-commit-a9f46b8 → 0.4.220-commit-5c7810f
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/api/utils.js +1 -1
- package/dist/cjs/{utils → node/plugin}/getOutDirs.js +11 -11
- package/dist/cjs/node/plugin/index.js +1 -7
- package/dist/cjs/node/plugin/onLoad.js +6 -1
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +12 -13
- package/dist/cjs/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +6 -3
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +24 -21
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -3
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +18 -13
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +29 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +216 -233
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
- package/dist/cjs/node/plugin/plugins/previewConfig.js +3 -4
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/context.js +6 -4
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +25 -0
- package/dist/cjs/node/prerender/runPrerender.js +9 -4
- package/dist/cjs/node/prerender/utils.js +2 -2
- package/dist/cjs/node/runtime/globalContext.js +42 -36
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +6 -5
- package/dist/cjs/node/runtime/renderPage.js +10 -5
- package/dist/cjs/node/runtime/utils.js +2 -2
- package/dist/cjs/node/shared/resolveBase.js +9 -0
- package/dist/cjs/shared/getPageContextUrlComputed.js +6 -1
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +2 -2
- package/dist/cjs/shared/utils.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findFile.js +3 -3
- package/dist/cjs/utils/isDev.js +3 -2
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
- package/dist/cjs/utils/requireResolve.js +3 -3
- package/dist/esm/node/api/utils.d.ts +1 -1
- package/dist/esm/node/api/utils.js +1 -1
- package/dist/esm/{utils → node/plugin}/getOutDirs.js +5 -5
- package/dist/esm/node/plugin/index.d.ts +29 -1
- package/dist/esm/node/plugin/index.js +2 -8
- package/dist/esm/node/plugin/onLoad.js +7 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +12 -13
- package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +7 -4
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +25 -22
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +4 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +4 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +19 -14
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +5 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +30 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +23 -101
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +219 -236
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +3 -4
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/context.d.ts +2 -2
- package/dist/esm/node/prerender/context.js +6 -4
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +5 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +23 -0
- package/dist/esm/node/prerender/runPrerender.js +9 -4
- package/dist/esm/node/prerender/utils.d.ts +2 -2
- package/dist/esm/node/prerender/utils.js +2 -2
- package/dist/esm/node/runtime/globalContext.d.ts +15 -9
- package/dist/esm/node/runtime/globalContext.js +43 -37
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +5 -5
- package/dist/esm/node/runtime/renderPage.js +10 -5
- package/dist/esm/node/runtime/utils.d.ts +2 -2
- package/dist/esm/node/runtime/utils.js +2 -2
- package/dist/esm/node/shared/resolveBase.d.ts +4 -1
- package/dist/esm/node/shared/resolveBase.js +9 -0
- package/dist/esm/shared/getPageContextUrlComputed.js +6 -1
- package/dist/esm/shared/page-configs/Config.d.ts +76 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +25 -19
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +1 -1
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +2 -2
- package/dist/esm/shared/utils.d.ts +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/findFile.js +1 -1
- package/dist/esm/utils/isDev.js +3 -2
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -17
- package/dist/cjs/node/shared/assertPluginManifest.js +0 -20
- package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -16
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -15
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -12
- package/dist/esm/node/shared/assertPluginManifest.js +0 -18
- package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -10
- package/dist/esm/node/shared/assertRuntimeManifest.js +0 -14
- /package/dist/cjs/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
- /package/dist/esm/{utils → node/plugin}/getOutDirs.d.ts +0 -0
- /package/dist/esm/utils/{filesystemPathHandling.d.ts → toPosixPath.d.ts} +0 -0
- /package/dist/esm/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { loadImportedFile };
|
|
2
2
|
export { loadValueFile };
|
|
3
|
+
export { loadValueFiles };
|
|
3
4
|
export { loadConfigFile };
|
|
4
5
|
export type { ImportedFilesLoaded };
|
|
5
6
|
export type { ConfigFile };
|
|
6
7
|
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
7
|
-
import type
|
|
8
|
+
import { InterfaceFilesByLocationId, type InterfaceValueFile } from '../getVikeConfig.js';
|
|
9
|
+
import type { ConfigDefinitions } from './configDefinitionsBuiltIn.js';
|
|
8
10
|
type ImportedFilesLoaded = Record<string, Promise<Record<string, unknown>>>;
|
|
9
11
|
type ConfigFile = {
|
|
10
12
|
fileExports: Record<string, unknown>;
|
|
@@ -14,7 +16,8 @@ type ConfigFile = {
|
|
|
14
16
|
declare function loadImportedFile(import_: FilePathResolved & {
|
|
15
17
|
fileExportName: string;
|
|
16
18
|
}, userRootDir: string, importedFilesLoaded: ImportedFilesLoaded): Promise<unknown>;
|
|
17
|
-
declare function loadValueFile(interfaceValueFile: InterfaceValueFile,
|
|
19
|
+
declare function loadValueFile(interfaceValueFile: InterfaceValueFile, configDefinitions: ConfigDefinitions, userRootDir: string): Promise<void>;
|
|
20
|
+
declare function loadValueFiles(interfaceFiles: InterfaceFilesByLocationId, configDefinitions: ConfigDefinitions, userRootDir: string): Promise<void>;
|
|
18
21
|
declare function loadConfigFile(configFilePath: FilePathResolved, userRootDir: string, visited: string[], isExtensionConfig: boolean): Promise<{
|
|
19
22
|
configFile: ConfigFile;
|
|
20
23
|
extendsConfigs: ConfigFile[];
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// Files
|
|
1
|
+
// Files loaded at config time:
|
|
2
2
|
export { loadImportedFile };
|
|
3
3
|
export { loadValueFile };
|
|
4
|
+
export { loadValueFiles };
|
|
4
5
|
export { loadConfigFile };
|
|
5
|
-
import { assert, assertUsage, assertIsNotProductionRuntime, isArrayOfStrings, isObject } from '../../../../utils.js';
|
|
6
|
+
import { assert, assertUsage, assertIsNotProductionRuntime, isArrayOfStrings, isObject, genPromise } from '../../../../utils.js';
|
|
6
7
|
import { transpileAndExecuteFile } from './transpileAndExecuteFile.js';
|
|
8
|
+
import { getConfigDefinitionOptional, shouldBeLoadableAtBuildTime } from '../getVikeConfig.js';
|
|
7
9
|
import { assertPlusFileExport } from '../../../../../../shared/page-configs/assertPlusFileExport.js';
|
|
8
10
|
import pc from '@brillout/picocolors';
|
|
9
11
|
import { parsePointerImportData } from './transformPointerImports.js';
|
|
@@ -21,15 +23,39 @@ async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
|
21
23
|
return fileExport;
|
|
22
24
|
}
|
|
23
25
|
// Load +{configName}.js
|
|
24
|
-
async function loadValueFile(interfaceValueFile,
|
|
26
|
+
async function loadValueFile(interfaceValueFile, configDefinitions, userRootDir) {
|
|
27
|
+
const { configName } = interfaceValueFile;
|
|
28
|
+
const configDef = getConfigDefinitionOptional(configDefinitions, configName);
|
|
29
|
+
if (!configDef || !shouldBeLoadableAtBuildTime(configDef)) {
|
|
30
|
+
// Only load value files with `env.config===true`
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (interfaceValueFile.isValueLoaded) {
|
|
34
|
+
await interfaceValueFile.isValueLoaded;
|
|
35
|
+
if (
|
|
36
|
+
// Help TS
|
|
37
|
+
true)
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const { promise, resolve } = genPromise();
|
|
41
|
+
interfaceValueFile.isValueLoaded = promise;
|
|
42
|
+
assert(interfaceValueFile.isValueLoaded);
|
|
43
|
+
interfaceValueFile.fileExportsByConfigName = {};
|
|
25
44
|
const { fileExports } = await transpileAndExecuteFile(interfaceValueFile.filePath, userRootDir, false);
|
|
45
|
+
resolve();
|
|
26
46
|
const { filePathToShowToUser } = interfaceValueFile.filePath;
|
|
27
47
|
assertPlusFileExport(fileExports, filePathToShowToUser, configName);
|
|
28
48
|
Object.entries(fileExports).forEach(([exportName, configValue]) => {
|
|
29
49
|
const configName_ = exportName === 'default' ? configName : exportName;
|
|
30
|
-
interfaceValueFile.fileExportsByConfigName[configName_] =
|
|
50
|
+
interfaceValueFile.fileExportsByConfigName[configName_] = configValue;
|
|
31
51
|
});
|
|
32
52
|
}
|
|
53
|
+
async function loadValueFiles(interfaceFiles, configDefinitions, userRootDir) {
|
|
54
|
+
await Promise.all(Object.values(interfaceFiles)
|
|
55
|
+
.flat(1)
|
|
56
|
+
.filter((interfaceFile) => interfaceFile.isValueFile)
|
|
57
|
+
.map(async (interfaceFile) => await loadValueFile(interfaceFile, configDefinitions, userRootDir)));
|
|
58
|
+
}
|
|
33
59
|
// Load +config.js, including all its extends pointer imports
|
|
34
60
|
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig) {
|
|
35
61
|
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
@@ -4,13 +4,15 @@ export { reloadVikeConfig };
|
|
|
4
4
|
export { vikeConfigDependencies };
|
|
5
5
|
export { isVikeConfigFile };
|
|
6
6
|
export { isV1Design };
|
|
7
|
-
export {
|
|
7
|
+
export { getConfVal };
|
|
8
|
+
export { getConfigDefinitionOptional };
|
|
9
|
+
export { shouldBeLoadableAtBuildTime };
|
|
8
10
|
export type { VikeConfigObject };
|
|
9
11
|
export type { InterfaceValueFile };
|
|
10
12
|
export type { InterfaceFile };
|
|
11
|
-
export type {
|
|
12
|
-
export type { VikeVitePluginOptions };
|
|
13
|
+
export type { InterfaceFilesByLocationId };
|
|
13
14
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
15
|
+
import { type ConfigDefinitions, type ConfigDefinitionInternal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
14
16
|
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
15
17
|
import type { ResolvedConfig } from 'vite';
|
|
16
18
|
import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
|
|
@@ -19,26 +21,31 @@ type InterfaceFile = InterfaceConfigFile | InterfaceValueFile;
|
|
|
19
21
|
type InterfaceFileCommons = {
|
|
20
22
|
locationId: LocationId;
|
|
21
23
|
filePath: FilePathResolved;
|
|
22
|
-
fileExportsByConfigName: Record<ConfigName, {
|
|
23
|
-
configValue?: unknown;
|
|
24
|
-
}>;
|
|
25
24
|
};
|
|
26
25
|
type InterfaceConfigFile = InterfaceFileCommons & {
|
|
27
26
|
isConfigFile: true;
|
|
28
27
|
isValueFile: false;
|
|
29
28
|
extendsFilePaths: string[];
|
|
30
29
|
isConfigExtend: boolean;
|
|
30
|
+
isValueLoaded: true;
|
|
31
|
+
fileExportsByConfigName: Record<string, // configName
|
|
32
|
+
unknown>;
|
|
31
33
|
};
|
|
32
34
|
type InterfaceValueFile = InterfaceFileCommons & {
|
|
33
35
|
isConfigFile: false;
|
|
34
36
|
isValueFile: true;
|
|
35
37
|
configName: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
+
} & ({
|
|
39
|
+
isValueLoaded: Promise<void>;
|
|
40
|
+
fileExportsByConfigName: Record<string, // configName
|
|
41
|
+
unknown>;
|
|
42
|
+
} | {
|
|
43
|
+
isValueLoaded: false;
|
|
44
|
+
});
|
|
45
|
+
type InterfaceFilesByLocationId = Record<LocationId, InterfaceFile[]>;
|
|
38
46
|
type VikeConfigObject = {
|
|
39
47
|
pageConfigs: PageConfigBuildTime[];
|
|
40
48
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
41
|
-
vikeConfigGlobal: VikeConfigGlobal;
|
|
42
49
|
global: ReturnType<typeof getPageConfigUserFriendlyNew>;
|
|
43
50
|
};
|
|
44
51
|
declare const vikeConfigDependencies: Set<string>;
|
|
@@ -49,96 +56,11 @@ declare function getVikeConfig(config: ResolvedConfig, { doNotRestartViteOnError
|
|
|
49
56
|
declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePluginOptions: unknown): Promise<VikeConfigObject>;
|
|
50
57
|
declare function isV1Design(config: ResolvedConfig): Promise<boolean>;
|
|
51
58
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
52
|
-
declare function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
disableAutoFullBuild: boolean | 'prerender' | null;
|
|
61
|
-
includeAssetsImportedByServer: boolean;
|
|
62
|
-
baseAssets: string | null;
|
|
63
|
-
baseServer: string | null;
|
|
64
|
-
trailingSlash: boolean;
|
|
65
|
-
disableUrlNormalization: boolean;
|
|
66
|
-
};
|
|
67
|
-
type VikeVitePluginOptions = {
|
|
68
|
-
/**
|
|
69
|
-
* Enable pre-rendering.
|
|
70
|
-
*
|
|
71
|
-
* https://vike.dev/pre-rendering
|
|
72
|
-
*
|
|
73
|
-
* @default false
|
|
74
|
-
*/
|
|
75
|
-
prerender?: boolean | {
|
|
76
|
-
/**
|
|
77
|
-
* Don't create a new directory for each HTML file.
|
|
78
|
-
*
|
|
79
|
-
* For example, generate `dist/client/about.html` instead of `dist/client/about/index.html`.
|
|
80
|
-
*
|
|
81
|
-
* @default false
|
|
82
|
-
*/
|
|
83
|
-
noExtraDir?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Number of concurrent pre-render jobs.
|
|
86
|
-
*
|
|
87
|
-
* Set to `false` to disable concurrency.
|
|
88
|
-
*
|
|
89
|
-
* @default os.cpus().length
|
|
90
|
-
*/
|
|
91
|
-
parallel?: boolean | number;
|
|
92
|
-
/**
|
|
93
|
-
* Allow only some of your pages to be pre-rendered.
|
|
94
|
-
*
|
|
95
|
-
* This setting doesn't affect the pre-rendering process: it merely suppresses the warnings when some of your pages cannot be pre-rendered.
|
|
96
|
-
|
|
97
|
-
* @default false
|
|
98
|
-
*/
|
|
99
|
-
partial?: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Disable the automatic initiation of the pre-rendering process when running `$ vike build`.
|
|
102
|
-
*
|
|
103
|
-
* Use this if you want to programmatically initiate the pre-rendering process instead.
|
|
104
|
-
*
|
|
105
|
-
* https://vike.dev/api#prerender
|
|
106
|
-
*
|
|
107
|
-
* @default false
|
|
108
|
-
*/
|
|
109
|
-
disableAutoRun?: boolean;
|
|
110
|
-
};
|
|
111
|
-
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
112
|
-
disableAutoFullBuild?: boolean | 'prerender';
|
|
113
|
-
/** The Base URL of your server.
|
|
114
|
-
*
|
|
115
|
-
* https://vike.dev/base-url
|
|
116
|
-
*/
|
|
117
|
-
baseServer?: string;
|
|
118
|
-
/** The Base URL of your static assets.
|
|
119
|
-
*
|
|
120
|
-
* https://vike.dev/base-url
|
|
121
|
-
*/
|
|
122
|
-
baseAssets?: string;
|
|
123
|
-
/** @deprecated It's now `true` by default. You can remove this option. */
|
|
124
|
-
includeAssetsImportedByServer?: boolean;
|
|
125
|
-
/** Permanent redirections (HTTP status code 301)
|
|
126
|
-
*
|
|
127
|
-
* https://vike.dev/redirects
|
|
128
|
-
*/
|
|
129
|
-
redirects?: Record<string, string>;
|
|
130
|
-
/** Whether URLs should end with a trailing slash.
|
|
131
|
-
*
|
|
132
|
-
* https://vike.dev/url-normalization
|
|
133
|
-
*
|
|
134
|
-
* @default false
|
|
135
|
-
*/
|
|
136
|
-
trailingSlash?: boolean;
|
|
137
|
-
/** Disable automatic URL normalization.
|
|
138
|
-
*
|
|
139
|
-
* https://vike.dev/url-normalization
|
|
140
|
-
*
|
|
141
|
-
* @default false
|
|
142
|
-
*/
|
|
143
|
-
disableUrlNormalization?: boolean;
|
|
59
|
+
declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitions, configName: string): ConfigDefinitionInternal | null;
|
|
60
|
+
declare function shouldBeLoadableAtBuildTime(configDef: ConfigDefinitionInternal): boolean;
|
|
61
|
+
declare function getConfVal(interfaceFile: InterfaceFile, configName: string): null | {
|
|
62
|
+
configValue: unknown;
|
|
63
|
+
configValueLoaded: true;
|
|
64
|
+
} | {
|
|
65
|
+
configValueLoaded: false;
|
|
144
66
|
};
|