vike 0.4.237 → 0.4.238-commit-3c1a09d
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/csp.js +46 -0
- package/dist/cjs/node/runtime/globalContext.js +128 -112
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +11 -8
- package/dist/cjs/node/runtime/html/injectAssets/inferHtmlTags.js +5 -2
- package/dist/cjs/node/runtime/html/injectAssets/mergeScriptTags.js +4 -2
- 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 +57 -50
- 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 +23 -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 +10 -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 +14 -303
- package/dist/esm/node/prerender/runPrerender.js +8 -9
- package/dist/esm/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/esm/node/runtime/csp.d.ts +12 -0
- package/dist/esm/node/runtime/csp.js +44 -0
- 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 +11 -8
- package/dist/esm/node/runtime/html/injectAssets/inferHtmlTags.d.ts +2 -1
- package/dist/esm/node/runtime/html/injectAssets/inferHtmlTags.js +5 -2
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +2 -1
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.js +4 -2
- package/dist/esm/node/runtime/html/serializeContext.d.ts +2 -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 +108 -20
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +59 -52
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/{renderPageAlreadyRouted.d.ts → renderPageAfterRoute.d.ts} +30 -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 +24 -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 +10 -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 +13 -9
- package/dist/esm/types/PageConfig.d.ts +11 -9
- package/dist/esm/types/PageContext.d.ts +6 -0
- 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
|
@@ -1,30 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConfigValueSourcesRelevant = getConfigValueSourcesRelevant;
|
|
4
|
+
exports.getConfigValueSourceRelevantAnyEnv = getConfigValueSourceRelevantAnyEnv;
|
|
4
5
|
exports.isRuntimeEnvMatch = isRuntimeEnvMatch;
|
|
6
|
+
exports.isConfigSourceValueNull = isConfigSourceValueNull;
|
|
5
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
|
+
(0, utils_js_1.assertIsNotBrowser)();
|
|
6
9
|
function getConfigValueSourcesRelevant(configName, runtimeEnv, pageConfig) {
|
|
7
10
|
const configDef = pageConfig.configDefinitions[configName];
|
|
8
11
|
(0, utils_js_1.assert)(configDef);
|
|
9
12
|
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
10
13
|
if (!sourcesRelevant)
|
|
11
14
|
return [];
|
|
12
|
-
|
|
15
|
+
// Ignore configs with value `undefined`
|
|
16
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
|
|
17
|
+
// Environment filtering
|
|
18
|
+
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
19
|
+
// Overriding - non-cumulative configs
|
|
20
|
+
if (!configDef.cumulative && sourcesRelevant.length > 1) {
|
|
13
21
|
const source = sourcesRelevant[0];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
(0, utils_js_1.assert)(sourcesRelevant.length === 0);
|
|
19
|
-
}
|
|
22
|
+
(0, utils_js_1.assert)(source);
|
|
23
|
+
sourcesRelevant = [source];
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
sourcesRelevant = sourcesRelevant
|
|
25
|
+
// Overriding - cumulative configs
|
|
26
|
+
if (configDef.cumulative && sourcesRelevant.length > 0) {
|
|
27
|
+
sourcesRelevant = applyFilenameSuffix(sourcesRelevant);
|
|
24
28
|
}
|
|
25
|
-
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
26
29
|
return sourcesRelevant;
|
|
27
30
|
}
|
|
31
|
+
function getConfigValueSourceRelevantAnyEnv(configName, pageConfig) {
|
|
32
|
+
const configDef = pageConfig.configDefinitions[configName];
|
|
33
|
+
(0, utils_js_1.assert)(configDef);
|
|
34
|
+
(0, utils_js_1.assert)(!configDef.cumulative); // So far, this function is only used by non-cumulative configs
|
|
35
|
+
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
36
|
+
if (!sourcesRelevant)
|
|
37
|
+
return null;
|
|
38
|
+
// Ignore configs with value `undefined`
|
|
39
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
|
|
40
|
+
const source = sourcesRelevant[0];
|
|
41
|
+
if (!source)
|
|
42
|
+
return null;
|
|
43
|
+
if (isConfigSourceValueNull(source))
|
|
44
|
+
return null;
|
|
45
|
+
return source;
|
|
46
|
+
}
|
|
28
47
|
function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
29
48
|
if ('isForConfig' in runtimeEnv)
|
|
30
49
|
return !!configEnv.config;
|
|
@@ -54,14 +73,25 @@ function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
|
54
73
|
}
|
|
55
74
|
return true;
|
|
56
75
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
(
|
|
66
|
-
|
|
76
|
+
// Setting a config to `undefined` should be equivalent to not setting it at all
|
|
77
|
+
function isConfigSourceValueUndefined(source) {
|
|
78
|
+
if (!source.valueIsLoaded)
|
|
79
|
+
return null;
|
|
80
|
+
return source.value === undefined;
|
|
81
|
+
}
|
|
82
|
+
// Setting a config to `null` enables the user to suppress inherited config by overriding it with `null` (this only works when setting the config value to `null` inside a +config.js file — it doesn't work when setting the config value to `null` with a +{configName}.js file).
|
|
83
|
+
function isConfigSourceValueNull(source) {
|
|
84
|
+
if (!source.valueIsLoaded)
|
|
85
|
+
return null;
|
|
86
|
+
return source.value === null;
|
|
87
|
+
}
|
|
88
|
+
function applyFilenameSuffix(sourcesRelevant) {
|
|
89
|
+
const getFileName = (source) => source.plusFile?.filePath.fileName ?? '';
|
|
90
|
+
// Apply `clear`: truncate at first clear file
|
|
91
|
+
const clearIndex = sourcesRelevant.findIndex((source) => getFileName(source).includes('.clear.'));
|
|
92
|
+
if (clearIndex !== -1)
|
|
93
|
+
sourcesRelevant = sourcesRelevant.slice(0, clearIndex + 1);
|
|
94
|
+
// Apply `default`: exclude defaults if any non-defaults exist, otherwise keep only first default
|
|
95
|
+
const nonDefaults = sourcesRelevant.filter((source) => !getFileName(source).includes('.default.'));
|
|
96
|
+
return nonDefaults.length > 0 ? nonDefaults : sourcesRelevant.slice(0, 1);
|
|
67
97
|
}
|
|
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.pluginVirtualFiles = pluginVirtualFiles;
|
|
7
7
|
const vite_1 = require("vite");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const generateVirtualFilePageEntry_js_1 = require("./pluginVirtualFiles/generateVirtualFilePageEntry.js");
|
|
9
|
+
const generateVirtualFileGlobalEntryWithOldDesign_js_1 = require("./pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js");
|
|
10
10
|
const utils_js_1 = require("../utils.js");
|
|
11
|
-
const
|
|
12
|
-
const virtualFileEntry_js_1 = require("../../shared/virtualFiles/virtualFileEntry.js");
|
|
11
|
+
const virtualFileId_js_1 = require("../../shared/virtualFileId.js");
|
|
13
12
|
const resolveVikeConfigInternal_js_1 = require("../shared/resolveVikeConfigInternal.js");
|
|
14
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
14
|
const loggerNotProd_js_1 = require("../shared/loggerNotProd.js");
|
|
@@ -49,13 +48,16 @@ function pluginVirtualFiles() {
|
|
|
49
48
|
id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
|
|
50
49
|
const isDev = config._isDev;
|
|
51
50
|
(0, utils_js_1.assert)(typeof isDev === 'boolean');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
const idParsed = (0, virtualFileId_js_1.parseVirtualFileId)(id);
|
|
52
|
+
if (idParsed) {
|
|
53
|
+
if (idParsed.type === 'page-entry') {
|
|
54
|
+
const code = await (0, generateVirtualFilePageEntry_js_1.generateVirtualFilePageEntry)(id, isDev);
|
|
55
|
+
return code;
|
|
56
|
+
}
|
|
57
|
+
if (idParsed.type === 'global-entry') {
|
|
58
|
+
const code = await (0, generateVirtualFileGlobalEntryWithOldDesign_js_1.generateVirtualFileGlobalEntryWithOldDesign)(id, options, config, this.environment, isDev);
|
|
59
|
+
return code;
|
|
60
|
+
}
|
|
59
61
|
}
|
|
60
62
|
},
|
|
61
63
|
configureServer(server) {
|
|
@@ -168,7 +170,7 @@ function reloadConfig(filePath, config, op, server) {
|
|
|
168
170
|
}
|
|
169
171
|
function getVikeVirtualFiles(server) {
|
|
170
172
|
const vikeVirtualFiles = Array.from(server.moduleGraph.urlToModuleMap.keys())
|
|
171
|
-
.filter((url) => (0,
|
|
173
|
+
.filter((url) => (0, virtualFileId_js_1.parseVirtualFileId)(url))
|
|
172
174
|
.map((url) => {
|
|
173
175
|
const mod = server.moduleGraph.urlToModuleMap.get(url);
|
|
174
176
|
(0, utils_js_1.assert)(mod);
|
|
@@ -10,7 +10,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
10
10
|
const getOutDirs_js_1 = require("./getOutDirs.js");
|
|
11
11
|
async function findPageFiles(config, fileTypes, isDev) {
|
|
12
12
|
const cwd = config.root;
|
|
13
|
-
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
13
|
+
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config, undefined);
|
|
14
14
|
const timeBase = new Date().getTime();
|
|
15
15
|
let pageFiles = await (0, tinyglobby_1.glob)(fileTypes.map((fileType) => `**/*${fileType}.${utils_js_1.scriptFileExtensionPattern}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false, expandDirectories: false });
|
|
16
16
|
pageFiles = pageFiles.map((p) => '/' + (0, utils_js_1.toPosixPath)(p));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getClientEntrySrcDev = getClientEntrySrcDev;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
6
|
-
function
|
|
6
|
+
function getClientEntrySrcDev(clientEntry, viteDevServer) {
|
|
7
7
|
let userRootDir = viteDevServer.config.root;
|
|
8
8
|
(0, utils_js_1.assert)(userRootDir);
|
|
9
9
|
userRootDir = (0, utils_js_1.toPosixPath)(userRootDir);
|
|
@@ -25,7 +25,7 @@ function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
25
25
|
else {
|
|
26
26
|
if (clientEntry.startsWith('@@vike/')) {
|
|
27
27
|
(0, utils_js_1.assert)(clientEntry.endsWith('.js'));
|
|
28
|
-
filePath = (0, utils_js_1.
|
|
28
|
+
filePath = (0, utils_js_1.requireResolveDistFile)(`dist/esm/${clientEntry.replace('@@vike/dist/esm/', '')}`);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
(0, utils_js_1.assertIsImportPathNpmPackage)(clientEntry);
|
|
@@ -45,7 +45,9 @@ const loggerNotProd_js_1 = require("./loggerNotProd.js");
|
|
|
45
45
|
const errorWithCodeSnippet_js_1 = require("./loggerNotProd/errorWithCodeSnippet.js");
|
|
46
46
|
const node_util_1 = require("node:util");
|
|
47
47
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
48
|
-
|
|
48
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('getHttpRequestAsyncStore.ts', {
|
|
49
|
+
asyncLocalStorage: null,
|
|
50
|
+
});
|
|
49
51
|
async function installHttpRequestAsyncStore() {
|
|
50
52
|
let mod;
|
|
51
53
|
try {
|
|
@@ -54,9 +56,9 @@ async function installHttpRequestAsyncStore() {
|
|
|
54
56
|
catch {
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
|
-
asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
59
|
+
globalObject.asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
58
60
|
(0, renderPage_js_1.renderPage_addAsyncHookwrapper)(async (httpRequestId, renderPage) => {
|
|
59
|
-
(0, utils_js_1.assert)(asyncLocalStorage);
|
|
61
|
+
(0, utils_js_1.assert)(globalObject.asyncLocalStorage);
|
|
60
62
|
const loggedErrors = new Set();
|
|
61
63
|
const markErrorAsLogged = (err) => {
|
|
62
64
|
loggedErrors.add(err);
|
|
@@ -79,15 +81,15 @@ async function installHttpRequestAsyncStore() {
|
|
|
79
81
|
shouldErrorBeSwallowed,
|
|
80
82
|
errorDebugNoteAlreadyShown: false,
|
|
81
83
|
};
|
|
82
|
-
const pageContextReturn = await asyncLocalStorage.run(store, renderPage);
|
|
84
|
+
const pageContextReturn = await globalObject.asyncLocalStorage.run(store, renderPage);
|
|
83
85
|
return { pageContextReturn };
|
|
84
86
|
});
|
|
85
87
|
return;
|
|
86
88
|
}
|
|
87
89
|
function getHttpRequestAsyncStore() {
|
|
88
|
-
if (asyncLocalStorage === null)
|
|
90
|
+
if (globalObject.asyncLocalStorage === null)
|
|
89
91
|
return null;
|
|
90
|
-
const store = asyncLocalStorage.getStore();
|
|
92
|
+
const store = globalObject.asyncLocalStorage.getStore();
|
|
91
93
|
(0, utils_js_1.assert)(store === undefined || (0, utils_js_1.isObject)(store));
|
|
92
94
|
return store;
|
|
93
95
|
}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getMagicString = getMagicString;
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
|
-
//
|
|
8
|
+
// Used everywhere instead of `new MagicString()` for consistent source map generation
|
|
9
9
|
function getMagicString(code, id) {
|
|
10
10
|
const magicString = new magic_string_1.default(code);
|
|
11
11
|
const getMagicStringResult = () => {
|
|
@@ -7,27 +7,23 @@ exports.getOutDirs = getOutDirs;
|
|
|
7
7
|
exports.resolveOutDir = resolveOutDir;
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
9
|
const utils_js_1 = require("../utils.js");
|
|
10
|
-
const
|
|
10
|
+
const isViteServerSide_js_1 = require("./isViteServerSide.js");
|
|
11
11
|
const debug = (0, utils_js_1.createDebugger)('vike:outDir');
|
|
12
12
|
function getOutDirs(configGlobal, viteEnv) {
|
|
13
|
-
const configEnv = viteEnv?.config ?? configGlobal;
|
|
14
13
|
debug('getOutDirs()', new Error().stack);
|
|
15
|
-
const outDir =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const outDir = getOutDirFromResolvedConfig(configGlobal, viteEnv);
|
|
15
|
+
assertOutDirResolved(outDir, configGlobal, viteEnv);
|
|
16
|
+
const outDirs = getOutDirsAll(outDir, configGlobal.root);
|
|
17
|
+
assertNormalization(outDirs.outDirRoot);
|
|
18
|
+
assertNormalization(outDirs.outDirClient);
|
|
19
|
+
assertNormalization(outDirs.outDirServer);
|
|
19
20
|
return outDirs;
|
|
20
21
|
}
|
|
21
22
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
22
|
-
function resolveOutDir(config,
|
|
23
|
-
debug('resolveOutDir()'
|
|
24
|
-
const isServerSide = (0, isViteServerBuild_js_1.isViteServerBuild)(config) || isSSR;
|
|
25
|
-
debug('isServerSide', isServerSide);
|
|
23
|
+
function resolveOutDir(config, isServerSide) {
|
|
24
|
+
debug('resolveOutDir()');
|
|
26
25
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
27
26
|
debug('outDir', outDir);
|
|
28
|
-
/* outDir may already be resolved when using Telefunc + Vike (because both Telefunc and Vike use this logic)
|
|
29
|
-
assert(isOutDirRoot(outDir))
|
|
30
|
-
*/
|
|
31
27
|
const { outDirClient, outDirServer } = getOutDirsAll(outDir);
|
|
32
28
|
if (isServerSide) {
|
|
33
29
|
debug('outDirServer', 'outDirServer');
|
|
@@ -91,9 +87,9 @@ function getOutDirsAllFromRootNormalized(outDirRoot, root) {
|
|
|
91
87
|
}
|
|
92
88
|
function assertNormalization(outDirAny) {
|
|
93
89
|
(0, utils_js_1.assertPosixPath)(outDirAny);
|
|
94
|
-
(0, utils_js_1.assert)(outDirIsAbsolutePath(outDirAny));
|
|
95
|
-
(0, utils_js_1.assert)(outDirAny.endsWith('/'));
|
|
96
|
-
(0, utils_js_1.assert)(!outDirAny.endsWith('//'));
|
|
90
|
+
(0, utils_js_1.assert)(outDirIsAbsolutePath(outDirAny), outDirAny);
|
|
91
|
+
(0, utils_js_1.assert)(outDirAny.endsWith('/'), outDirAny);
|
|
92
|
+
(0, utils_js_1.assert)(!outDirAny.endsWith('//'), outDirAny);
|
|
97
93
|
}
|
|
98
94
|
function isOutDirRoot(outDirRot) {
|
|
99
95
|
const p = outDirRot.split('/').filter(Boolean);
|
|
@@ -103,14 +99,17 @@ function isOutDirRoot(outDirRot) {
|
|
|
103
99
|
function assertIsNotOutDirRoot(outDir) {
|
|
104
100
|
(0, utils_js_1.assert)(outDir.endsWith('/client') || outDir.endsWith('/server'));
|
|
105
101
|
}
|
|
106
|
-
/** Assert that `outDir` ends with `/server` or `/client` */
|
|
107
|
-
function assertOutDirResolved(outDir,
|
|
102
|
+
/** Assert that `outDir` ends with the correct directory `/server` or `/client` */
|
|
103
|
+
function assertOutDirResolved(outDir, configGlobal, viteEnv) {
|
|
108
104
|
(0, utils_js_1.assertPosixPath)(outDir);
|
|
109
|
-
|
|
105
|
+
if (isOutDirRoot(outDir))
|
|
106
|
+
return;
|
|
107
|
+
(0, utils_js_1.assert)(outDir.endsWith('/client') || outDir.endsWith('/server')); // we normalized outDir
|
|
110
108
|
(0, utils_js_1.assert)('/client'.length === '/server'.length);
|
|
111
109
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
112
110
|
const wrongUsage = `You've set Vite's config.build.outDir to ${picocolors_1.default.cyan(outDir)} but you should set it to ${picocolors_1.default.cyan(outDirCorrected)} instead.`;
|
|
113
|
-
|
|
111
|
+
const isServerSide = (0, isViteServerSide_js_1.isViteServerSide_viteEnvOptional)(configGlobal, viteEnv);
|
|
112
|
+
if (isServerSide) {
|
|
114
113
|
(0, utils_js_1.assertUsage)(outDir.endsWith('/server'), wrongUsage);
|
|
115
114
|
}
|
|
116
115
|
else {
|
|
@@ -124,8 +123,8 @@ function getOutDirFromViteUserConfig(config) {
|
|
|
124
123
|
outDir = normalizeOutDir(outDir);
|
|
125
124
|
return outDir;
|
|
126
125
|
}
|
|
127
|
-
function
|
|
128
|
-
let outDir = config.build.outDir;
|
|
126
|
+
function getOutDirFromResolvedConfig(config, viteEnv) {
|
|
127
|
+
let outDir = viteEnv?.config.build?.outDir ?? config.build.outDir;
|
|
129
128
|
(0, utils_js_1.assert)(outDir);
|
|
130
129
|
outDir = normalizeOutDir(outDir);
|
|
131
130
|
return outDir;
|
|
@@ -5,7 +5,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
5
5
|
const getOutDirs_js_1 = require("./getOutDirs.js");
|
|
6
6
|
function getViteConfigRuntime(config) {
|
|
7
7
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(config, '_baseViteOriginal', 'string'));
|
|
8
|
-
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
8
|
+
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config, undefined);
|
|
9
9
|
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(outDirRoot);
|
|
10
10
|
const viteConfigRuntime = {
|
|
11
11
|
root: config.root,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isViteServerSide = isViteServerSide;
|
|
4
|
+
exports.isViteClientSide = isViteClientSide;
|
|
5
|
+
exports.isViteServerSide_viteEnvOptional = isViteServerSide_viteEnvOptional;
|
|
6
|
+
exports.isViteServerSide_onlySsrEnv = isViteServerSide_onlySsrEnv;
|
|
7
|
+
exports.isViteServerSide_extraSafe = isViteServerSide_extraSafe;
|
|
8
|
+
const assert_js_1 = require("../../../utils/assert.js");
|
|
9
|
+
function isViteServerSide_impl(configGlobal, viteEnv) {
|
|
10
|
+
(0, assert_js_1.assert)(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
11
|
+
const debug = {
|
|
12
|
+
viteEnvIsUndefined: !viteEnv,
|
|
13
|
+
viteEnvName: viteEnv?.name ?? null,
|
|
14
|
+
viteEnvConsumer: viteEnv?.config.consumer ?? null,
|
|
15
|
+
configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
|
|
16
|
+
configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
|
|
17
|
+
};
|
|
18
|
+
if (!viteEnv) {
|
|
19
|
+
const isServerSide = getBuildSsrValue(configGlobal.build?.ssr);
|
|
20
|
+
(0, assert_js_1.assert)(typeof isServerSide === 'boolean', debug);
|
|
21
|
+
return isServerSide;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const isServerSide1 = !viteEnv.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
25
|
+
const isServerSide2 = getBuildSsrValue(viteEnv.config.build?.ssr);
|
|
26
|
+
const isServerSide3 = viteEnv.name === 'ssr' ? true : viteEnv.name === 'client' ? false : null;
|
|
27
|
+
const isServerSide = isServerSide1 ?? isServerSide2;
|
|
28
|
+
(0, assert_js_1.assert)(isServerSide === isServerSide1 || isServerSide1 === null, debug);
|
|
29
|
+
(0, assert_js_1.assert)(isServerSide === isServerSide2 || isServerSide2 === null, debug);
|
|
30
|
+
(0, assert_js_1.assert)(isServerSide === isServerSide3 || isServerSide3 === null, debug);
|
|
31
|
+
(0, assert_js_1.assert)(isServerSide !== null);
|
|
32
|
+
return isServerSide;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function getBuildSsrValue(buildSsr) {
|
|
36
|
+
if (buildSsr === undefined)
|
|
37
|
+
return null;
|
|
38
|
+
(0, assert_js_1.assert)(typeof buildSsr === 'boolean' || typeof buildSsr === 'string');
|
|
39
|
+
return !!buildSsr;
|
|
40
|
+
}
|
|
41
|
+
function isViteServerSide(configGlobal, viteEnv) {
|
|
42
|
+
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
43
|
+
}
|
|
44
|
+
function isViteServerSide_viteEnvOptional(configGlobal, viteEnv) {
|
|
45
|
+
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
46
|
+
}
|
|
47
|
+
function isViteClientSide(configGlobal, viteEnv) {
|
|
48
|
+
return !isViteServerSide(configGlobal, viteEnv);
|
|
49
|
+
}
|
|
50
|
+
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
51
|
+
function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
|
|
52
|
+
return viteEnv.name ? viteEnv.name === 'ssr' : isViteServerSide(configGlobal, viteEnv);
|
|
53
|
+
}
|
|
54
|
+
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
55
|
+
function isViteServerSide_extraSafe(config, viteEnv, options) {
|
|
56
|
+
const isServerSide = isViteServerSide(config, viteEnv);
|
|
57
|
+
const debug = {
|
|
58
|
+
isServerSide,
|
|
59
|
+
configCommand: config.command,
|
|
60
|
+
configBuildSsr: getBuildSsrValue(config.build.ssr),
|
|
61
|
+
optionsIsUndefined: options === undefined,
|
|
62
|
+
optionsSsr: options?.ssr ?? null,
|
|
63
|
+
};
|
|
64
|
+
(0, assert_js_1.assert)(options, debug);
|
|
65
|
+
(0, assert_js_1.assert)(typeof options.ssr === 'boolean', debug);
|
|
66
|
+
(0, assert_js_1.assert)(options.ssr === isServerSide, debug);
|
|
67
|
+
return isServerSide;
|
|
68
|
+
}
|
|
@@ -4,10 +4,12 @@ exports.removeSuperfluousViteLog = removeSuperfluousViteLog;
|
|
|
4
4
|
exports.removeSuperfluousViteLog_enable = removeSuperfluousViteLog_enable;
|
|
5
5
|
exports.removeSuperfluousViteLog_disable = removeSuperfluousViteLog_disable;
|
|
6
6
|
const utils_js_1 = require("../../utils.js");
|
|
7
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('removeSuperfluousViteLog.ts', {
|
|
8
|
+
enabled: false,
|
|
9
|
+
});
|
|
7
10
|
const superfluousLog = 'Forced re-optimization of dependencies';
|
|
8
|
-
let enabled = false;
|
|
9
11
|
function removeSuperfluousViteLog(msg) {
|
|
10
|
-
if (!enabled) {
|
|
12
|
+
if (!globalObject.enabled) {
|
|
11
13
|
return false;
|
|
12
14
|
}
|
|
13
15
|
if (msg.toLowerCase().includes('forced') && msg.toLowerCase().includes('optimization')) {
|
|
@@ -17,8 +19,8 @@ function removeSuperfluousViteLog(msg) {
|
|
|
17
19
|
return false;
|
|
18
20
|
}
|
|
19
21
|
function removeSuperfluousViteLog_enable() {
|
|
20
|
-
enabled = true;
|
|
22
|
+
globalObject.enabled = true;
|
|
21
23
|
}
|
|
22
24
|
function removeSuperfluousViteLog_disable() {
|
|
23
|
-
enabled = false;
|
|
25
|
+
globalObject.enabled = false;
|
|
24
26
|
}
|
|
@@ -33,7 +33,7 @@ function intercept(logType, config) {
|
|
|
33
33
|
// We swallow Vite's message: we didn't see it add any value so far.
|
|
34
34
|
// - It can even be confusing, such as the following:
|
|
35
35
|
// ```
|
|
36
|
-
// Error when evaluating SSR module virtual:vike:
|
|
36
|
+
// Error when evaluating SSR module virtual:vike:page-entry:server:/pages/abort: failed to import "/pages/abort/+Page.mdx"
|
|
37
37
|
// ```
|
|
38
38
|
(0, utils_js_1.assert)(!(0, isErrorDebug_js_1.isErrorDebug)());
|
|
39
39
|
return;
|
|
@@ -110,7 +110,9 @@ const configDefinitionsBuiltIn = {
|
|
|
110
110
|
}, pageConfig))
|
|
111
111
|
.flat(1)
|
|
112
112
|
// Server-only
|
|
113
|
-
.filter((source) => !source.configEnv.client)
|
|
113
|
+
.filter((source) => !source.configEnv.client)
|
|
114
|
+
// Config value isn't `null`
|
|
115
|
+
.filter((source) => !(0, getConfigValueSourcesRelevant_js_1.isConfigSourceValueNull)(source));
|
|
114
116
|
return sources.length > 0;
|
|
115
117
|
},
|
|
116
118
|
},
|
|
@@ -122,22 +124,19 @@ const configDefinitionsBuiltIn = {
|
|
|
122
124
|
env: { server: true, client: true },
|
|
123
125
|
eager: true,
|
|
124
126
|
_computed: (pageConfig) => {
|
|
125
|
-
const { configValueSources } = pageConfig;
|
|
126
127
|
{
|
|
127
|
-
const source =
|
|
128
|
+
const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)('clientHooks', pageConfig);
|
|
128
129
|
if (source) {
|
|
129
130
|
(0, utils_js_1.assert)(source.valueIsLoaded);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return value;
|
|
135
|
-
}
|
|
131
|
+
const { value, definedAt } = source;
|
|
132
|
+
const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', definedAt);
|
|
133
|
+
(0, utils_js_1.assertUsage)(typeof value === 'boolean', `${configDefinedAt} should be a boolean`);
|
|
134
|
+
return value;
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
|
-
return (isConfigSet(
|
|
139
|
-
isConfigSet(
|
|
140
|
-
!!getConfigEnv(
|
|
137
|
+
return (isConfigSet(pageConfig, 'onRenderClient') &&
|
|
138
|
+
isConfigSet(pageConfig, 'Page') &&
|
|
139
|
+
!!getConfigEnv(pageConfig, 'Page')?.client);
|
|
141
140
|
},
|
|
142
141
|
},
|
|
143
142
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -145,10 +144,7 @@ const configDefinitionsBuiltIn = {
|
|
|
145
144
|
env: { client: true },
|
|
146
145
|
eager: true,
|
|
147
146
|
_computed: (pageConfig) => {
|
|
148
|
-
|
|
149
|
-
return !isConfigSet(configValueSources, 'onBeforeRender')
|
|
150
|
-
? null
|
|
151
|
-
: getConfigEnv(configValueSources, 'onBeforeRender');
|
|
147
|
+
return !isConfigSet(pageConfig, 'onBeforeRender') ? null : getConfigEnv(pageConfig, 'onBeforeRender');
|
|
152
148
|
},
|
|
153
149
|
},
|
|
154
150
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -156,8 +152,7 @@ const configDefinitionsBuiltIn = {
|
|
|
156
152
|
env: { client: true },
|
|
157
153
|
eager: true,
|
|
158
154
|
_computed: (pageConfig) => {
|
|
159
|
-
|
|
160
|
-
return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
|
|
155
|
+
return !isConfigSet(pageConfig, 'data') ? null : getConfigEnv(pageConfig, 'data');
|
|
161
156
|
},
|
|
162
157
|
},
|
|
163
158
|
hooksTimeout: {
|
|
@@ -178,6 +173,9 @@ const configDefinitionsBuiltIn = {
|
|
|
178
173
|
env: { config: true },
|
|
179
174
|
global: true,
|
|
180
175
|
},
|
|
176
|
+
csp: {
|
|
177
|
+
env: { server: true },
|
|
178
|
+
},
|
|
181
179
|
injectScriptsAt: {
|
|
182
180
|
env: { server: true },
|
|
183
181
|
},
|
|
@@ -246,11 +244,11 @@ const configDefinitionsBuiltIn = {
|
|
|
246
244
|
},
|
|
247
245
|
};
|
|
248
246
|
exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
|
|
249
|
-
function getConfigEnv(
|
|
250
|
-
const
|
|
251
|
-
if (!
|
|
247
|
+
function getConfigEnv(pageConfig, configName) {
|
|
248
|
+
const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)(configName, pageConfig);
|
|
249
|
+
if (!source)
|
|
252
250
|
return null;
|
|
253
|
-
const { configEnv } =
|
|
251
|
+
const { configEnv } = source;
|
|
254
252
|
const env = {};
|
|
255
253
|
if (configEnv.client)
|
|
256
254
|
env.client = true;
|
|
@@ -258,18 +256,7 @@ function getConfigEnv(configValueSources, configName) {
|
|
|
258
256
|
env.server = true;
|
|
259
257
|
return env;
|
|
260
258
|
}
|
|
261
|
-
function isConfigSet(
|
|
262
|
-
const source =
|
|
263
|
-
return
|
|
264
|
-
!(source.valueIsLoaded &&
|
|
265
|
-
// Enable users to suppress inherited config by overriding it with `null`
|
|
266
|
-
source.value === null));
|
|
267
|
-
}
|
|
268
|
-
function getConfigValueSource(configValueSources, configName) {
|
|
269
|
-
const sources = configValueSources[configName];
|
|
270
|
-
if (!sources)
|
|
271
|
-
return null;
|
|
272
|
-
const configValueSource = sources[0];
|
|
273
|
-
(0, utils_js_1.assert)(configValueSource);
|
|
274
|
-
return configValueSource;
|
|
259
|
+
function isConfigSet(pageConfig, configName) {
|
|
260
|
+
const source = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourceRelevantAnyEnv)(configName, pageConfig);
|
|
261
|
+
return !!source;
|
|
275
262
|
}
|
|
@@ -19,8 +19,9 @@ const ignorePatternsBuiltIn_js_1 = require("./crawlPlusFiles/ignorePatternsBuilt
|
|
|
19
19
|
const execA = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
20
20
|
const debug = (0, utils_js_1.createDebugger)('vike:crawl');
|
|
21
21
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
22
|
-
(0, utils_js_1.
|
|
23
|
-
|
|
22
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('getVikeConfig/crawlPlusFiles.ts', {
|
|
23
|
+
gitIsNotUsable: false,
|
|
24
|
+
});
|
|
24
25
|
async function crawlPlusFiles(userRootDir) {
|
|
25
26
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
26
27
|
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(userRootDir);
|
|
@@ -53,7 +54,7 @@ async function crawlPlusFiles(userRootDir) {
|
|
|
53
54
|
}
|
|
54
55
|
// Same as tinyglobby() but using `$ git ls-files`
|
|
55
56
|
async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
56
|
-
if (gitIsNotUsable)
|
|
57
|
+
if (globalObject.gitIsNotUsable)
|
|
57
58
|
return null;
|
|
58
59
|
// Preserve UTF-8 file paths.
|
|
59
60
|
// https://github.com/vikejs/vike/issues/1658
|
|
@@ -87,7 +88,7 @@ async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
|
87
88
|
}
|
|
88
89
|
catch (err) {
|
|
89
90
|
if (await isGitNotUsable(userRootDir)) {
|
|
90
|
-
gitIsNotUsable = true;
|
|
91
|
+
globalObject.gitIsNotUsable = true;
|
|
91
92
|
return null;
|
|
92
93
|
}
|
|
93
94
|
throw err;
|