vike 0.4.220-commit-af5c91f → 0.4.221-commit-8577456
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 +5 -23
- package/dist/cjs/node/api/build.js +55 -11
- package/dist/cjs/node/api/prepareViteApiCall.js +20 -17
- package/dist/cjs/node/api/prerender.js +1 -0
- package/dist/cjs/node/api/utils.js +1 -0
- package/dist/cjs/node/plugin/index.js +2 -0
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +9 -20
- package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildApp.js +72 -0
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +8 -10
- package/dist/cjs/node/plugin/plugins/buildConfig.js +5 -5
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +8 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{assertExtensions.js → getVikeConfig/assertExtensions.js} +31 -31
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +53 -21
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.js → getVikeConfig/getConfigFileExport.js} +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +159 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +205 -343
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{debug.js → virtual-files/debug.js} +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.js → virtual-files/getVirtualFilePageConfigValuesAll.js} +7 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.js → virtual-files/getVirtualFilePageConfigs.js} +3 -3
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -4
- package/dist/cjs/node/plugin/shared/getFullBuildInlineConfig.js +20 -0
- package/dist/cjs/node/plugin/shared/getOutDirs.js +50 -38
- package/dist/cjs/node/prerender/runPrerender.js +29 -30
- package/dist/cjs/node/runtime/globalContext.js +186 -100
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -3
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +2 -3
- package/dist/cjs/node/runtime/html/injectAssets.js +4 -4
- package/dist/cjs/node/runtime/html/renderHtml.js +4 -5
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -3
- package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +2 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +4 -4
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +3 -5
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +5 -4
- package/dist/cjs/node/runtime/renderPage/log404/index.js +1 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +10 -9
- package/dist/cjs/node/runtime/renderPage.js +27 -30
- package/dist/cjs/node/runtime/utils.js +1 -0
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +5 -3
- package/dist/cjs/node/shared/resolveBase.js +3 -5
- package/dist/cjs/shared/getPageConfigsRuntime.js +20 -0
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +4 -3
- package/dist/cjs/shared/getPageFiles.js +1 -3
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +13 -4
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +1 -1
- package/dist/cjs/utils/debug.js +8 -6
- package/dist/cjs/utils/findFile.js +1 -0
- package/dist/cjs/utils/objectAssignSafe.js +7 -0
- package/dist/esm/__internal/index.d.ts +2 -2
- package/dist/esm/__internal/index.js +7 -26
- package/dist/esm/client/client-routing-runtime/createPageContext.js +5 -9
- package/dist/esm/client/server-routing-runtime/getPageContext.js +3 -4
- package/dist/esm/client/shared/loadUserFilesClientSide.js +3 -2
- package/dist/esm/node/api/build.js +23 -12
- package/dist/esm/node/api/prepareViteApiCall.d.ts +4 -2
- package/dist/esm/node/api/prepareViteApiCall.js +20 -17
- package/dist/esm/node/api/prerender.js +1 -0
- package/dist/esm/node/api/utils.d.ts +1 -0
- package/dist/esm/node/api/utils.js +1 -0
- package/dist/esm/node/plugin/index.js +2 -0
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +10 -21
- package/dist/esm/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/esm/node/plugin/plugins/buildApp.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/buildApp.js +70 -0
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +8 -10
- package/dist/esm/node/plugin/plugins/buildConfig.js +6 -6
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +2 -2
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +8 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.d.ts +6 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{assertExtensions.js → getVikeConfig/assertExtensions.js} +31 -31
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +52 -20
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.js → getVikeConfig/getConfigFileExport.js} +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.d.ts +39 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +154 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -38
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +208 -346
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{debug.js → virtual-files/debug.js} +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.js → virtual-files/getVirtualFilePageConfigValuesAll.js} +7 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.js → virtual-files/getVirtualFilePageConfigs.js} +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.d.ts → virtual-files/isRuntimeEnvMatch.d.ts} +1 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +2 -5
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.d.ts +2 -0
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.js +17 -0
- package/dist/esm/node/plugin/shared/getOutDirs.d.ts +1 -1
- package/dist/esm/node/plugin/shared/getOutDirs.js +50 -38
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +2 -5
- package/dist/esm/node/prerender/runPrerender.d.ts +2 -2
- package/dist/esm/node/prerender/runPrerender.js +30 -31
- package/dist/esm/node/runtime/globalContext.d.ts +31 -29
- package/dist/esm/node/runtime/globalContext.js +186 -100
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -3
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +4 -1
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +2 -3
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -0
- package/dist/esm/node/runtime/html/injectAssets.js +4 -4
- package/dist/esm/node/runtime/html/renderHtml.js +4 -5
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -3
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +2 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +4 -4
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +3 -5
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +6 -5
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/log404/index.js +1 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +21 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +10 -9
- package/dist/esm/node/runtime/renderPage.js +28 -31
- package/dist/esm/node/runtime/utils.d.ts +1 -0
- package/dist/esm/node/runtime/utils.js +1 -0
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +5 -3
- package/dist/esm/node/shared/resolveBase.d.ts +2 -1
- package/dist/esm/node/shared/resolveBase.js +3 -5
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +13 -0
- package/dist/esm/shared/getPageConfigsRuntime.js +18 -0
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +4 -3
- package/dist/esm/shared/getPageFiles.d.ts +0 -1
- package/dist/esm/shared/getPageFiles.js +0 -1
- package/dist/esm/shared/page-configs/Config.d.ts +7 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +9 -5
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +5 -7
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +13 -4
- package/dist/esm/shared/route/loadPageRoutes.js +1 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSetup.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +8 -6
- package/dist/esm/utils/findFile.js +1 -0
- package/dist/esm/utils/objectAssignSafe.d.ts +1 -0
- package/dist/esm/utils/objectAssignSafe.js +4 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/shared/getPageFiles/getPageFiles.js +0 -48
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +0 -6
- package/dist/esm/shared/getPageFiles/getPageFiles.d.ts +0 -15
- package/dist/esm/shared/getPageFiles/getPageFiles.js +0 -46
- /package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.js → virtual-files/isRuntimeEnvMatch.js} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.d.ts → getVikeConfig/getConfigFileExport.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{debug.d.ts → virtual-files/debug.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.d.ts → virtual-files/getVirtualFilePageConfigValuesAll.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.d.ts → virtual-files/getVirtualFilePageConfigs.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.js → virtual-files/isRuntimeEnvMatch.js} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Needed by Vike
|
|
2
2
|
export { setGlobalContext_buildEntry } from '../node/runtime/globalContext.js';
|
|
3
|
-
//
|
|
3
|
+
// Needed by vite-plugin-vercel
|
|
4
4
|
export { route, getPagesAndRoutes };
|
|
5
|
-
// Internals needed by experimental implementation of vike-telefunc
|
|
6
|
-
export { getMiddlewares };
|
|
7
5
|
import { route as routeInternal } from '../shared/route/index.js';
|
|
8
|
-
import {
|
|
9
|
-
import { getGlobalContext, initGlobalContext_getGlobalContextAsync } from '../node/runtime/globalContext.js';
|
|
6
|
+
import { getGlobalContextInternal, initGlobalContext_getPagesAndRoutes } from '../node/runtime/globalContext.js';
|
|
10
7
|
import { setNodeEnvProduction } from '../utils/assertSetup.js';
|
|
11
8
|
/**
|
|
12
9
|
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel} to compute some rewrite rules and extract { isr } configs.
|
|
10
|
+
*
|
|
11
|
+
* TODO/eventually: remove
|
|
13
12
|
*/
|
|
14
13
|
async function getPagesAndRoutes() {
|
|
15
14
|
setNodeEnvProduction();
|
|
16
|
-
|
|
15
|
+
await initGlobalContext_getPagesAndRoutes();
|
|
16
|
+
const globalContext = await getGlobalContextInternal();
|
|
17
17
|
const {
|
|
18
18
|
//
|
|
19
19
|
pageRoutes, pageFilesAll, pageConfigs, allPageIds } = globalContext;
|
|
@@ -24,25 +24,6 @@ async function getPagesAndRoutes() {
|
|
|
24
24
|
allPageIds
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
// TODO/eventually:
|
|
28
|
-
// - Remove the need for `isProduction` after Vike's CLI is implemented
|
|
29
|
-
// - Remove it in favor of https://vike.dev/getGlobalContext
|
|
30
|
-
async function getMiddlewares() {
|
|
31
|
-
const isProduction = process.env.NODE_ENV === 'production';
|
|
32
|
-
const { pageConfigs } = await getPageFilesAllSafe(isProduction);
|
|
33
|
-
const middlewares = pageConfigs[0].configValues.middleware.value.flat(Infinity);
|
|
34
|
-
return middlewares;
|
|
35
|
-
}
|
|
36
|
-
// TODO/eventually:
|
|
37
|
-
// - Make it cleaner once the internal refactoring about global configs is done.
|
|
38
|
-
// - Remove it in favor of https://vike.dev/getGlobalContext
|
|
39
|
-
// Demo usage: https://github.com/vikejs/vike/pull/1823
|
|
40
|
-
async function getPageFilesAllSafe(isProduction) {
|
|
41
|
-
await initGlobalContext_getGlobalContextAsync(isProduction);
|
|
42
|
-
const globalContext = getGlobalContext();
|
|
43
|
-
const pageFilesAll = await getPageFilesAll(false, globalContext.isProduction);
|
|
44
|
-
return pageFilesAll;
|
|
45
|
-
}
|
|
46
27
|
async function route(pageContext) {
|
|
47
28
|
const pageContextFromRoute = await routeInternal(pageContext);
|
|
48
29
|
// Old interface
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
export { createPageContext };
|
|
2
|
+
import { getPageConfigsRuntime } from '../../shared/getPageConfigsRuntime.js';
|
|
2
3
|
import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed.js';
|
|
3
|
-
import { getPageFilesAll, setPageFiles } from '../../shared/getPageFiles/getPageFiles.js';
|
|
4
4
|
import { loadPageRoutes } from '../../shared/route/loadPageRoutes.js';
|
|
5
5
|
import { getBaseServer } from './getBaseServer.js';
|
|
6
|
-
import { assert, isBaseServer,
|
|
6
|
+
import { assert, isBaseServer, objectAssign } from './utils.js';
|
|
7
|
+
// TODO/now: can we avoid optimizeDeps.exclude of client runtime?
|
|
7
8
|
// @ts-ignore
|
|
8
|
-
import * as
|
|
9
|
-
const
|
|
10
|
-
setPageFiles(pageFilesExports);
|
|
9
|
+
import * as virtualFileExports from 'virtual:vike:importUserCode:client:client-routing';
|
|
10
|
+
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = getPageConfigsRuntime(virtualFileExports);
|
|
11
11
|
async function createPageContext(urlOriginal) {
|
|
12
|
-
if (!globalObject.pageFilesData) {
|
|
13
|
-
globalObject.pageFilesData = await getPageFilesAll(true);
|
|
14
|
-
}
|
|
15
|
-
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = globalObject.pageFilesData;
|
|
16
12
|
const { pageRoutes, onBeforeRouteHook } = await loadPageRoutes(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
17
13
|
const baseServer = getBaseServer();
|
|
18
14
|
assert(isBaseServer(baseServer));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { getPageContext };
|
|
2
2
|
import { assertUsage, assertWarning, objectAssign } from './utils.js';
|
|
3
3
|
import { getPageContextSerializedInHtml } from '../shared/getPageContextSerializedInHtml.js';
|
|
4
|
-
import { getPageFilesAll, setPageFiles } from '../../shared/getPageFiles/getPageFiles.js';
|
|
5
4
|
import { loadUserFilesClientSide } from '../shared/loadUserFilesClientSide.js';
|
|
6
5
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
6
|
+
import { getPageConfigsRuntime } from '../../shared/getPageConfigsRuntime.js';
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
import * as
|
|
8
|
+
import * as virtualFileExports from 'virtual:vike:importUserCode:client:server-routing';
|
|
9
|
+
const { pageFilesAll, pageConfigs } = getPageConfigsRuntime(virtualFileExports);
|
|
9
10
|
const urlFirst = getCurrentUrl({ withoutHash: true });
|
|
10
|
-
setPageFiles(pageFilesExports);
|
|
11
11
|
async function getPageContext() {
|
|
12
12
|
const pageContext = getPageContextSerializedInHtml();
|
|
13
13
|
objectAssign(pageContext, {
|
|
@@ -26,7 +26,6 @@ function assertPristineUrl() {
|
|
|
26
26
|
}
|
|
27
27
|
async function loadPageUserFiles(pageId) {
|
|
28
28
|
const pageContextAddendum = {};
|
|
29
|
-
const { pageFilesAll, pageConfigs } = await getPageFilesAll(true);
|
|
30
29
|
objectAssign(pageContextAddendum, {
|
|
31
30
|
_pageFilesAll: pageFilesAll,
|
|
32
31
|
_pageConfigs: pageConfigs
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { loadUserFilesClientSide };
|
|
2
2
|
export { isErrorFetchingStaticAssets };
|
|
3
|
-
import { getPageFilesClientSide
|
|
3
|
+
import { getPageFilesClientSide } from '../../shared/getPageFiles.js';
|
|
4
|
+
import { getPageConfigUserFriendlyOld } from '../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
4
5
|
import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
|
|
5
6
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
6
7
|
import { objectAssign } from '../server-routing-runtime/utils.js';
|
|
@@ -29,7 +30,7 @@ async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
|
|
|
29
30
|
}
|
|
30
31
|
throw err;
|
|
31
32
|
}
|
|
32
|
-
const pageContextExports =
|
|
33
|
+
const pageContextExports = getPageConfigUserFriendlyOld(pageFilesClientSide, pageConfigLoaded);
|
|
33
34
|
const pageContextAddendum = {};
|
|
34
35
|
objectAssign(pageContextAddendum, pageContextExports);
|
|
35
36
|
objectAssign(pageContextAddendum, { _pageFilesLoaded: pageFilesClientSide });
|
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
export { build };
|
|
2
2
|
import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
3
|
-
import { build as buildVite } from 'vite';
|
|
3
|
+
import { build as buildVite, version } from 'vite';
|
|
4
4
|
import assert from 'assert';
|
|
5
5
|
import { isVikeCli } from '../cli/context.js';
|
|
6
6
|
import { isPrerendering } from '../prerender/context.js';
|
|
7
|
+
import { assertVersion } from './utils.js';
|
|
7
8
|
/**
|
|
8
9
|
* Programmatically trigger `$ vike build`
|
|
9
10
|
*
|
|
10
11
|
* https://vike.dev/api#build
|
|
11
12
|
*/
|
|
12
13
|
async function build(options = {}) {
|
|
13
|
-
const { viteConfigEnhanced } = await prepareViteApiCall(options.viteConfig, 'build');
|
|
14
|
+
const { viteConfigEnhanced, vikeConfig } = await prepareViteApiCall(options.viteConfig, 'build');
|
|
14
15
|
// Pass it to autoFullBuild()
|
|
15
16
|
if (viteConfigEnhanced)
|
|
16
17
|
viteConfigEnhanced._viteConfigEnhanced = viteConfigEnhanced;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
if (vikeConfig.global.config.viteEnvironmentAPI) {
|
|
19
|
+
assertVersion('Vite', version, '6.0.0');
|
|
20
|
+
const { createBuilder } = await import('vite');
|
|
21
|
+
const builder = await createBuilder(viteConfigEnhanced);
|
|
22
|
+
await builder.buildApp();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// This buildVite() call does everything:
|
|
26
|
+
// 1. Build client-side
|
|
27
|
+
// 2. Build server-side
|
|
28
|
+
// > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L90
|
|
29
|
+
// 3. Pre-render (if enabled)
|
|
30
|
+
// > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L98
|
|
31
|
+
// > We purposely don't start the pre-rendering in this `build()` function but in a Rollup hook instead.
|
|
32
|
+
// > Rationale: https://github.com/vikejs/vike/issues/2123
|
|
33
|
+
await buildVite(viteConfigEnhanced);
|
|
34
|
+
// After pre-rendering, when using the Vike CLI, the process is forcefully exited at the end of the buildVite() call above.
|
|
35
|
+
if (isVikeCli() && isPrerendering())
|
|
36
|
+
assert(false);
|
|
37
|
+
}
|
|
27
38
|
return {
|
|
28
39
|
/* We don't return `viteConfig` because `viteConfigEnhanced` is `InlineConfig` not `ResolvedConfig`
|
|
29
40
|
viteConfig: viteConfigEnhanced,
|
|
@@ -4,9 +4,11 @@ export { assertViteRoot };
|
|
|
4
4
|
export { normalizeViteRoot };
|
|
5
5
|
import type { InlineConfig, ResolvedConfig } from 'vite';
|
|
6
6
|
import type { Operation } from './types.js';
|
|
7
|
-
|
|
7
|
+
import { type VikeConfigObject } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
8
|
+
declare function prepareViteApiCall(viteConfigFromOptions: InlineConfig | undefined, operation: Operation): Promise<{
|
|
9
|
+
vikeConfig: VikeConfigObject;
|
|
8
10
|
viteConfigEnhanced: InlineConfig | undefined;
|
|
9
11
|
}>;
|
|
10
|
-
declare function getViteRoot(operation:
|
|
12
|
+
declare function getViteRoot(operation: Operation): Promise<string>;
|
|
11
13
|
declare function normalizeViteRoot(root: string): string;
|
|
12
14
|
declare function assertViteRoot(root: string, config: ResolvedConfig): void;
|
|
@@ -11,32 +11,34 @@ import { assert, assertUsage, getGlobalObject, isObject, toPosixPath } from './u
|
|
|
11
11
|
import pc from '@brillout/picocolors';
|
|
12
12
|
import { clearGlobalContext } from '../runtime/globalContext.js';
|
|
13
13
|
const globalObject = getGlobalObject('prepareViteApiCall.ts', {});
|
|
14
|
-
async function prepareViteApiCall(
|
|
14
|
+
async function prepareViteApiCall(viteConfigFromOptions, operation) {
|
|
15
15
|
clear();
|
|
16
16
|
setContextApiOperation(operation);
|
|
17
|
-
return enhanceViteConfig(
|
|
17
|
+
return enhanceViteConfig(viteConfigFromOptions, operation);
|
|
18
18
|
}
|
|
19
19
|
// For subsequent API calls, e.g. calling prerender() after build()
|
|
20
20
|
function clear() {
|
|
21
21
|
clearContextApiOperation();
|
|
22
22
|
clearGlobalContext();
|
|
23
23
|
}
|
|
24
|
-
async function enhanceViteConfig(
|
|
25
|
-
const viteInfo = await getInfoFromVite(
|
|
24
|
+
async function enhanceViteConfig(viteConfigFromOptions, operation) {
|
|
25
|
+
const viteInfo = await getInfoFromVite(viteConfigFromOptions, operation);
|
|
26
26
|
await assertViteRoot2(viteInfo.root, viteInfo.viteConfigEnhanced, operation);
|
|
27
27
|
const vikeConfig = await getVikeConfig2(viteInfo.root, operation === 'dev', viteInfo.vikeVitePluginOptions);
|
|
28
28
|
const viteConfigEnhanced = addViteSettingsSetByVikeConfig(viteInfo.viteConfigEnhanced, vikeConfig);
|
|
29
29
|
return {
|
|
30
|
+
vikeConfig,
|
|
30
31
|
viteConfigEnhanced
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
function addViteSettingsSetByVikeConfig(viteConfigEnhanced, vikeConfig) {
|
|
34
|
-
const viteConfigs = vikeConfig.global.
|
|
35
|
+
const viteConfigs = vikeConfig.global._from.configsCumulative.vite;
|
|
35
36
|
if (!viteConfigs)
|
|
36
37
|
return viteConfigEnhanced;
|
|
37
38
|
viteConfigs.values.forEach((v) => {
|
|
38
39
|
assertUsage(isObject(v.value), `${v.definedAt} should be an object`);
|
|
39
40
|
viteConfigEnhanced = mergeConfig(viteConfigEnhanced ?? {}, v.value);
|
|
41
|
+
assertUsage(findVikeVitePlugin(v.value), "Using the +vite setting to add Vike's Vite plugin is forbidden");
|
|
40
42
|
});
|
|
41
43
|
return viteConfigEnhanced;
|
|
42
44
|
}
|
|
@@ -46,13 +48,14 @@ async function getViteRoot(operation) {
|
|
|
46
48
|
assert(globalObject.root);
|
|
47
49
|
return globalObject.root;
|
|
48
50
|
}
|
|
49
|
-
async function getInfoFromVite(
|
|
50
|
-
const
|
|
51
|
-
const root = normalizeViteRoot(
|
|
51
|
+
async function getInfoFromVite(viteConfigFromOptions, operation) {
|
|
52
|
+
const viteConfigFromUserViteFile = await loadViteConfigFile(viteConfigFromOptions, operation);
|
|
53
|
+
const root = normalizeViteRoot(viteConfigFromUserViteFile?.root ?? viteConfigFromOptions?.root ?? process.cwd());
|
|
52
54
|
globalObject.root = root;
|
|
53
55
|
let vikeVitePluginOptions;
|
|
54
|
-
let viteConfigEnhanced =
|
|
55
|
-
|
|
56
|
+
let viteConfigEnhanced = viteConfigFromOptions;
|
|
57
|
+
// If Vike's Vite plugin is found in both viteConfigFromOptions and viteConfigFromUserViteFile then Vike will later throw an error
|
|
58
|
+
const found = findVikeVitePlugin(viteConfigFromOptions) || findVikeVitePlugin(viteConfigFromUserViteFile);
|
|
56
59
|
if (found) {
|
|
57
60
|
vikeVitePluginOptions = found.vikeVitePluginOptions;
|
|
58
61
|
}
|
|
@@ -61,20 +64,20 @@ async function getInfoFromVite(viteConfig, operation) {
|
|
|
61
64
|
// Using a dynamic import because the script calling the Vike API may not live in the same place as vite.config.js, thus vike/plugin may resolved to two different node_modules/vike directories.
|
|
62
65
|
const { plugin: vikePlugin } = await import('../plugin/index.js');
|
|
63
66
|
viteConfigEnhanced = {
|
|
64
|
-
...
|
|
65
|
-
plugins: [...(
|
|
67
|
+
...viteConfigFromOptions,
|
|
68
|
+
plugins: [...(viteConfigFromOptions?.plugins ?? []), vikePlugin()]
|
|
66
69
|
};
|
|
67
|
-
const res = findVikeVitePlugin(viteConfigEnhanced
|
|
70
|
+
const res = findVikeVitePlugin(viteConfigEnhanced);
|
|
68
71
|
assert(res);
|
|
69
72
|
vikeVitePluginOptions = res.vikeVitePluginOptions;
|
|
70
73
|
}
|
|
71
74
|
assert(vikeVitePluginOptions);
|
|
72
75
|
return { root, vikeVitePluginOptions, viteConfigEnhanced };
|
|
73
76
|
}
|
|
74
|
-
function findVikeVitePlugin(
|
|
77
|
+
function findVikeVitePlugin(viteConfig) {
|
|
75
78
|
let vikeVitePluginOptions;
|
|
76
79
|
let vikeVitePuginFound = false;
|
|
77
|
-
plugins
|
|
80
|
+
viteConfig?.plugins?.forEach((p) => {
|
|
78
81
|
if (p && '__vikeVitePluginOptions' in p) {
|
|
79
82
|
vikeVitePuginFound = true;
|
|
80
83
|
const options = p.__vikeVitePluginOptions;
|
|
@@ -87,8 +90,8 @@ function findVikeVitePlugin(plugins) {
|
|
|
87
90
|
return { vikeVitePluginOptions };
|
|
88
91
|
}
|
|
89
92
|
// Copied from https://github.com/vitejs/vite/blob/4f5845a3182fc950eb9cd76d7161698383113b18/packages/vite/src/node/config.ts#L961-L1005
|
|
90
|
-
async function loadViteConfigFile(
|
|
91
|
-
const [inlineConfig, command, defaultMode, _defaultNodeEnv, isPreview] = getResolveConfigArgs(
|
|
93
|
+
async function loadViteConfigFile(viteConfigFromOptions, operation) {
|
|
94
|
+
const [inlineConfig, command, defaultMode, _defaultNodeEnv, isPreview] = getResolveConfigArgs(viteConfigFromOptions, operation);
|
|
92
95
|
let config = inlineConfig;
|
|
93
96
|
let mode = inlineConfig.mode || defaultMode;
|
|
94
97
|
const configEnv = {
|
|
@@ -26,6 +26,7 @@ import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.
|
|
|
26
26
|
import { resolveClientEntriesDev } from './shared/resolveClientEntriesDev.js';
|
|
27
27
|
import { workaroundCssModuleHmr } from './plugins/workaroundCssModuleHmr.js';
|
|
28
28
|
import { workaroundVite6HmrRegression } from './plugins/workaroundVite6HmrRegression.js';
|
|
29
|
+
import { buildApp } from './plugins/buildApp.js';
|
|
29
30
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
30
31
|
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
31
32
|
// Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
|
|
@@ -35,6 +36,7 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
35
36
|
importUserCode(),
|
|
36
37
|
...devConfig(),
|
|
37
38
|
...buildConfig(),
|
|
39
|
+
...buildApp(),
|
|
38
40
|
previewConfig(),
|
|
39
41
|
...autoFullBuild(),
|
|
40
42
|
packageJsonFile(),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// TODO/v1-release: remove this file
|
|
2
|
+
import { getFullBuildInlineConfig } from '../shared/getFullBuildInlineConfig.js';
|
|
2
3
|
export { autoFullBuild };
|
|
3
4
|
import { build } from 'vite';
|
|
4
|
-
import { assertWarning } from '../utils.js';
|
|
5
|
+
import { assert, assertWarning } from '../utils.js';
|
|
5
6
|
import { runPrerenderFromAutoRun, runPrerender_forceExit } from '../../prerender/runPrerender.js';
|
|
6
7
|
import { isPrerenderAutoRunEnabled } from '../../prerender/context.js';
|
|
7
8
|
import { isViteCliCall, getViteConfigFromCli } from '../shared/isViteCliCall.js';
|
|
@@ -10,7 +11,6 @@ import { logErrorHint } from '../../runtime/renderPage/logErrorHint.js';
|
|
|
10
11
|
import { manifestTempFile } from './buildConfig.js';
|
|
11
12
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
12
13
|
import { isVikeCliOrApi } from '../../api/context.js';
|
|
13
|
-
import { isVikeCli } from '../../cli/context.js';
|
|
14
14
|
let forceExit = false;
|
|
15
15
|
function autoFullBuild() {
|
|
16
16
|
let config;
|
|
@@ -52,6 +52,7 @@ function autoFullBuild() {
|
|
|
52
52
|
handler() {
|
|
53
53
|
if (forceExit) {
|
|
54
54
|
runPrerender_forceExit();
|
|
55
|
+
assert(false);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -69,21 +70,7 @@ async function triggerFullBuild(config, vikeConfig, bundle) {
|
|
|
69
70
|
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
70
71
|
if (!bundle[manifestTempFile])
|
|
71
72
|
return;
|
|
72
|
-
const
|
|
73
|
-
let configInline;
|
|
74
|
-
if (config._viteConfigEnhanced) {
|
|
75
|
-
configInline = config._viteConfigEnhanced;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
configInline = {
|
|
79
|
-
...configFromCli,
|
|
80
|
-
configFile: configFromCli?.configFile || config.configFile,
|
|
81
|
-
root: config.root,
|
|
82
|
-
build: {
|
|
83
|
-
...configFromCli?.build
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
73
|
+
const configInline = getFullBuildInlineConfig(config);
|
|
87
74
|
try {
|
|
88
75
|
await build(setSSR(configInline));
|
|
89
76
|
}
|
|
@@ -93,9 +80,8 @@ async function triggerFullBuild(config, vikeConfig, bundle) {
|
|
|
93
80
|
process.exit(1);
|
|
94
81
|
}
|
|
95
82
|
if (isPrerenderAutoRunEnabled(vikeConfig)) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
forceExit = isVikeCli() || isViteCliCall();
|
|
83
|
+
const res = await runPrerenderFromAutoRun(configInline, config);
|
|
84
|
+
forceExit = res.forceExit;
|
|
99
85
|
}
|
|
100
86
|
}
|
|
101
87
|
function setSSR(configInline) {
|
|
@@ -114,7 +100,10 @@ function abortViteBuildSsr(vikeConfig) {
|
|
|
114
100
|
}
|
|
115
101
|
}
|
|
116
102
|
function isDisabled(vikeConfig) {
|
|
117
|
-
const { disableAutoFullBuild } = vikeConfig.global.config;
|
|
103
|
+
const { disableAutoFullBuild, viteEnvironmentAPI } = vikeConfig.global.config;
|
|
104
|
+
if (viteEnvironmentAPI) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
118
107
|
if (disableAutoFullBuild === undefined || disableAutoFullBuild === 'prerender') {
|
|
119
108
|
const isViteApi = !isViteCliCall() && !isVikeCliOrApi();
|
|
120
109
|
return isViteApi;
|
|
@@ -11,7 +11,7 @@ function baseUrls() {
|
|
|
11
11
|
const isDev = config._isDev;
|
|
12
12
|
assert(typeof isDev === 'boolean');
|
|
13
13
|
const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
|
|
14
|
-
basesResolved = resolveBase(baseViteOriginal, config.vike.
|
|
14
|
+
basesResolved = resolveBase(baseViteOriginal, config.vike.config.baseServer ?? null, config.vike.config.baseAssets ?? null);
|
|
15
15
|
// We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
|
|
16
16
|
process.env.BASE_SERVER = basesResolved.baseServer;
|
|
17
17
|
process.env.BASE_ASSETS = basesResolved.baseAssets;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { runPrerender_forceExit, runPrerenderFromAutoRun } from '../../prerender/runPrerender.js';
|
|
2
|
+
export { buildApp };
|
|
3
|
+
import { isPrerenderAutoRunEnabled } from '../../prerender/context.js';
|
|
4
|
+
import { resolveOutDir } from '../shared/getOutDirs.js';
|
|
5
|
+
import { assert } from '../utils.js';
|
|
6
|
+
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
+
import { getFullBuildInlineConfig } from '../shared/getFullBuildInlineConfig.js';
|
|
8
|
+
function buildApp() {
|
|
9
|
+
let config;
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
name: 'vike:buildApp',
|
|
13
|
+
apply: 'build',
|
|
14
|
+
config(config) {
|
|
15
|
+
if (!config.vike.config.viteEnvironmentAPI)
|
|
16
|
+
return;
|
|
17
|
+
return {
|
|
18
|
+
builder: {
|
|
19
|
+
buildApp: async (builder) => {
|
|
20
|
+
assert(builder.environments.client);
|
|
21
|
+
assert(builder.environments.ssr);
|
|
22
|
+
await builder.build(builder.environments.client);
|
|
23
|
+
await builder.build(builder.environments.ssr);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
environments: {
|
|
27
|
+
ssr: {
|
|
28
|
+
consumer: 'server',
|
|
29
|
+
build: {
|
|
30
|
+
outDir: resolveOutDir(config, true),
|
|
31
|
+
ssr: true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
client: {
|
|
35
|
+
consumer: 'client',
|
|
36
|
+
build: {
|
|
37
|
+
copyPublicDir: true,
|
|
38
|
+
ssr: false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'vike:buildApp:prerender',
|
|
47
|
+
apply: 'build',
|
|
48
|
+
enforce: 'pre',
|
|
49
|
+
applyToEnvironment(env) {
|
|
50
|
+
return env.name === 'ssr';
|
|
51
|
+
},
|
|
52
|
+
configResolved(_config) {
|
|
53
|
+
config = _config;
|
|
54
|
+
},
|
|
55
|
+
async writeBundle() {
|
|
56
|
+
if (!config.vike.config.viteEnvironmentAPI)
|
|
57
|
+
return;
|
|
58
|
+
const vikeConfig = await getVikeConfig(config);
|
|
59
|
+
if (!isPrerenderAutoRunEnabled(vikeConfig))
|
|
60
|
+
return;
|
|
61
|
+
const configInline = getFullBuildInlineConfig(config);
|
|
62
|
+
const { forceExit } = await runPrerenderFromAutoRun(configInline, config);
|
|
63
|
+
if (forceExit) {
|
|
64
|
+
runPrerender_forceExit();
|
|
65
|
+
assert(false);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
}
|
|
@@ -2,7 +2,6 @@ export { fixServerAssets };
|
|
|
2
2
|
export { fixServerAssets_isEnabled };
|
|
3
3
|
export { fixServerAssets_assertCssCodeSplit };
|
|
4
4
|
export { fixServerAssets_assertCssTarget };
|
|
5
|
-
export { fixServerAssets_assertCssTarget_populate };
|
|
6
5
|
import { ViteManifest } from '../../../shared/ViteManifest.js';
|
|
7
6
|
import { ResolvedConfig } from 'vite';
|
|
8
7
|
/**
|
|
@@ -18,5 +17,4 @@ declare function fixServerAssets(config: ResolvedConfig): Promise<{
|
|
|
18
17
|
serverManifestMod: ViteManifest;
|
|
19
18
|
}>;
|
|
20
19
|
declare function fixServerAssets_assertCssCodeSplit(config: ResolvedConfig): void;
|
|
21
|
-
declare function fixServerAssets_assertCssTarget_populate(config: ResolvedConfig): void;
|
|
22
20
|
declare function fixServerAssets_assertCssTarget(config: ResolvedConfig): Promise<void>;
|
|
@@ -2,7 +2,6 @@ export { fixServerAssets };
|
|
|
2
2
|
export { fixServerAssets_isEnabled };
|
|
3
3
|
export { fixServerAssets_assertCssCodeSplit };
|
|
4
4
|
export { fixServerAssets_assertCssTarget };
|
|
5
|
-
export { fixServerAssets_assertCssTarget_populate };
|
|
6
5
|
import fs from 'fs/promises';
|
|
7
6
|
import fs_sync from 'fs';
|
|
8
7
|
import path from 'path';
|
|
@@ -195,17 +194,15 @@ function fixServerAssets_assertCssCodeSplit(config) {
|
|
|
195
194
|
assertWarning(config.build.cssCodeSplit, `${pc.cyan('build.cssCodeSplit')} shouldn't be set to ${pc.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
196
195
|
}
|
|
197
196
|
const targets = [];
|
|
198
|
-
function fixServerAssets_assertCssTarget_populate(config) {
|
|
199
|
-
const isServerSide = viteIsSSR(config);
|
|
200
|
-
assert(typeof isServerSide === 'boolean');
|
|
201
|
-
assert(config.build.target !== undefined);
|
|
202
|
-
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
203
|
-
}
|
|
204
197
|
async function fixServerAssets_assertCssTarget(config) {
|
|
205
198
|
if (!fixServerAssets_isEnabled())
|
|
206
199
|
return;
|
|
207
200
|
if (!(await isV1Design(config)))
|
|
208
201
|
return;
|
|
202
|
+
const isServerSide = viteIsSSR(config);
|
|
203
|
+
assert(typeof isServerSide === 'boolean');
|
|
204
|
+
assert(config.build.target !== undefined);
|
|
205
|
+
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
209
206
|
const targetsServer = targets.filter((t) => t.isServerSide);
|
|
210
207
|
const targetsClient = targets.filter((t) => !t.isServerSide);
|
|
211
208
|
targetsClient.forEach((targetClient) => {
|
|
@@ -213,9 +210,10 @@ async function fixServerAssets_assertCssTarget(config) {
|
|
|
213
210
|
targetsServer.forEach((targetServer) => {
|
|
214
211
|
const targetCssResolvedServer = resolveCssTarget(targetServer);
|
|
215
212
|
assertWarning(isEqualStringList(targetCssResolvedClient, targetCssResolvedServer), [
|
|
216
|
-
'The CSS browser target should be the same for both client
|
|
217
|
-
`Client
|
|
218
|
-
`Server
|
|
213
|
+
'The CSS browser target should be the same for both client and server, but we got:',
|
|
214
|
+
`Client: ${pc.cyan(JSON.stringify(targetCssResolvedClient))}`,
|
|
215
|
+
`Server: ${pc.cyan(JSON.stringify(targetCssResolvedServer))}`,
|
|
216
|
+
`Different targets leads to CSS duplication, see ${pc.underline('https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979')} for more information.`
|
|
219
217
|
].join('\n'), {
|
|
220
218
|
showStackTrace: true,
|
|
221
219
|
onlyOnce: 'different-css-target'
|
|
@@ -10,7 +10,7 @@ import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
|
10
10
|
import { createRequire } from 'module';
|
|
11
11
|
import fs from 'fs/promises';
|
|
12
12
|
import path from 'path';
|
|
13
|
-
import { fixServerAssets, fixServerAssets_assertCssCodeSplit, fixServerAssets_assertCssTarget,
|
|
13
|
+
import { fixServerAssets, fixServerAssets_assertCssCodeSplit, fixServerAssets_assertCssTarget, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
14
14
|
import { set_ASSETS_MANIFEST } from './buildEntry/index.js';
|
|
15
15
|
import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
|
|
16
16
|
import { getFilePathResolved } from '../shared/getFilePath.js';
|
|
@@ -23,7 +23,6 @@ const require_ = createRequire(importMetaUrl);
|
|
|
23
23
|
const manifestTempFile = '_temp_manifest.json';
|
|
24
24
|
function buildConfig() {
|
|
25
25
|
let isServerAssetsFixEnabled;
|
|
26
|
-
let isSsrBuild;
|
|
27
26
|
let outDirs;
|
|
28
27
|
let config;
|
|
29
28
|
return [
|
|
@@ -49,7 +48,6 @@ function buildConfig() {
|
|
|
49
48
|
config.build.ssrEmitAssets = true;
|
|
50
49
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
51
50
|
config.build.cssMinify = 'esbuild';
|
|
52
|
-
fixServerAssets_assertCssTarget_populate(config);
|
|
53
51
|
fixServerAssets_assertCssCodeSplit(config);
|
|
54
52
|
}
|
|
55
53
|
}
|
|
@@ -59,12 +57,14 @@ function buildConfig() {
|
|
|
59
57
|
order: 'post',
|
|
60
58
|
handler(config) {
|
|
61
59
|
onSetupBuild();
|
|
62
|
-
isSsrBuild = viteIsSSR(config);
|
|
63
60
|
return {
|
|
64
61
|
build: {
|
|
65
62
|
outDir: resolveOutDir(config),
|
|
66
63
|
manifest: manifestTempFile,
|
|
67
|
-
copyPublicDir:
|
|
64
|
+
copyPublicDir: config.vike.config.viteEnvironmentAPI
|
|
65
|
+
? // Already set by buildApp() plugin
|
|
66
|
+
undefined
|
|
67
|
+
: !viteIsSSR(config)
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
@@ -88,7 +88,7 @@ function buildConfig() {
|
|
|
88
88
|
order: 'pre',
|
|
89
89
|
sequential: true,
|
|
90
90
|
async handler(options, bundle) {
|
|
91
|
-
if (
|
|
91
|
+
if (viteIsSSR(config)) {
|
|
92
92
|
// Ideally we'd move dist/_temp_manifest.json to dist/server/client-assets.json instead of dist/assets.json
|
|
93
93
|
// - But we can't because there is no guarentee whether dist/server/ is generated before or after dist/client/ (generating dist/server/ after dist/client/ erases dist/server/client-assets.json)
|
|
94
94
|
// - We'll able to do so once we replace `$ vite build` with `$ vike build`
|
|
@@ -42,14 +42,14 @@ function getServerProductionEntryCode(config) {
|
|
|
42
42
|
// After the old design is removed, let's maybe simplify and move everything into a single virtual module
|
|
43
43
|
const importerCode = [
|
|
44
44
|
` import { setGlobalContext_buildEntry } from '${importPath}';`,
|
|
45
|
-
` import * as
|
|
45
|
+
` import * as virtualFileExports from '${virtualFileIdImportUserCodeServer}';`,
|
|
46
46
|
` {`,
|
|
47
47
|
// Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to setGlobalContext_buildEntry()
|
|
48
48
|
// - This workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
49
49
|
` const assetsManifest = ${ASSETS_MANIFEST};`,
|
|
50
50
|
` const buildInfo = ${JSON.stringify(buildInfo, null, 2)};`,
|
|
51
51
|
' setGlobalContext_buildEntry({',
|
|
52
|
-
`
|
|
52
|
+
` virtualFileExports,`,
|
|
53
53
|
` assetsManifest,`,
|
|
54
54
|
` buildInfo,`,
|
|
55
55
|
' });',
|
|
@@ -30,7 +30,7 @@ function commonConfig(vikeVitePluginOptions) {
|
|
|
30
30
|
_isDev: isDev,
|
|
31
31
|
_root: root,
|
|
32
32
|
_vikeVitePluginOptions: vikeVitePluginOptions,
|
|
33
|
-
vike: {
|
|
33
|
+
vike: { config: vikeConfig.global.config },
|
|
34
34
|
// TODO/v1-release: remove https://github.com/vikejs/vike/issues/2122
|
|
35
35
|
configVikePromise: Promise.resolve({
|
|
36
36
|
prerender: isPrerenderEnabled(vikeConfig)
|