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
|
@@ -16,28 +16,22 @@ exports.initGlobalContext_getPagesAndRoutes = initGlobalContext_getPagesAndRoute
|
|
|
16
16
|
exports.setGlobalContext_viteDevServer = setGlobalContext_viteDevServer;
|
|
17
17
|
exports.setGlobalContext_viteConfig = setGlobalContext_viteConfig;
|
|
18
18
|
exports.setGlobalContext_isPrerendering = setGlobalContext_isPrerendering;
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
19
|
+
exports.setGlobalContext_isProductionAccordingToVite = setGlobalContext_isProductionAccordingToVite;
|
|
20
|
+
exports.setGlobalContext_prodBuildEntry = setGlobalContext_prodBuildEntry;
|
|
21
21
|
exports.clearGlobalContext = clearGlobalContext;
|
|
22
22
|
exports.assertBuildInfo = assertBuildInfo;
|
|
23
23
|
exports.updateUserFiles = updateUserFiles;
|
|
24
|
-
// TODO/now: use isProductionEnvironment() instead of globalObject.isProduction
|
|
25
|
-
// TODO/now: rename:
|
|
26
|
-
// - isProduction => isProductionEnvironment
|
|
27
|
-
// - setIsProduction => setIsProductionEnvironment
|
|
28
|
-
// - setGlobalContext_isProduction => setGlobalContext_isProductionEnvironment
|
|
29
|
-
// - sProductionEnvironment => sDevEnv
|
|
30
24
|
// The core logic revolves around:
|
|
31
|
-
// -
|
|
32
|
-
// - In production: globalObject.
|
|
33
|
-
// -
|
|
34
|
-
// - 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
|
|
25
|
+
// - virtualFileExportsGlobalEntry is the main requirement
|
|
26
|
+
// - In production: globalObject.prodBuildEntry which is the production entry set by @brillout/vite-plugin-server-entry
|
|
27
|
+
// - loadProdBuildEntry() sets globalObject.prodBuildEntry and then sets virtualFileExportsGlobalEntry
|
|
28
|
+
// - 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()
|
|
35
29
|
// - Without vike-server it's manually loaded here using importServerProductionEntry() which uses @brillout/vite-plugin-server-entry's autoImporter or crawler
|
|
36
30
|
// - In development: globalObject.viteDevServer which is Vite's development server
|
|
37
|
-
// - globalObject.viteDevServer is used by updateUserFiles() which then sets
|
|
31
|
+
// - globalObject.viteDevServer is used by updateUserFiles() which then sets virtualFileExportsGlobalEntry
|
|
38
32
|
const utils_js_1 = require("./utils.js");
|
|
39
33
|
const runtime_1 = require("@brillout/vite-plugin-server-entry/runtime");
|
|
40
|
-
const
|
|
34
|
+
const virtualFileId_js_1 = require("../shared/virtualFileId.js");
|
|
41
35
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
42
36
|
const loadPageRoutes_js_1 = require("../../shared/route/loadPageRoutes.js");
|
|
43
37
|
const assertV1Design_js_1 = require("../shared/assertV1Design.js");
|
|
@@ -47,6 +41,7 @@ const prepareGlobalContextForPublicUsage_js_1 = require("../../shared/prepareGlo
|
|
|
47
41
|
const loggerRuntime_js_1 = require("./loggerRuntime.js");
|
|
48
42
|
const getVikeConfigError_js_1 = require("../shared/getVikeConfigError.js");
|
|
49
43
|
const isNewError_js_1 = require("./renderPage/isNewError.js");
|
|
44
|
+
const context_js_1 = require("../api/context.js");
|
|
50
45
|
const debug = (0, utils_js_1.createDebugger)('vike:globalContext');
|
|
51
46
|
const globalObject = (0, utils_js_1.getGlobalObject)('runtime/globalContext.ts', getInitialGlobalObject());
|
|
52
47
|
// Trick to break down TypeScript circular dependency
|
|
@@ -59,7 +54,7 @@ async function getGlobalContextServerInternal() {
|
|
|
59
54
|
// getGlobalContextServerInternal() should always be called after initGlobalContext()
|
|
60
55
|
(0, utils_js_1.assert)(globalObject.isInitialized);
|
|
61
56
|
assertGlobalContextIsDefined();
|
|
62
|
-
if (
|
|
57
|
+
if (!isProd())
|
|
63
58
|
await globalObject.waitForUserFilesUpdate;
|
|
64
59
|
const { globalContext } = globalObjectTyped;
|
|
65
60
|
assertIsDefined(globalContext);
|
|
@@ -84,10 +79,9 @@ function assertGlobalContextIsDefined() {
|
|
|
84
79
|
*/
|
|
85
80
|
async function getGlobalContext() {
|
|
86
81
|
debug('getGlobalContext()');
|
|
87
|
-
const
|
|
82
|
+
const isProduction = isProdOptional();
|
|
88
83
|
// 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).
|
|
89
|
-
(0, utils_js_1.assertUsage)(isProduction !==
|
|
90
|
-
(0, utils_js_1.assert)(typeof globalObject.isProduction === 'boolean');
|
|
84
|
+
(0, utils_js_1.assertUsage)(isProduction !== null, "The global context isn't set yet, use getGlobalContextAsync() instead.");
|
|
91
85
|
return await getGlobalContextAsync(isProduction);
|
|
92
86
|
}
|
|
93
87
|
/**
|
|
@@ -98,7 +92,7 @@ async function getGlobalContext() {
|
|
|
98
92
|
async function getGlobalContextAsync(isProduction) {
|
|
99
93
|
debug('getGlobalContextAsync()');
|
|
100
94
|
(0, utils_js_1.assertUsage)(typeof isProduction === 'boolean', `[getGlobalContextAsync(isProduction)] Argument ${picocolors_1.default.cyan('isProduction')} ${isProduction === undefined ? 'is missing' : `should be ${picocolors_1.default.cyan('true')} or ${picocolors_1.default.cyan('false')}`}`);
|
|
101
|
-
|
|
95
|
+
globalObject.isProductionAccordingToUser = isProduction;
|
|
102
96
|
if (!globalObject.globalContext)
|
|
103
97
|
await initGlobalContext_getGlobalContextAsync();
|
|
104
98
|
if (!isProduction)
|
|
@@ -115,9 +109,7 @@ function getGlobalContextSync() {
|
|
|
115
109
|
debug('getGlobalContextSync()');
|
|
116
110
|
const { globalContext } = globalObjectTyped;
|
|
117
111
|
(0, utils_js_1.assertUsage)(globalContext, createGlobalContextShared_js_1.getGlobalContextSyncErrMsg);
|
|
118
|
-
|
|
119
|
-
(0, utils_js_1.assert)(typeof isProd === 'boolean');
|
|
120
|
-
(0, utils_js_1.assertWarning)(isProd,
|
|
112
|
+
(0, utils_js_1.assertWarning)(isProd(),
|
|
121
113
|
// - 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.
|
|
122
114
|
// - I don't see any issues with getGlobalContextSync() in production.
|
|
123
115
|
// - getGlobalContextSync() is used in production by vike-vercel
|
|
@@ -133,7 +125,6 @@ function getGlobalContextForPublicUsage() {
|
|
|
133
125
|
}
|
|
134
126
|
async function setGlobalContext_viteDevServer(viteDevServer) {
|
|
135
127
|
debug('setGlobalContext_viteDevServer()');
|
|
136
|
-
setIsProduction(false);
|
|
137
128
|
// 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.
|
|
138
129
|
if (!globalObject.viteDevServer) {
|
|
139
130
|
assertIsNotInitializedYet();
|
|
@@ -161,18 +152,9 @@ function assertIsNotInitializedYet() {
|
|
|
161
152
|
}
|
|
162
153
|
function setGlobalContext_isPrerendering() {
|
|
163
154
|
globalObject.isPrerendering = true;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
function setGlobalContext_isProduction(isProduction, tolerateContraditction = false) {
|
|
168
|
-
if (debug.isActivated)
|
|
169
|
-
debug('setGlobalContext_isProduction()', { isProduction, tolerateContraditction });
|
|
170
|
-
if (globalObject.isProduction === undefined) {
|
|
171
|
-
setIsProduction(isProduction);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
(0, utils_js_1.assert)(globalObject.isProduction === isProduction || tolerateContraditction);
|
|
175
|
-
}
|
|
155
|
+
}
|
|
156
|
+
function setGlobalContext_isProductionAccordingToVite(isProductionAccordingToVite) {
|
|
157
|
+
globalObject.isProductionAccordingToVite = isProductionAccordingToVite;
|
|
176
158
|
}
|
|
177
159
|
function getViteDevServer() {
|
|
178
160
|
return globalObject.viteDevServer ?? null;
|
|
@@ -182,15 +164,13 @@ function getViteConfig() {
|
|
|
182
164
|
}
|
|
183
165
|
async function initGlobalContext_renderPage() {
|
|
184
166
|
debug('initGlobalContext_renderPage()');
|
|
185
|
-
|
|
186
|
-
if (globalObject.isProduction === undefined)
|
|
187
|
-
setIsProduction(true);
|
|
167
|
+
globalObject.isAfterFirstRenderPageCall = true;
|
|
188
168
|
await initGlobalContext();
|
|
189
169
|
}
|
|
190
170
|
async function initGlobalContext_runPrerender() {
|
|
191
171
|
debug('initGlobalContext_runPrerender()');
|
|
192
172
|
(0, utils_js_1.assert)(globalObject.isPrerendering === true);
|
|
193
|
-
(0, utils_js_1.assert)(
|
|
173
|
+
(0, utils_js_1.assert)(isProd());
|
|
194
174
|
if (globalObject.initGlobalContext_runPrerender_alreadyCalled)
|
|
195
175
|
return;
|
|
196
176
|
globalObject.initGlobalContext_runPrerender_alreadyCalled = true;
|
|
@@ -208,36 +188,28 @@ async function initGlobalContext_getGlobalContextAsync() {
|
|
|
208
188
|
}
|
|
209
189
|
async function initGlobalContext_getPagesAndRoutes() {
|
|
210
190
|
debug('initGlobalContext_getPagesAndRoutes()');
|
|
211
|
-
|
|
191
|
+
globalObject.isProductionAccordingToPhotonVercel = true;
|
|
212
192
|
await initGlobalContext();
|
|
213
193
|
}
|
|
214
194
|
async function initGlobalContext() {
|
|
215
|
-
const
|
|
216
|
-
(0, utils_js_1.assert)(typeof isProduction === 'boolean');
|
|
195
|
+
const isProduction = isProd();
|
|
217
196
|
if (!isProduction) {
|
|
218
197
|
if (isProcessSharedWithVite()) {
|
|
219
198
|
await globalObject.viteDevServerPromise;
|
|
220
199
|
}
|
|
221
200
|
else {
|
|
222
|
-
(0, utils_js_1.assert)(isNonRunnableDev());
|
|
201
|
+
(0, utils_js_1.assert)((0, utils_js_1.isNonRunnableDev)());
|
|
223
202
|
await updateUserFiles();
|
|
224
203
|
}
|
|
225
204
|
(0, utils_js_1.assert)(globalObject.waitForUserFilesUpdate);
|
|
226
205
|
await globalObject.waitForUserFilesUpdate;
|
|
227
206
|
}
|
|
228
207
|
else {
|
|
229
|
-
await
|
|
208
|
+
await loadProdBuildEntry(globalObject.viteConfigRuntime?.build.outDir);
|
|
230
209
|
}
|
|
231
210
|
assertGlobalContextIsDefined();
|
|
232
211
|
globalObject.isInitialized = true;
|
|
233
212
|
}
|
|
234
|
-
function setIsProduction(isProduction) {
|
|
235
|
-
debug('setIsProduction', isProduction);
|
|
236
|
-
(0, utils_js_1.assert)(typeof isProduction === 'boolean');
|
|
237
|
-
if (globalObject.isProduction !== undefined)
|
|
238
|
-
(0, utils_js_1.assert)(globalObject.isProduction === isProduction);
|
|
239
|
-
globalObject.isProduction = isProduction;
|
|
240
|
-
}
|
|
241
213
|
function assertViteManifest(manifest) {
|
|
242
214
|
(0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(manifest));
|
|
243
215
|
/* We should include these assertions but we don't as a workaround for PWA manifests: https://github.com/vikejs/vike/issues/769
|
|
@@ -251,59 +223,58 @@ function assertViteManifest(manifest) {
|
|
|
251
223
|
})
|
|
252
224
|
*/
|
|
253
225
|
}
|
|
254
|
-
async function
|
|
255
|
-
debug('
|
|
226
|
+
async function loadProdBuildEntry(outDir) {
|
|
227
|
+
debug('loadProdBuildEntry()');
|
|
256
228
|
if (globalObject.globalContext) {
|
|
257
|
-
debug('
|
|
229
|
+
debug('loadProdBuildEntry() - already done');
|
|
258
230
|
return;
|
|
259
231
|
}
|
|
260
|
-
if (!globalObject.
|
|
232
|
+
if (!globalObject.prodBuildEntry) {
|
|
261
233
|
debug('importServerProductionEntry()');
|
|
262
|
-
// importServerProductionEntry() loads dist/server/entry.mjs which calls
|
|
234
|
+
// importServerProductionEntry() loads dist/server/entry.mjs which calls setGlobalContext_prodBuildEntry()
|
|
263
235
|
await (0, runtime_1.importServerProductionEntry)({ outDir });
|
|
264
|
-
if (!globalObject.
|
|
265
|
-
debug('globalObject.
|
|
236
|
+
if (!globalObject.prodBuildEntry) {
|
|
237
|
+
debug('globalObject.prodBuildEntryPrevious');
|
|
266
238
|
// 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.)
|
|
267
|
-
globalObject.
|
|
239
|
+
globalObject.prodBuildEntry = globalObject.prodBuildEntryPrevious;
|
|
268
240
|
}
|
|
269
|
-
(0, utils_js_1.assert)(globalObject.
|
|
270
|
-
// If using `inject` then dist/server/index.js imports dist/server/entry.js and
|
|
241
|
+
(0, utils_js_1.assert)(globalObject.prodBuildEntry);
|
|
242
|
+
// If using `inject` then dist/server/index.js imports dist/server/entry.js and loadProdBuildEntry() isn't needed.
|
|
271
243
|
// If dist/server/entry.js isn't imported then this means the user is running the original server entry `$ ts-node server/index.ts`.
|
|
272
244
|
(0, utils_js_1.assertWarning)(
|
|
273
245
|
// vike-server => `inject === true`
|
|
274
246
|
// vike-node => `inject === [ 'index' ]` => we don't show the warning to vike-node users (I don't remember why).
|
|
275
247
|
globalObject.buildInfo?.viteConfigRuntime.vitePluginServerEntry.inject !== true || globalObject.isPrerendering, `Run the built server entry (e.g. ${picocolors_1.default.cyan('$ node dist/server/index.mjs')}) instead of the original server entry (e.g. ${picocolors_1.default.cyan('$ ts-node server/index.ts')})`, { onlyOnce: true });
|
|
276
248
|
}
|
|
277
|
-
const {
|
|
278
|
-
|
|
279
|
-
globalObject.assetsManifest =
|
|
280
|
-
globalObject.buildInfo =
|
|
281
|
-
await createGlobalContext(
|
|
249
|
+
const { prodBuildEntry } = globalObject;
|
|
250
|
+
assertProdBuildEntry(prodBuildEntry);
|
|
251
|
+
globalObject.assetsManifest = prodBuildEntry.assetsManifest;
|
|
252
|
+
globalObject.buildInfo = prodBuildEntry.buildInfo;
|
|
253
|
+
await createGlobalContext(prodBuildEntry.virtualFileExportsGlobalEntry);
|
|
282
254
|
}
|
|
283
255
|
// This is the production entry, see:
|
|
284
|
-
// https://github.com/vikejs/vike/blob/
|
|
285
|
-
async function
|
|
286
|
-
debug('
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
globalObject.
|
|
290
|
-
globalObject.
|
|
291
|
-
|
|
292
|
-
await loadBuildEntry();
|
|
256
|
+
// https://github.com/vikejs/vike/blob/8c350e8105a626469e87594d983090919e82099b/packages/vike/node/vite/plugins/pluginBuild/pluginProdBuildEntry.ts#L47
|
|
257
|
+
async function setGlobalContext_prodBuildEntry(prodBuildEntry) {
|
|
258
|
+
debug('setGlobalContext_prodBuildEntry()');
|
|
259
|
+
assertProdBuildEntry(prodBuildEntry);
|
|
260
|
+
globalObject.prodBuildEntry = prodBuildEntry;
|
|
261
|
+
globalObject.prodBuildEntryPrevious = prodBuildEntry;
|
|
262
|
+
(0, utils_js_1.assert)(globalObject.prodBuildEntry); // ensure no infinite loop
|
|
263
|
+
await loadProdBuildEntry();
|
|
293
264
|
assertGlobalContextIsDefined();
|
|
294
|
-
debug('
|
|
295
|
-
}
|
|
296
|
-
function
|
|
297
|
-
(0, utils_js_1.assert)((0, utils_js_1.isObject)(
|
|
298
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
299
|
-
const {
|
|
300
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
301
|
-
const { assetsManifest } =
|
|
265
|
+
debug('setGlobalContext_prodBuildEntry() - done');
|
|
266
|
+
}
|
|
267
|
+
function assertProdBuildEntry(prodBuildEntry) {
|
|
268
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(prodBuildEntry));
|
|
269
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(prodBuildEntry, 'virtualFileExportsGlobalEntry', 'object'));
|
|
270
|
+
const { virtualFileExportsGlobalEntry } = prodBuildEntry;
|
|
271
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(prodBuildEntry, 'assetsManifest', 'object'));
|
|
272
|
+
const { assetsManifest } = prodBuildEntry;
|
|
302
273
|
assertViteManifest(assetsManifest);
|
|
303
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
304
|
-
const { buildInfo } =
|
|
274
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(prodBuildEntry, 'buildInfo', 'object'));
|
|
275
|
+
const { buildInfo } = prodBuildEntry;
|
|
305
276
|
assertBuildInfo(buildInfo);
|
|
306
|
-
(0, utils_js_1.checkType)({
|
|
277
|
+
(0, utils_js_1.checkType)({ virtualFileExportsGlobalEntry, assetsManifest, buildInfo });
|
|
307
278
|
}
|
|
308
279
|
function assertBuildInfo(buildInfo) {
|
|
309
280
|
(0, utils_js_1.assert)((0, utils_js_1.isObject)(buildInfo));
|
|
@@ -324,7 +295,7 @@ function assertVersionAtBuildTime(versionAtBuildTime) {
|
|
|
324
295
|
}
|
|
325
296
|
async function updateUserFiles() {
|
|
326
297
|
debug('updateUserFiles()');
|
|
327
|
-
(0, utils_js_1.assert)(!
|
|
298
|
+
(0, utils_js_1.assert)(!isProd());
|
|
328
299
|
const { promise, resolve } = (0, utils_js_1.genPromise)();
|
|
329
300
|
globalObject.waitForUserFilesUpdate = promise;
|
|
330
301
|
globalObject.waitForUserFilesUpdateResolve ?? (globalObject.waitForUserFilesUpdateResolve = []);
|
|
@@ -357,15 +328,15 @@ async function updateUserFiles() {
|
|
|
357
328
|
viteDevServer !== globalObject.viteDevServer;
|
|
358
329
|
const { viteDevServer } = globalObject;
|
|
359
330
|
let hasError = false;
|
|
360
|
-
let
|
|
331
|
+
let virtualFileExportsGlobalEntry;
|
|
361
332
|
let err;
|
|
362
333
|
if (viteDevServer) {
|
|
363
334
|
(0, utils_js_1.assert)(isRunnable(viteDevServer));
|
|
364
335
|
/* 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()
|
|
365
336
|
// Vite 6
|
|
366
337
|
try {
|
|
367
|
-
|
|
368
|
-
'virtual:vike:entry:server',
|
|
338
|
+
virtualFileExportsGlobalEntry = await (viteDevServer.environments.ssr as RunnableDevEnvironment).runner.import(
|
|
339
|
+
'virtual:vike:global-entry:server',
|
|
369
340
|
)
|
|
370
341
|
} catch (err_) {
|
|
371
342
|
hasError = true
|
|
@@ -374,7 +345,7 @@ async function updateUserFiles() {
|
|
|
374
345
|
*/
|
|
375
346
|
// Vite 5
|
|
376
347
|
try {
|
|
377
|
-
|
|
348
|
+
virtualFileExportsGlobalEntry = await viteDevServer.ssrLoadModule(virtualFileId_js_1.virtualFileIdGlobalEntryServer);
|
|
378
349
|
}
|
|
379
350
|
catch (err_) {
|
|
380
351
|
hasError = true;
|
|
@@ -387,10 +358,10 @@ async function updateUserFiles() {
|
|
|
387
358
|
```js
|
|
388
359
|
assert(false)
|
|
389
360
|
// 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.
|
|
390
|
-
import('virtual:vike:entry:server')
|
|
361
|
+
import('virtual:vike:global-entry:server')
|
|
391
362
|
```
|
|
392
363
|
*/
|
|
393
|
-
|
|
364
|
+
virtualFileExportsGlobalEntry = await __VIKE__DYNAMIC_IMPORT('virtual:vike:global-entry:server');
|
|
394
365
|
}
|
|
395
366
|
catch (err_) {
|
|
396
367
|
hasError = true;
|
|
@@ -401,12 +372,12 @@ async function updateUserFiles() {
|
|
|
401
372
|
return { success: false };
|
|
402
373
|
if (hasError)
|
|
403
374
|
return onError(err);
|
|
404
|
-
|
|
375
|
+
virtualFileExportsGlobalEntry = virtualFileExportsGlobalEntry.default || virtualFileExportsGlobalEntry;
|
|
405
376
|
if ((0, getVikeConfigError_js_1.getVikeConfigErrorBuild)()) {
|
|
406
377
|
return { success: false };
|
|
407
378
|
}
|
|
408
379
|
try {
|
|
409
|
-
await createGlobalContext(
|
|
380
|
+
await createGlobalContext(virtualFileExportsGlobalEntry);
|
|
410
381
|
}
|
|
411
382
|
catch (err_) {
|
|
412
383
|
hasError = true;
|
|
@@ -418,16 +389,21 @@ async function updateUserFiles() {
|
|
|
418
389
|
return onError(err);
|
|
419
390
|
return onSuccess();
|
|
420
391
|
}
|
|
421
|
-
async function createGlobalContext(
|
|
392
|
+
async function createGlobalContext(virtualFileExportsGlobalEntry) {
|
|
422
393
|
debug('createGlobalContext()');
|
|
423
394
|
(0, utils_js_1.assert)(!(0, getVikeConfigError_js_1.getVikeConfigErrorBuild)());
|
|
424
|
-
const
|
|
395
|
+
const globalContextPromise = (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExportsGlobalEntry, globalObject, addGlobalContext, addGlobalContextTmp, addGlobalContextAsync);
|
|
396
|
+
debug('createGlobalContext() - done [sync]');
|
|
397
|
+
// We define an early globalContext version synchronously, so that getGlobalContextSync() can be called early.
|
|
398
|
+
// - Required by vike-vercel
|
|
399
|
+
(0, utils_js_1.assert)(globalObject.globalContext);
|
|
400
|
+
const globalContext = await globalContextPromise;
|
|
401
|
+
debug('createGlobalContext() - done [async]');
|
|
425
402
|
(0, assertV1Design_js_1.assertV1Design)(
|
|
426
403
|
// pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
|
|
427
404
|
globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
|
|
428
405
|
assertGlobalContextIsDefined();
|
|
429
406
|
(0, utils_js_1.onSetupRuntime)();
|
|
430
|
-
debug('createGlobalContext() - done');
|
|
431
407
|
// Never actually used, only used for TypeScript `ReturnType<typeof createGlobalContext>`
|
|
432
408
|
return globalContext;
|
|
433
409
|
}
|
|
@@ -447,8 +423,8 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
447
423
|
_pageRoutes: pageRoutes,
|
|
448
424
|
_onBeforeRouteHook: onBeforeRouteHook,
|
|
449
425
|
};
|
|
450
|
-
const { viteDevServer, viteConfig, isPrerendering
|
|
451
|
-
|
|
426
|
+
const { viteDevServer, viteConfig, isPrerendering } = globalObject;
|
|
427
|
+
const isProduction = isProd();
|
|
452
428
|
if (!isProduction) {
|
|
453
429
|
(0, utils_js_1.assert)(globalContext); // main common requirement
|
|
454
430
|
(0, utils_js_1.assert)(!isPrerendering);
|
|
@@ -462,7 +438,7 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
462
438
|
};
|
|
463
439
|
}
|
|
464
440
|
else {
|
|
465
|
-
(0, utils_js_1.assert)(globalObject.
|
|
441
|
+
(0, utils_js_1.assert)(globalObject.prodBuildEntry);
|
|
466
442
|
(0, utils_js_1.assert)(globalContext); // main common requiement
|
|
467
443
|
const { buildInfo, assetsManifest } = globalObject;
|
|
468
444
|
(0, utils_js_1.assert)(buildInfo);
|
|
@@ -500,8 +476,8 @@ async function addGlobalContextAsync(globalContext) {
|
|
|
500
476
|
}
|
|
501
477
|
else {
|
|
502
478
|
(0, utils_js_1.assert)(!isProcessSharedWithVite()); // process shared with Vite => globalObject.viteConfigRuntime should be set
|
|
503
|
-
(0, utils_js_1.assert)(!
|
|
504
|
-
(0, utils_js_1.assert)(isNonRunnableDev());
|
|
479
|
+
(0, utils_js_1.assert)(!isProd()); // production => globalObject.buildInfo.viteConfigRuntime should be set
|
|
480
|
+
(0, utils_js_1.assert)((0, utils_js_1.isNonRunnableDev)());
|
|
505
481
|
const rpc = (0, utils_js_1.getViteRPC)();
|
|
506
482
|
viteConfigRuntime = await rpc.getViteConfigRuntimeRPC();
|
|
507
483
|
}
|
|
@@ -514,13 +490,12 @@ async function addGlobalContextAsync(globalContext) {
|
|
|
514
490
|
}
|
|
515
491
|
function clearGlobalContext() {
|
|
516
492
|
debug('clearGlobalContext()');
|
|
517
|
-
(0, utils_js_1.objectReplace)(globalObject, getInitialGlobalObject(), ['
|
|
493
|
+
(0, utils_js_1.objectReplace)(globalObject, getInitialGlobalObject(), ['prodBuildEntryPrevious']);
|
|
518
494
|
}
|
|
519
495
|
function getInitialGlobalObject() {
|
|
520
496
|
debug('getInitialGlobalObject()');
|
|
521
497
|
const { promise: viteDevServerPromise, resolve: viteDevServerPromiseResolve } = (0, utils_js_1.genPromise)();
|
|
522
498
|
return {
|
|
523
|
-
isProduction: isNonRunnableDev() ? false : undefined,
|
|
524
499
|
viteDevServerPromise,
|
|
525
500
|
viteDevServerPromiseResolve,
|
|
526
501
|
};
|
|
@@ -534,7 +509,7 @@ function resolveBaseRuntime(viteConfigRuntime, config) {
|
|
|
534
509
|
function isProcessSharedWithVite() {
|
|
535
510
|
const yes = globalThis.__VIKE__IS_PROCESS_SHARED_WITH_VITE ?? false;
|
|
536
511
|
if (yes)
|
|
537
|
-
(0, utils_js_1.assert)(!isNonRunnableDev());
|
|
512
|
+
(0, utils_js_1.assert)(!(0, utils_js_1.isNonRunnableDev)());
|
|
538
513
|
return yes;
|
|
539
514
|
}
|
|
540
515
|
function isRunnable(viteDevServer) {
|
|
@@ -544,13 +519,54 @@ function isRunnable(viteDevServer) {
|
|
|
544
519
|
// Vite 6 or above
|
|
545
520
|
(0, utils_js_1.isRunnableDevEnvironment)(viteDevServer.environments.ssr);
|
|
546
521
|
if (yes)
|
|
547
|
-
(0, utils_js_1.assert)(!isNonRunnableDev());
|
|
522
|
+
(0, utils_js_1.assert)(!(0, utils_js_1.isNonRunnableDev)());
|
|
548
523
|
return yes;
|
|
549
524
|
}
|
|
550
|
-
function
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
525
|
+
function isProd() {
|
|
526
|
+
const isProduction = isProdOptional();
|
|
527
|
+
if (isProduction === null) {
|
|
528
|
+
if (globalObject.isAfterFirstRenderPageCall) {
|
|
529
|
+
// 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.
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
(0, utils_js_1.assert)(false);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return isProduction;
|
|
537
|
+
}
|
|
538
|
+
function isProdOptional() {
|
|
539
|
+
const vikeApiOperation = (0, context_js_1.getVikeApiOperation)()?.operation ?? null;
|
|
540
|
+
const yes =
|
|
541
|
+
// setGlobalContext_prodBuildEntry() was called
|
|
542
|
+
!!globalObject.prodBuildEntry ||
|
|
543
|
+
globalObject.isPrerendering === true ||
|
|
544
|
+
// Vike CLI & Vike API
|
|
545
|
+
(!!vikeApiOperation && vikeApiOperation !== 'dev') ||
|
|
546
|
+
// Vite command
|
|
547
|
+
globalObject.isProductionAccordingToVite === true ||
|
|
548
|
+
// getGlobalContextAsync(isProduction)
|
|
549
|
+
globalObject.isProductionAccordingToUser === true ||
|
|
550
|
+
// vite-plugin-vercel
|
|
551
|
+
globalObject.isProductionAccordingToPhotonVercel === true;
|
|
554
552
|
(0, utils_js_1.assert)(typeof yes === 'boolean');
|
|
555
|
-
|
|
553
|
+
const no = !!globalObject.viteDevServer ||
|
|
554
|
+
// Vike CLI & Vike API
|
|
555
|
+
vikeApiOperation === 'dev' ||
|
|
556
|
+
// Vite command
|
|
557
|
+
globalObject.isProductionAccordingToVite === false ||
|
|
558
|
+
// getGlobalContextAsync(isProduction)
|
|
559
|
+
globalObject.isProductionAccordingToUser === false ||
|
|
560
|
+
// @cloudflare/vite-plugin
|
|
561
|
+
(0, utils_js_1.isNonRunnableDev)() === true;
|
|
562
|
+
(0, utils_js_1.assert)(typeof no === 'boolean');
|
|
563
|
+
if (yes) {
|
|
564
|
+
(0, utils_js_1.assert)(no === false);
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
if (no) {
|
|
568
|
+
(0, utils_js_1.assert)(yes === false);
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
return null;
|
|
556
572
|
}
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getHtmlTags = getHtmlTags;
|
|
7
|
-
const isFontFallback_js_1 = require("../../renderPage/isFontFallback.js");
|
|
8
7
|
const utils_js_1 = require("../../utils.js");
|
|
9
8
|
const serializeContext_js_1 = require("../serializeContext.js");
|
|
10
9
|
const sanitizeJson_js_1 = require("./sanitizeJson.js");
|
|
@@ -15,6 +14,7 @@ const getConfigValueRuntime_js_1 = require("../../../../shared/page-configs/getC
|
|
|
15
14
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
16
15
|
const getConfigDefinedAt_js_1 = require("../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
17
16
|
const htmlElementIds_js_1 = require("../../../../shared/htmlElementIds.js");
|
|
17
|
+
const isFontFallback_js_1 = require("../../renderPage/isFontFallback.js");
|
|
18
18
|
const stamp = '__injectFilterEntry';
|
|
19
19
|
async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript, isStream) {
|
|
20
20
|
(0, utils_js_1.assert)([true, false].includes(pageContext._isHtmlOnly));
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.analyzePage = analyzePage;
|
|
4
4
|
const determineClientEntry_js_1 = require("../../../shared/getPageFiles/analyzePageClientSide/determineClientEntry.js");
|
|
5
5
|
const analyzePageClientSide_js_1 = require("../../../shared/getPageFiles/analyzePageClientSide.js");
|
|
6
|
-
const
|
|
6
|
+
const virtualFileId_js_1 = require("../../shared/virtualFileId.js");
|
|
7
7
|
const analyzeClientSide_js_1 = require("../../../shared/getPageFiles/analyzeClientSide.js");
|
|
8
8
|
const getConfigValueRuntime_js_1 = require("../../../shared/page-configs/getConfigValueRuntime.js");
|
|
9
|
-
|
|
9
|
+
function analyzePage(pageContext) {
|
|
10
|
+
const { pageId, _pageConfig: pageConfig, _globalContext: globalContext } = pageContext;
|
|
11
|
+
const { _pageFilesAll: pageFilesAll } = globalContext;
|
|
10
12
|
if (pageConfig) {
|
|
11
13
|
const { isClientRuntimeLoaded, isClientRouting } = (0, analyzeClientSide_js_1.analyzeClientSide)(pageConfig, pageFilesAll, pageId);
|
|
12
14
|
const clientEntries = [];
|
|
@@ -17,14 +19,14 @@ async function analyzePage(pageFilesAll, pageConfig, pageId, globalContext) {
|
|
|
17
19
|
clientEntries.push((0, determineClientEntry_js_1.getVikeClientEntry)(isClientRouting));
|
|
18
20
|
const clientDependencies = [];
|
|
19
21
|
clientDependencies.push({
|
|
20
|
-
id: (0,
|
|
22
|
+
id: (0, virtualFileId_js_1.generateVirtualFileId)({ type: 'page-entry', pageId: pageConfig.pageId, isForClientSide: true }),
|
|
21
23
|
onlyAssets: isClientRuntimeLoaded ? false : true,
|
|
22
24
|
eagerlyImported: false,
|
|
23
25
|
});
|
|
24
26
|
// In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
|
|
25
27
|
if (!globalContext._isProduction) {
|
|
26
28
|
clientDependencies.push({
|
|
27
|
-
id: (0,
|
|
29
|
+
id: (0, virtualFileId_js_1.generateVirtualFileId)({ type: 'page-entry', pageId: pageConfig.pageId, isForClientSide: false }),
|
|
28
30
|
onlyAssets: true,
|
|
29
31
|
eagerlyImported: false,
|
|
30
32
|
});
|
|
@@ -41,7 +41,7 @@ function createPageContextServerSide(pageContextInit, globalContext, args) {
|
|
|
41
41
|
(0, utils_js_1.objectAssign)(pageContextCreated, { headers });
|
|
42
42
|
}
|
|
43
43
|
const pageContextAugmented = (0, createPageContextShared_js_1.createPageContextShared)(pageContextCreated, globalContext._vikeConfigPublicGlobal);
|
|
44
|
-
(0, utils_js_1.
|
|
44
|
+
(0, utils_js_1.updateType)(pageContextCreated, pageContextAugmented);
|
|
45
45
|
return pageContextCreated;
|
|
46
46
|
}
|
|
47
47
|
function createPageContextServerSideWithoutGlobalContext(pageContextInit) {
|
|
@@ -58,17 +58,7 @@ function getRenderHook(pageContext) {
|
|
|
58
58
|
}
|
|
59
59
|
if (!hookFound) {
|
|
60
60
|
const hookName = pageContext._globalContext._pageConfigs.length > 0 ? 'onRenderHtml' : 'render';
|
|
61
|
-
(0, utils_js_1.assertUsage)(false,
|
|
62
|
-
`No ${hookName}() hook found, see https://vike.dev/${hookName}`,
|
|
63
|
-
/*
|
|
64
|
-
'See https://vike.dev/render-modes for more information.',
|
|
65
|
-
[
|
|
66
|
-
// 'Loaded config files (none of them define the onRenderHtml() hook):',
|
|
67
|
-
'Loaded server-side page files (none of them `export { render }`):',
|
|
68
|
-
...pageContext._pageFilePathsLoaded.map((f, i) => ` (${i + 1}): ${f}`)
|
|
69
|
-
].join('\n')
|
|
70
|
-
*/
|
|
71
|
-
].join(' '));
|
|
61
|
+
(0, utils_js_1.assertUsage)(false, `No ${hookName}() hook found, see https://vike.dev/${hookName}`);
|
|
72
62
|
}
|
|
73
63
|
return hookFound;
|
|
74
64
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getManifestEntry = getManifestEntry;
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
const
|
|
5
|
+
const virtualFileId_js_1 = require("../../../shared/virtualFileId.js");
|
|
6
6
|
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
7
7
|
function getManifestEntry(id, assetsManifest) {
|
|
8
8
|
const debugInfo = getDebugInfo(id, assetsManifest);
|
|
@@ -14,7 +14,8 @@ function getManifestEntry(id, assetsManifest) {
|
|
|
14
14
|
return { manifestEntry, manifestKey };
|
|
15
15
|
}
|
|
16
16
|
// Page code importer
|
|
17
|
-
|
|
17
|
+
const virtualFile = (0, virtualFileId_js_1.parseVirtualFileId)(id);
|
|
18
|
+
if (virtualFile && virtualFile.type === 'page-entry') {
|
|
18
19
|
{
|
|
19
20
|
const manifestKey = id;
|
|
20
21
|
const manifestEntry = assetsManifest[manifestKey];
|
|
@@ -24,9 +25,9 @@ function getManifestEntry(id, assetsManifest) {
|
|
|
24
25
|
}
|
|
25
26
|
// Workaround for what seems to be a Vite bug when process.cwd() !== config.root
|
|
26
27
|
// - Manifest key is:
|
|
27
|
-
// ../../virtual:vike:
|
|
28
|
+
// ../../virtual:vike:page-entry:client:/pages/index
|
|
28
29
|
// But it should be this instead:
|
|
29
|
-
// virtual:vike:
|
|
30
|
+
// virtual:vike:page-entry:client:/pages/index
|
|
30
31
|
// - This workaround was implemented to support Vitest running /tests/*
|
|
31
32
|
// - I don't know whether end users actually need this workaround? (I'm not sure what the bug actually is.)
|
|
32
33
|
const manifestKeyEnd = id;
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.retrievePageAssetsDev = retrievePageAssetsDev;
|
|
4
|
+
exports.setGetClientEntrySrcDev = setGetClientEntrySrcDev;
|
|
4
5
|
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
const
|
|
6
|
-
|
|
6
|
+
const virtualFileId_js_1 = require("../../../shared/virtualFileId.js");
|
|
7
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('getPageAssets/retrievePageAssetsDev.ts', {
|
|
8
|
+
// We cannot define getClientEntrySrcDev() in this file because it depends on utils/requireResolve.ts which isn't available in production
|
|
9
|
+
getClientEntrySrcDev: null,
|
|
10
|
+
});
|
|
11
|
+
async function retrievePageAssetsDev(viteDevServer, clientDependencies, clientEntries) {
|
|
12
|
+
const clientEntriesSrc = clientEntries.map((clientEntry) => globalObject.getClientEntrySrcDev(clientEntry, viteDevServer));
|
|
13
|
+
const assetUrls = await getAssetUrls(clientDependencies, viteDevServer);
|
|
14
|
+
return { clientEntriesSrc, assetUrls };
|
|
15
|
+
}
|
|
16
|
+
function setGetClientEntrySrcDev(getClientEntrySrcDev) {
|
|
17
|
+
globalObject.getClientEntrySrcDev = getClientEntrySrcDev;
|
|
18
|
+
}
|
|
19
|
+
async function getAssetUrls(clientDependencies, viteDevServer) {
|
|
7
20
|
const assetUrls = new Set();
|
|
8
21
|
await Promise.all(clientDependencies.map(async ({ id }) => {
|
|
9
22
|
if (id.startsWith('@@vike'))
|
|
10
23
|
return; // vike doesn't have any CSS
|
|
11
24
|
(0, utils_js_1.assert)(id);
|
|
12
|
-
|
|
25
|
+
const virtualFile = (0, virtualFileId_js_1.parseVirtualFileId)(id);
|
|
26
|
+
(0, utils_js_1.assert)(!virtualFile || virtualFile.type !== 'global-entry');
|
|
13
27
|
const { moduleGraph } = viteDevServer;
|
|
14
28
|
const [_, graphId] = await moduleGraph.resolveUrl(id);
|
|
15
29
|
(0, utils_js_1.assert)(graphId, { id });
|
|
@@ -36,8 +50,9 @@ function collectCss(mod, styleUrls, visitedModules, importer) {
|
|
|
36
50
|
if (visitedModules.has(mod.url))
|
|
37
51
|
return;
|
|
38
52
|
visitedModules.add(mod.url);
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
const virtualFile = (0, virtualFileId_js_1.parseVirtualFileId)(mod.id || mod.url);
|
|
54
|
+
if (virtualFile && virtualFile.type === 'global-entry')
|
|
55
|
+
return; // virtual:vike:global-entry:server dependency list includes all pages
|
|
41
56
|
if (isStyle(mod) && (!importer || !isStyle(importer))) {
|
|
42
57
|
if (mod.url.startsWith('/')) {
|
|
43
58
|
styleUrls.add(mod.url);
|