vike 0.4.237 → 0.4.238
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 +3 -3
- 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/runtime-server-routing/utils.js +1 -1
- package/dist/cjs/client/shared/createGetGlobalContextClient.js +5 -5
- package/dist/cjs/node/api/build.js +5 -31
- package/dist/cjs/node/api/context.js +13 -12
- package/dist/cjs/node/api/dev.js +0 -2
- package/dist/cjs/node/api/index.js +0 -2
- package/dist/cjs/node/api/onLoad.js +2 -2
- package/dist/cjs/node/api/prepareViteApiCall.js +2 -3
- package/dist/cjs/node/api/preview.js +2 -3
- package/dist/cjs/node/api/utils.js +1 -0
- package/dist/cjs/node/cli/index.js +2 -2
- package/dist/cjs/node/cli/onLoad.js +2 -2
- package/dist/cjs/node/prerender/runPrerender.js +7 -8
- package/dist/cjs/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +128 -112
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +6 -4
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +1 -11
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsDev.js → retrievePageAssetsDev.js} +21 -6
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsProd.js → retrievePageAssetsProd.js} +19 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +5 -34
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +42 -46
- package/dist/cjs/node/runtime/renderPage/{renderPageAlreadyRouted.js → renderPageAfterRoute.js} +3 -4
- package/dist/cjs/node/runtime/renderPage.js +18 -16
- package/dist/cjs/node/runtime/utils.js +3 -2
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -2
- package/dist/cjs/node/shared/virtualFileId.js +110 -0
- package/dist/cjs/node/vite/index.js +3 -3
- package/dist/cjs/node/vite/onLoad.js +5 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +29 -30
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +122 -10
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +12 -17
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +2 -10
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +5 -11
- package/dist/cjs/node/vite/plugins/pluginBuild/{pluginBuildEntry.js → pluginProdBuildEntry.js} +11 -11
- package/dist/cjs/node/vite/plugins/pluginBuild.js +2 -4
- package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +6 -5
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +6 -13
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +7 -7
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +6 -2
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +4 -3
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +11 -11
- package/dist/cjs/node/vite/plugins/pluginPreview.js +4 -7
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +6 -13
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +5 -6
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFileEntry.js → generateVirtualFileGlobalEntryWithOldDesign.js} +12 -12
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigLazy.js → generateVirtualFilePageEntry.js} +10 -11
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +51 -21
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +14 -12
- package/dist/cjs/node/vite/shared/findPageFiles.js +1 -1
- package/dist/cjs/node/vite/shared/{resolveClientEntriesDev.js → getClientEntrySrcDev.js} +3 -3
- package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +8 -6
- package/dist/cjs/node/vite/shared/getMagicString.js +1 -1
- package/dist/cjs/node/vite/shared/getOutDirs.js +21 -22
- package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +1 -1
- package/dist/cjs/node/vite/shared/isViteServerSide.js +68 -0
- package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +6 -4
- package/dist/cjs/node/vite/shared/loggerVite.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +20 -36
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +5 -4
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +46 -48
- package/dist/cjs/shared/createGlobalContextShared.js +16 -14
- package/dist/cjs/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -26
- package/dist/cjs/shared/page-configs/loadAndParseVirtualFilePageEntry.js +25 -0
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +9 -4
- package/dist/cjs/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js} +2 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +3 -3
- package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -1
- package/dist/cjs/shared/route/index.js +0 -1
- package/dist/cjs/types/VikeGlobalInternal.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +2 -3
- package/dist/cjs/utils/assertVersion.js +2 -0
- package/dist/cjs/utils/debug.js +4 -4
- package/dist/cjs/utils/getGlobalObject.js +8 -15
- package/dist/cjs/utils/isNonRunnableDev.js +12 -0
- package/dist/cjs/utils/isScriptFile.js +1 -1
- package/dist/cjs/utils/path.js +5 -5
- package/dist/cjs/utils/requireResolve.js +13 -12
- package/dist/cjs/utils/{augmentType.js → updateType.js} +3 -3
- package/dist/esm/__internal/index.d.ts +2 -2
- package/dist/esm/__internal/index.js +3 -3
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +12 -12
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/globalContext.js +2 -2
- 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 +6 -7
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +6 -6
- package/dist/esm/client/runtime-client-routing/utils.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/utils.js +1 -1
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +3 -3
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +3 -3
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +2 -2
- 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/runtime-server-routing/utils.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/utils.js +1 -1
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +3 -3
- package/dist/esm/client/shared/createGetGlobalContextClient.js +5 -5
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
- 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/node/api/build.d.ts +2 -2
- package/dist/esm/node/api/build.js +6 -32
- package/dist/esm/node/api/context.d.ts +10 -10
- package/dist/esm/node/api/context.js +13 -12
- package/dist/esm/node/api/dev.d.ts +2 -2
- package/dist/esm/node/api/dev.js +0 -2
- package/dist/esm/node/api/index.js +0 -2
- package/dist/esm/node/api/onLoad.js +1 -1
- package/dist/esm/node/api/prepareViteApiCall.d.ts +3 -5
- package/dist/esm/node/api/prepareViteApiCall.js +3 -4
- package/dist/esm/node/api/preview.d.ts +2 -2
- package/dist/esm/node/api/preview.js +2 -3
- package/dist/esm/node/api/types.d.ts +4 -4
- package/dist/esm/node/api/utils.d.ts +1 -0
- package/dist/esm/node/api/utils.js +1 -0
- package/dist/esm/node/cli/index.js +1 -1
- package/dist/esm/node/cli/onLoad.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +13 -304
- package/dist/esm/node/prerender/runPrerender.js +8 -9
- package/dist/esm/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +13 -13
- package/dist/esm/node/runtime/globalContext.js +125 -109
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +4 -3
- package/dist/esm/node/runtime/renderPage/analyzePage.js +6 -4
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.d.ts +0 -1
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.js +1 -11
- 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 -7
- 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 +2 -10
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +4 -33
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +106 -20
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +44 -48
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.d.ts → renderPageAfterRoute.d.ts} +26 -10
- package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.js → renderPageAfterRoute.js} +5 -6
- package/dist/esm/node/runtime/renderPage.d.ts +9 -6
- package/dist/esm/node/runtime/renderPage.js +20 -18
- package/dist/esm/node/runtime/utils.d.ts +3 -2
- package/dist/esm/node/runtime/utils.js +3 -2
- package/dist/esm/node/runtime-dev/createDevMiddleware.d.ts +2 -2
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +0 -2
- 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 +3 -3
- package/dist/esm/node/vite/onLoad.js +5 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +5 -6
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +31 -32
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +119 -10
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +12 -17
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +2 -10
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +5 -8
- package/dist/esm/node/vite/plugins/pluginBuild/{pluginBuildEntry.d.ts → pluginProdBuildEntry.d.ts} +2 -2
- package/dist/esm/node/vite/plugins/pluginBuild/{pluginBuildEntry.js → pluginProdBuildEntry.js} +12 -12
- package/dist/esm/node/vite/plugins/pluginBuild.js +2 -4
- package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +3 -3
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +6 -5
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +6 -10
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +5 -5
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +6 -2
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +4 -3
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +12 -12
- package/dist/esm/node/vite/plugins/pluginPreview.js +5 -8
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +6 -10
- package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.d.ts +2 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +5 -6
- 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 +2 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigLazy.js → generateVirtualFilePageEntry.js} +10 -11
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.d.ts +5 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +52 -22
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +14 -12
- 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} +4 -4
- package/dist/esm/node/vite/shared/getHttpRequestAsyncStore.js +9 -7
- package/dist/esm/node/vite/shared/getMagicString.js +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +4 -3
- package/dist/esm/node/vite/shared/getOutDirs.js +21 -22
- package/dist/esm/node/vite/shared/getViteConfigRuntime.js +1 -1
- package/dist/esm/node/vite/shared/isViteServerSide.d.ts +18 -0
- package/dist/esm/node/vite/shared/isViteServerSide.js +66 -0
- package/dist/esm/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +7 -5
- package/dist/esm/node/vite/shared/loggerVite.js +1 -1
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.d.ts +3 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +21 -37
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +6 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +4 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +49 -51
- package/dist/esm/shared/createGlobalContextShared.d.ts +7 -6
- package/dist/esm/shared/createGlobalContextShared.js +18 -16
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.d.ts → parseVirtualFileExportsGlobalEntry.d.ts} +2 -2
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -26
- 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/page-configs/loadAndParseVirtualFilePageEntry.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadAndParseVirtualFilePageEntry.js +23 -0
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +9 -9
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +9 -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.js +3 -3
- package/dist/esm/shared/route/execHookOnBeforeRoute.d.ts +3 -3
- package/dist/esm/shared/route/execHookOnBeforeRoute.js +0 -1
- package/dist/esm/shared/route/index.d.ts +5 -6
- package/dist/esm/shared/route/index.js +0 -1
- package/dist/esm/types/Config.d.ts +3 -7
- package/dist/esm/types/PageConfig.d.ts +11 -9
- package/dist/esm/types/VikeGlobalInternal.d.ts +4 -0
- package/dist/esm/types/VikeGlobalInternal.js +1 -0
- package/dist/esm/types/VikeNamespace.d.ts +13 -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 +2 -3
- package/dist/esm/utils/assertVersion.js +2 -0
- package/dist/esm/utils/debug.js +3 -3
- package/dist/esm/utils/getGlobalObject.d.ts +6 -5
- package/dist/esm/utils/getGlobalObject.js +8 -15
- package/dist/esm/utils/isNonRunnableDev.d.ts +2 -0
- package/dist/esm/utils/isNonRunnableDev.js +10 -0
- package/dist/esm/utils/isScriptFile.d.ts +1 -1
- package/dist/esm/utils/isScriptFile.js +1 -1
- package/dist/esm/utils/path.d.ts +2 -0
- package/dist/esm/utils/path.js +5 -5
- package/dist/esm/utils/requireResolve.d.ts +4 -4
- package/dist/esm/utils/requireResolve.js +13 -12
- package/dist/esm/utils/updateType.d.ts +3 -0
- package/dist/esm/utils/updateType.js +7 -0
- package/package.json +6 -6
- package/dist/cjs/node/runtime/renderPage/debugPageFiles.js +0 -52
- package/dist/cjs/node/shared/virtualFiles/virtualFileEntry.js +0 -31
- package/dist/cjs/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -45
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +0 -149
- package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +0 -11
- package/dist/cjs/node/vite/shared/isViteServerBuild.js +0 -47
- package/dist/cjs/shared/page-configs/loadConfigValues.js +0 -21
- package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +0 -23
- package/dist/esm/node/runtime/renderPage/debugPageFiles.js +0 -47
- 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 -28
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.d.ts +0 -9
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -43
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.d.ts +0 -5
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +0 -144
- 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/shared/applyRegExWithMagicString.d.ts +0 -3
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.js +0 -9
- package/dist/esm/node/vite/shared/isViteServerBuild.d.ts +0 -15
- package/dist/esm/node/vite/shared/isViteServerBuild.js +0 -45
- 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
- package/dist/esm/utils/augmentType.d.ts +0 -3
- package/dist/esm/utils/augmentType.js +0 -7
- /package/dist/cjs/utils/{getTerminWidth.js → getTerminalWidth.js} +0 -0
- /package/dist/esm/utils/{getTerminWidth.d.ts → getTerminalWidth.d.ts} +0 -0
- /package/dist/esm/utils/{getTerminWidth.js → getTerminalWidth.js} +0 -0
|
@@ -10,8 +10,8 @@ export { initGlobalContext_getPagesAndRoutes };
|
|
|
10
10
|
export { setGlobalContext_viteDevServer };
|
|
11
11
|
export { setGlobalContext_viteConfig };
|
|
12
12
|
export { setGlobalContext_isPrerendering };
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
13
|
+
export { setGlobalContext_isProductionAccordingToVite };
|
|
14
|
+
export { setGlobalContext_prodBuildEntry };
|
|
15
15
|
export { clearGlobalContext };
|
|
16
16
|
export { assertBuildInfo };
|
|
17
17
|
export { updateUserFiles };
|
|
@@ -32,7 +32,7 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
32
32
|
globalContext: (Record<string, unknown> & {
|
|
33
33
|
isGlobalContext: true;
|
|
34
34
|
_isOriginalObject: true;
|
|
35
|
-
|
|
35
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
36
36
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
37
37
|
_pageConfigs: import("../../types/PageConfig.js").PageConfigRuntime[];
|
|
38
38
|
_pageConfigGlobal: import("../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -45,7 +45,7 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
45
45
|
};
|
|
46
46
|
config: import("../../types/index.js").ConfigResolved;
|
|
47
47
|
pages: {
|
|
48
|
-
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").
|
|
48
|
+
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
49
49
|
};
|
|
50
50
|
} & {
|
|
51
51
|
_isProduction: false;
|
|
@@ -72,7 +72,7 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
72
72
|
}) | (Record<string, unknown> & {
|
|
73
73
|
isGlobalContext: true;
|
|
74
74
|
_isOriginalObject: true;
|
|
75
|
-
|
|
75
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
76
76
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
77
77
|
_pageConfigs: import("../../types/PageConfig.js").PageConfigRuntime[];
|
|
78
78
|
_pageConfigGlobal: import("../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -85,7 +85,7 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
85
85
|
};
|
|
86
86
|
config: import("../../types/index.js").ConfigResolved;
|
|
87
87
|
pages: {
|
|
88
|
-
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").
|
|
88
|
+
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
89
89
|
};
|
|
90
90
|
} & {
|
|
91
91
|
_isPrerendering: true;
|
|
@@ -113,7 +113,7 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
113
113
|
}) | (Record<string, unknown> & {
|
|
114
114
|
isGlobalContext: true;
|
|
115
115
|
_isOriginalObject: true;
|
|
116
|
-
|
|
116
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
117
117
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
118
118
|
_pageConfigs: import("../../types/PageConfig.js").PageConfigRuntime[];
|
|
119
119
|
_pageConfigGlobal: import("../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -126,7 +126,7 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
126
126
|
};
|
|
127
127
|
config: import("../../types/index.js").ConfigResolved;
|
|
128
128
|
pages: {
|
|
129
|
-
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").
|
|
129
|
+
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
130
130
|
};
|
|
131
131
|
} & {
|
|
132
132
|
_isPrerendering: false;
|
|
@@ -174,13 +174,13 @@ declare function getGlobalContextSync(): GlobalContext;
|
|
|
174
174
|
declare function setGlobalContext_viteDevServer(viteDevServer: ViteDevServer): Promise<void>;
|
|
175
175
|
declare function setGlobalContext_viteConfig(viteConfig: ResolvedConfig, viteConfigRuntime: ViteConfigRuntime): void;
|
|
176
176
|
declare function setGlobalContext_isPrerendering(): void;
|
|
177
|
-
declare function
|
|
177
|
+
declare function setGlobalContext_isProductionAccordingToVite(isProductionAccordingToVite: boolean): void;
|
|
178
178
|
declare function getViteDevServer(): ViteDevServer | null;
|
|
179
179
|
declare function getViteConfig(): ResolvedConfig | null;
|
|
180
180
|
declare function initGlobalContext_renderPage(): Promise<void>;
|
|
181
181
|
declare function initGlobalContext_runPrerender(): Promise<void>;
|
|
182
182
|
declare function initGlobalContext_getPagesAndRoutes(): Promise<void>;
|
|
183
|
-
declare function
|
|
183
|
+
declare function setGlobalContext_prodBuildEntry(prodBuildEntry: unknown): Promise<void>;
|
|
184
184
|
type BuildInfo = {
|
|
185
185
|
versionAtBuildTime: string;
|
|
186
186
|
usesClientRouter: boolean;
|
|
@@ -190,10 +190,10 @@ declare function assertBuildInfo(buildInfo: unknown): asserts buildInfo is Build
|
|
|
190
190
|
declare function updateUserFiles(): Promise<{
|
|
191
191
|
success: boolean;
|
|
192
192
|
}>;
|
|
193
|
-
declare function createGlobalContext(
|
|
193
|
+
declare function createGlobalContext(virtualFileExportsGlobalEntry: unknown): Promise<{
|
|
194
194
|
isGlobalContext: true;
|
|
195
195
|
_isOriginalObject: true;
|
|
196
|
-
|
|
196
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
197
197
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
198
198
|
_pageConfigs: import("../../types/PageConfig.js").PageConfigRuntime[];
|
|
199
199
|
_pageConfigGlobal: import("../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -206,7 +206,7 @@ declare function createGlobalContext(virtualFileExports: unknown): Promise<{
|
|
|
206
206
|
};
|
|
207
207
|
config: import("../../types/index.js").ConfigResolved;
|
|
208
208
|
pages: {
|
|
209
|
-
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").
|
|
209
|
+
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
210
210
|
};
|
|
211
211
|
} & (({
|
|
212
212
|
_isProduction: false;
|
|
@@ -12,29 +12,23 @@ export { initGlobalContext_getPagesAndRoutes };
|
|
|
12
12
|
export { setGlobalContext_viteDevServer };
|
|
13
13
|
export { setGlobalContext_viteConfig };
|
|
14
14
|
export { setGlobalContext_isPrerendering };
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
15
|
+
export { setGlobalContext_isProductionAccordingToVite };
|
|
16
|
+
export { setGlobalContext_prodBuildEntry }; // production entry
|
|
17
17
|
export { clearGlobalContext };
|
|
18
18
|
export { assertBuildInfo };
|
|
19
19
|
export { updateUserFiles };
|
|
20
20
|
export { vikeConfigErrorRecoverMsg };
|
|
21
|
-
// TODO/now: use isProductionEnvironment() instead of globalObject.isProduction
|
|
22
|
-
// TODO/now: rename:
|
|
23
|
-
// - isProduction => isProductionEnvironment
|
|
24
|
-
// - setIsProduction => setIsProductionEnvironment
|
|
25
|
-
// - setGlobalContext_isProduction => setGlobalContext_isProductionEnvironment
|
|
26
|
-
// - sProductionEnvironment => sDevEnv
|
|
27
21
|
// The core logic revolves around:
|
|
28
|
-
// -
|
|
29
|
-
// - In production: globalObject.
|
|
30
|
-
// -
|
|
31
|
-
// - With vike-server it's set at server start: @brillout/vite-plugin-server-entry injects `import './entry.mjs'` (the production entry generated by @brillout/vite-plugin-server-entry) as first line of code of dist/server/index.mjs while dist/server/entry.mjs calls
|
|
22
|
+
// - virtualFileExportsGlobalEntry is the main requirement
|
|
23
|
+
// - In production: globalObject.prodBuildEntry which is the production entry set by @brillout/vite-plugin-server-entry
|
|
24
|
+
// - loadProdBuildEntry() sets globalObject.prodBuildEntry and then sets virtualFileExportsGlobalEntry
|
|
25
|
+
// - With vike-server it's set at server start: @brillout/vite-plugin-server-entry injects `import './entry.mjs'` (the production entry generated by @brillout/vite-plugin-server-entry) as first line of code of dist/server/index.mjs while dist/server/entry.mjs calls setGlobalContext_prodBuildEntry()
|
|
32
26
|
// - Without vike-server it's manually loaded here using importServerProductionEntry() which uses @brillout/vite-plugin-server-entry's autoImporter or crawler
|
|
33
27
|
// - In development: globalObject.viteDevServer which is Vite's development server
|
|
34
|
-
// - globalObject.viteDevServer is used by updateUserFiles() which then sets
|
|
35
|
-
import { assert, onSetupRuntime, assertUsage, assertWarning, isPlainObject, objectReplace, isObject, hasProp, getGlobalObject, genPromise, createDebugger, checkType, PROJECT_VERSION, getViteRPC, isRunnableDevEnvironment, assertIsNotBrowser, } from './utils.js';
|
|
28
|
+
// - globalObject.viteDevServer is used by updateUserFiles() which then sets virtualFileExportsGlobalEntry
|
|
29
|
+
import { assert, onSetupRuntime, assertUsage, assertWarning, isPlainObject, objectReplace, isObject, hasProp, getGlobalObject, genPromise, createDebugger, checkType, PROJECT_VERSION, getViteRPC, isRunnableDevEnvironment, assertIsNotBrowser, isNonRunnableDev, } from './utils.js';
|
|
36
30
|
import { importServerProductionEntry } from '@brillout/vite-plugin-server-entry/runtime';
|
|
37
|
-
import {
|
|
31
|
+
import { virtualFileIdGlobalEntryServer } from '../shared/virtualFileId.js';
|
|
38
32
|
import pc from '@brillout/picocolors';
|
|
39
33
|
import { loadPageRoutes, loadPageRoutesSync } from '../../shared/route/loadPageRoutes.js';
|
|
40
34
|
import { assertV1Design } from '../shared/assertV1Design.js';
|
|
@@ -44,6 +38,7 @@ import { prepareGlobalContextForPublicUsage } from '../../shared/prepareGlobalCo
|
|
|
44
38
|
import { logRuntimeError, logRuntimeInfo } from './loggerRuntime.js';
|
|
45
39
|
import { getVikeConfigErrorBuild, setVikeConfigError } from '../shared/getVikeConfigError.js';
|
|
46
40
|
import { hasAlreadyLogged } from './renderPage/isNewError.js';
|
|
41
|
+
import { getVikeApiOperation } from '../api/context.js';
|
|
47
42
|
const debug = createDebugger('vike:globalContext');
|
|
48
43
|
const globalObject = getGlobalObject('runtime/globalContext.ts', getInitialGlobalObject());
|
|
49
44
|
// Trick to break down TypeScript circular dependency
|
|
@@ -55,7 +50,7 @@ async function getGlobalContextServerInternal() {
|
|
|
55
50
|
// getGlobalContextServerInternal() should always be called after initGlobalContext()
|
|
56
51
|
assert(globalObject.isInitialized);
|
|
57
52
|
assertGlobalContextIsDefined();
|
|
58
|
-
if (
|
|
53
|
+
if (!isProd())
|
|
59
54
|
await globalObject.waitForUserFilesUpdate;
|
|
60
55
|
const { globalContext } = globalObjectTyped;
|
|
61
56
|
assertIsDefined(globalContext);
|
|
@@ -80,10 +75,9 @@ function assertGlobalContextIsDefined() {
|
|
|
80
75
|
*/
|
|
81
76
|
async function getGlobalContext() {
|
|
82
77
|
debug('getGlobalContext()');
|
|
83
|
-
const
|
|
78
|
+
const isProduction = isProdOptional();
|
|
84
79
|
// This assertion cannot fail for vike-server users (because when using vike-server it's guaranteed that globalObject.isProduction is set before executing any user-land code and any Vike extension code).
|
|
85
|
-
assertUsage(isProduction !==
|
|
86
|
-
assert(typeof globalObject.isProduction === 'boolean');
|
|
80
|
+
assertUsage(isProduction !== null, "The global context isn't set yet, use getGlobalContextAsync() instead.");
|
|
87
81
|
return await getGlobalContextAsync(isProduction);
|
|
88
82
|
}
|
|
89
83
|
/**
|
|
@@ -94,7 +88,7 @@ async function getGlobalContext() {
|
|
|
94
88
|
async function getGlobalContextAsync(isProduction) {
|
|
95
89
|
debug('getGlobalContextAsync()');
|
|
96
90
|
assertUsage(typeof isProduction === 'boolean', `[getGlobalContextAsync(isProduction)] Argument ${pc.cyan('isProduction')} ${isProduction === undefined ? 'is missing' : `should be ${pc.cyan('true')} or ${pc.cyan('false')}`}`);
|
|
97
|
-
|
|
91
|
+
globalObject.isProductionAccordingToUser = isProduction;
|
|
98
92
|
if (!globalObject.globalContext)
|
|
99
93
|
await initGlobalContext_getGlobalContextAsync();
|
|
100
94
|
if (!isProduction)
|
|
@@ -111,9 +105,7 @@ function getGlobalContextSync() {
|
|
|
111
105
|
debug('getGlobalContextSync()');
|
|
112
106
|
const { globalContext } = globalObjectTyped;
|
|
113
107
|
assertUsage(globalContext, getGlobalContextSyncErrMsg);
|
|
114
|
-
|
|
115
|
-
assert(typeof isProd === 'boolean');
|
|
116
|
-
assertWarning(isProd,
|
|
108
|
+
assertWarning(isProd(),
|
|
117
109
|
// - We discourage users from using it in development because `pageContext.globalContext` is safer: I ain't sure but there could be race conditions when using `getGlobalContextSync()` inside React/Vue components upon HMR.
|
|
118
110
|
// - I don't see any issues with getGlobalContextSync() in production.
|
|
119
111
|
// - getGlobalContextSync() is used in production by vike-vercel
|
|
@@ -129,7 +121,6 @@ function getGlobalContextForPublicUsage() {
|
|
|
129
121
|
}
|
|
130
122
|
async function setGlobalContext_viteDevServer(viteDevServer) {
|
|
131
123
|
debug('setGlobalContext_viteDevServer()');
|
|
132
|
-
setIsProduction(false);
|
|
133
124
|
// We cannot cache globalObject.viteDevServer because it's fully replaced when the user modifies vite.config.js => Vite's dev server is fully reloaded and a new viteDevServer replaces the previous one.
|
|
134
125
|
if (!globalObject.viteDevServer) {
|
|
135
126
|
assertIsNotInitializedYet();
|
|
@@ -157,18 +148,9 @@ function assertIsNotInitializedYet() {
|
|
|
157
148
|
}
|
|
158
149
|
function setGlobalContext_isPrerendering() {
|
|
159
150
|
globalObject.isPrerendering = true;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
function setGlobalContext_isProduction(isProduction, tolerateContraditction = false) {
|
|
164
|
-
if (debug.isActivated)
|
|
165
|
-
debug('setGlobalContext_isProduction()', { isProduction, tolerateContraditction });
|
|
166
|
-
if (globalObject.isProduction === undefined) {
|
|
167
|
-
setIsProduction(isProduction);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
assert(globalObject.isProduction === isProduction || tolerateContraditction);
|
|
171
|
-
}
|
|
151
|
+
}
|
|
152
|
+
function setGlobalContext_isProductionAccordingToVite(isProductionAccordingToVite) {
|
|
153
|
+
globalObject.isProductionAccordingToVite = isProductionAccordingToVite;
|
|
172
154
|
}
|
|
173
155
|
function getViteDevServer() {
|
|
174
156
|
return globalObject.viteDevServer ?? null;
|
|
@@ -178,15 +160,13 @@ function getViteConfig() {
|
|
|
178
160
|
}
|
|
179
161
|
async function initGlobalContext_renderPage() {
|
|
180
162
|
debug('initGlobalContext_renderPage()');
|
|
181
|
-
|
|
182
|
-
if (globalObject.isProduction === undefined)
|
|
183
|
-
setIsProduction(true);
|
|
163
|
+
globalObject.isAfterFirstRenderPageCall = true;
|
|
184
164
|
await initGlobalContext();
|
|
185
165
|
}
|
|
186
166
|
async function initGlobalContext_runPrerender() {
|
|
187
167
|
debug('initGlobalContext_runPrerender()');
|
|
188
168
|
assert(globalObject.isPrerendering === true);
|
|
189
|
-
assert(
|
|
169
|
+
assert(isProd());
|
|
190
170
|
if (globalObject.initGlobalContext_runPrerender_alreadyCalled)
|
|
191
171
|
return;
|
|
192
172
|
globalObject.initGlobalContext_runPrerender_alreadyCalled = true;
|
|
@@ -204,12 +184,11 @@ async function initGlobalContext_getGlobalContextAsync() {
|
|
|
204
184
|
}
|
|
205
185
|
async function initGlobalContext_getPagesAndRoutes() {
|
|
206
186
|
debug('initGlobalContext_getPagesAndRoutes()');
|
|
207
|
-
|
|
187
|
+
globalObject.isProductionAccordingToPhotonVercel = true;
|
|
208
188
|
await initGlobalContext();
|
|
209
189
|
}
|
|
210
190
|
async function initGlobalContext() {
|
|
211
|
-
const
|
|
212
|
-
assert(typeof isProduction === 'boolean');
|
|
191
|
+
const isProduction = isProd();
|
|
213
192
|
if (!isProduction) {
|
|
214
193
|
if (isProcessSharedWithVite()) {
|
|
215
194
|
await globalObject.viteDevServerPromise;
|
|
@@ -222,18 +201,11 @@ async function initGlobalContext() {
|
|
|
222
201
|
await globalObject.waitForUserFilesUpdate;
|
|
223
202
|
}
|
|
224
203
|
else {
|
|
225
|
-
await
|
|
204
|
+
await loadProdBuildEntry(globalObject.viteConfigRuntime?.build.outDir);
|
|
226
205
|
}
|
|
227
206
|
assertGlobalContextIsDefined();
|
|
228
207
|
globalObject.isInitialized = true;
|
|
229
208
|
}
|
|
230
|
-
function setIsProduction(isProduction) {
|
|
231
|
-
debug('setIsProduction', isProduction);
|
|
232
|
-
assert(typeof isProduction === 'boolean');
|
|
233
|
-
if (globalObject.isProduction !== undefined)
|
|
234
|
-
assert(globalObject.isProduction === isProduction);
|
|
235
|
-
globalObject.isProduction = isProduction;
|
|
236
|
-
}
|
|
237
209
|
function assertViteManifest(manifest) {
|
|
238
210
|
assert(isPlainObject(manifest));
|
|
239
211
|
/* We should include these assertions but we don't as a workaround for PWA manifests: https://github.com/vikejs/vike/issues/769
|
|
@@ -247,59 +219,58 @@ function assertViteManifest(manifest) {
|
|
|
247
219
|
})
|
|
248
220
|
*/
|
|
249
221
|
}
|
|
250
|
-
async function
|
|
251
|
-
debug('
|
|
222
|
+
async function loadProdBuildEntry(outDir) {
|
|
223
|
+
debug('loadProdBuildEntry()');
|
|
252
224
|
if (globalObject.globalContext) {
|
|
253
|
-
debug('
|
|
225
|
+
debug('loadProdBuildEntry() - already done');
|
|
254
226
|
return;
|
|
255
227
|
}
|
|
256
|
-
if (!globalObject.
|
|
228
|
+
if (!globalObject.prodBuildEntry) {
|
|
257
229
|
debug('importServerProductionEntry()');
|
|
258
|
-
// importServerProductionEntry() loads dist/server/entry.mjs which calls
|
|
230
|
+
// importServerProductionEntry() loads dist/server/entry.mjs which calls setGlobalContext_prodBuildEntry()
|
|
259
231
|
await importServerProductionEntry({ outDir });
|
|
260
|
-
if (!globalObject.
|
|
261
|
-
debug('globalObject.
|
|
232
|
+
if (!globalObject.prodBuildEntry) {
|
|
233
|
+
debug('globalObject.prodBuildEntryPrevious');
|
|
262
234
|
// Needed, for example, when calling the API prerender() then preview() because both trigger a importServerProductionEntry() call but only the first only is applied because of the import() cache. (A proper implementation would be to clear the import() cache, but it probably isn't possible on platforms such as Cloudflare Workers.)
|
|
263
|
-
globalObject.
|
|
235
|
+
globalObject.prodBuildEntry = globalObject.prodBuildEntryPrevious;
|
|
264
236
|
}
|
|
265
|
-
assert(globalObject.
|
|
266
|
-
// If using `inject` then dist/server/index.js imports dist/server/entry.js and
|
|
237
|
+
assert(globalObject.prodBuildEntry);
|
|
238
|
+
// If using `inject` then dist/server/index.js imports dist/server/entry.js and loadProdBuildEntry() isn't needed.
|
|
267
239
|
// If dist/server/entry.js isn't imported then this means the user is running the original server entry `$ ts-node server/index.ts`.
|
|
268
240
|
assertWarning(
|
|
269
241
|
// vike-server => `inject === true`
|
|
270
242
|
// vike-node => `inject === [ 'index' ]` => we don't show the warning to vike-node users (I don't remember why).
|
|
271
243
|
globalObject.buildInfo?.viteConfigRuntime.vitePluginServerEntry.inject !== true || globalObject.isPrerendering, `Run the built server entry (e.g. ${pc.cyan('$ node dist/server/index.mjs')}) instead of the original server entry (e.g. ${pc.cyan('$ ts-node server/index.ts')})`, { onlyOnce: true });
|
|
272
244
|
}
|
|
273
|
-
const {
|
|
274
|
-
|
|
275
|
-
globalObject.assetsManifest =
|
|
276
|
-
globalObject.buildInfo =
|
|
277
|
-
await createGlobalContext(
|
|
245
|
+
const { prodBuildEntry } = globalObject;
|
|
246
|
+
assertProdBuildEntry(prodBuildEntry);
|
|
247
|
+
globalObject.assetsManifest = prodBuildEntry.assetsManifest;
|
|
248
|
+
globalObject.buildInfo = prodBuildEntry.buildInfo;
|
|
249
|
+
await createGlobalContext(prodBuildEntry.virtualFileExportsGlobalEntry);
|
|
278
250
|
}
|
|
279
251
|
// This is the production entry, see:
|
|
280
|
-
// https://github.com/vikejs/vike/blob/
|
|
281
|
-
async function
|
|
282
|
-
debug('
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
globalObject.
|
|
286
|
-
globalObject.
|
|
287
|
-
|
|
288
|
-
await loadBuildEntry();
|
|
252
|
+
// https://github.com/vikejs/vike/blob/8c350e8105a626469e87594d983090919e82099b/packages/vike/node/vite/plugins/pluginBuild/pluginProdBuildEntry.ts#L47
|
|
253
|
+
async function setGlobalContext_prodBuildEntry(prodBuildEntry) {
|
|
254
|
+
debug('setGlobalContext_prodBuildEntry()');
|
|
255
|
+
assertProdBuildEntry(prodBuildEntry);
|
|
256
|
+
globalObject.prodBuildEntry = prodBuildEntry;
|
|
257
|
+
globalObject.prodBuildEntryPrevious = prodBuildEntry;
|
|
258
|
+
assert(globalObject.prodBuildEntry); // ensure no infinite loop
|
|
259
|
+
await loadProdBuildEntry();
|
|
289
260
|
assertGlobalContextIsDefined();
|
|
290
|
-
debug('
|
|
291
|
-
}
|
|
292
|
-
function
|
|
293
|
-
assert(isObject(
|
|
294
|
-
assert(hasProp(
|
|
295
|
-
const {
|
|
296
|
-
assert(hasProp(
|
|
297
|
-
const { assetsManifest } =
|
|
261
|
+
debug('setGlobalContext_prodBuildEntry() - done');
|
|
262
|
+
}
|
|
263
|
+
function assertProdBuildEntry(prodBuildEntry) {
|
|
264
|
+
assert(isObject(prodBuildEntry));
|
|
265
|
+
assert(hasProp(prodBuildEntry, 'virtualFileExportsGlobalEntry', 'object'));
|
|
266
|
+
const { virtualFileExportsGlobalEntry } = prodBuildEntry;
|
|
267
|
+
assert(hasProp(prodBuildEntry, 'assetsManifest', 'object'));
|
|
268
|
+
const { assetsManifest } = prodBuildEntry;
|
|
298
269
|
assertViteManifest(assetsManifest);
|
|
299
|
-
assert(hasProp(
|
|
300
|
-
const { buildInfo } =
|
|
270
|
+
assert(hasProp(prodBuildEntry, 'buildInfo', 'object'));
|
|
271
|
+
const { buildInfo } = prodBuildEntry;
|
|
301
272
|
assertBuildInfo(buildInfo);
|
|
302
|
-
checkType({
|
|
273
|
+
checkType({ virtualFileExportsGlobalEntry, assetsManifest, buildInfo });
|
|
303
274
|
}
|
|
304
275
|
function assertBuildInfo(buildInfo) {
|
|
305
276
|
assert(isObject(buildInfo));
|
|
@@ -320,7 +291,7 @@ function assertVersionAtBuildTime(versionAtBuildTime) {
|
|
|
320
291
|
}
|
|
321
292
|
async function updateUserFiles() {
|
|
322
293
|
debug('updateUserFiles()');
|
|
323
|
-
assert(!
|
|
294
|
+
assert(!isProd());
|
|
324
295
|
const { promise, resolve } = genPromise();
|
|
325
296
|
globalObject.waitForUserFilesUpdate = promise;
|
|
326
297
|
globalObject.waitForUserFilesUpdateResolve ?? (globalObject.waitForUserFilesUpdateResolve = []);
|
|
@@ -353,15 +324,15 @@ async function updateUserFiles() {
|
|
|
353
324
|
viteDevServer !== globalObject.viteDevServer;
|
|
354
325
|
const { viteDevServer } = globalObject;
|
|
355
326
|
let hasError = false;
|
|
356
|
-
let
|
|
327
|
+
let virtualFileExportsGlobalEntry;
|
|
357
328
|
let err;
|
|
358
329
|
if (viteDevServer) {
|
|
359
330
|
assert(isRunnable(viteDevServer));
|
|
360
331
|
/* We don't use runner.import() yet, because as of vite@7.0.6 (July 2025) runner.import() unexpectedly invalidates the module graph, which is a unexpected behavior that doesn't happen with ssrLoadModule()
|
|
361
332
|
// Vite 6
|
|
362
333
|
try {
|
|
363
|
-
|
|
364
|
-
'virtual:vike:entry:server',
|
|
334
|
+
virtualFileExportsGlobalEntry = await (viteDevServer.environments.ssr as RunnableDevEnvironment).runner.import(
|
|
335
|
+
'virtual:vike:global-entry:server',
|
|
365
336
|
)
|
|
366
337
|
} catch (err_) {
|
|
367
338
|
hasError = true
|
|
@@ -370,7 +341,7 @@ async function updateUserFiles() {
|
|
|
370
341
|
*/
|
|
371
342
|
// Vite 5
|
|
372
343
|
try {
|
|
373
|
-
|
|
344
|
+
virtualFileExportsGlobalEntry = await viteDevServer.ssrLoadModule(virtualFileIdGlobalEntryServer);
|
|
374
345
|
}
|
|
375
346
|
catch (err_) {
|
|
376
347
|
hasError = true;
|
|
@@ -383,10 +354,10 @@ async function updateUserFiles() {
|
|
|
383
354
|
```js
|
|
384
355
|
assert(false)
|
|
385
356
|
// This line breaks the HMR of regular (runnable) apps, even though (as per the assert() above) it's never run. It seems to be a Vite bug: handleHotUpdate() receives an empty `modules` list.
|
|
386
|
-
import('virtual:vike:entry:server')
|
|
357
|
+
import('virtual:vike:global-entry:server')
|
|
387
358
|
```
|
|
388
359
|
*/
|
|
389
|
-
|
|
360
|
+
virtualFileExportsGlobalEntry = await __VIKE__DYNAMIC_IMPORT('virtual:vike:global-entry:server');
|
|
390
361
|
}
|
|
391
362
|
catch (err_) {
|
|
392
363
|
hasError = true;
|
|
@@ -397,12 +368,12 @@ async function updateUserFiles() {
|
|
|
397
368
|
return { success: false };
|
|
398
369
|
if (hasError)
|
|
399
370
|
return onError(err);
|
|
400
|
-
|
|
371
|
+
virtualFileExportsGlobalEntry = virtualFileExportsGlobalEntry.default || virtualFileExportsGlobalEntry;
|
|
401
372
|
if (getVikeConfigErrorBuild()) {
|
|
402
373
|
return { success: false };
|
|
403
374
|
}
|
|
404
375
|
try {
|
|
405
|
-
await createGlobalContext(
|
|
376
|
+
await createGlobalContext(virtualFileExportsGlobalEntry);
|
|
406
377
|
}
|
|
407
378
|
catch (err_) {
|
|
408
379
|
hasError = true;
|
|
@@ -414,16 +385,21 @@ async function updateUserFiles() {
|
|
|
414
385
|
return onError(err);
|
|
415
386
|
return onSuccess();
|
|
416
387
|
}
|
|
417
|
-
async function createGlobalContext(
|
|
388
|
+
async function createGlobalContext(virtualFileExportsGlobalEntry) {
|
|
418
389
|
debug('createGlobalContext()');
|
|
419
390
|
assert(!getVikeConfigErrorBuild());
|
|
420
|
-
const
|
|
391
|
+
const globalContextPromise = createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext, addGlobalContextTmp, addGlobalContextAsync);
|
|
392
|
+
debug('createGlobalContext() - done [sync]');
|
|
393
|
+
// We define an early globalContext version synchronously, so that getGlobalContextSync() can be called early.
|
|
394
|
+
// - Required by vike-vercel
|
|
395
|
+
assert(globalObject.globalContext);
|
|
396
|
+
const globalContext = await globalContextPromise;
|
|
397
|
+
debug('createGlobalContext() - done [async]');
|
|
421
398
|
assertV1Design(
|
|
422
399
|
// pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
|
|
423
400
|
globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
|
|
424
401
|
assertGlobalContextIsDefined();
|
|
425
402
|
onSetupRuntime();
|
|
426
|
-
debug('createGlobalContext() - done');
|
|
427
403
|
// Never actually used, only used for TypeScript `ReturnType<typeof createGlobalContext>`
|
|
428
404
|
return globalContext;
|
|
429
405
|
}
|
|
@@ -443,8 +419,8 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
443
419
|
_pageRoutes: pageRoutes,
|
|
444
420
|
_onBeforeRouteHook: onBeforeRouteHook,
|
|
445
421
|
};
|
|
446
|
-
const { viteDevServer, viteConfig, isPrerendering
|
|
447
|
-
|
|
422
|
+
const { viteDevServer, viteConfig, isPrerendering } = globalObject;
|
|
423
|
+
const isProduction = isProd();
|
|
448
424
|
if (!isProduction) {
|
|
449
425
|
assert(globalContext); // main common requirement
|
|
450
426
|
assert(!isPrerendering);
|
|
@@ -458,7 +434,7 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
458
434
|
};
|
|
459
435
|
}
|
|
460
436
|
else {
|
|
461
|
-
assert(globalObject.
|
|
437
|
+
assert(globalObject.prodBuildEntry);
|
|
462
438
|
assert(globalContext); // main common requiement
|
|
463
439
|
const { buildInfo, assetsManifest } = globalObject;
|
|
464
440
|
assert(buildInfo);
|
|
@@ -496,7 +472,7 @@ async function addGlobalContextAsync(globalContext) {
|
|
|
496
472
|
}
|
|
497
473
|
else {
|
|
498
474
|
assert(!isProcessSharedWithVite()); // process shared with Vite => globalObject.viteConfigRuntime should be set
|
|
499
|
-
assert(!
|
|
475
|
+
assert(!isProd()); // production => globalObject.buildInfo.viteConfigRuntime should be set
|
|
500
476
|
assert(isNonRunnableDev());
|
|
501
477
|
const rpc = getViteRPC();
|
|
502
478
|
viteConfigRuntime = await rpc.getViteConfigRuntimeRPC();
|
|
@@ -510,13 +486,12 @@ async function addGlobalContextAsync(globalContext) {
|
|
|
510
486
|
}
|
|
511
487
|
function clearGlobalContext() {
|
|
512
488
|
debug('clearGlobalContext()');
|
|
513
|
-
objectReplace(globalObject, getInitialGlobalObject(), ['
|
|
489
|
+
objectReplace(globalObject, getInitialGlobalObject(), ['prodBuildEntryPrevious']);
|
|
514
490
|
}
|
|
515
491
|
function getInitialGlobalObject() {
|
|
516
492
|
debug('getInitialGlobalObject()');
|
|
517
493
|
const { promise: viteDevServerPromise, resolve: viteDevServerPromiseResolve } = genPromise();
|
|
518
494
|
return {
|
|
519
|
-
isProduction: isNonRunnableDev() ? false : undefined,
|
|
520
495
|
viteDevServerPromise,
|
|
521
496
|
viteDevServerPromiseResolve,
|
|
522
497
|
};
|
|
@@ -543,10 +518,51 @@ function isRunnable(viteDevServer) {
|
|
|
543
518
|
assert(!isNonRunnableDev());
|
|
544
519
|
return yes;
|
|
545
520
|
}
|
|
546
|
-
function
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
521
|
+
function isProd() {
|
|
522
|
+
const isProduction = isProdOptional();
|
|
523
|
+
if (isProduction === null) {
|
|
524
|
+
if (globalObject.isAfterFirstRenderPageCall) {
|
|
525
|
+
// When using a production server without vike-server, there isn't any reliable signal we can use to determine early whether the environment is production or development. If renderPage() was called then some non-negligible amount of time passed — it's likely that, in dev, one of the Vite hooks should have already sent a signal we can use to determine prod/dev.
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
assert(false);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return isProduction;
|
|
533
|
+
}
|
|
534
|
+
function isProdOptional() {
|
|
535
|
+
const vikeApiOperation = getVikeApiOperation()?.operation ?? null;
|
|
536
|
+
const yes =
|
|
537
|
+
// setGlobalContext_prodBuildEntry() was called
|
|
538
|
+
!!globalObject.prodBuildEntry ||
|
|
539
|
+
globalObject.isPrerendering === true ||
|
|
540
|
+
// Vike CLI & Vike API
|
|
541
|
+
(!!vikeApiOperation && vikeApiOperation !== 'dev') ||
|
|
542
|
+
// Vite command
|
|
543
|
+
globalObject.isProductionAccordingToVite === true ||
|
|
544
|
+
// getGlobalContextAsync(isProduction)
|
|
545
|
+
globalObject.isProductionAccordingToUser === true ||
|
|
546
|
+
// vite-plugin-vercel
|
|
547
|
+
globalObject.isProductionAccordingToPhotonVercel === true;
|
|
550
548
|
assert(typeof yes === 'boolean');
|
|
551
|
-
|
|
549
|
+
const no = !!globalObject.viteDevServer ||
|
|
550
|
+
// Vike CLI & Vike API
|
|
551
|
+
vikeApiOperation === 'dev' ||
|
|
552
|
+
// Vite command
|
|
553
|
+
globalObject.isProductionAccordingToVite === false ||
|
|
554
|
+
// getGlobalContextAsync(isProduction)
|
|
555
|
+
globalObject.isProductionAccordingToUser === false ||
|
|
556
|
+
// @cloudflare/vite-plugin
|
|
557
|
+
isNonRunnableDev() === true;
|
|
558
|
+
assert(typeof no === 'boolean');
|
|
559
|
+
if (yes) {
|
|
560
|
+
assert(no === false);
|
|
561
|
+
return true;
|
|
562
|
+
}
|
|
563
|
+
if (no) {
|
|
564
|
+
assert(yes === false);
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
return null;
|
|
552
568
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isFontFallback } from '../../renderPage/isFontFallback.js';
|
|
2
1
|
export { getHtmlTags };
|
|
3
2
|
import { assert, assertWarning, assertUsage, isObject, freezePartial } from '../../utils.js';
|
|
4
3
|
import { getGlobalContextClientSerialized, getPageContextClientSerialized, } from '../serializeContext.js';
|
|
@@ -10,6 +9,7 @@ import { getConfigValueRuntime } from '../../../../shared/page-configs/getConfig
|
|
|
10
9
|
import pc from '@brillout/picocolors';
|
|
11
10
|
import { getConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
12
11
|
import { htmlElementId_globalContext, htmlElementId_pageContext } from '../../../../shared/htmlElementIds.js';
|
|
12
|
+
import { isFontFallback } from '../../renderPage/isFontFallback.js';
|
|
13
13
|
const stamp = '__injectFilterEntry';
|
|
14
14
|
async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript, isStream) {
|
|
15
15
|
assert([true, false].includes(pageContext._isHtmlOnly));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { analyzePage };
|
|
2
|
-
import type { PageFile } from '../../../shared/getPageFiles/getPageFileObject.js';
|
|
3
2
|
import type { PageConfigRuntime } from '../../../types/PageConfig.js';
|
|
4
3
|
import { type AnalysisResult } from '../../../shared/getPageFiles/analyzePageClientSide.js';
|
|
5
|
-
import type {
|
|
6
|
-
declare function analyzePage(
|
|
4
|
+
import type { PageContext_loadPageConfigsLazyServerSide } from './loadPageConfigsLazyServerSide.js';
|
|
5
|
+
declare function analyzePage(pageContext: PageContext_loadPageConfigsLazyServerSide & {
|
|
6
|
+
_pageConfig: null | PageConfigRuntime;
|
|
7
|
+
}): AnalysisResult;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { analyzePage };
|
|
2
2
|
import { getVikeClientEntry } from '../../../shared/getPageFiles/analyzePageClientSide/determineClientEntry.js';
|
|
3
3
|
import { analyzePageClientSide } from '../../../shared/getPageFiles/analyzePageClientSide.js';
|
|
4
|
-
import {
|
|
4
|
+
import { generateVirtualFileId } from '../../shared/virtualFileId.js';
|
|
5
5
|
import { analyzeClientSide } from '../../../shared/getPageFiles/analyzeClientSide.js';
|
|
6
6
|
import { getConfigValueRuntime } from '../../../shared/page-configs/getConfigValueRuntime.js';
|
|
7
|
-
|
|
7
|
+
function analyzePage(pageContext) {
|
|
8
|
+
const { pageId, _pageConfig: pageConfig, _globalContext: globalContext } = pageContext;
|
|
9
|
+
const { _pageFilesAll: pageFilesAll } = globalContext;
|
|
8
10
|
if (pageConfig) {
|
|
9
11
|
const { isClientRuntimeLoaded, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
|
|
10
12
|
const clientEntries = [];
|
|
@@ -15,14 +17,14 @@ async function analyzePage(pageFilesAll, pageConfig, pageId, globalContext) {
|
|
|
15
17
|
clientEntries.push(getVikeClientEntry(isClientRouting));
|
|
16
18
|
const clientDependencies = [];
|
|
17
19
|
clientDependencies.push({
|
|
18
|
-
id:
|
|
20
|
+
id: generateVirtualFileId({ type: 'page-entry', pageId: pageConfig.pageId, isForClientSide: true }),
|
|
19
21
|
onlyAssets: isClientRuntimeLoaded ? false : true,
|
|
20
22
|
eagerlyImported: false,
|
|
21
23
|
});
|
|
22
24
|
// In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
|
|
23
25
|
if (!globalContext._isProduction) {
|
|
24
26
|
clientDependencies.push({
|
|
25
|
-
id:
|
|
27
|
+
id: generateVirtualFileId({ type: 'page-entry', pageId: pageConfig.pageId, isForClientSide: false }),
|
|
26
28
|
onlyAssets: true,
|
|
27
29
|
eagerlyImported: false,
|
|
28
30
|
});
|
|
@@ -26,7 +26,7 @@ declare function createPageContextServerSide(pageContextInit: PageContextInit, g
|
|
|
26
26
|
_globalContext: {
|
|
27
27
|
isGlobalContext: true;
|
|
28
28
|
_isOriginalObject: true;
|
|
29
|
-
|
|
29
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
30
30
|
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
31
31
|
_pageConfigs: import("../../../types/PageConfig.js").PageConfigRuntime[];
|
|
32
32
|
_pageConfigGlobal: import("../../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -39,7 +39,7 @@ declare function createPageContextServerSide(pageContextInit: PageContextInit, g
|
|
|
39
39
|
};
|
|
40
40
|
config: import("../../../types/index.js").ConfigResolved;
|
|
41
41
|
pages: {
|
|
42
|
-
[k: string]: import("../../../shared/page-configs/resolveVikeConfigPublic.js").
|
|
42
|
+
[k: string]: import("../../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
43
43
|
};
|
|
44
44
|
} & (({
|
|
45
45
|
_isProduction: false;
|