vike 0.4.161 → 0.4.162-commit-49fe40c
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/__internal/index.js +2 -2
- package/dist/cjs/node/plugin/index.js +0 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +20 -20
- package/dist/cjs/node/plugin/plugins/config/index.js +2 -7
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -18
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -4
- package/dist/cjs/node/plugin/plugins/envVars.js +6 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +10 -22
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +1 -21
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +29 -95
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +8 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +109 -104
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +39 -33
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +0 -14
- package/dist/cjs/node/plugin/shared/rollupSourceMap.js +20 -0
- package/dist/cjs/node/plugin/utils.js +0 -1
- package/dist/cjs/node/prerender/runPrerender.js +3 -2
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +8 -19
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +23 -28
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -23
- package/dist/cjs/node/runtime/utils.js +1 -2
- package/dist/cjs/node/shared/assertPluginManifest.js +1 -4
- package/dist/cjs/node/shared/assertV1Design.js +26 -0
- package/dist/cjs/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +3 -3
- package/dist/cjs/node/shared/prependEntriesDir.js +13 -0
- package/dist/cjs/node/shared/utils.js +2 -0
- package/dist/cjs/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +1 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/cjs/shared/route/abort.js +1 -0
- package/dist/cjs/shared/route/resolvePrecedence.js +1 -0
- package/dist/cjs/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
- package/dist/cjs/utils/formatHintLog.js +1 -0
- package/dist/cjs/utils/hasProp.js +1 -0
- package/dist/cjs/utils/isScriptFile.js +15 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/__internal/index.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +20 -14
- package/dist/esm/client/shared/getPageContextProxyForUser.js +19 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +1 -0
- package/dist/esm/node/plugin/index.js +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +19 -19
- package/dist/esm/node/plugin/plugins/config/index.js +2 -7
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -19
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -4
- package/dist/esm/node/plugin/plugins/envVars.js +6 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +11 -23
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -19
- package/dist/esm/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +31 -97
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +8 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +1 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +111 -106
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +39 -33
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -15
- package/dist/esm/node/plugin/shared/rollupSourceMap.d.ts +14 -0
- package/dist/esm/node/plugin/shared/rollupSourceMap.js +17 -0
- package/dist/esm/node/plugin/utils.d.ts +0 -1
- package/dist/esm/node/plugin/utils.js +0 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +3 -3
- package/dist/esm/node/prerender/runPrerender.js +4 -3
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +3 -10
- package/dist/esm/node/runtime/globalContext.js +7 -18
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +24 -29
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -24
- package/dist/esm/node/runtime/utils.d.ts +1 -2
- package/dist/esm/node/runtime/utils.js +1 -2
- package/dist/esm/node/shared/ViteManifest.d.ts +1 -0
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertPluginManifest.js +2 -5
- package/dist/esm/node/shared/assertV1Design.d.ts +4 -0
- package/dist/esm/node/shared/assertV1Design.js +23 -0
- package/dist/esm/node/shared/getClientEntry.d.ts +3 -0
- package/dist/esm/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +2 -2
- package/dist/esm/node/shared/prependEntriesDir.d.ts +2 -0
- package/dist/esm/node/shared/prependEntriesDir.js +10 -0
- package/dist/esm/node/shared/utils.d.ts +2 -0
- package/dist/esm/node/shared/utils.js +2 -0
- package/dist/esm/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
- package/dist/esm/shared/ConfigVike.d.ts +0 -27
- package/dist/esm/shared/hooks/getHook.js +2 -2
- package/dist/esm/shared/page-configs/Config.d.ts +5 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +2 -4
- package/dist/esm/shared/page-configs/helpers/getConfigValue.js +1 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/esm/shared/route/abort.js +1 -0
- package/dist/esm/shared/route/resolvePrecedence.js +1 -0
- package/dist/esm/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/formatHintLog.js +1 -0
- package/dist/esm/utils/hasProp.js +1 -0
- package/dist/esm/utils/isScriptFile.d.ts +3 -1
- package/dist/esm/utils/isScriptFile.js +14 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +4 -3
- package/dist/cjs/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -27
- package/dist/cjs/node/plugin/plugins/config/resolveExtensions.js +0 -107
- package/dist/cjs/node/plugin/plugins/config/stemUtils.js +0 -85
- package/dist/cjs/node/plugin/plugins/extensionsAssets.js +0 -101
- package/dist/cjs/node/plugin/shared/removeSourceMap.js +0 -12
- package/dist/cjs/utils/getDependencyPackageJson.js +0 -91
- package/dist/cjs/utils/isStemPackageName.js +0 -14
- package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -24
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.d.ts +0 -4
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.js +0 -101
- package/dist/esm/node/plugin/plugins/config/stemUtils.d.ts +0 -8
- package/dist/esm/node/plugin/plugins/config/stemUtils.js +0 -79
- package/dist/esm/node/plugin/plugins/extensionsAssets.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/extensionsAssets.js +0 -95
- package/dist/esm/node/plugin/shared/removeSourceMap.d.ts +0 -7
- package/dist/esm/node/plugin/shared/removeSourceMap.js +0 -9
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +0 -3
- package/dist/esm/utils/getDependencyPackageJson.d.ts +0 -6
- package/dist/esm/utils/getDependencyPackageJson.js +0 -85
- package/dist/esm/utils/isStemPackageName.d.ts +0 -1
- package/dist/esm/utils/isStemPackageName.js +0 -10
- /package/dist/esm/utils/{nodeEnv.d.ts → assertNodeEnv.d.ts} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from '../runtime/utils.js';
|
|
2
2
|
export * from '../../utils/viteIsSSR.js';
|
|
3
3
|
export * from '../../utils/getFilePathAbsolute.js';
|
|
4
|
-
export * from '../../utils/getDependencyPackageJson.js';
|
|
5
4
|
export * from '../../utils/requireResolve.js';
|
|
6
5
|
export * from '../../utils/arrayIncludes.js';
|
|
7
6
|
export * from '../../utils/isDev.js';
|
|
@@ -7,7 +7,6 @@ export * from '../runtime/utils.js';
|
|
|
7
7
|
// Utils only needed by `plugin/*`
|
|
8
8
|
export * from '../../utils/viteIsSSR.js';
|
|
9
9
|
export * from '../../utils/getFilePathAbsolute.js';
|
|
10
|
-
export * from '../../utils/getDependencyPackageJson.js';
|
|
11
10
|
export * from '../../utils/requireResolve.js';
|
|
12
11
|
export * from '../../utils/arrayIncludes.js';
|
|
13
12
|
export * from '../../utils/isDev.js';
|
|
@@ -36,11 +36,11 @@ type PrerenderOptions = {
|
|
|
36
36
|
root?: string;
|
|
37
37
|
/** @deprecated Define `prerender({ viteConfig: { configFile }})` instead. */
|
|
38
38
|
configFile?: string;
|
|
39
|
-
/** @deprecated Define `partial` in vite.config.js instead, see https://vike.dev/prerender
|
|
39
|
+
/** @deprecated Define `partial` in vite.config.js instead, see https://vike.dev/prerender */
|
|
40
40
|
partial?: boolean;
|
|
41
|
-
/** @deprecated Define `noExtraDir` in vite.config.js instead, see https://vike.dev/prerender
|
|
41
|
+
/** @deprecated Define `noExtraDir` in vite.config.js instead, see https://vike.dev/prerender */
|
|
42
42
|
noExtraDir?: boolean;
|
|
43
|
-
/** @deprecated Define `parallel` in vite.config.js instead, see https://vike.dev/prerender
|
|
43
|
+
/** @deprecated Define `parallel` in vite.config.js instead, see https://vike.dev/prerender */
|
|
44
44
|
parallel?: number;
|
|
45
45
|
/** @deprecated */
|
|
46
46
|
outDir?: string;
|
|
@@ -10,7 +10,7 @@ import { pLimit } from '../../utils/pLimit.js';
|
|
|
10
10
|
import { prerenderPage, prerender404Page, getRenderContext, getPageContextInitEnhanced } from '../runtime/renderPage/renderPageAlreadyRouted.js';
|
|
11
11
|
import pc from '@brillout/picocolors';
|
|
12
12
|
import { cpus } from 'os';
|
|
13
|
-
import { getGlobalContext, initGlobalContext } from '../runtime/globalContext.js';
|
|
13
|
+
import { getGlobalContext, initGlobalContext, setGlobalContext_prerender } from '../runtime/globalContext.js';
|
|
14
14
|
import { resolveConfig } from 'vite';
|
|
15
15
|
import { getConfigVike } from '../shared/getConfigVike.js';
|
|
16
16
|
import { getPageFilesServerSide } from '../../shared/getPageFiles.js';
|
|
@@ -62,6 +62,7 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
62
62
|
handleNodeEnv();
|
|
63
63
|
await disableReactStreaming();
|
|
64
64
|
const viteConfig = await resolveConfig(options.viteConfig || {}, 'vike pre-rendering', 'production');
|
|
65
|
+
setGlobalContext_prerender(viteConfig);
|
|
65
66
|
assertLoadedConfig(viteConfig, options);
|
|
66
67
|
const configVike = await getConfigVike(viteConfig);
|
|
67
68
|
const { outDirClient, outDirRoot } = getOutDirs(viteConfig);
|
|
@@ -529,7 +530,7 @@ function warnMissingPages(prerenderedPageContexts, doNotPrerenderList, renderCon
|
|
|
529
530
|
.filter((pageId) => !isErrorPage(pageId, renderContext.pageConfigs))
|
|
530
531
|
.forEach((pageId) => {
|
|
531
532
|
const pageAt = isV1 ? pageId : `\`${pageId}.page.*\``;
|
|
532
|
-
assertWarning(partial, `Cannot pre-render page ${pageAt} because it has a non-static route, while no ${hookName}() hook returned any URL matching the page's route. You need to use a ${hookName}() hook (https://vike.dev/${hookName}) providing a list of URLs for ${pageAt} that should be pre-rendered. If you don't want to pre-render ${pageAt} then use the option prerender.partial (https://vike.dev/prerender
|
|
533
|
+
assertWarning(partial, `Cannot pre-render page ${pageAt} because it has a non-static route, while no ${hookName}() hook returned any URL matching the page's route. You need to use a ${hookName}() hook (https://vike.dev/${hookName}) providing a list of URLs for ${pageAt} that should be pre-rendered. If you don't want to pre-render ${pageAt} then use the option prerender.partial (https://vike.dev/prerender#partial) to suppress this warning.`, { onlyOnce: true });
|
|
533
534
|
});
|
|
534
535
|
}
|
|
535
536
|
async function prerender404(prerenderedPageContexts, renderContext, prerenderContext, onComplete) {
|
|
@@ -645,7 +646,7 @@ function checkOutdatedOptions(options) {
|
|
|
645
646
|
assertUsage(options.root === undefined, 'Option `prerender({ root })` deprecated: set `prerender({ viteConfig: { root }})` instead.', { showStackTrace: true });
|
|
646
647
|
assertUsage(options.configFile === undefined, 'Option `prerender({ configFile })` deprecated: set `prerender({ viteConfig: { configFile }})` instead.', { showStackTrace: true });
|
|
647
648
|
['noExtraDir', 'partial', 'parallel'].forEach((prop) => {
|
|
648
|
-
assertUsage(options[prop] === undefined, `[prerender()] Option ${pc.cyan(prop)} is deprecated. Define ${pc.cyan(prop)} in vite.config.js instead. See https://vike.dev/prerender
|
|
649
|
+
assertUsage(options[prop] === undefined, `[prerender()] Option ${pc.cyan(prop)} is deprecated. Define ${pc.cyan(prop)} in vite.config.js instead. See https://vike.dev/prerender`, { showStackTrace: true });
|
|
649
650
|
});
|
|
650
651
|
['base', 'outDir'].forEach((prop) => {
|
|
651
652
|
assertWarning(options[prop] === undefined, `[prerender()] Option ${pc.cyan(prop)} is outdated and has no effect (vike now automatically determines ${pc.cyan(prop)})`, {
|
|
@@ -10,4 +10,4 @@ export * from '../../utils/filesystemPathHandling.js';
|
|
|
10
10
|
export * from '../../utils/urlToFile.js';
|
|
11
11
|
export * from '../../shared/hooks/executeHook.js';
|
|
12
12
|
export * from '../../utils/isPlainObject.js';
|
|
13
|
-
export * from '../../utils/
|
|
13
|
+
export * from '../../utils/assertNodeEnv.js';
|
|
@@ -12,4 +12,4 @@ export * from '../../utils/filesystemPathHandling.js';
|
|
|
12
12
|
export * from '../../utils/urlToFile.js';
|
|
13
13
|
export * from '../../shared/hooks/executeHook.js';
|
|
14
14
|
export * from '../../utils/isPlainObject.js';
|
|
15
|
-
export * from '../../utils/
|
|
15
|
+
export * from '../../utils/assertNodeEnv.js';
|
|
@@ -3,11 +3,10 @@ export { getGlobalContext };
|
|
|
3
3
|
export { getViteDevServer };
|
|
4
4
|
export { getViteConfig };
|
|
5
5
|
export { setGlobalContext_viteDevServer };
|
|
6
|
-
export {
|
|
7
|
-
export { setGlobalContext_viteConfig };
|
|
6
|
+
export { setGlobalContext_prerender };
|
|
8
7
|
export { getRuntimeManifest };
|
|
9
8
|
import type { ViteManifest } from '../shared/ViteManifest.js';
|
|
10
|
-
import type { ResolvedConfig, ViteDevServer
|
|
9
|
+
import type { ResolvedConfig, ViteDevServer } from 'vite';
|
|
11
10
|
import { PluginManifest } from '../shared/assertPluginManifest.js';
|
|
12
11
|
import type { ConfigVikeResolved } from '../../shared/ConfigVike.js';
|
|
13
12
|
import { type RuntimeManifest } from '../shared/assertRuntimeManifest.js';
|
|
@@ -22,9 +21,7 @@ type GlobalContext = {
|
|
|
22
21
|
isProduction: false;
|
|
23
22
|
isPrerendering: false;
|
|
24
23
|
viteConfig: ResolvedConfig;
|
|
25
|
-
configVike: ConfigVikeResolved;
|
|
26
24
|
viteDevServer: ViteDevServer;
|
|
27
|
-
vitePreviewServer: null;
|
|
28
25
|
clientManifest: null;
|
|
29
26
|
pluginManifest: null;
|
|
30
27
|
} | ({
|
|
@@ -32,21 +29,17 @@ type GlobalContext = {
|
|
|
32
29
|
clientManifest: ViteManifest;
|
|
33
30
|
pluginManifest: PluginManifest;
|
|
34
31
|
viteDevServer: null;
|
|
35
|
-
vitePreviewServer: null | VitePreviewServer;
|
|
36
32
|
} & ({
|
|
37
33
|
isPrerendering: false;
|
|
38
34
|
viteConfig: null;
|
|
39
|
-
configVike: null;
|
|
40
35
|
} | {
|
|
41
36
|
isPrerendering: true;
|
|
42
37
|
viteConfig: ResolvedConfig;
|
|
43
|
-
configVike: ConfigVikeResolved;
|
|
44
38
|
})));
|
|
45
39
|
declare function getGlobalContext(): GlobalContext;
|
|
46
40
|
declare function setGlobalContext_viteDevServer(viteDevServer: ViteDevServer): void;
|
|
47
|
-
declare function setGlobalContext_vitePreviewServer(vitePreviewServer: VitePreviewServer): void;
|
|
48
41
|
declare function getViteDevServer(): ViteDevServer | null;
|
|
49
|
-
declare function
|
|
42
|
+
declare function setGlobalContext_prerender(viteConfig: ResolvedConfig): void;
|
|
50
43
|
declare function getViteConfig(): ResolvedConfig | null;
|
|
51
44
|
declare function initGlobalContext(isPrerendering?: boolean, outDir?: string): Promise<void>;
|
|
52
45
|
declare function getRuntimeManifest(configVike: ConfigVikeResolved): RuntimeManifest;
|
|
@@ -3,8 +3,7 @@ export { getGlobalContext };
|
|
|
3
3
|
export { getViteDevServer };
|
|
4
4
|
export { getViteConfig };
|
|
5
5
|
export { setGlobalContext_viteDevServer };
|
|
6
|
-
export {
|
|
7
|
-
export { setGlobalContext_viteConfig };
|
|
6
|
+
export { setGlobalContext_prerender };
|
|
8
7
|
export { getRuntimeManifest };
|
|
9
8
|
import { assert, assertUsage, getGlobalObject, getNodeEnv, getNodeEnvDesc, isNodeEnvDev, isPlainObject, objectAssign } from './utils.js';
|
|
10
9
|
import { loadImportBuild } from './globalContext/loadImportBuild.js';
|
|
@@ -22,18 +21,14 @@ function setGlobalContext_viteDevServer(viteDevServer) {
|
|
|
22
21
|
if (globalObject.viteDevServer)
|
|
23
22
|
return;
|
|
24
23
|
assert(!globalObject.globalContext);
|
|
25
|
-
globalObject.viteDevServer = viteDevServer;
|
|
26
|
-
}
|
|
27
|
-
function setGlobalContext_vitePreviewServer(vitePreviewServer) {
|
|
28
|
-
if (globalObject.vitePreviewServer)
|
|
29
|
-
return;
|
|
30
24
|
assert(!globalObject.globalContext);
|
|
31
|
-
globalObject.
|
|
25
|
+
globalObject.viteConfig = viteDevServer.config;
|
|
26
|
+
globalObject.viteDevServer = viteDevServer;
|
|
32
27
|
}
|
|
33
28
|
function getViteDevServer() {
|
|
34
29
|
return globalObject.viteDevServer ?? null;
|
|
35
30
|
}
|
|
36
|
-
function
|
|
31
|
+
function setGlobalContext_prerender(viteConfig) {
|
|
37
32
|
if (globalObject.viteConfig)
|
|
38
33
|
return;
|
|
39
34
|
assert(!globalObject.globalContext);
|
|
@@ -45,13 +40,12 @@ function getViteConfig() {
|
|
|
45
40
|
async function initGlobalContext(isPrerendering = false, outDir) {
|
|
46
41
|
if (globalObject.globalContext)
|
|
47
42
|
return;
|
|
48
|
-
const { viteDevServer,
|
|
43
|
+
const { viteDevServer, viteConfig } = globalObject;
|
|
49
44
|
assertNodeEnv(!!viteDevServer);
|
|
50
45
|
const isProduction = !viteDevServer;
|
|
51
46
|
if (!isProduction) {
|
|
52
47
|
assert(viteConfig);
|
|
53
48
|
assert(!isPrerendering);
|
|
54
|
-
assert(!vitePreviewServer);
|
|
55
49
|
const configVike = await getConfigVike(viteConfig);
|
|
56
50
|
const pluginManifest = getRuntimeManifest(configVike);
|
|
57
51
|
globalObject.globalContext = {
|
|
@@ -60,9 +54,7 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
60
54
|
clientManifest: null,
|
|
61
55
|
pluginManifest: null,
|
|
62
56
|
viteDevServer,
|
|
63
|
-
vitePreviewServer: null,
|
|
64
57
|
viteConfig,
|
|
65
|
-
configVike,
|
|
66
58
|
baseServer: pluginManifest.baseServer,
|
|
67
59
|
baseAssets: pluginManifest.baseAssets,
|
|
68
60
|
includeAssetsImportedByServer: pluginManifest.includeAssetsImportedByServer,
|
|
@@ -83,7 +75,6 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
83
75
|
clientManifest,
|
|
84
76
|
pluginManifest,
|
|
85
77
|
viteDevServer: null,
|
|
86
|
-
vitePreviewServer: vitePreviewServer ?? null,
|
|
87
78
|
baseServer: pluginManifest.baseServer,
|
|
88
79
|
baseAssets: pluginManifest.baseAssets,
|
|
89
80
|
includeAssetsImportedByServer: pluginManifest.includeAssetsImportedByServer,
|
|
@@ -97,16 +88,14 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
97
88
|
assert(configVike);
|
|
98
89
|
objectAssign(globalContext, {
|
|
99
90
|
isPrerendering: true,
|
|
100
|
-
viteConfig
|
|
101
|
-
configVike
|
|
91
|
+
viteConfig
|
|
102
92
|
});
|
|
103
93
|
globalObject.globalContext = globalContext;
|
|
104
94
|
}
|
|
105
95
|
else {
|
|
106
96
|
objectAssign(globalContext, {
|
|
107
97
|
isPrerendering: false,
|
|
108
|
-
viteConfig: null
|
|
109
|
-
configVike: null
|
|
98
|
+
viteConfig: null
|
|
110
99
|
});
|
|
111
100
|
globalObject.globalContext = globalContext;
|
|
112
101
|
}
|
|
@@ -100,6 +100,7 @@ function serializePageContextAbort(pageContext) {
|
|
|
100
100
|
delete pageContext._abortCaller;
|
|
101
101
|
const unknownProps = Object.keys(pageContext).filter((prop) => ![
|
|
102
102
|
// prettier-ignore
|
|
103
|
+
// biome-ignore format:
|
|
103
104
|
'_abortCall',
|
|
104
105
|
/* Not needed on the client-side
|
|
105
106
|
'_abortCaller',
|
|
@@ -4,11 +4,11 @@ import { analyzePageClientSide } from '../../../shared/getPageFiles/analyzePageC
|
|
|
4
4
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { analyzeClientSide } from '../../../shared/getPageFiles/analyzeClientSide.js';
|
|
6
6
|
import { getGlobalContext } from '../globalContext.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getClientEntry } from '../../shared/getClientEntry.js';
|
|
8
8
|
function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
9
9
|
if (pageConfig) {
|
|
10
10
|
const { isClientSideRenderable, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
|
|
11
|
-
const clientFilePath =
|
|
11
|
+
const clientFilePath = getClientEntry(pageConfig);
|
|
12
12
|
const clientEntry = !isClientSideRenderable ? clientFilePath : getVikeClientEntry(isClientRouting);
|
|
13
13
|
const clientDependencies = [];
|
|
14
14
|
clientDependencies.push({
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export { assertClientEntryId };
|
|
2
|
-
import { getGlobalContext } from '../../globalContext.js';
|
|
3
2
|
import { assert, assertPosixPath, isNpmPackageImport } from '../../utils.js';
|
|
4
3
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
4
|
function assertClientEntryId(id) {
|
|
6
5
|
assertPosixPath(id);
|
|
7
6
|
assert(!id.startsWith('/@fs'), id);
|
|
8
|
-
const isPkg = isNpmPackageImport(id);
|
|
9
7
|
assert(
|
|
10
8
|
// Client entry
|
|
11
9
|
id.startsWith('@@vike/') ||
|
|
@@ -13,10 +11,6 @@ function assertClientEntryId(id) {
|
|
|
13
11
|
id.startsWith('/') ||
|
|
14
12
|
// Page code importer
|
|
15
13
|
isVirtualFileIdPageConfigValuesAll(id) ||
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
if (isPkg) {
|
|
19
|
-
const { configVike } = getGlobalContext();
|
|
20
|
-
assert(configVike === null || configVike.extensions.some(({ npmPackageName }) => id.startsWith(npmPackageName)), id);
|
|
21
|
-
}
|
|
14
|
+
// Import
|
|
15
|
+
isNpmPackageImport(id), id);
|
|
22
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getManifestEntry };
|
|
2
2
|
import type { ViteManifest, ViteManifestEntry } from '../../../shared/ViteManifest.js';
|
|
3
|
-
declare function getManifestEntry(id: string, clientManifest: ViteManifest
|
|
3
|
+
declare function getManifestEntry(id: string, clientManifest: ViteManifest): {
|
|
4
4
|
manifestKey: string;
|
|
5
5
|
manifestEntry: ViteManifestEntry;
|
|
6
6
|
};
|
|
@@ -2,7 +2,8 @@ export { getManifestEntry };
|
|
|
2
2
|
import { assert, slice, isNpmPackageImport } from '../../utils.js';
|
|
3
3
|
import { assertClientEntryId } from './assertClientEntryId.js';
|
|
4
4
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
|
-
|
|
5
|
+
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
6
|
+
function getManifestEntry(id, clientManifest) {
|
|
6
7
|
assertClientEntryId(id);
|
|
7
8
|
const debugInfo = getDebugInfo(id, clientManifest);
|
|
8
9
|
// Vike client entry
|
|
@@ -40,13 +41,11 @@ function getManifestEntry(id, clientManifest, manifestKeyMap) {
|
|
|
40
41
|
assert(manifestEntry, debugInfo);
|
|
41
42
|
return { manifestEntry, manifestKey };
|
|
42
43
|
}
|
|
43
|
-
//
|
|
44
|
+
// npm package import
|
|
44
45
|
if (isNpmPackageImport(id)) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const manifestEntry = clientManifest[manifestKey];
|
|
49
|
-
assert(manifestEntry, debugInfo2);
|
|
46
|
+
const found = Object.entries(clientManifest).find(([, e]) => e.name === prependEntriesDir(id));
|
|
47
|
+
assert(found);
|
|
48
|
+
const [manifestKey, manifestEntry] = found;
|
|
50
49
|
return { manifestEntry, manifestKey };
|
|
51
50
|
}
|
|
52
51
|
// extensions[number].pageConfigsSrcDir
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { retrieveAssetsProd };
|
|
2
2
|
import type { ViteManifest } from '../../../shared/ViteManifest.js';
|
|
3
3
|
import type { ClientDependency } from '../../../../shared/getPageFiles/analyzePageClientSide/ClientDependency.js';
|
|
4
|
-
declare function retrieveAssetsProd(clientDependencies: ClientDependency[], clientManifest: ViteManifest, includeAssetsImportedByServer: boolean
|
|
4
|
+
declare function retrieveAssetsProd(clientDependencies: ClientDependency[], clientManifest: ViteManifest, includeAssetsImportedByServer: boolean): string[];
|
|
@@ -2,7 +2,7 @@ export { retrieveAssetsProd };
|
|
|
2
2
|
import { assert, isNpmPackageImport } from '../../utils.js';
|
|
3
3
|
import { getManifestEntry } from './getManifestEntry.js';
|
|
4
4
|
import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
5
|
-
function retrieveAssetsProd(clientDependencies, clientManifest, includeAssetsImportedByServer
|
|
5
|
+
function retrieveAssetsProd(clientDependencies, clientManifest, includeAssetsImportedByServer) {
|
|
6
6
|
let assetUrls = new Set();
|
|
7
7
|
assert(clientManifest);
|
|
8
8
|
const visistedAssets = new Set();
|
|
@@ -19,7 +19,7 @@ function retrieveAssetsProd(clientDependencies, clientManifest, includeAssetsImp
|
|
|
19
19
|
id = extractAssetsAddQuery(id);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
const { manifestKey } = getManifestEntry(id, clientManifest
|
|
22
|
+
const { manifestKey } = getManifestEntry(id, clientManifest);
|
|
23
23
|
collectAssets(manifestKey, assetUrls, visistedAssets, clientManifest, onlyAssets);
|
|
24
24
|
});
|
|
25
25
|
collectSingleStyle(assetUrls, clientManifest);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getPageAssets };
|
|
2
|
-
import { assert, prependBase, assertPosixPath, toPosixPath, isNpmPackageImport, unique,
|
|
2
|
+
import { assert, prependBase, assertPosixPath, toPosixPath, isNpmPackageImport, unique, pathJoin } from '../utils.js';
|
|
3
3
|
import { retrieveAssetsDev } from './getPageAssets/retrieveAssetsDev.js';
|
|
4
4
|
import { retrieveAssetsProd } from './getPageAssets/retrieveAssetsProd.js';
|
|
5
5
|
import { inferMediaType } from './inferMediaType.js';
|
|
@@ -14,15 +14,14 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
14
14
|
let assetUrls;
|
|
15
15
|
let clientEntriesSrc;
|
|
16
16
|
if (isDev) {
|
|
17
|
-
const { viteDevServer
|
|
18
|
-
clientEntriesSrc = await Promise.all(clientEntries.map((clientEntry) => resolveClientEntriesDev(clientEntry, viteDevServer
|
|
17
|
+
const { viteDevServer } = globalContext;
|
|
18
|
+
clientEntriesSrc = await Promise.all(clientEntries.map((clientEntry) => resolveClientEntriesDev(clientEntry, viteDevServer)));
|
|
19
19
|
assetUrls = await retrieveAssetsDev(clientDependencies, viteDevServer);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
assetUrls = retrieveAssetsProd(clientDependencies, clientManifest, pageContext._includeAssetsImportedByServer, manifestKeyMap);
|
|
22
|
+
const { clientManifest } = globalContext;
|
|
23
|
+
clientEntriesSrc = clientEntries.map((clientEntry) => resolveClientEntriesProd(clientEntry, clientManifest));
|
|
24
|
+
assetUrls = retrieveAssetsProd(clientDependencies, clientManifest, pageContext._includeAssetsImportedByServer);
|
|
26
25
|
}
|
|
27
26
|
let pageAssets = [];
|
|
28
27
|
unique([...clientEntriesSrc, ...assetUrls]).forEach((src) => {
|
|
@@ -56,7 +55,7 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
56
55
|
sortPageAssetsForEarlyHintsHeader(pageAssets);
|
|
57
56
|
return pageAssets;
|
|
58
57
|
}
|
|
59
|
-
async function resolveClientEntriesDev(clientEntry, viteDevServer
|
|
58
|
+
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
60
59
|
assertClientEntryId(clientEntry);
|
|
61
60
|
let root = viteDevServer.config.root;
|
|
62
61
|
assert(root);
|
|
@@ -77,7 +76,7 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
77
76
|
// User files
|
|
78
77
|
filePath = pathJoin(root, clientEntry);
|
|
79
78
|
}
|
|
80
|
-
else if (clientEntry.startsWith('@@vike/')) {
|
|
79
|
+
else if (clientEntry.startsWith('@@vike/') || isNpmPackageImport(clientEntry)) {
|
|
81
80
|
// Vike client entry
|
|
82
81
|
const { createRequire } = (await import_('module')).default;
|
|
83
82
|
const { dirname } = (await import_('path')).default;
|
|
@@ -89,27 +88,23 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
89
88
|
// @ts-expect-error
|
|
90
89
|
// Bun workaround https://github.com/vikejs/vike/pull/1048
|
|
91
90
|
const res = typeof Bun !== 'undefined' ? (toPath) => Bun.resolveSync(toPath, __dirname_) : require_.resolve;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
95
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/runtime/renderPage/getPageAssets.js
|
|
96
|
-
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
91
|
+
if (isNpmPackageImport(clientEntry)) {
|
|
92
|
+
filePath = res(clientEntry);
|
|
97
93
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
else {
|
|
95
|
+
assert(clientEntry.endsWith('.js'));
|
|
96
|
+
try {
|
|
97
|
+
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
98
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/runtime/renderPage/getPageAssets.js
|
|
99
|
+
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// For users
|
|
103
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/runtime/renderPage/getPageAssets.js
|
|
104
|
+
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
105
|
+
}
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
|
-
else if (isNpmPackageImport(clientEntry)) {
|
|
105
|
-
const extensionPageFile = configVike.extensions
|
|
106
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
107
|
-
.flat()
|
|
108
|
-
.filter(isNotNullish)
|
|
109
|
-
.find((e) => e.importPath === clientEntry);
|
|
110
|
-
assert(extensionPageFile, clientEntry);
|
|
111
|
-
filePath = extensionPageFile.filePath;
|
|
112
|
-
}
|
|
113
108
|
else {
|
|
114
109
|
assert(false);
|
|
115
110
|
}
|
|
@@ -121,8 +116,8 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
121
116
|
assertPosixPath(filePath);
|
|
122
117
|
return filePath;
|
|
123
118
|
}
|
|
124
|
-
function resolveClientEntriesProd(clientEntry, clientManifest
|
|
125
|
-
const { manifestEntry } = getManifestEntry(clientEntry, clientManifest
|
|
119
|
+
function resolveClientEntriesProd(clientEntry, clientManifest) {
|
|
120
|
+
const { manifestEntry } = getManifestEntry(clientEntry, clientManifest);
|
|
126
121
|
assert(manifestEntry.isEntry || manifestEntry.isDynamicEntry || clientEntry.endsWith('.css'), { clientEntry });
|
|
127
122
|
let { file } = manifestEntry;
|
|
128
123
|
assert(!file.startsWith('/'));
|
|
@@ -6,7 +6,7 @@ export { getRenderContext };
|
|
|
6
6
|
import { getErrorPageId } from '../../../shared/error-page.js';
|
|
7
7
|
import { getHtmlString } from '../html/renderHtml.js';
|
|
8
8
|
import { getPageFilesAll } from '../../../shared/getPageFiles.js';
|
|
9
|
-
import { assert, assertUsage,
|
|
9
|
+
import { assert, assertUsage, hasProp, objectAssign } from '../utils.js';
|
|
10
10
|
import { serializePageContextClientSide } from '../html/serializePageContextClientSide.js';
|
|
11
11
|
import { addUrlComputedProps } from '../../../shared/addUrlComputedProps.js';
|
|
12
12
|
import { getGlobalContext } from '../globalContext.js';
|
|
@@ -20,8 +20,8 @@ import { preparePageContextForUserConsumptionServerSide } from './preparePageCon
|
|
|
20
20
|
import { executeGuardHook } from '../../../shared/route/executeGuardHook.js';
|
|
21
21
|
import { loadPageRoutes } from '../../../shared/route/loadPageRoutes.js';
|
|
22
22
|
import pc from '@brillout/picocolors';
|
|
23
|
-
import { getConfigValueFilePathToShowToUser } from '../../../shared/page-configs/helpers.js';
|
|
24
23
|
import { isServerSideError } from '../../../shared/misc/isServerSideError.js';
|
|
24
|
+
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
25
25
|
async function renderPageAlreadyRouted(pageContext) {
|
|
26
26
|
// pageContext._pageId can either be the:
|
|
27
27
|
// - ID of the page matching the routing, or the
|
|
@@ -151,7 +151,7 @@ async function getRenderContext() {
|
|
|
151
151
|
const globalContext = getGlobalContext();
|
|
152
152
|
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await getPageFilesAll(false, globalContext.isProduction);
|
|
153
153
|
const { pageRoutes, onBeforeRouteHook } = await loadPageRoutes(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
154
|
-
assertV1Design(pageFilesAll, pageConfigs);
|
|
154
|
+
assertV1Design(pageFilesAll.length > 0, pageConfigs, pageFilesAll);
|
|
155
155
|
const renderContext = {
|
|
156
156
|
pageFilesAll: pageFilesAll,
|
|
157
157
|
pageConfigs,
|
|
@@ -162,24 +162,3 @@ async function getRenderContext() {
|
|
|
162
162
|
};
|
|
163
163
|
return renderContext;
|
|
164
164
|
}
|
|
165
|
-
function assertV1Design(pageFilesAll, pageConfigs) {
|
|
166
|
-
const isV1Design = pageConfigs.length !== 0;
|
|
167
|
-
const isDesignOld = pageFilesAll.length !== 0;
|
|
168
|
-
if (isV1Design && isDesignOld) {
|
|
169
|
-
const indent = '- ';
|
|
170
|
-
const v1Files = unique(pageConfigs
|
|
171
|
-
.map((p) => Object.values(p.configValues)
|
|
172
|
-
.map(getConfigValueFilePathToShowToUser)
|
|
173
|
-
.filter(isNotNullish)
|
|
174
|
-
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
175
|
-
.flat(2));
|
|
176
|
-
assertUsage(false, [
|
|
177
|
-
'Mixing the new V1 design with the old V0.4 design is forbidden.',
|
|
178
|
-
'V1 files:',
|
|
179
|
-
...v1Files,
|
|
180
|
-
'V0.4 files:',
|
|
181
|
-
...pageFilesAll.map((p) => indent + p.filePath)
|
|
182
|
-
].join('\n'));
|
|
183
|
-
}
|
|
184
|
-
assertWarning(!isDesignOld, "You are using Vike's deprecated design. Update to the new V1 design, see https://vike.dev/migration/v1-design for how to migrate.", { onlyOnce: true });
|
|
185
|
-
}
|
|
@@ -30,7 +30,6 @@ export * from '../../utils/debug.js';
|
|
|
30
30
|
export * from '../../utils/urlToFile.js';
|
|
31
31
|
export * from '../../utils/getGlobalObject.js';
|
|
32
32
|
export * from '../../shared/hooks/executeHook.js';
|
|
33
|
-
export * from '../../utils/isStemPackageName.js';
|
|
34
33
|
export * from '../../utils/freezePartial.js';
|
|
35
34
|
export * from '../../utils/isNpmPackage.js';
|
|
36
35
|
export * from '../../utils/isNotNullish.js';
|
|
@@ -42,7 +41,7 @@ export * from '../../utils/getFileExtension.js';
|
|
|
42
41
|
export * from '../../utils/assertIsNotProductionRuntime.js';
|
|
43
42
|
export * from '../../utils/virtual-files.js';
|
|
44
43
|
export * from '../../utils/path-shim.js';
|
|
45
|
-
export * from '../../utils/
|
|
44
|
+
export * from '../../utils/assertNodeEnv.js';
|
|
46
45
|
export * from '../../utils/isHtml.js';
|
|
47
46
|
export * from '../../utils/warnIfErrorIsNotObject.js';
|
|
48
47
|
export * from '../../utils/stripAnsi.js';
|
|
@@ -33,7 +33,6 @@ export * from '../../utils/debug.js';
|
|
|
33
33
|
export * from '../../utils/urlToFile.js';
|
|
34
34
|
export * from '../../utils/getGlobalObject.js';
|
|
35
35
|
export * from '../../shared/hooks/executeHook.js';
|
|
36
|
-
export * from '../../utils/isStemPackageName.js';
|
|
37
36
|
export * from '../../utils/freezePartial.js';
|
|
38
37
|
export * from '../../utils/isNpmPackage.js';
|
|
39
38
|
export * from '../../utils/isNotNullish.js';
|
|
@@ -45,7 +44,7 @@ export * from '../../utils/getFileExtension.js';
|
|
|
45
44
|
export * from '../../utils/assertIsNotProductionRuntime.js';
|
|
46
45
|
export * from '../../utils/virtual-files.js';
|
|
47
46
|
export * from '../../utils/path-shim.js';
|
|
48
|
-
export * from '../../utils/
|
|
47
|
+
export * from '../../utils/assertNodeEnv.js';
|
|
49
48
|
export * from '../../utils/isHtml.js';
|
|
50
49
|
export * from '../../utils/warnIfErrorIsNotObject.js';
|
|
51
50
|
export * from '../../utils/stripAnsi.js';
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
export { assertPluginManifest };
|
|
2
2
|
import { assertRuntimeManifest } from './assertRuntimeManifest.js';
|
|
3
|
-
import { assert, assertUsage, isPlainObject, projectInfo, checkType, hasProp
|
|
3
|
+
import { assert, assertUsage, isPlainObject, projectInfo, checkType, hasProp } from './utils.js';
|
|
4
4
|
function assertPluginManifest(pluginManifest) {
|
|
5
5
|
assert(isPlainObject(pluginManifest));
|
|
6
6
|
assertUsage(pluginManifest.version === projectInfo.projectVersion, `Re-build your app (you're using vike@${projectInfo.projectVersion} but your app was built with vike@${pluginManifest.version})`);
|
|
7
7
|
assertRuntimeManifest(pluginManifest);
|
|
8
8
|
assert(hasProp(pluginManifest, 'usesClientRouter', 'boolean'));
|
|
9
9
|
assert(hasProp(pluginManifest, 'version', 'string'));
|
|
10
|
-
assert(hasProp(pluginManifest, 'manifestKeyMap', 'object'));
|
|
11
|
-
const { manifestKeyMap } = pluginManifest;
|
|
12
|
-
assert(isStringRecord(manifestKeyMap));
|
|
13
10
|
// Avoid:
|
|
14
11
|
// ```
|
|
15
12
|
// Uncaught (in promise) TypeError: Cannot set property manifestKeyMap of #<Object> which has only a getter
|
|
16
13
|
// ```
|
|
14
|
+
// We removed manifestKeyMap, maybe this isn't needed anymore.
|
|
17
15
|
// See https://github.com/vikejs/vike/issues/596
|
|
18
16
|
const pluginManifestClone = { ...pluginManifest };
|
|
19
|
-
objectAssign(pluginManifestClone, { manifestKeyMap });
|
|
20
17
|
checkType(pluginManifestClone);
|
|
21
18
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { assertV1Design };
|
|
2
|
+
import { PageFile } from '../../shared/getPageFiles.js';
|
|
3
|
+
import type { PageConfigBuildTime, PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
4
|
+
declare function assertV1Design(isOldDesign: boolean, pageConfigs: (PageConfigRuntime | PageConfigBuildTime)[], pageFilesAll?: PageFile[]): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { assertV1Design };
|
|
2
|
+
import { getConfigValueFilePathToShowToUser } from '../../shared/page-configs/helpers.js';
|
|
3
|
+
import { assert, assertUsage, assertWarning, isNotNullish, unique } from './utils.js';
|
|
4
|
+
function assertV1Design(isOldDesign, pageConfigs, pageFilesAll) {
|
|
5
|
+
const isV1Design = pageConfigs.length > 0;
|
|
6
|
+
if (isV1Design && isOldDesign) {
|
|
7
|
+
const lines = ['Mixing the new V1 design with the old V0.4 design is forbidden.'];
|
|
8
|
+
if (pageFilesAll) {
|
|
9
|
+
assert(pageFilesAll.length > 0);
|
|
10
|
+
const indent = '- ';
|
|
11
|
+
const filesV1 = unique(pageConfigs
|
|
12
|
+
.map((p) => Object.values(p.configValues)
|
|
13
|
+
.map(getConfigValueFilePathToShowToUser)
|
|
14
|
+
.filter(isNotNullish)
|
|
15
|
+
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
16
|
+
.flat(2));
|
|
17
|
+
const filesOld = pageFilesAll.map((p) => indent + p.filePath);
|
|
18
|
+
lines.push(...['V1 design files:', ...filesV1, 'Old design files:', ...filesOld]);
|
|
19
|
+
}
|
|
20
|
+
assertUsage(false, lines.join('\n'));
|
|
21
|
+
}
|
|
22
|
+
assertWarning(!isOldDesign, "You are using Vike's deprecated design. Update to the new V1 design, see https://vike.dev/migration/v1-design for how to migrate.", { onlyOnce: true });
|
|
23
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getClientEntry };
|
|
2
2
|
import { getConfigValue } from '../../shared/page-configs/helpers.js';
|
|
3
|
-
function
|
|
3
|
+
function getClientEntry(pageConfig) {
|
|
4
4
|
const configName = 'client';
|
|
5
5
|
const configValue = getConfigValue(pageConfig, configName, 'string');
|
|
6
6
|
if (!configValue)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { prependEntriesDir };
|
|
2
|
+
import { assert } from './utils.js';
|
|
3
|
+
function prependEntriesDir(entryName) {
|
|
4
|
+
if (entryName.startsWith('/')) {
|
|
5
|
+
entryName = entryName.slice(1);
|
|
6
|
+
}
|
|
7
|
+
assert(!entryName.startsWith('/'));
|
|
8
|
+
entryName = `entries/${entryName}`;
|
|
9
|
+
return entryName;
|
|
10
|
+
}
|
|
@@ -13,3 +13,5 @@ export * from '../../utils/parseUrl-extras.js';
|
|
|
13
13
|
export * from '../../utils/isObject.js';
|
|
14
14
|
export * from '../../utils/virtual-files.js';
|
|
15
15
|
export * from '../../utils/assertIsNotBrowser.js';
|
|
16
|
+
export * from '../../utils/isNotNullish.js';
|
|
17
|
+
export * from '../../utils/unique.js';
|