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
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
export { getHttpRequestAsyncStore };
|
|
10
10
|
export { installHttpRequestAsyncStore };
|
|
11
11
|
import { renderPage_addAsyncHookwrapper } from '../../runtime/renderPage.js';
|
|
12
|
-
import { assert, assertIsNotProductionRuntime, isObject, unique } from '../utils.js';
|
|
12
|
+
import { assert, assertIsNotProductionRuntime, getGlobalObject, isObject, unique } from '../utils.js';
|
|
13
13
|
import { getConfigBuildErrorFormatted } from './resolveVikeConfigInternal/transpileAndExecuteFile.js';
|
|
14
14
|
import { logErrorDebugNote } from './loggerNotProd.js';
|
|
15
15
|
import { isEquivalentErrorWithCodeSnippet } from './loggerNotProd/errorWithCodeSnippet.js';
|
|
16
16
|
import { isDeepStrictEqual } from 'node:util';
|
|
17
17
|
assertIsNotProductionRuntime();
|
|
18
|
-
|
|
18
|
+
const globalObject = getGlobalObject('getHttpRequestAsyncStore.ts', {
|
|
19
|
+
asyncLocalStorage: null,
|
|
20
|
+
});
|
|
19
21
|
async function installHttpRequestAsyncStore() {
|
|
20
22
|
let mod;
|
|
21
23
|
try {
|
|
@@ -24,9 +26,9 @@ async function installHttpRequestAsyncStore() {
|
|
|
24
26
|
catch {
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
|
-
asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
29
|
+
globalObject.asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
28
30
|
renderPage_addAsyncHookwrapper(async (httpRequestId, renderPage) => {
|
|
29
|
-
assert(asyncLocalStorage);
|
|
31
|
+
assert(globalObject.asyncLocalStorage);
|
|
30
32
|
const loggedErrors = new Set();
|
|
31
33
|
const markErrorAsLogged = (err) => {
|
|
32
34
|
loggedErrors.add(err);
|
|
@@ -49,15 +51,15 @@ async function installHttpRequestAsyncStore() {
|
|
|
49
51
|
shouldErrorBeSwallowed,
|
|
50
52
|
errorDebugNoteAlreadyShown: false,
|
|
51
53
|
};
|
|
52
|
-
const pageContextReturn = await asyncLocalStorage.run(store, renderPage);
|
|
54
|
+
const pageContextReturn = await globalObject.asyncLocalStorage.run(store, renderPage);
|
|
53
55
|
return { pageContextReturn };
|
|
54
56
|
});
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
59
|
function getHttpRequestAsyncStore() {
|
|
58
|
-
if (asyncLocalStorage === null)
|
|
60
|
+
if (globalObject.asyncLocalStorage === null)
|
|
59
61
|
return null;
|
|
60
|
-
const store = asyncLocalStorage.getStore();
|
|
62
|
+
const store = globalObject.asyncLocalStorage.getStore();
|
|
61
63
|
assert(store === undefined || isObject(store));
|
|
62
64
|
return store;
|
|
63
65
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getMagicString };
|
|
2
2
|
import MagicString from 'magic-string';
|
|
3
|
-
//
|
|
3
|
+
// Used everywhere instead of `new MagicString()` for consistent source map generation
|
|
4
4
|
function getMagicString(code, id) {
|
|
5
5
|
const magicString = new MagicString(code);
|
|
6
6
|
const getMagicStringResult = () => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
export type { OutDirs };
|
|
4
|
-
import type { UserConfig, ResolvedConfig
|
|
4
|
+
import type { UserConfig, ResolvedConfig } from 'vite';
|
|
5
|
+
import { type ViteEnv } from './isViteServerSide.js';
|
|
5
6
|
type OutDirs = {
|
|
6
7
|
/** Absolute path to `outDir` */
|
|
7
8
|
outDirRoot: string;
|
|
@@ -10,6 +11,6 @@ type OutDirs = {
|
|
|
10
11
|
/** Absolute path to `${outDir}/server` */
|
|
11
12
|
outDirServer: string;
|
|
12
13
|
};
|
|
13
|
-
declare function getOutDirs(configGlobal: ResolvedConfig, viteEnv
|
|
14
|
+
declare function getOutDirs(configGlobal: ResolvedConfig, viteEnv: ViteEnv | undefined): OutDirs;
|
|
14
15
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
15
|
-
declare function resolveOutDir(config: UserConfig,
|
|
16
|
+
declare function resolveOutDir(config: UserConfig, isServerSide: boolean): string;
|
|
@@ -2,27 +2,23 @@ export { getOutDirs };
|
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
import { assert, assertPosixPath, assertUsage, createDebugger, pathJoin, toPosixPath } from '../utils.js';
|
|
5
|
-
import {
|
|
5
|
+
import { isViteServerSide_viteEnvOptional } from './isViteServerSide.js';
|
|
6
6
|
const debug = createDebugger('vike:outDir');
|
|
7
7
|
function getOutDirs(configGlobal, viteEnv) {
|
|
8
|
-
const configEnv = viteEnv?.config ?? configGlobal;
|
|
9
8
|
debug('getOutDirs()', new Error().stack);
|
|
10
|
-
const outDir =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const outDir = getOutDirFromResolvedConfig(configGlobal, viteEnv);
|
|
10
|
+
assertOutDirResolved(outDir, configGlobal, viteEnv);
|
|
11
|
+
const outDirs = getOutDirsAll(outDir, configGlobal.root);
|
|
12
|
+
assertNormalization(outDirs.outDirRoot);
|
|
13
|
+
assertNormalization(outDirs.outDirClient);
|
|
14
|
+
assertNormalization(outDirs.outDirServer);
|
|
14
15
|
return outDirs;
|
|
15
16
|
}
|
|
16
17
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
17
|
-
function resolveOutDir(config,
|
|
18
|
-
debug('resolveOutDir()'
|
|
19
|
-
const isServerSide = isViteServerBuild(config) || isSSR;
|
|
20
|
-
debug('isServerSide', isServerSide);
|
|
18
|
+
function resolveOutDir(config, isServerSide) {
|
|
19
|
+
debug('resolveOutDir()');
|
|
21
20
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
22
21
|
debug('outDir', outDir);
|
|
23
|
-
/* outDir may already be resolved when using Telefunc + Vike (because both Telefunc and Vike use this logic)
|
|
24
|
-
assert(isOutDirRoot(outDir))
|
|
25
|
-
*/
|
|
26
22
|
const { outDirClient, outDirServer } = getOutDirsAll(outDir);
|
|
27
23
|
if (isServerSide) {
|
|
28
24
|
debug('outDirServer', 'outDirServer');
|
|
@@ -86,9 +82,9 @@ function getOutDirsAllFromRootNormalized(outDirRoot, root) {
|
|
|
86
82
|
}
|
|
87
83
|
function assertNormalization(outDirAny) {
|
|
88
84
|
assertPosixPath(outDirAny);
|
|
89
|
-
assert(outDirIsAbsolutePath(outDirAny));
|
|
90
|
-
assert(outDirAny.endsWith('/'));
|
|
91
|
-
assert(!outDirAny.endsWith('//'));
|
|
85
|
+
assert(outDirIsAbsolutePath(outDirAny), outDirAny);
|
|
86
|
+
assert(outDirAny.endsWith('/'), outDirAny);
|
|
87
|
+
assert(!outDirAny.endsWith('//'), outDirAny);
|
|
92
88
|
}
|
|
93
89
|
function isOutDirRoot(outDirRot) {
|
|
94
90
|
const p = outDirRot.split('/').filter(Boolean);
|
|
@@ -98,14 +94,17 @@ function isOutDirRoot(outDirRot) {
|
|
|
98
94
|
function assertIsNotOutDirRoot(outDir) {
|
|
99
95
|
assert(outDir.endsWith('/client') || outDir.endsWith('/server'));
|
|
100
96
|
}
|
|
101
|
-
/** Assert that `outDir` ends with `/server` or `/client` */
|
|
102
|
-
function assertOutDirResolved(outDir,
|
|
97
|
+
/** Assert that `outDir` ends with the correct directory `/server` or `/client` */
|
|
98
|
+
function assertOutDirResolved(outDir, configGlobal, viteEnv) {
|
|
103
99
|
assertPosixPath(outDir);
|
|
104
|
-
|
|
100
|
+
if (isOutDirRoot(outDir))
|
|
101
|
+
return;
|
|
102
|
+
assert(outDir.endsWith('/client') || outDir.endsWith('/server')); // we normalized outDir
|
|
105
103
|
assert('/client'.length === '/server'.length);
|
|
106
104
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
107
105
|
const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
|
|
108
|
-
|
|
106
|
+
const isServerSide = isViteServerSide_viteEnvOptional(configGlobal, viteEnv);
|
|
107
|
+
if (isServerSide) {
|
|
109
108
|
assertUsage(outDir.endsWith('/server'), wrongUsage);
|
|
110
109
|
}
|
|
111
110
|
else {
|
|
@@ -119,8 +118,8 @@ function getOutDirFromViteUserConfig(config) {
|
|
|
119
118
|
outDir = normalizeOutDir(outDir);
|
|
120
119
|
return outDir;
|
|
121
120
|
}
|
|
122
|
-
function
|
|
123
|
-
let outDir = config.build.outDir;
|
|
121
|
+
function getOutDirFromResolvedConfig(config, viteEnv) {
|
|
122
|
+
let outDir = viteEnv?.config.build?.outDir ?? config.build.outDir;
|
|
124
123
|
assert(outDir);
|
|
125
124
|
outDir = normalizeOutDir(outDir);
|
|
126
125
|
return outDir;
|
|
@@ -3,7 +3,7 @@ import { assert, assertFilePathAbsoluteFilesystem, hasProp } from '../utils.js';
|
|
|
3
3
|
import { getOutDirs } from './getOutDirs.js';
|
|
4
4
|
function getViteConfigRuntime(config) {
|
|
5
5
|
assert(hasProp(config, '_baseViteOriginal', 'string'));
|
|
6
|
-
const { outDirRoot } = getOutDirs(config);
|
|
6
|
+
const { outDirRoot } = getOutDirs(config, undefined);
|
|
7
7
|
assertFilePathAbsoluteFilesystem(outDirRoot);
|
|
8
8
|
const viteConfigRuntime = {
|
|
9
9
|
root: config.root,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { isViteServerSide };
|
|
2
|
+
export { isViteClientSide };
|
|
3
|
+
export { isViteServerSide_viteEnvOptional };
|
|
4
|
+
export { isViteServerSide_onlySsrEnv };
|
|
5
|
+
export { isViteServerSide_extraSafe };
|
|
6
|
+
export type { ViteEnv };
|
|
7
|
+
import type { Environment, EnvironmentOptions, ResolvedConfig, UserConfig } from 'vite';
|
|
8
|
+
type ViteEnv = {
|
|
9
|
+
name?: string;
|
|
10
|
+
config: EnvironmentOptions | Environment['config'];
|
|
11
|
+
};
|
|
12
|
+
declare function isViteServerSide(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
|
|
13
|
+
declare function isViteServerSide_viteEnvOptional(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv | undefined): boolean;
|
|
14
|
+
declare function isViteClientSide(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
15
|
+
declare function isViteServerSide_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
16
|
+
declare function isViteServerSide_extraSafe(config: ResolvedConfig, viteEnv: ViteEnv, options: {
|
|
17
|
+
ssr?: boolean;
|
|
18
|
+
} | undefined): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export { isViteServerSide };
|
|
2
|
+
export { isViteClientSide };
|
|
3
|
+
export { isViteServerSide_viteEnvOptional };
|
|
4
|
+
export { isViteServerSide_onlySsrEnv };
|
|
5
|
+
export { isViteServerSide_extraSafe };
|
|
6
|
+
import { assert } from '../../../utils/assert.js';
|
|
7
|
+
function isViteServerSide_impl(configGlobal, viteEnv) {
|
|
8
|
+
assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
9
|
+
const debug = {
|
|
10
|
+
viteEnvIsUndefined: !viteEnv,
|
|
11
|
+
viteEnvName: viteEnv?.name ?? null,
|
|
12
|
+
viteEnvConsumer: viteEnv?.config.consumer ?? null,
|
|
13
|
+
configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
|
|
14
|
+
configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
|
|
15
|
+
};
|
|
16
|
+
if (!viteEnv) {
|
|
17
|
+
const isServerSide = getBuildSsrValue(configGlobal.build?.ssr);
|
|
18
|
+
assert(typeof isServerSide === 'boolean', debug);
|
|
19
|
+
return isServerSide;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const isServerSide1 = !viteEnv.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
23
|
+
const isServerSide2 = getBuildSsrValue(viteEnv.config.build?.ssr);
|
|
24
|
+
const isServerSide3 = viteEnv.name === 'ssr' ? true : viteEnv.name === 'client' ? false : null;
|
|
25
|
+
const isServerSide = isServerSide1 ?? isServerSide2;
|
|
26
|
+
assert(isServerSide === isServerSide1 || isServerSide1 === null, debug);
|
|
27
|
+
assert(isServerSide === isServerSide2 || isServerSide2 === null, debug);
|
|
28
|
+
assert(isServerSide === isServerSide3 || isServerSide3 === null, debug);
|
|
29
|
+
assert(isServerSide !== null);
|
|
30
|
+
return isServerSide;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function getBuildSsrValue(buildSsr) {
|
|
34
|
+
if (buildSsr === undefined)
|
|
35
|
+
return null;
|
|
36
|
+
assert(typeof buildSsr === 'boolean' || typeof buildSsr === 'string');
|
|
37
|
+
return !!buildSsr;
|
|
38
|
+
}
|
|
39
|
+
function isViteServerSide(configGlobal, viteEnv) {
|
|
40
|
+
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
41
|
+
}
|
|
42
|
+
function isViteServerSide_viteEnvOptional(configGlobal, viteEnv) {
|
|
43
|
+
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
44
|
+
}
|
|
45
|
+
function isViteClientSide(configGlobal, viteEnv) {
|
|
46
|
+
return !isViteServerSide(configGlobal, viteEnv);
|
|
47
|
+
}
|
|
48
|
+
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
49
|
+
function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
|
|
50
|
+
return viteEnv.name ? viteEnv.name === 'ssr' : isViteServerSide(configGlobal, viteEnv);
|
|
51
|
+
}
|
|
52
|
+
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
53
|
+
function isViteServerSide_extraSafe(config, viteEnv, options) {
|
|
54
|
+
const isServerSide = isViteServerSide(config, viteEnv);
|
|
55
|
+
const debug = {
|
|
56
|
+
isServerSide,
|
|
57
|
+
configCommand: config.command,
|
|
58
|
+
configBuildSsr: getBuildSsrValue(config.build.ssr),
|
|
59
|
+
optionsIsUndefined: options === undefined,
|
|
60
|
+
optionsSsr: options?.ssr ?? null,
|
|
61
|
+
};
|
|
62
|
+
assert(options, debug);
|
|
63
|
+
assert(typeof options.ssr === 'boolean', debug);
|
|
64
|
+
assert(options.ssr === isServerSide, debug);
|
|
65
|
+
return isServerSide;
|
|
66
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { removeSuperfluousViteLog };
|
|
2
2
|
export { removeSuperfluousViteLog_enable };
|
|
3
3
|
export { removeSuperfluousViteLog_disable };
|
|
4
|
-
import { assert } from '../../utils.js';
|
|
4
|
+
import { assert, getGlobalObject } from '../../utils.js';
|
|
5
|
+
const globalObject = getGlobalObject('removeSuperfluousViteLog.ts', {
|
|
6
|
+
enabled: false,
|
|
7
|
+
});
|
|
5
8
|
const superfluousLog = 'Forced re-optimization of dependencies';
|
|
6
|
-
let enabled = false;
|
|
7
9
|
function removeSuperfluousViteLog(msg) {
|
|
8
|
-
if (!enabled) {
|
|
10
|
+
if (!globalObject.enabled) {
|
|
9
11
|
return false;
|
|
10
12
|
}
|
|
11
13
|
if (msg.toLowerCase().includes('forced') && msg.toLowerCase().includes('optimization')) {
|
|
@@ -15,8 +17,8 @@ function removeSuperfluousViteLog(msg) {
|
|
|
15
17
|
return false;
|
|
16
18
|
}
|
|
17
19
|
function removeSuperfluousViteLog_enable() {
|
|
18
|
-
enabled = true;
|
|
20
|
+
globalObject.enabled = true;
|
|
19
21
|
}
|
|
20
22
|
function removeSuperfluousViteLog_disable() {
|
|
21
|
-
enabled = false;
|
|
23
|
+
globalObject.enabled = false;
|
|
22
24
|
}
|
|
@@ -31,7 +31,7 @@ function intercept(logType, config) {
|
|
|
31
31
|
// We swallow Vite's message: we didn't see it add any value so far.
|
|
32
32
|
// - It can even be confusing, such as the following:
|
|
33
33
|
// ```
|
|
34
|
-
// Error when evaluating SSR module virtual:vike:
|
|
34
|
+
// Error when evaluating SSR module virtual:vike:page-entry:server:/pages/abort: failed to import "/pages/abort/+Page.mdx"
|
|
35
35
|
// ```
|
|
36
36
|
assert(!isErrorDebug());
|
|
37
37
|
return;
|
|
@@ -4,9 +4,10 @@ export type { ConfigDefinitions };
|
|
|
4
4
|
export type { ConfigDefinitionsInternal };
|
|
5
5
|
export type { ConfigDefinitionInternal };
|
|
6
6
|
export type { ConfigEffect };
|
|
7
|
-
import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath
|
|
7
|
+
import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath } from '../../../../types/PageConfig.js';
|
|
8
8
|
import type { Config, ConfigNameBuiltIn, ConfigNameGlobal } from '../../../../types/Config.js';
|
|
9
9
|
import { type ConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
10
|
+
import type { PageConfigBuildTimeBeforeComputed } from '../resolveVikeConfigInternal.js';
|
|
10
11
|
/** The meta definition of a config.
|
|
11
12
|
*
|
|
12
13
|
* https://vike.dev/meta
|
|
@@ -75,7 +76,7 @@ type ConfigEffect = (config: {
|
|
|
75
76
|
}) => Config | undefined;
|
|
76
77
|
/** For Vike internal use */
|
|
77
78
|
type ConfigDefinitionInternal = Omit<ConfigDefinition_, 'env'> & {
|
|
78
|
-
_computed?: (pageConfig:
|
|
79
|
+
_computed?: (pageConfig: PageConfigBuildTimeBeforeComputed) => unknown;
|
|
79
80
|
_valueIsFilePath?: true;
|
|
80
81
|
_userEffectDefinedAtFilePath?: DefinedAtFilePath;
|
|
81
82
|
env: ConfigEnvInternal;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { configDefinitionsBuiltIn };
|
|
2
2
|
import { assert, assertUsage } from '../../utils.js';
|
|
3
3
|
import { getConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
4
|
-
import { getConfigValueSourcesRelevant } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
4
|
+
import { getConfigValueSourceRelevantAnyEnv, getConfigValueSourcesRelevant, isConfigSourceValueNull, } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
5
5
|
const configDefinitionsBuiltIn = {
|
|
6
6
|
onRenderHtml: {
|
|
7
7
|
env: { server: true },
|
|
@@ -108,7 +108,9 @@ const configDefinitionsBuiltIn = {
|
|
|
108
108
|
}, pageConfig))
|
|
109
109
|
.flat(1)
|
|
110
110
|
// Server-only
|
|
111
|
-
.filter((source) => !source.configEnv.client)
|
|
111
|
+
.filter((source) => !source.configEnv.client)
|
|
112
|
+
// Config value isn't `null`
|
|
113
|
+
.filter((source) => !isConfigSourceValueNull(source));
|
|
112
114
|
return sources.length > 0;
|
|
113
115
|
},
|
|
114
116
|
},
|
|
@@ -120,22 +122,19 @@ const configDefinitionsBuiltIn = {
|
|
|
120
122
|
env: { server: true, client: true },
|
|
121
123
|
eager: true,
|
|
122
124
|
_computed: (pageConfig) => {
|
|
123
|
-
const { configValueSources } = pageConfig;
|
|
124
125
|
{
|
|
125
|
-
const source =
|
|
126
|
+
const source = getConfigValueSourceRelevantAnyEnv('clientHooks', pageConfig);
|
|
126
127
|
if (source) {
|
|
127
128
|
assert(source.valueIsLoaded);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
129
|
+
const { value, definedAt } = source;
|
|
130
|
+
const configDefinedAt = getConfigDefinedAt('Config', 'clientHooks', definedAt);
|
|
131
|
+
assertUsage(typeof value === 'boolean', `${configDefinedAt} should be a boolean`);
|
|
132
|
+
return value;
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
|
-
return (isConfigSet(
|
|
137
|
-
isConfigSet(
|
|
138
|
-
!!getConfigEnv(
|
|
135
|
+
return (isConfigSet(pageConfig, 'onRenderClient') &&
|
|
136
|
+
isConfigSet(pageConfig, 'Page') &&
|
|
137
|
+
!!getConfigEnv(pageConfig, 'Page')?.client);
|
|
139
138
|
},
|
|
140
139
|
},
|
|
141
140
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -143,10 +142,7 @@ const configDefinitionsBuiltIn = {
|
|
|
143
142
|
env: { client: true },
|
|
144
143
|
eager: true,
|
|
145
144
|
_computed: (pageConfig) => {
|
|
146
|
-
|
|
147
|
-
return !isConfigSet(configValueSources, 'onBeforeRender')
|
|
148
|
-
? null
|
|
149
|
-
: getConfigEnv(configValueSources, 'onBeforeRender');
|
|
145
|
+
return !isConfigSet(pageConfig, 'onBeforeRender') ? null : getConfigEnv(pageConfig, 'onBeforeRender');
|
|
150
146
|
},
|
|
151
147
|
},
|
|
152
148
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -154,8 +150,7 @@ const configDefinitionsBuiltIn = {
|
|
|
154
150
|
env: { client: true },
|
|
155
151
|
eager: true,
|
|
156
152
|
_computed: (pageConfig) => {
|
|
157
|
-
|
|
158
|
-
return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
|
|
153
|
+
return !isConfigSet(pageConfig, 'data') ? null : getConfigEnv(pageConfig, 'data');
|
|
159
154
|
},
|
|
160
155
|
},
|
|
161
156
|
hooksTimeout: {
|
|
@@ -243,11 +238,11 @@ const configDefinitionsBuiltIn = {
|
|
|
243
238
|
cumulative: true,
|
|
244
239
|
},
|
|
245
240
|
};
|
|
246
|
-
function getConfigEnv(
|
|
247
|
-
const
|
|
248
|
-
if (!
|
|
241
|
+
function getConfigEnv(pageConfig, configName) {
|
|
242
|
+
const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
|
|
243
|
+
if (!source)
|
|
249
244
|
return null;
|
|
250
|
-
const { configEnv } =
|
|
245
|
+
const { configEnv } = source;
|
|
251
246
|
const env = {};
|
|
252
247
|
if (configEnv.client)
|
|
253
248
|
env.client = true;
|
|
@@ -255,18 +250,7 @@ function getConfigEnv(configValueSources, configName) {
|
|
|
255
250
|
env.server = true;
|
|
256
251
|
return env;
|
|
257
252
|
}
|
|
258
|
-
function isConfigSet(
|
|
259
|
-
const source =
|
|
260
|
-
return
|
|
261
|
-
!(source.valueIsLoaded &&
|
|
262
|
-
// Enable users to suppress inherited config by overriding it with `null`
|
|
263
|
-
source.value === null));
|
|
264
|
-
}
|
|
265
|
-
function getConfigValueSource(configValueSources, configName) {
|
|
266
|
-
const sources = configValueSources[configName];
|
|
267
|
-
if (!sources)
|
|
268
|
-
return null;
|
|
269
|
-
const configValueSource = sources[0];
|
|
270
|
-
assert(configValueSource);
|
|
271
|
-
return configValueSource;
|
|
253
|
+
function isConfigSet(pageConfig, configName) {
|
|
254
|
+
const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
|
|
255
|
+
return !!source;
|
|
272
256
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
2
|
export { isPlusFile };
|
|
3
3
|
export { getPlusFileValueConfigName };
|
|
4
|
-
import { assertPosixPath, assert, scriptFileExtensionPattern,
|
|
4
|
+
import { assertPosixPath, assert, scriptFileExtensionPattern, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList, createDebugger, deepEqual, assertUsage, assertFilePathAbsoluteFilesystem, assertWarning, hasProp, isNotNullish, getGlobalObject, } from '../../utils.js';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { glob } from 'tinyglobby';
|
|
7
7
|
import { exec } from 'node:child_process';
|
|
@@ -14,8 +14,9 @@ import { ignorePatternsBuiltIn } from './crawlPlusFiles/ignorePatternsBuiltIn.js
|
|
|
14
14
|
const execA = promisify(exec);
|
|
15
15
|
const debug = createDebugger('vike:crawl');
|
|
16
16
|
assertIsNotProductionRuntime();
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const globalObject = getGlobalObject('getVikeConfig/crawlPlusFiles.ts', {
|
|
18
|
+
gitIsNotUsable: false,
|
|
19
|
+
});
|
|
19
20
|
async function crawlPlusFiles(userRootDir) {
|
|
20
21
|
assertPosixPath(userRootDir);
|
|
21
22
|
assertFilePathAbsoluteFilesystem(userRootDir);
|
|
@@ -48,7 +49,7 @@ async function crawlPlusFiles(userRootDir) {
|
|
|
48
49
|
}
|
|
49
50
|
// Same as tinyglobby() but using `$ git ls-files`
|
|
50
51
|
async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
51
|
-
if (gitIsNotUsable)
|
|
52
|
+
if (globalObject.gitIsNotUsable)
|
|
52
53
|
return null;
|
|
53
54
|
// Preserve UTF-8 file paths.
|
|
54
55
|
// https://github.com/vikejs/vike/issues/1658
|
|
@@ -82,7 +83,7 @@ async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
|
82
83
|
}
|
|
83
84
|
catch (err) {
|
|
84
85
|
if (await isGitNotUsable(userRootDir)) {
|
|
85
|
-
gitIsNotUsable = true;
|
|
86
|
+
globalObject.gitIsNotUsable = true;
|
|
86
87
|
return null;
|
|
87
88
|
}
|
|
88
89
|
throw err;
|
|
@@ -8,11 +8,12 @@ export { getConfVal };
|
|
|
8
8
|
export { getConfigDefinitionOptional };
|
|
9
9
|
export { getVikeConfigFromCliOrEnv };
|
|
10
10
|
export type { VikeConfigInternal };
|
|
11
|
+
export type { PageConfigBuildTimeBeforeComputed };
|
|
11
12
|
export { getVikeConfig };
|
|
12
13
|
export type { VikeConfig };
|
|
13
14
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../types/PageConfig.js';
|
|
14
15
|
import { type ConfigDefinitionsInternal, type ConfigDefinitionInternal } from './resolveVikeConfigInternal/configDefinitionsBuiltIn.js';
|
|
15
|
-
import { type VikeConfigPublicGlobal, type
|
|
16
|
+
import { type VikeConfigPublicGlobal, type VikeConfigPublicPageEagerLoaded } from '../../../shared/page-configs/resolveVikeConfigPublic.js';
|
|
16
17
|
import { type PlusFile } from './resolveVikeConfigInternal/getPlusFilesAll.js';
|
|
17
18
|
import type { PrerenderContextPublic } from '../../prerender/runPrerender.js';
|
|
18
19
|
import type { ResolvedConfig, UserConfig } from 'vite';
|
|
@@ -33,7 +34,7 @@ type VikeConfigInternal = {
|
|
|
33
34
|
config: VikeConfigPublicGlobal['config'];
|
|
34
35
|
_from: VikeConfigPublicGlobal['_from'];
|
|
35
36
|
pages: Record<string, // pageId
|
|
36
|
-
|
|
37
|
+
VikeConfigPublicPageEagerLoaded>;
|
|
37
38
|
_vikeConfigDependencies: Set<string>;
|
|
38
39
|
prerenderContext: PrerenderContext;
|
|
39
40
|
};
|
|
@@ -57,6 +58,7 @@ declare function getVikeConfigFromCliOrEnv(): {
|
|
|
57
58
|
configFromCliOptions: import("../../cli/parseCli.js").CliOptions | null;
|
|
58
59
|
configFromEnvVar: Record<string, unknown> | null;
|
|
59
60
|
};
|
|
61
|
+
type PageConfigBuildTimeBeforeComputed = Omit<PageConfigBuildTime, 'configValuesComputed'>;
|
|
60
62
|
declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitionsInternal, configName: string): ConfigDefinitionInternal | null;
|
|
61
63
|
declare function getConfVal(plusFile: PlusFile, configName: string): null | {
|
|
62
64
|
value: unknown;
|