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
|
@@ -8,14 +8,14 @@ import fs_sync from 'node:fs';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { existsSync } from 'node:fs';
|
|
10
10
|
import { assert, assertIsSingleModuleInstance, assertWarning, isEqualStringList, isObject, pLimit, unique, } from '../../utils.js';
|
|
11
|
-
import {
|
|
12
|
-
import { manifestTempFile } from './pluginBuildConfig.js';
|
|
11
|
+
import { parseVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
13
12
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
14
13
|
import pc from '@brillout/picocolors';
|
|
15
14
|
import { getVikeConfigInternal, isV1Design } from '../../shared/resolveVikeConfigInternal.js';
|
|
16
15
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
17
|
-
import { isViteServerBuild_onlySsrEnv, isViteServerBuild } from '../../shared/isViteServerBuild.js';
|
|
16
|
+
import { isViteServerBuild_onlySsrEnv, isViteServerBuild, isViteServerBuild_withoutEnv, } from '../../shared/isViteServerBuild.js';
|
|
18
17
|
import { set_macro_ASSETS_MANIFEST } from './pluginBuildEntry.js';
|
|
18
|
+
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
19
19
|
assertIsSingleModuleInstance('build/handleAssetsManifest.ts');
|
|
20
20
|
let assetsJsonFilePath;
|
|
21
21
|
// true => use workaround config.build.ssrEmitAssets
|
|
@@ -26,15 +26,14 @@ function handleAssetsManifest_isFixEnabled(config) {
|
|
|
26
26
|
}
|
|
27
27
|
/** https://github.com/vikejs/vike/issues/1339 */
|
|
28
28
|
async function fixServerAssets(config) {
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const serverManifest = await readManifestFile(outDirs.outDirServer);
|
|
29
|
+
const clientManifest = await readManifestFile(config, true);
|
|
30
|
+
const serverManifest = await readManifestFile(config, false);
|
|
32
31
|
const { clientManifestMod, serverManifestMod, filesToMove, filesToRemove } = addServerAssets(clientManifest, serverManifest);
|
|
33
32
|
await copyAssets(filesToMove, filesToRemove, config);
|
|
34
33
|
return { clientManifestMod, serverManifestMod };
|
|
35
34
|
}
|
|
36
35
|
async function copyAssets(filesToMove, filesToRemove, config) {
|
|
37
|
-
const { outDirClient, outDirServer } = getOutDirs(config);
|
|
36
|
+
const { outDirClient, outDirServer } = getOutDirs(config, undefined);
|
|
38
37
|
const assetsDir = getAssetsDir(config);
|
|
39
38
|
const assetsDirServer = path.posix.join(outDirServer, assetsDir);
|
|
40
39
|
if (!filesToMove.length && !filesToRemove.length && !existsSync(assetsDirServer))
|
|
@@ -166,13 +165,13 @@ function addServerAssets(clientManifest, serverManifest) {
|
|
|
166
165
|
}
|
|
167
166
|
function getPageId(key) {
|
|
168
167
|
// Normalize from:
|
|
169
|
-
// ../../virtual:vike:
|
|
168
|
+
// ../../virtual:vike:page-entry:client:/pages/index
|
|
170
169
|
// to:
|
|
171
|
-
// virtual:vike:
|
|
170
|
+
// virtual:vike:page-entry:client:/pages/index
|
|
172
171
|
// (This seems to be needed only for vitest tests that use Vite's build() API with an inline config.)
|
|
173
172
|
key = key.substring(key.indexOf('virtual:vike'));
|
|
174
|
-
const result =
|
|
175
|
-
return result && result.pageId;
|
|
173
|
+
const result = parseVirtualFileId(key);
|
|
174
|
+
return result && result.type === 'page-entry' ? result.pageId : null;
|
|
176
175
|
}
|
|
177
176
|
function collectResources(entryRoot, manifest) {
|
|
178
177
|
const css = [];
|
|
@@ -217,10 +216,10 @@ function handleAssetsManifest_assertUsageCssCodeSplit(config) {
|
|
|
217
216
|
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 });
|
|
218
217
|
}
|
|
219
218
|
const targets = [];
|
|
220
|
-
function handleAssetsManifest_assertUsageCssTarget(config) {
|
|
219
|
+
function handleAssetsManifest_assertUsageCssTarget(config, env) {
|
|
221
220
|
if (!handleAssetsManifest_isFixEnabled(config))
|
|
222
221
|
return;
|
|
223
|
-
const isServerSide = isViteServerBuild(config);
|
|
222
|
+
const isServerSide = isViteServerBuild(config, env);
|
|
224
223
|
assert(typeof isServerSide === 'boolean');
|
|
225
224
|
assert(config.build.target !== undefined);
|
|
226
225
|
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
@@ -265,8 +264,8 @@ function removeEmptyDirectories(dirPath) {
|
|
|
265
264
|
fs_sync.rmdirSync(dirPath);
|
|
266
265
|
}
|
|
267
266
|
}
|
|
268
|
-
async function readManifestFile(
|
|
269
|
-
const manifestFilePath =
|
|
267
|
+
async function readManifestFile(config, client) {
|
|
268
|
+
const manifestFilePath = getManifestFilePath(config, client);
|
|
270
269
|
const manifestFileContent = await fs.readFile(manifestFilePath, 'utf-8');
|
|
271
270
|
assert(manifestFileContent);
|
|
272
271
|
const manifest = JSON.parse(manifestFileContent);
|
|
@@ -287,20 +286,20 @@ async function handleAssetsManifest_getBuildConfig(config) {
|
|
|
287
286
|
ssrEmitAssets: isFixEnabled ? true : undefined,
|
|
288
287
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
289
288
|
cssMinify: isFixEnabled ? 'esbuild' : undefined,
|
|
290
|
-
manifest:
|
|
289
|
+
manifest: true,
|
|
291
290
|
copyPublicDir: vikeConfig.config.vite6BuilderApp
|
|
292
291
|
? // Already set by vike:build:pluginBuildApp
|
|
293
292
|
undefined
|
|
294
|
-
: !
|
|
293
|
+
: !isViteServerBuild_withoutEnv(config),
|
|
295
294
|
};
|
|
296
295
|
}
|
|
297
296
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
297
|
+
const isSsrEnv = isViteServerBuild_onlySsrEnv(config, viteEnv);
|
|
298
|
+
if (isSsrEnv) {
|
|
300
299
|
assert(!assetsJsonFilePath);
|
|
301
300
|
const outDirs = getOutDirs(config, viteEnv);
|
|
302
301
|
assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
303
|
-
await writeAssetsManifestFile(
|
|
302
|
+
await writeAssetsManifestFile(assetsJsonFilePath, config);
|
|
304
303
|
}
|
|
305
304
|
if (isViteServerBuild(config, viteEnv)) {
|
|
306
305
|
const outDir = options.dir;
|
|
@@ -310,14 +309,14 @@ async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
|
310
309
|
// - Also in some other server builds such as dist/vercel/ from vike-vercel
|
|
311
310
|
// - Don't replace it in dist/rsc/ from vike-react-rsc since __VITE_ASSETS_MANIFEST__ doesn't exist there
|
|
312
311
|
const noop = await set_macro_ASSETS_MANIFEST(assetsJsonFilePath, bundle, outDir);
|
|
313
|
-
if (
|
|
312
|
+
if (isSsrEnv)
|
|
314
313
|
assert(!noop); // dist/server should always contain __VITE_ASSETS_MANIFEST__
|
|
315
314
|
}
|
|
316
315
|
}
|
|
317
|
-
async function writeAssetsManifestFile(
|
|
316
|
+
async function writeAssetsManifestFile(assetsJsonFilePath, config) {
|
|
318
317
|
const isFixEnabled = handleAssetsManifest_isFixEnabled(config);
|
|
319
|
-
const clientManifestFilePath =
|
|
320
|
-
const serverManifestFilePath =
|
|
318
|
+
const clientManifestFilePath = getManifestFilePath(config, true);
|
|
319
|
+
const serverManifestFilePath = getManifestFilePath(config, false);
|
|
321
320
|
if (!isFixEnabled) {
|
|
322
321
|
await fs.copyFile(clientManifestFilePath, assetsJsonFilePath);
|
|
323
322
|
}
|
|
@@ -328,3 +327,12 @@ async function writeAssetsManifestFile(outDirs, assetsJsonFilePath, config) {
|
|
|
328
327
|
await fs.rm(clientManifestFilePath);
|
|
329
328
|
await fs.rm(serverManifestFilePath);
|
|
330
329
|
}
|
|
330
|
+
function getManifestFilePath(config, client) {
|
|
331
|
+
const outDirs = getOutDirs(config, undefined);
|
|
332
|
+
const outDir = client ? outDirs.outDirClient : outDirs.outDirServer;
|
|
333
|
+
const env = client ? config.environments.client : config.environments.ssr;
|
|
334
|
+
assert(env);
|
|
335
|
+
const manifestFilePathRelative = getManifestFilePathRelative(env.build.manifest);
|
|
336
|
+
const manifestFilePath = path.posix.join(outDir, manifestFilePathRelative);
|
|
337
|
+
return manifestFilePath;
|
|
338
|
+
}
|
|
@@ -6,12 +6,12 @@ import { isPrerenderAutoRunEnabled, wasPrerenderRun } from '../../../prerender/c
|
|
|
6
6
|
import { isViteCliCall, getViteConfigFromCli } from '../../shared/isViteCliCall.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
import { logErrorHint } from '../../../runtime/renderPage/logErrorHint.js';
|
|
9
|
-
import { manifestTempFile } from './pluginBuildConfig.js';
|
|
10
9
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
11
10
|
import { isVikeCliOrApi } from '../../../api/context.js';
|
|
12
11
|
import { handleAssetsManifest, handleAssetsManifest_assertUsageCssTarget } from './handleAssetsManifest.js';
|
|
13
12
|
import { isViteClientBuild, isViteServerBuild_onlySsrEnv } from '../../shared/isViteServerBuild.js';
|
|
14
13
|
import { runPrerender_forceExit, runPrerenderFromAutoRun } from '../../../prerender/runPrerenderEntry.js';
|
|
14
|
+
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
15
15
|
assertIsSingleModuleInstance('build/pluginAutoFullBuild.ts');
|
|
16
16
|
let forceExit = false;
|
|
17
17
|
function pluginAutoFullBuild() {
|
|
@@ -55,7 +55,7 @@ function pluginAutoFullBuild() {
|
|
|
55
55
|
order: 'post',
|
|
56
56
|
async handler() {
|
|
57
57
|
onSetupBuild();
|
|
58
|
-
handleAssetsManifest_assertUsageCssTarget(config);
|
|
58
|
+
handleAssetsManifest_assertUsageCssTarget(config, this.environment);
|
|
59
59
|
const vikeConfig = await getVikeConfigInternal();
|
|
60
60
|
if (forceExit &&
|
|
61
61
|
// Let vike:build:pluginBuildApp force exit
|
|
@@ -82,7 +82,7 @@ async function triggerFullBuild(config, viteEnv, bundle) {
|
|
|
82
82
|
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
83
83
|
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
84
84
|
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
85
|
-
if (!bundle[
|
|
85
|
+
if (!bundle[getManifestFilePathRelative(config.build.manifest)])
|
|
86
86
|
return;
|
|
87
87
|
const configInline = getFullBuildInlineConfig(config);
|
|
88
88
|
if (!isBuilderApp) {
|
|
@@ -6,6 +6,34 @@ import { isPrerenderForceExit } from './pluginAutoFullBuild.js';
|
|
|
6
6
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
7
7
|
function pluginBuildApp() {
|
|
8
8
|
return [
|
|
9
|
+
{
|
|
10
|
+
name: 'vike:build:pluginBuildApp:pre',
|
|
11
|
+
apply: 'build',
|
|
12
|
+
enforce: 'pre',
|
|
13
|
+
config: {
|
|
14
|
+
order: 'pre',
|
|
15
|
+
async handler(_config) {
|
|
16
|
+
const vikeConfig = await getVikeConfigInternal();
|
|
17
|
+
if (!vikeConfig.config.vite6BuilderApp)
|
|
18
|
+
return;
|
|
19
|
+
return {
|
|
20
|
+
builder: {
|
|
21
|
+
// Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
22
|
+
async buildApp(builder) {
|
|
23
|
+
assert(builder.environments.client);
|
|
24
|
+
assert(builder.environments.ssr);
|
|
25
|
+
await builder.build(builder.environments.client);
|
|
26
|
+
await builder.build(builder.environments.ssr);
|
|
27
|
+
if (isPrerenderForceExit()) {
|
|
28
|
+
runPrerender_forceExit();
|
|
29
|
+
assert(false);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
9
37
|
{
|
|
10
38
|
name: 'vike:build:pluginBuildApp',
|
|
11
39
|
apply: 'build',
|
|
@@ -14,19 +42,6 @@ function pluginBuildApp() {
|
|
|
14
42
|
if (!vikeConfig.config.vite6BuilderApp)
|
|
15
43
|
return;
|
|
16
44
|
return {
|
|
17
|
-
builder: {
|
|
18
|
-
// Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
19
|
-
async buildApp(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
|
-
if (isPrerenderForceExit()) {
|
|
25
|
-
runPrerender_forceExit();
|
|
26
|
-
assert(false);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
45
|
environments: {
|
|
31
46
|
ssr: {
|
|
32
47
|
consumer: 'server',
|
|
@@ -38,6 +53,7 @@ function pluginBuildApp() {
|
|
|
38
53
|
client: {
|
|
39
54
|
consumer: 'client',
|
|
40
55
|
build: {
|
|
56
|
+
outDir: resolveOutDir(config, false),
|
|
41
57
|
copyPublicDir: true,
|
|
42
58
|
ssr: false,
|
|
43
59
|
},
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export { pluginBuildConfig };
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
|
-
export { manifestTempFile };
|
|
5
4
|
import type { ResolvedConfig, Plugin } from 'vite';
|
|
6
5
|
import type { PageConfigBuildTime } from '../../../../types/PageConfig.js';
|
|
7
|
-
declare const manifestTempFile = "_temp_manifest.json";
|
|
8
6
|
declare function pluginBuildConfig(): Plugin[];
|
|
9
7
|
declare function analyzeClientEntries(pageConfigs: PageConfigBuildTime[], config: ResolvedConfig): {
|
|
10
8
|
hasClientRouting: boolean;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
export { pluginBuildConfig };
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
|
-
export { manifestTempFile };
|
|
5
4
|
import { assert, addOnBeforeLogHook, removeFileExtension, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsImportPathNpmPackage, requireResolveVikeDistFile, } from '../../utils.js';
|
|
6
5
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
7
6
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
8
|
-
import {
|
|
7
|
+
import { generateVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
9
8
|
import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
10
9
|
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
11
10
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
12
11
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { isViteServerBuild_withoutEnv } from '../../shared/isViteServerBuild.js';
|
|
13
|
+
import { resolveOutDir_configEnvironment } from '../../shared/getOutDirs.js';
|
|
15
14
|
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, } from './handleAssetsManifest.js';
|
|
16
|
-
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets.js';
|
|
17
|
-
const manifestTempFile = '_temp_manifest.json';
|
|
15
|
+
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
18
16
|
function pluginBuildConfig() {
|
|
19
17
|
let config;
|
|
18
|
+
let configUnresolved;
|
|
20
19
|
return [
|
|
21
20
|
{
|
|
22
21
|
name: 'vike:build:pluginBuildConfig',
|
|
@@ -35,18 +34,26 @@ function pluginBuildConfig() {
|
|
|
35
34
|
handleAssetsManifest_assertUsageCssCodeSplit(config);
|
|
36
35
|
},
|
|
37
36
|
},
|
|
38
|
-
|
|
37
|
+
configEnvironment: {
|
|
39
38
|
order: 'post',
|
|
40
|
-
async handler(
|
|
41
|
-
|
|
39
|
+
async handler(envName, configEnv) {
|
|
40
|
+
assert(configUnresolved);
|
|
42
41
|
return {
|
|
43
42
|
build: {
|
|
44
|
-
outDir:
|
|
45
|
-
...(await handleAssetsManifest_getBuildConfig(config)),
|
|
43
|
+
outDir: resolveOutDir_configEnvironment(configUnresolved, envName, configEnv),
|
|
46
44
|
},
|
|
47
45
|
};
|
|
48
46
|
},
|
|
49
47
|
},
|
|
48
|
+
config: {
|
|
49
|
+
order: 'post',
|
|
50
|
+
async handler(config) {
|
|
51
|
+
configUnresolved = config;
|
|
52
|
+
onSetupBuild();
|
|
53
|
+
const build = await handleAssetsManifest_getBuildConfig(config);
|
|
54
|
+
return { build };
|
|
55
|
+
},
|
|
56
|
+
},
|
|
50
57
|
buildStart() {
|
|
51
58
|
onSetupBuild();
|
|
52
59
|
},
|
|
@@ -59,7 +66,7 @@ async function getEntries(config) {
|
|
|
59
66
|
// TO-DO/next-major-release: remove
|
|
60
67
|
const pageFileEntries = await getPageFileEntries(config, resolveIncludeAssetsImportedByServer(vikeConfig.config));
|
|
61
68
|
assertUsage(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
62
|
-
if (
|
|
69
|
+
if (isViteServerBuild_withoutEnv(config)) {
|
|
63
70
|
const pageEntries = getPageEntries(pageConfigs);
|
|
64
71
|
const entries = {
|
|
65
72
|
...pageFileEntries,
|
|
@@ -132,7 +139,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
132
139
|
// Ensure Rollup creates entries for each page file, see https://github.com/vikejs/vike/issues/350
|
|
133
140
|
// (Otherwise the page files may be missing in the client manifest.json)
|
|
134
141
|
async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
135
|
-
const isForClientSide = !
|
|
142
|
+
const isForClientSide = !isViteServerBuild_withoutEnv(config);
|
|
136
143
|
const fileTypes = isForClientSide ? ['.page', '.page.client'] : ['.page', '.page.server'];
|
|
137
144
|
if (isForClientSide && includeAssetsImportedByServer) {
|
|
138
145
|
fileTypes.push('.page.server');
|
|
@@ -176,7 +183,7 @@ function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
|
176
183
|
}
|
|
177
184
|
function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
178
185
|
let { pageId } = pageConfig;
|
|
179
|
-
const entryTarget =
|
|
186
|
+
const entryTarget = generateVirtualFileId({ type: 'page-entry', pageId, isForClientSide });
|
|
180
187
|
let entryName = pageId;
|
|
181
188
|
// Avoid:
|
|
182
189
|
// ```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginBuildEntry };
|
|
2
2
|
export { set_macro_ASSETS_MANIFEST };
|
|
3
3
|
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
|
-
import {
|
|
4
|
+
import { virtualFileIdGlobalEntryServer } from '../../../shared/virtualFileId.js';
|
|
5
5
|
import { assert, PROJECT_VERSION, requireResolveVikeDistFile } from '../../utils.js';
|
|
6
6
|
import fs from 'node:fs/promises';
|
|
7
7
|
import path from 'node:path';
|
|
@@ -40,14 +40,14 @@ function getServerProductionEntryCode(config) {
|
|
|
40
40
|
// After the old design is removed, let's maybe simplify and move everything into a single virtual module
|
|
41
41
|
const importerCode = [
|
|
42
42
|
` import { setGlobalContext_buildEntry } from '${importPath}';`,
|
|
43
|
-
` import * as
|
|
43
|
+
` import * as virtualFileExportsGlobalEntry from '${virtualFileIdGlobalEntryServer}';`,
|
|
44
44
|
` {`,
|
|
45
45
|
// Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to setGlobalContext_buildEntry()
|
|
46
46
|
// - This workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
47
47
|
` const assetsManifest = ${ASSETS_MANIFEST};`,
|
|
48
48
|
` const buildInfo = ${JSON.stringify(buildInfo, null, 2)};`,
|
|
49
49
|
' setGlobalContext_buildEntry({',
|
|
50
|
-
`
|
|
50
|
+
` virtualFileExportsGlobalEntry,`,
|
|
51
51
|
` assetsManifest,`,
|
|
52
52
|
` buildInfo,`,
|
|
53
53
|
' });',
|
|
@@ -97,7 +97,7 @@ function getImportPath(config) {
|
|
|
97
97
|
return 'vike/__internal';
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
|
-
const { outDirServer } = getOutDirs(config);
|
|
100
|
+
const { outDirServer } = getOutDirs(config, undefined);
|
|
101
101
|
const filePathRelative = path.posix.relative(outDirServer, filePathAbsolute);
|
|
102
102
|
return filePathRelative;
|
|
103
103
|
}
|
|
@@ -101,6 +101,7 @@ function getIdHash(id) {
|
|
|
101
101
|
return crypto.createHash('md5').update(id).digest('hex').slice(0, 8);
|
|
102
102
|
}
|
|
103
103
|
function getAssetFileName(assetInfo, config) {
|
|
104
|
+
const userRootDir = config.root;
|
|
104
105
|
const assetsDir = getAssetsDir(config);
|
|
105
106
|
const dir = assetsDir + '/static';
|
|
106
107
|
let { name } = assetInfo;
|
|
@@ -118,11 +119,11 @@ function getAssetFileName(assetInfo, config) {
|
|
|
118
119
|
// Vite 3
|
|
119
120
|
name?.endsWith('?extractAssets&lang.css')) {
|
|
120
121
|
name = name.split('.').slice(0, -2).join('.');
|
|
121
|
-
name = clean(name);
|
|
122
|
+
name = clean(name, userRootDir);
|
|
122
123
|
return `${dir}/${name}.[hash][extname]`;
|
|
123
124
|
}
|
|
124
125
|
name = name.split('.').slice(0, -1).join('.');
|
|
125
|
-
name = clean(name);
|
|
126
|
+
name = clean(name, userRootDir);
|
|
126
127
|
return `${dir}/${name}.[hash][extname]`;
|
|
127
128
|
}
|
|
128
129
|
function getChunkFileName(_chunkInfo, config) {
|
|
@@ -135,11 +136,12 @@ function getChunkFileName(_chunkInfo, config) {
|
|
|
135
136
|
return name;
|
|
136
137
|
}
|
|
137
138
|
function getEntryFileName(chunkInfo, config, isEntry) {
|
|
139
|
+
const userRootDir = config.root;
|
|
138
140
|
const assetsDir = getAssetsDir(config);
|
|
139
141
|
const isForClientSide = !config.build.ssr;
|
|
140
142
|
let { name } = chunkInfo;
|
|
141
143
|
assertPosixPath(name);
|
|
142
|
-
name = clean(name, true,
|
|
144
|
+
name = clean(name, userRootDir, true,
|
|
143
145
|
// Not needed for client-side because dist/ filenames contain `.[hash].js`
|
|
144
146
|
!isForClientSide);
|
|
145
147
|
if (isForClientSide) {
|
|
@@ -151,7 +153,7 @@ function getEntryFileName(chunkInfo, config, isEntry) {
|
|
|
151
153
|
}
|
|
152
154
|
function removePathSeparators(name) {
|
|
153
155
|
assertPosixPath(name);
|
|
154
|
-
assert(!name.startsWith('/'));
|
|
156
|
+
assert(!name.startsWith('/'), { name });
|
|
155
157
|
const entryDir = 'entries/';
|
|
156
158
|
const hasEntryDir = name.startsWith(entryDir);
|
|
157
159
|
if (hasEntryDir) {
|
|
@@ -164,7 +166,17 @@ function removePathSeparators(name) {
|
|
|
164
166
|
}
|
|
165
167
|
return name;
|
|
166
168
|
}
|
|
167
|
-
function
|
|
169
|
+
function removeUserRootDir(name, userRootDir) {
|
|
170
|
+
if (name.startsWith(userRootDir)) {
|
|
171
|
+
name = name.slice(userRootDir.length);
|
|
172
|
+
if (name.startsWith('/'))
|
|
173
|
+
name = name.slice(1);
|
|
174
|
+
}
|
|
175
|
+
assert(!name.startsWith('/'), { name });
|
|
176
|
+
return name;
|
|
177
|
+
}
|
|
178
|
+
function clean(name, userRootDir, removePathSep, fixGlob) {
|
|
179
|
+
name = removeUserRootDir(name, userRootDir);
|
|
168
180
|
name = fixExtractAssetsQuery(name);
|
|
169
181
|
if (fixGlob) {
|
|
170
182
|
name = workaroundGlob(name);
|
|
@@ -18,7 +18,7 @@ function pluginDistPackageJsonFile() {
|
|
|
18
18
|
config = config_;
|
|
19
19
|
},
|
|
20
20
|
generateBundle(options, bundle) {
|
|
21
|
-
if (!isViteServerBuild(config))
|
|
21
|
+
if (!isViteServerBuild(config, this.environment))
|
|
22
22
|
return;
|
|
23
23
|
const isEsm = rollupIsEsm(options);
|
|
24
24
|
const fileName = 'package.json';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginModuleBanner };
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { removeVirtualFileIdPrefix } from '../../utils.js';
|
|
3
|
+
import { getMagicString } from '../../shared/getMagicString.js';
|
|
4
|
+
import { isViteServerBuild_extraSafe } from '../../shared/isViteServerBuild.js';
|
|
5
5
|
// Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
|
|
6
6
|
// But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
|
|
7
7
|
function pluginModuleBanner() {
|
|
@@ -16,26 +16,23 @@ function pluginModuleBanner() {
|
|
|
16
16
|
transform: {
|
|
17
17
|
order: 'post',
|
|
18
18
|
handler(code, id, options) {
|
|
19
|
-
if (!
|
|
19
|
+
if (!isViteServerBuild_extraSafe(config, options, this.environment) &&
|
|
20
20
|
// Inject module banners if user sets `build.minify` to `false` for inspecting dist/client/
|
|
21
21
|
config.build.minify) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
if (id.startsWith('\0'))
|
|
25
25
|
id = id;
|
|
26
|
-
id =
|
|
26
|
+
id = removeVirtualFileIdPrefix(id);
|
|
27
27
|
if (id.startsWith(config.root))
|
|
28
28
|
id = id.slice(config.root.length + 1);
|
|
29
29
|
id = id.replaceAll('*/', '*\\/'); // https://github.com/vikejs/vike/issues/2377
|
|
30
|
-
const magicString =
|
|
30
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
31
31
|
// Use legal comment so that esbuild doesn't remove it.
|
|
32
32
|
// - Terser still removes the comment, but I guess users use terser to minify JavaScript so I guess it's a good thing that comment is removed.
|
|
33
33
|
// - https://esbuild.github.io/api/#legal-comments
|
|
34
34
|
magicString.prepend(`/*! ${id} [vike:pluginModuleBanner] */\n`);
|
|
35
|
-
return
|
|
36
|
-
code: magicString.toString(),
|
|
37
|
-
map: magicString.generateMap({ hires: true, source: id }),
|
|
38
|
-
};
|
|
35
|
+
return getMagicStringResult();
|
|
39
36
|
},
|
|
40
37
|
},
|
|
41
38
|
};
|
|
@@ -11,6 +11,7 @@ import { getVikeConfigInternal, setVikeConfigContext } from '../shared/resolveVi
|
|
|
11
11
|
import { assertViteRoot, getViteRoot, normalizeViteRoot } from '../../api/prepareViteApiCall.js';
|
|
12
12
|
import { temp_disablePrerenderAutoRun } from '../../prerender/context.js';
|
|
13
13
|
const pluginName = 'vike:pluginCommon';
|
|
14
|
+
globalThis.__VIKE__IS_PROCESS_SHARED_WITH_VITE = true;
|
|
14
15
|
function pluginCommon(vikeVitePluginOptions) {
|
|
15
16
|
return [
|
|
16
17
|
{
|