vike 0.4.236 → 0.4.237-commit-8749e81
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/client/runtime-client-routing/globalContext.js +2 -2
- package/dist/cjs/client/runtime-server-routing/globalContext.js +2 -2
- package/dist/cjs/client/shared/createGetGlobalContextClient.js +21 -13
- package/dist/cjs/client/shared/getJsonSerializedInHtml.js +10 -1
- package/dist/cjs/client/shared/utils.js +1 -0
- package/dist/cjs/node/api/preview.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +4 -4
- package/dist/cjs/node/runtime/globalContext.js +127 -41
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +3 -1
- package/dist/cjs/node/runtime/html/serializeContext.js +25 -64
- package/dist/cjs/node/runtime/html/stream.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +3 -3
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +4 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsDev.js → retrievePageAssetsDev.js} +21 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsProd.js → retrievePageAssetsProd.js} +19 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +8 -34
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +50 -14
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +23 -9
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -5
- package/dist/cjs/node/runtime/renderPage.js +9 -8
- package/dist/cjs/node/runtime/utils.js +4 -0
- package/dist/cjs/node/shared/utils.js +1 -0
- package/dist/cjs/node/shared/virtualFileId.js +110 -0
- package/dist/cjs/node/vite/index.js +5 -3
- package/dist/cjs/node/vite/onLoad.js +5 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +31 -23
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +29 -13
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +20 -14
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildEntry.js +4 -4
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +17 -5
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +6 -12
- package/dist/cjs/node/vite/plugins/pluginCommon.js +1 -0
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +119 -73
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +8 -15
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +8 -9
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +7 -3
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +47 -0
- package/dist/cjs/node/vite/plugins/pluginPreview.js +11 -4
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +6 -13
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +11 -9
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFileEntry.js → generateVirtualFileGlobalEntryWithOldDesign.js} +11 -11
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigLazy.js → generateVirtualFilePageEntry.js} +10 -11
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +67 -0
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +18 -17
- package/dist/cjs/node/vite/shared/findPageFiles.js +1 -1
- package/dist/cjs/node/vite/shared/{resolveClientEntriesDev.js → getClientEntrySrcDev.js} +2 -2
- package/dist/cjs/node/vite/shared/getMagicString.js +18 -0
- package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +10 -0
- package/dist/cjs/node/vite/shared/getOutDirs.js +18 -12
- package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +1 -1
- package/dist/cjs/node/vite/shared/isViteServerBuild.js +56 -31
- package/dist/cjs/node/vite/shared/loggerVite.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +31 -3
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -3
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +8 -19
- package/dist/cjs/node/vite/utils.js +1 -0
- package/dist/cjs/shared/createGlobalContextShared.js +36 -15
- package/dist/cjs/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -20
- package/dist/cjs/shared/getProxyForPublicUsage.js +2 -2
- package/dist/cjs/shared/modifyUrlSameOrigin.js +9 -4
- package/dist/cjs/shared/page-configs/loadPageEntry.js +25 -0
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +4 -4
- package/dist/cjs/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js} +2 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +16 -16
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +7 -5
- package/dist/cjs/utils/cast.js +1 -1
- package/dist/cjs/utils/debug.js +1 -0
- package/dist/cjs/utils/getViteRPC.js +79 -0
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +1 -0
- package/dist/cjs/utils/isRunnableDevEnvironment.js +9 -0
- package/dist/cjs/utils/virtualFileId.js +39 -0
- package/dist/esm/client/node.js +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +3 -3
- package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +14 -14
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +35 -48
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +3 -3
- package/dist/esm/client/runtime-client-routing/globalContext.js +2 -2
- package/dist/esm/client/runtime-client-routing/history.d.ts +3 -5
- package/dist/esm/client/runtime-client-routing/history.js +39 -22
- package/dist/esm/client/runtime-client-routing/initClientRouter.js +2 -3
- package/dist/esm/client/runtime-client-routing/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.js +2 -2
- package/dist/esm/client/runtime-client-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +5 -5
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +43 -30
- package/dist/esm/client/runtime-client-routing/utils.d.ts +2 -0
- package/dist/esm/client/runtime-client-routing/utils.js +2 -0
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +4 -4
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +3 -3
- package/dist/esm/client/runtime-server-routing/globalContext.js +2 -2
- package/dist/esm/client/runtime-server-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +4 -4
- package/dist/esm/client/shared/createGetGlobalContextClient.js +21 -13
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
- package/dist/esm/client/shared/getJsonSerializedInHtml.js +10 -1
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.d.ts +1 -1
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +4 -4
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +2 -2
- package/dist/esm/client/shared/utils.d.ts +1 -0
- package/dist/esm/client/shared/utils.js +1 -0
- package/dist/esm/node/api/preview.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +49 -141
- package/dist/esm/node/prerender/runPrerender.js +4 -4
- package/dist/esm/node/runtime/globalContext.d.ts +43 -63
- package/dist/esm/node/runtime/globalContext.js +128 -42
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +4 -2
- package/dist/esm/node/runtime/html/serializeContext.d.ts +11 -6
- package/dist/esm/node/runtime/html/serializeContext.js +25 -64
- package/dist/esm/node/runtime/html/stream.js +1 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +3 -3
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +13 -36
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +4 -7
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/{retrieveAssetsDev.js → retrievePageAssetsDev.js} +22 -3
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/{retrieveAssetsProd.js → retrievePageAssetsProd.js} +19 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +0 -6
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +8 -34
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.js +51 -15
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +26 -12
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -3
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +30 -77
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -5
- package/dist/esm/node/runtime/renderPage.d.ts +13 -35
- package/dist/esm/node/runtime/renderPage.js +9 -8
- package/dist/esm/node/runtime/utils.d.ts +4 -0
- package/dist/esm/node/runtime/utils.js +4 -0
- package/dist/esm/node/shared/utils.d.ts +1 -0
- package/dist/esm/node/shared/utils.js +1 -0
- package/dist/esm/node/shared/virtualFileId.d.ts +28 -0
- package/dist/esm/node/shared/virtualFileId.js +107 -0
- package/dist/esm/node/vite/index.js +5 -3
- package/dist/esm/node/vite/onLoad.js +5 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +3 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +32 -24
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +3 -3
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +29 -13
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +0 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +21 -14
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildEntry.js +4 -4
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +17 -5
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +7 -10
- package/dist/esm/node/vite/plugins/pluginCommon.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginCommon.js +1 -0
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +121 -75
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +6 -10
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +7 -8
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +6 -2
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +26 -0
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +45 -0
- package/dist/esm/node/vite/plugins/pluginPreview.js +13 -6
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +6 -10
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.d.ts +2 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +11 -9
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.d.ts +6 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFileEntry.js → generateVirtualFileGlobalEntryWithOldDesign.js} +11 -11
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigLazy.js → generateVirtualFilePageEntry.js} +10 -11
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.d.ts +14 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +65 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +17 -16
- package/dist/esm/node/vite/shared/findPageFiles.js +1 -1
- package/dist/esm/node/vite/shared/getClientEntrySrcDev.d.ts +4 -0
- package/dist/esm/node/vite/shared/{resolveClientEntriesDev.js → getClientEntrySrcDev.js} +2 -2
- package/dist/esm/node/vite/shared/getMagicString.d.ts +9 -0
- package/dist/esm/node/vite/shared/getMagicString.js +13 -0
- package/dist/esm/node/vite/shared/getManifestFilePathRelative.d.ts +2 -0
- package/dist/esm/node/vite/shared/getManifestFilePathRelative.js +8 -0
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +6 -3
- package/dist/esm/node/vite/shared/getOutDirs.js +19 -13
- package/dist/esm/node/vite/shared/getViteConfigRuntime.js +1 -1
- package/dist/esm/node/vite/shared/isViteServerBuild.d.ts +14 -11
- package/dist/esm/node/vite/shared/isViteServerBuild.js +58 -31
- package/dist/esm/node/vite/shared/loggerVite.js +1 -1
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +31 -3
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -3
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +3 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +10 -21
- package/dist/esm/node/vite/utils.d.ts +1 -0
- package/dist/esm/node/vite/utils.js +1 -0
- package/dist/esm/shared/createGlobalContextShared.d.ts +8 -8
- package/dist/esm/shared/createGlobalContextShared.js +38 -17
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.d.ts → parseVirtualFileExportsGlobalEntry.d.ts} +2 -2
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -20
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/hooks/execHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/modifyUrlSameOrigin.d.ts +1 -1
- package/dist/esm/shared/modifyUrlSameOrigin.js +9 -4
- package/dist/esm/shared/page-configs/loadPageEntry.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadPageEntry.js +23 -0
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +9 -9
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +4 -4
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +1 -1
- package/dist/esm/shared/page-configs/serialize/{parsePageConfigs.d.ts → parsePageConfigsSerialized.d.ts} +2 -2
- package/dist/esm/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js} +2 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +17 -17
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/Config.d.ts +33 -98
- package/dist/esm/types/PageConfig.d.ts +9 -7
- package/dist/esm/types/VikeNamespace.d.ts +13 -0
- package/dist/esm/types/index.d.ts +3 -1
- 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 +7 -5
- package/dist/esm/utils/cast.d.ts +2 -2
- package/dist/esm/utils/cast.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +1 -0
- package/dist/esm/utils/getViteRPC.d.ts +6 -0
- package/dist/esm/utils/getViteRPC.js +77 -0
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.d.ts +7 -0
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -0
- package/dist/esm/utils/isRunnableDevEnvironment.d.ts +3 -0
- package/dist/esm/utils/isRunnableDevEnvironment.js +7 -0
- package/dist/esm/utils/objectFilter.d.ts +1 -1
- package/dist/esm/utils/virtualFileId.d.ts +6 -0
- package/dist/esm/{node/shared/virtualFiles.js → utils/virtualFileId.js} +15 -17
- package/package.json +16 -7
- package/dist/cjs/node/shared/virtualFiles/virtualFileEntry.js +0 -29
- package/dist/cjs/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -39
- package/dist/cjs/node/shared/virtualFiles.js +0 -41
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -23
- package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +0 -10
- package/dist/cjs/shared/page-configs/loadConfigValues.js +0 -21
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.d.ts +0 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +0 -4
- package/dist/esm/node/shared/virtualFiles/virtualFileEntry.d.ts +0 -11
- package/dist/esm/node/shared/virtualFiles/virtualFileEntry.js +0 -26
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.d.ts +0 -9
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -37
- package/dist/esm/node/shared/virtualFiles.d.ts +0 -8
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFileEntry.d.ts +0 -5
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigsEager.d.ts +0 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.d.ts +0 -7
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -21
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.d.ts +0 -3
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.js +0 -8
- package/dist/esm/node/vite/shared/resolveClientEntriesDev.d.ts +0 -4
- package/dist/esm/shared/page-configs/loadConfigValues.d.ts +0 -3
- package/dist/esm/shared/page-configs/loadConfigValues.js +0 -19
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { generateVirtualFileGlobalEntryWithOldDesign };
|
|
2
2
|
import { assert, assertPosixPath, scriptFileExtensionPattern, debugGlob, isVersionOrAbove, assertWarning, } from '../../utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { parseVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
4
4
|
import { version as viteVersion } from 'vite';
|
|
5
5
|
import { fileTypes } from '../../../../shared/getPageFiles/fileTypes.js';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
-
import {
|
|
7
|
+
import { generateVirtualFileGlobalEntry } from './generateVirtualFileGlobalEntry.js';
|
|
8
8
|
import { getVikeConfigInternal, isV1Design as isV1Design_ } from '../../shared/resolveVikeConfigInternal.js';
|
|
9
9
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
10
|
-
import {
|
|
11
|
-
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets.js';
|
|
12
|
-
async function
|
|
13
|
-
const idParsed =
|
|
14
|
-
assert(idParsed);
|
|
10
|
+
import { isViteServerBuild_extraSafe } from '../../shared/isViteServerBuild.js';
|
|
11
|
+
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
12
|
+
async function generateVirtualFileGlobalEntryWithOldDesign(id, options, config, env, isDev) {
|
|
13
|
+
const idParsed = parseVirtualFileId(id);
|
|
14
|
+
assert(idParsed && idParsed.type === 'global-entry');
|
|
15
15
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
16
|
-
assert(isForClientSide === !
|
|
16
|
+
assert(isForClientSide === !isViteServerBuild_extraSafe(config, options, env));
|
|
17
17
|
const code = await getCode(config, isForClientSide, isClientRouting, isDev, id);
|
|
18
18
|
return code;
|
|
19
19
|
}
|
|
@@ -66,7 +66,7 @@ export const pageFilesExportNamesEager = {};
|
|
|
66
66
|
export const pageFilesList = [];
|
|
67
67
|
export const neverLoaded = {};
|
|
68
68
|
|
|
69
|
-
${await
|
|
69
|
+
${await generateVirtualFileGlobalEntry(isForClientSide, isDev, id, isClientRouting)}
|
|
70
70
|
|
|
71
71
|
`;
|
|
72
72
|
// We still use import.meta.glob() when using th V1 design in order to not break the V1 design deprecation warning
|
|
@@ -168,7 +168,7 @@ function getGlobRoots(config) {
|
|
|
168
168
|
const globRoots = [
|
|
169
169
|
{
|
|
170
170
|
includeDir: '/',
|
|
171
|
-
excludeDir: path.posix.relative(config.root, getOutDirs(config).outDirRoot),
|
|
171
|
+
excludeDir: path.posix.relative(config.root, getOutDirs(config, undefined).outDirRoot),
|
|
172
172
|
},
|
|
173
173
|
];
|
|
174
174
|
return globRoots;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { generateVirtualFilePageEntry };
|
|
2
2
|
import { assert, getProjectError } from '../../utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { parseVirtualFileId, generateVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
4
4
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
5
5
|
import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
6
6
|
import { debug } from './debug.js';
|
|
7
|
-
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
8
7
|
import { serializeConfigValues } from '../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
9
8
|
import { handleAssetsManifest_isFixEnabled } from '../pluginBuild/handleAssetsManifest.js';
|
|
10
9
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
11
|
-
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets.js';
|
|
12
|
-
async function
|
|
13
|
-
const result =
|
|
14
|
-
assert(result);
|
|
10
|
+
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
11
|
+
async function generateVirtualFilePageEntry(id, isDev, config) {
|
|
12
|
+
const result = parseVirtualFileId(id);
|
|
13
|
+
assert(result && result.type === 'page-entry');
|
|
15
14
|
/* This assertion fails when using includeAssetsImportedByServer
|
|
16
15
|
{
|
|
17
16
|
const isForClientSide = !config.build.ssr
|
|
@@ -33,20 +32,20 @@ async function getVirtualFilePageConfigLazy(id, isDev, config) {
|
|
|
33
32
|
throw getProjectError('Outdated request');
|
|
34
33
|
//*/
|
|
35
34
|
}
|
|
36
|
-
const code =
|
|
35
|
+
const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config), config, isDev);
|
|
37
36
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
38
37
|
return code;
|
|
39
38
|
}
|
|
40
|
-
function
|
|
39
|
+
function getCode(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, config, isDev) {
|
|
41
40
|
const lines = [];
|
|
42
41
|
const importStatements = [];
|
|
43
42
|
const filesEnv = new Map();
|
|
44
43
|
const isClientRouting = getConfigValueBuildTime(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
45
44
|
lines.push('export const configValuesSerialized = {');
|
|
46
|
-
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv,
|
|
45
|
+
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, { isForClientSide, isClientRouting, isDev }, '', false));
|
|
47
46
|
lines.push('};');
|
|
48
47
|
if (!handleAssetsManifest_isFixEnabled(config) && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
49
|
-
importStatements.push(`import '${extractAssetsAddQuery(
|
|
48
|
+
importStatements.push(`import '${extractAssetsAddQuery(generateVirtualFileId({ type: 'page-entry', pageId, isForClientSide: false }))}'`);
|
|
50
49
|
}
|
|
51
50
|
const code = [...importStatements, ...lines].join('\n');
|
|
52
51
|
return code;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { getConfigValueSourcesRelevant };
|
|
2
|
+
export { isRuntimeEnvMatch };
|
|
3
|
+
export type { RuntimeEnv };
|
|
4
|
+
import type { ConfigEnvInternal, ConfigValueSource, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../../types/PageConfig.js';
|
|
5
|
+
type RuntimeEnv = {
|
|
6
|
+
isForClientSide: boolean;
|
|
7
|
+
isClientRouting: boolean;
|
|
8
|
+
isDev?: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
isForConfig: true;
|
|
11
|
+
};
|
|
12
|
+
declare function getConfigValueSourcesRelevant(configName: string, runtimeEnv: RuntimeEnv, pageConfig: PageConfigPartial): ConfigValueSource[];
|
|
13
|
+
declare function isRuntimeEnvMatch(configEnv: ConfigEnvInternal, runtimeEnv: RuntimeEnv): boolean;
|
|
14
|
+
type PageConfigPartial = Pick<PageConfigBuildTime | PageConfigGlobalBuildTime, 'configValueSources' | 'configDefinitions'>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export { getConfigValueSourcesRelevant };
|
|
2
|
+
export { isRuntimeEnvMatch };
|
|
3
|
+
import { assert } from '../../utils.js';
|
|
4
|
+
function getConfigValueSourcesRelevant(configName, runtimeEnv, pageConfig) {
|
|
5
|
+
const configDef = pageConfig.configDefinitions[configName];
|
|
6
|
+
assert(configDef);
|
|
7
|
+
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
8
|
+
if (!sourcesRelevant)
|
|
9
|
+
return [];
|
|
10
|
+
if (!configDef.cumulative) {
|
|
11
|
+
const source = sourcesRelevant[0];
|
|
12
|
+
if (source) {
|
|
13
|
+
sourcesRelevant = [source];
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
assert(sourcesRelevant.length === 0);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
// isOverridden() must be called before isRuntimeEnvMatch() is called (otherwise isOverridden() will return a wrong value)
|
|
21
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isOverridden(source, configName, pageConfig));
|
|
22
|
+
}
|
|
23
|
+
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
24
|
+
return sourcesRelevant;
|
|
25
|
+
}
|
|
26
|
+
function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
27
|
+
if ('isForConfig' in runtimeEnv)
|
|
28
|
+
return !!configEnv.config;
|
|
29
|
+
// Runtime
|
|
30
|
+
if (!runtimeEnv.isForClientSide) {
|
|
31
|
+
if (!configEnv.server)
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (!configEnv.client)
|
|
36
|
+
return false;
|
|
37
|
+
if (configEnv.client === 'if-client-routing' && !runtimeEnv.isClientRouting)
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
// Production/development
|
|
41
|
+
if (configEnv.production !== undefined) {
|
|
42
|
+
assert(typeof configEnv.production === 'boolean');
|
|
43
|
+
assert(typeof runtimeEnv.isDev === 'boolean');
|
|
44
|
+
if (configEnv.production) {
|
|
45
|
+
if (runtimeEnv.isDev)
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (!runtimeEnv.isDev)
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
function isOverridden(source, configName, pageConfig) {
|
|
56
|
+
const configDef = pageConfig.configDefinitions[configName];
|
|
57
|
+
assert(configDef);
|
|
58
|
+
if (configDef.cumulative)
|
|
59
|
+
return false;
|
|
60
|
+
const sources = pageConfig.configValueSources[configName];
|
|
61
|
+
assert(sources);
|
|
62
|
+
const idx = sources.indexOf(source);
|
|
63
|
+
assert(idx >= 0);
|
|
64
|
+
return idx > 0;
|
|
65
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export { pluginVirtualFiles };
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { assert, assertPosixPath, isScriptFile } from '../utils.js';
|
|
6
|
-
import {
|
|
7
|
-
import { isVirtualFileIdPageConfigLazy } from '../../shared/virtualFiles/virtualFilePageConfigLazy.js';
|
|
8
|
-
import { isVirtualFileIdEntry } from '../../shared/virtualFiles/virtualFileEntry.js';
|
|
3
|
+
import { generateVirtualFilePageEntry } from './pluginVirtualFiles/generateVirtualFilePageEntry.js';
|
|
4
|
+
import { generateVirtualFileGlobalEntryWithOldDesign } from './pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js';
|
|
5
|
+
import { assert, assertPosixPath, isScriptFile, addVirtualFileIdPrefix, isVirtualFileId, removeVirtualFileIdPrefix, } from '../utils.js';
|
|
6
|
+
import { parseVirtualFileId } from '../../shared/virtualFileId.js';
|
|
9
7
|
import { reloadVikeConfig, isV1Design, getVikeConfigInternalOptional } from '../shared/resolveVikeConfigInternal.js';
|
|
10
8
|
import pc from '@brillout/picocolors';
|
|
11
9
|
import { logConfigInfo } from '../shared/loggerNotProd.js';
|
|
@@ -26,7 +24,7 @@ function pluginVirtualFiles() {
|
|
|
26
24
|
},
|
|
27
25
|
resolveId(id) {
|
|
28
26
|
if (isVirtualFileId(id)) {
|
|
29
|
-
return
|
|
27
|
+
return addVirtualFileIdPrefix(id);
|
|
30
28
|
}
|
|
31
29
|
},
|
|
32
30
|
async handleHotUpdate(ctx) {
|
|
@@ -42,16 +40,19 @@ function pluginVirtualFiles() {
|
|
|
42
40
|
async load(id, options) {
|
|
43
41
|
if (!isVirtualFileId(id))
|
|
44
42
|
return undefined;
|
|
45
|
-
id =
|
|
43
|
+
id = removeVirtualFileIdPrefix(id);
|
|
46
44
|
const isDev = config._isDev;
|
|
47
45
|
assert(typeof isDev === 'boolean');
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
const idParsed = parseVirtualFileId(id);
|
|
47
|
+
if (idParsed) {
|
|
48
|
+
if (idParsed.type === 'page-entry') {
|
|
49
|
+
const code = await generateVirtualFilePageEntry(id, isDev, config);
|
|
50
|
+
return code;
|
|
51
|
+
}
|
|
52
|
+
if (idParsed.type === 'global-entry') {
|
|
53
|
+
const code = await generateVirtualFileGlobalEntryWithOldDesign(id, options, config, this.environment, isDev);
|
|
54
|
+
return code;
|
|
55
|
+
}
|
|
55
56
|
}
|
|
56
57
|
},
|
|
57
58
|
configureServer(server) {
|
|
@@ -164,7 +165,7 @@ function reloadConfig(filePath, config, op, server) {
|
|
|
164
165
|
}
|
|
165
166
|
function getVikeVirtualFiles(server) {
|
|
166
167
|
const vikeVirtualFiles = Array.from(server.moduleGraph.urlToModuleMap.keys())
|
|
167
|
-
.filter((url) =>
|
|
168
|
+
.filter((url) => parseVirtualFileId(url))
|
|
168
169
|
.map((url) => {
|
|
169
170
|
const mod = server.moduleGraph.urlToModuleMap.get(url);
|
|
170
171
|
assert(mod);
|
|
@@ -5,7 +5,7 @@ import pc from '@brillout/picocolors';
|
|
|
5
5
|
import { getOutDirs } from './getOutDirs.js';
|
|
6
6
|
async function findPageFiles(config, fileTypes, isDev) {
|
|
7
7
|
const cwd = config.root;
|
|
8
|
-
const { outDirRoot } = getOutDirs(config);
|
|
8
|
+
const { outDirRoot } = getOutDirs(config, undefined);
|
|
9
9
|
const timeBase = new Date().getTime();
|
|
10
10
|
let pageFiles = await glob(fileTypes.map((fileType) => `**/*${fileType}.${scriptFileExtensionPattern}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false, expandDirectories: false });
|
|
11
11
|
pageFiles = pageFiles.map((p) => '/' + toPosixPath(p));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getClientEntrySrcDev };
|
|
2
2
|
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsImportPathNpmPackage, assertIsNotProductionRuntime, requireResolveNpmPackage, requireResolveVikeDistFile, } from '../utils.js';
|
|
3
3
|
assertIsNotProductionRuntime();
|
|
4
|
-
function
|
|
4
|
+
function getClientEntrySrcDev(clientEntry, viteDevServer) {
|
|
5
5
|
let userRootDir = viteDevServer.config.root;
|
|
6
6
|
assert(userRootDir);
|
|
7
7
|
userRootDir = toPosixPath(userRootDir);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { getMagicString };
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
// Used everywhere instead of `new MagicString()` for consistent source map generation
|
|
4
|
+
function getMagicString(code, id) {
|
|
5
|
+
const magicString = new MagicString(code);
|
|
6
|
+
const getMagicStringResult = () => {
|
|
7
|
+
return {
|
|
8
|
+
code: magicString.toString(),
|
|
9
|
+
map: magicString.generateMap({ hires: true, source: id }),
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
return { magicString, getMagicStringResult };
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { getManifestFilePathRelative };
|
|
2
|
+
import { assert } from '../utils.js';
|
|
3
|
+
function getManifestFilePathRelative(manifestConfig) {
|
|
4
|
+
assert(['string', 'boolean'].includes(typeof manifestConfig));
|
|
5
|
+
assert(manifestConfig !== false);
|
|
6
|
+
const manifestFileRelative = typeof manifestConfig === 'string' ? manifestConfig : '.vite/manifest.json';
|
|
7
|
+
return manifestFileRelative;
|
|
8
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
2
|
export { resolveOutDir };
|
|
3
|
+
export { resolveOutDir_configEnvironment };
|
|
3
4
|
export type { OutDirs };
|
|
4
|
-
import type { UserConfig, ResolvedConfig,
|
|
5
|
+
import type { UserConfig, ResolvedConfig, EnvironmentOptions } from 'vite';
|
|
6
|
+
import { ViteEnv } from './isViteServerBuild.js';
|
|
5
7
|
type OutDirs = {
|
|
6
8
|
/** Absolute path to `outDir` */
|
|
7
9
|
outDirRoot: string;
|
|
@@ -10,6 +12,7 @@ type OutDirs = {
|
|
|
10
12
|
/** Absolute path to `${outDir}/server` */
|
|
11
13
|
outDirServer: string;
|
|
12
14
|
};
|
|
13
|
-
declare function getOutDirs(configGlobal: ResolvedConfig, viteEnv
|
|
15
|
+
declare function getOutDirs(configGlobal: ResolvedConfig, viteEnv: ViteEnv | undefined): OutDirs;
|
|
16
|
+
declare function resolveOutDir_configEnvironment(configGlobal: UserConfig, envName: string, configEnv: EnvironmentOptions): string;
|
|
14
17
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
15
|
-
declare function resolveOutDir(config: UserConfig,
|
|
18
|
+
declare function resolveOutDir(config: UserConfig, isServerSide: boolean): string;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
2
|
export { resolveOutDir };
|
|
3
|
+
export { resolveOutDir_configEnvironment };
|
|
3
4
|
import pc from '@brillout/picocolors';
|
|
4
5
|
import { assert, assertPosixPath, assertUsage, createDebugger, pathJoin, toPosixPath } from '../utils.js';
|
|
5
|
-
import { isViteServerBuild } from './isViteServerBuild.js';
|
|
6
|
+
import { isViteServerBuild, isViteServerBuild_withoutEnv } from './isViteServerBuild.js';
|
|
6
7
|
const debug = createDebugger('vike:outDir');
|
|
7
8
|
function getOutDirs(configGlobal, viteEnv) {
|
|
8
|
-
const configEnv = viteEnv?.config ?? configGlobal;
|
|
9
9
|
debug('getOutDirs()', new Error().stack);
|
|
10
|
-
const outDir =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const outDirs = getOutDirsAll(outDir, configEnv.root);
|
|
10
|
+
const outDir = getOutDirFromResolvedConfig(configGlobal);
|
|
11
|
+
assertOutDirResolved(outDir, configGlobal, viteEnv);
|
|
12
|
+
const outDirs = getOutDirsAll(outDir, configGlobal.root);
|
|
14
13
|
return outDirs;
|
|
15
14
|
}
|
|
15
|
+
function resolveOutDir_configEnvironment(configGlobal, envName, configEnv) {
|
|
16
|
+
assert(configGlobal && envName && configEnv);
|
|
17
|
+
const viteEnv = { name: envName, config: configEnv };
|
|
18
|
+
const isServerSide = isViteServerBuild(configGlobal, viteEnv);
|
|
19
|
+
return resolveOutDir(configEnv, isServerSide);
|
|
20
|
+
}
|
|
16
21
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
17
|
-
function resolveOutDir(config,
|
|
22
|
+
function resolveOutDir(config, isServerSide) {
|
|
18
23
|
debug('resolveOutDir()', new Error().stack);
|
|
19
|
-
const isServerSide = isViteServerBuild(config) || isSSR;
|
|
20
24
|
debug('isServerSide', isServerSide);
|
|
21
25
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
22
26
|
debug('outDir', outDir);
|
|
@@ -98,14 +102,16 @@ function isOutDirRoot(outDirRot) {
|
|
|
98
102
|
function assertIsNotOutDirRoot(outDir) {
|
|
99
103
|
assert(outDir.endsWith('/client') || outDir.endsWith('/server'));
|
|
100
104
|
}
|
|
101
|
-
/** Assert that `outDir` ends with `/server` or `/client` */
|
|
102
|
-
function assertOutDirResolved(outDir,
|
|
105
|
+
/** Assert that `outDir` ends with the correct directory `/server` or `/client` */
|
|
106
|
+
function assertOutDirResolved(outDir, configGlobal, viteEnv) {
|
|
103
107
|
assertPosixPath(outDir);
|
|
104
|
-
|
|
108
|
+
if (isOutDirRoot(outDir))
|
|
109
|
+
return;
|
|
110
|
+
assert(outDir.endsWith('/client') || outDir.endsWith('/server')); // we normalized outDir
|
|
105
111
|
assert('/client'.length === '/server'.length);
|
|
106
112
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
107
113
|
const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
|
|
108
|
-
if (
|
|
114
|
+
if (isViteServerBuild_withoutEnv(configGlobal, viteEnv)) {
|
|
109
115
|
assertUsage(outDir.endsWith('/server'), wrongUsage);
|
|
110
116
|
}
|
|
111
117
|
else {
|
|
@@ -119,7 +125,7 @@ function getOutDirFromViteUserConfig(config) {
|
|
|
119
125
|
outDir = normalizeOutDir(outDir);
|
|
120
126
|
return outDir;
|
|
121
127
|
}
|
|
122
|
-
function
|
|
128
|
+
function getOutDirFromResolvedConfig(config) {
|
|
123
129
|
let outDir = config.build.outDir;
|
|
124
130
|
assert(outDir);
|
|
125
131
|
outDir = normalizeOutDir(outDir);
|
|
@@ -3,7 +3,7 @@ import { assert, assertFilePathAbsoluteFilesystem, hasProp } from '../utils.js';
|
|
|
3
3
|
import { getOutDirs } from './getOutDirs.js';
|
|
4
4
|
function getViteConfigRuntime(config) {
|
|
5
5
|
assert(hasProp(config, '_baseViteOriginal', 'string'));
|
|
6
|
-
const { outDirRoot } = getOutDirs(config);
|
|
6
|
+
const { outDirRoot } = getOutDirs(config, undefined);
|
|
7
7
|
assertFilePathAbsoluteFilesystem(outDirRoot);
|
|
8
8
|
const viteConfigRuntime = {
|
|
9
9
|
root: config.root,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
export { isViteServerBuild };
|
|
2
2
|
export { isViteClientBuild };
|
|
3
|
-
export {
|
|
4
|
-
export { isViteServerBuild_safe };
|
|
3
|
+
export { isViteServerBuild_withoutEnv };
|
|
5
4
|
export { isViteServerBuild_onlySsrEnv };
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export { isViteServerBuild_extraSafe };
|
|
6
|
+
export type { ViteEnv };
|
|
7
|
+
import type { Environment, EnvironmentOptions, ResolvedConfig, UserConfig } from 'vite';
|
|
8
|
+
type ViteEnv = {
|
|
9
|
+
name?: string;
|
|
10
|
+
config: EnvironmentOptions | Environment['config'];
|
|
11
|
+
};
|
|
12
|
+
declare function isViteServerBuild_withoutEnv(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv): boolean;
|
|
13
|
+
declare function isViteServerBuild(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
|
|
14
|
+
declare function isViteClientBuild(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
15
|
+
declare function isViteServerBuild_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
16
|
+
declare function isViteServerBuild_extraSafe(config: ResolvedConfig, options: {
|
|
11
17
|
ssr?: boolean;
|
|
12
|
-
} | undefined): boolean;
|
|
13
|
-
declare function isViteServerBuild_safe(config: ResolvedConfig, options: {
|
|
14
|
-
ssr?: boolean;
|
|
15
|
-
} | undefined): boolean;
|
|
18
|
+
} | undefined, viteEnv: ViteEnv): boolean;
|
|
@@ -1,45 +1,72 @@
|
|
|
1
|
+
// TODO/now: rename to isViteServerSide
|
|
1
2
|
export { isViteServerBuild };
|
|
3
|
+
// TODO/now: rename to isViteClientSide
|
|
2
4
|
export { isViteClientBuild };
|
|
3
|
-
export {
|
|
4
|
-
export { isViteServerBuild_safe };
|
|
5
|
+
export { isViteServerBuild_withoutEnv };
|
|
5
6
|
export { isViteServerBuild_onlySsrEnv };
|
|
7
|
+
export { isViteServerBuild_extraSafe };
|
|
6
8
|
import { assert } from '../../../utils/assert.js';
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
function isViteServerBuild_withoutEnv(configGlobal, viteEnv) {
|
|
10
|
+
assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
11
|
+
const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
12
|
+
const isServerSide2 = !viteEnv?.name ? null : viteEnv.name !== 'client'; // I can't think of a use case for creating another client-side environment
|
|
13
|
+
const isServerSide3 = !viteEnv ? null : !!viteEnv.config.build?.ssr;
|
|
14
|
+
const isServerSide4 = !!configGlobal.build?.ssr;
|
|
15
|
+
const debug = {
|
|
16
|
+
envIsUndefined: !viteEnv,
|
|
17
|
+
envName: viteEnv?.name ?? null,
|
|
18
|
+
envConsumer: viteEnv?.config.consumer ?? null,
|
|
19
|
+
configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
|
|
20
|
+
configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
|
|
21
|
+
isServerSide1,
|
|
22
|
+
isServerSide2,
|
|
23
|
+
isServerSide3,
|
|
24
|
+
isServerSide4,
|
|
25
|
+
};
|
|
26
|
+
if (isServerSide1 !== null) {
|
|
27
|
+
assert(isServerSide1 === isServerSide2 || isServerSide2 === null, debug);
|
|
28
|
+
/* This assertion can fail, seems to be a Vite bug?
|
|
29
|
+
assert(isServerSide1 === isServerSide3, debug)
|
|
30
|
+
*/
|
|
31
|
+
return isServerSide1;
|
|
32
|
+
}
|
|
33
|
+
if (isServerSide2 !== null) {
|
|
34
|
+
/* This assertion can fail, seems to be a Vite bug?
|
|
35
|
+
assert(isServerSide2 === isServerSide3, debug)
|
|
36
|
+
*/
|
|
37
|
+
return isServerSide2;
|
|
38
|
+
}
|
|
39
|
+
if (isServerSide3 !== null) {
|
|
40
|
+
return isServerSide3;
|
|
41
|
+
}
|
|
42
|
+
return isServerSide4;
|
|
10
43
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return viteEnv ? viteEnv.name === 'ssr' : isViteServerBuild(configGlobal);
|
|
44
|
+
function isViteServerBuild(configGlobal, viteEnv) {
|
|
45
|
+
return isViteServerBuild_withoutEnv(configGlobal, viteEnv);
|
|
14
46
|
}
|
|
15
47
|
function isViteClientBuild(configGlobal, viteEnv) {
|
|
16
|
-
|
|
17
|
-
const isVite5 = viteEnv === undefined;
|
|
18
|
-
if (!isVite5) {
|
|
19
|
-
const yes2 = viteEnv.name === 'client';
|
|
20
|
-
assert(yes === yes2);
|
|
21
|
-
}
|
|
22
|
-
return yes;
|
|
48
|
+
return !isViteServerBuild(configGlobal, viteEnv);
|
|
23
49
|
}
|
|
24
|
-
|
|
25
|
-
|
|
50
|
+
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
51
|
+
function isViteServerBuild_onlySsrEnv(configGlobal, viteEnv) {
|
|
52
|
+
return viteEnv ? viteEnv.name === 'ssr' : isViteServerBuild(configGlobal, viteEnv);
|
|
26
53
|
}
|
|
27
|
-
// Vite is quite messy about setting
|
|
28
|
-
|
|
29
|
-
function isViteServerBuild_safe(config, options) {
|
|
54
|
+
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
55
|
+
function isViteServerBuild_extraSafe(config, options, viteEnv) {
|
|
30
56
|
if (config.command === 'build') {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
57
|
+
const res = config.build.ssr;
|
|
58
|
+
assert(typeof res === 'boolean');
|
|
59
|
+
assert(res === options?.ssr || options?.ssr === undefined);
|
|
60
|
+
assert(res === isViteServerBuild(config, viteEnv));
|
|
61
|
+
return res;
|
|
36
62
|
}
|
|
37
63
|
else {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/* This
|
|
41
|
-
if (typeof config.build.ssr === 'boolean') assert(
|
|
42
|
-
|
|
43
|
-
|
|
64
|
+
const res = options?.ssr;
|
|
65
|
+
assert(typeof res === 'boolean');
|
|
66
|
+
/* This assertion can fail, seems to be a Vite bug? It's very unexpected.
|
|
67
|
+
if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
|
|
68
|
+
*/
|
|
69
|
+
assert(res === isViteServerBuild(config, viteEnv));
|
|
70
|
+
return res;
|
|
44
71
|
}
|
|
45
72
|
}
|
|
@@ -31,7 +31,7 @@ function intercept(logType, config) {
|
|
|
31
31
|
// We swallow Vite's message: we didn't see it add any value so far.
|
|
32
32
|
// - It can even be confusing, such as the following:
|
|
33
33
|
// ```
|
|
34
|
-
// Error when evaluating SSR module virtual:vike:
|
|
34
|
+
// Error when evaluating SSR module virtual:vike:page-entry:server:/pages/abort: failed to import "/pages/abort/+Page.mdx"
|
|
35
35
|
// ```
|
|
36
36
|
assert(!isErrorDebug());
|
|
37
37
|
return;
|
|
@@ -4,7 +4,7 @@ export type { ConfigDefinitions };
|
|
|
4
4
|
export type { ConfigDefinitionsInternal };
|
|
5
5
|
export type { ConfigDefinitionInternal };
|
|
6
6
|
export type { ConfigEffect };
|
|
7
|
-
import type { ConfigEnvInternal, ConfigEnv,
|
|
7
|
+
import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath, PageConfigBuildTime } from '../../../../types/PageConfig.js';
|
|
8
8
|
import type { Config, ConfigNameBuiltIn, ConfigNameGlobal } from '../../../../types/Config.js';
|
|
9
9
|
import { type ConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
10
10
|
/** The meta definition of a config.
|
|
@@ -75,7 +75,7 @@ type ConfigEffect = (config: {
|
|
|
75
75
|
}) => Config | undefined;
|
|
76
76
|
/** For Vike internal use */
|
|
77
77
|
type ConfigDefinitionInternal = Omit<ConfigDefinition_, 'env'> & {
|
|
78
|
-
_computed?: (
|
|
78
|
+
_computed?: (pageConfig: Omit<PageConfigBuildTime, 'configValuesComputed'>) => unknown;
|
|
79
79
|
_valueIsFilePath?: true;
|
|
80
80
|
_userEffectDefinedAtFilePath?: DefinedAtFilePath;
|
|
81
81
|
env: ConfigEnvInternal;
|