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
|
@@ -7,20 +7,21 @@ import fs from 'node:fs/promises';
|
|
|
7
7
|
import fs_sync from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { existsSync } from 'node:fs';
|
|
10
|
-
import { assert,
|
|
11
|
-
import {
|
|
10
|
+
import { assert, assertWarning, getGlobalObject, isEqualStringList, isObject, pLimit, unique } from '../../utils.js';
|
|
11
|
+
import { parseVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
12
12
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
13
13
|
import pc from '@brillout/picocolors';
|
|
14
|
-
import {
|
|
14
|
+
import { isV1Design } from '../../shared/resolveVikeConfigInternal.js';
|
|
15
15
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
16
|
-
import {
|
|
17
|
-
import { set_macro_ASSETS_MANIFEST } from './
|
|
16
|
+
import { isViteServerSide_onlySsrEnv, isViteServerSide } from '../../shared/isViteServerSide.js';
|
|
17
|
+
import { set_macro_ASSETS_MANIFEST } from './pluginProdBuildEntry.js';
|
|
18
18
|
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const globalObject = getGlobalObject('build/handleAssetsManifest.ts', {
|
|
20
|
+
assetsJsonFilePath: undefined,
|
|
21
|
+
});
|
|
21
22
|
// true => use workaround config.build.ssrEmitAssets
|
|
22
23
|
// false => use workaround extractAssets plugin
|
|
23
|
-
function handleAssetsManifest_isFixEnabled(
|
|
24
|
+
function handleAssetsManifest_isFixEnabled() {
|
|
24
25
|
// Allow user to toggle between the two workarounds? E.g. based on https://vike.dev/includeAssetsImportedByServer.
|
|
25
26
|
return isV1Design();
|
|
26
27
|
}
|
|
@@ -33,7 +34,7 @@ async function fixServerAssets(config) {
|
|
|
33
34
|
return { clientManifestMod, serverManifestMod };
|
|
34
35
|
}
|
|
35
36
|
async function copyAssets(filesToMove, filesToRemove, config) {
|
|
36
|
-
const { outDirClient, outDirServer } = getOutDirs(config);
|
|
37
|
+
const { outDirClient, outDirServer } = getOutDirs(config, undefined);
|
|
37
38
|
const assetsDir = getAssetsDir(config);
|
|
38
39
|
const assetsDirServer = path.posix.join(outDirServer, assetsDir);
|
|
39
40
|
if (!filesToMove.length && !filesToRemove.length && !existsSync(assetsDirServer))
|
|
@@ -165,13 +166,13 @@ function addServerAssets(clientManifest, serverManifest) {
|
|
|
165
166
|
}
|
|
166
167
|
function getPageId(key) {
|
|
167
168
|
// Normalize from:
|
|
168
|
-
// ../../virtual:vike:
|
|
169
|
+
// ../../virtual:vike:page-entry:client:/pages/index
|
|
169
170
|
// to:
|
|
170
|
-
// virtual:vike:
|
|
171
|
+
// virtual:vike:page-entry:client:/pages/index
|
|
171
172
|
// (This seems to be needed only for vitest tests that use Vite's build() API with an inline config.)
|
|
172
173
|
key = key.substring(key.indexOf('virtual:vike'));
|
|
173
|
-
const result =
|
|
174
|
-
return result && result.pageId;
|
|
174
|
+
const result = parseVirtualFileId(key);
|
|
175
|
+
return result && result.type === 'page-entry' ? result.pageId : null;
|
|
175
176
|
}
|
|
176
177
|
function collectResources(entryRoot, manifest) {
|
|
177
178
|
const css = [];
|
|
@@ -211,15 +212,15 @@ function getHash(src) {
|
|
|
211
212
|
}
|
|
212
213
|
// https://github.com/vikejs/vike/issues/1993
|
|
213
214
|
function handleAssetsManifest_assertUsageCssCodeSplit(config) {
|
|
214
|
-
if (!handleAssetsManifest_isFixEnabled(
|
|
215
|
+
if (!handleAssetsManifest_isFixEnabled())
|
|
215
216
|
return;
|
|
216
217
|
assertWarning(config.build.cssCodeSplit, `${pc.cyan('build.cssCodeSplit')} shouldn't be set to ${pc.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
217
218
|
}
|
|
218
219
|
const targets = [];
|
|
219
|
-
function handleAssetsManifest_assertUsageCssTarget(config) {
|
|
220
|
-
if (!handleAssetsManifest_isFixEnabled(
|
|
220
|
+
function handleAssetsManifest_assertUsageCssTarget(config, env) {
|
|
221
|
+
if (!handleAssetsManifest_isFixEnabled())
|
|
221
222
|
return;
|
|
222
|
-
const isServerSide =
|
|
223
|
+
const isServerSide = isViteServerSide(config, env);
|
|
223
224
|
assert(typeof isServerSide === 'boolean');
|
|
224
225
|
assert(config.build.target !== undefined);
|
|
225
226
|
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
@@ -278,43 +279,41 @@ async function writeManifestFile(manifest, manifestFilePath) {
|
|
|
278
279
|
const manifestFileContent = JSON.stringify(manifest, null, 2);
|
|
279
280
|
await fs.writeFile(manifestFilePath, manifestFileContent, 'utf-8');
|
|
280
281
|
}
|
|
281
|
-
async function handleAssetsManifest_getBuildConfig(
|
|
282
|
-
const
|
|
283
|
-
const isFixEnabled = handleAssetsManifest_isFixEnabled(config);
|
|
282
|
+
async function handleAssetsManifest_getBuildConfig() {
|
|
283
|
+
const isFixEnabled = handleAssetsManifest_isFixEnabled();
|
|
284
284
|
return {
|
|
285
285
|
// https://github.com/vikejs/vike/issues/1339
|
|
286
286
|
ssrEmitAssets: isFixEnabled ? true : undefined,
|
|
287
287
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
288
288
|
cssMinify: isFixEnabled ? 'esbuild' : undefined,
|
|
289
289
|
manifest: true,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
: !isViteServerBuild(config),
|
|
290
|
+
/* Already set by vike:build:pluginBuildApp
|
|
291
|
+
copyPublicDir: !isViteServerSide_viteEnvOptional(config),
|
|
292
|
+
*/
|
|
294
293
|
};
|
|
295
294
|
}
|
|
296
295
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
297
|
-
const isSsrEnv =
|
|
296
|
+
const isSsrEnv = isViteServerSide_onlySsrEnv(config, viteEnv);
|
|
298
297
|
if (isSsrEnv) {
|
|
299
|
-
assert(!assetsJsonFilePath);
|
|
298
|
+
assert(!globalObject.assetsJsonFilePath);
|
|
300
299
|
const outDirs = getOutDirs(config, viteEnv);
|
|
301
|
-
assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
302
|
-
await writeAssetsManifestFile(assetsJsonFilePath, config);
|
|
300
|
+
globalObject.assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
301
|
+
await writeAssetsManifestFile(globalObject.assetsJsonFilePath, config);
|
|
303
302
|
}
|
|
304
|
-
if (
|
|
303
|
+
if (isViteServerSide(config, viteEnv)) {
|
|
305
304
|
const outDir = options.dir;
|
|
306
305
|
assert(outDir);
|
|
307
306
|
// Replace __VITE_ASSETS_MANIFEST__ in server builds
|
|
308
307
|
// - Always replace it in dist/server/
|
|
309
308
|
// - Also in some other server builds such as dist/vercel/ from vike-vercel
|
|
310
309
|
// - Don't replace it in dist/rsc/ from vike-react-rsc since __VITE_ASSETS_MANIFEST__ doesn't exist there
|
|
311
|
-
const noop = await set_macro_ASSETS_MANIFEST(assetsJsonFilePath, bundle, outDir);
|
|
310
|
+
const noop = await set_macro_ASSETS_MANIFEST(globalObject.assetsJsonFilePath, bundle, outDir);
|
|
312
311
|
if (isSsrEnv)
|
|
313
312
|
assert(!noop); // dist/server should always contain __VITE_ASSETS_MANIFEST__
|
|
314
313
|
}
|
|
315
314
|
}
|
|
316
315
|
async function writeAssetsManifestFile(assetsJsonFilePath, config) {
|
|
317
|
-
const isFixEnabled = handleAssetsManifest_isFixEnabled(
|
|
316
|
+
const isFixEnabled = handleAssetsManifest_isFixEnabled();
|
|
318
317
|
const clientManifestFilePath = getManifestFilePath(config, true);
|
|
319
318
|
const serverManifestFilePath = getManifestFilePath(config, false);
|
|
320
319
|
if (!isFixEnabled) {
|
|
@@ -328,7 +327,7 @@ async function writeAssetsManifestFile(assetsJsonFilePath, config) {
|
|
|
328
327
|
await fs.rm(serverManifestFilePath);
|
|
329
328
|
}
|
|
330
329
|
function getManifestFilePath(config, client) {
|
|
331
|
-
const outDirs = getOutDirs(config);
|
|
330
|
+
const outDirs = getOutDirs(config, undefined);
|
|
332
331
|
const outDir = client ? outDirs.outDirClient : outDirs.outDirServer;
|
|
333
332
|
const env = client ? config.environments.client : config.environments.ssr;
|
|
334
333
|
assert(env);
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
export { pluginBuildApp };
|
|
2
2
|
import { runPrerender_forceExit } from '../../../prerender/runPrerenderEntry.js';
|
|
3
3
|
import { resolveOutDir } from '../../shared/getOutDirs.js';
|
|
4
|
-
import { assert } from '../../utils.js';
|
|
5
|
-
import {
|
|
4
|
+
import { assert, assertWarning, getGlobalObject, onSetupBuild } from '../../utils.js';
|
|
5
|
+
import { isPrerenderAutoRunEnabled, wasPrerenderRun } from '../../../prerender/context.js';
|
|
6
|
+
import { isViteCliCall, getViteConfigFromCli } from '../../shared/isViteCliCall.js';
|
|
7
|
+
import pc from '@brillout/picocolors';
|
|
8
|
+
import { logErrorHint } from '../../../runtime/renderPage/logErrorHint.js';
|
|
6
9
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
10
|
+
import { isVikeCliOrApi } from '../../../api/context.js';
|
|
11
|
+
import { handleAssetsManifest, handleAssetsManifest_assertUsageCssTarget } from './handleAssetsManifest.js';
|
|
12
|
+
import { isViteServerSide_onlySsrEnv } from '../../shared/isViteServerSide.js';
|
|
13
|
+
import { runPrerenderFromAutoRun } from '../../../prerender/runPrerenderEntry.js';
|
|
14
|
+
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
15
|
+
const globalObject = getGlobalObject('build/pluginBuildApp.ts', {
|
|
16
|
+
forceExit: false,
|
|
17
|
+
});
|
|
7
18
|
function pluginBuildApp() {
|
|
19
|
+
let config;
|
|
8
20
|
return [
|
|
9
21
|
{
|
|
10
22
|
name: 'vike:build:pluginBuildApp:pre',
|
|
@@ -12,10 +24,7 @@ function pluginBuildApp() {
|
|
|
12
24
|
enforce: 'pre',
|
|
13
25
|
config: {
|
|
14
26
|
order: 'pre',
|
|
15
|
-
|
|
16
|
-
const vikeConfig = await getVikeConfigInternal();
|
|
17
|
-
if (!vikeConfig.config.vite6BuilderApp)
|
|
18
|
-
return;
|
|
27
|
+
handler(_config) {
|
|
19
28
|
return {
|
|
20
29
|
builder: {
|
|
21
30
|
// Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
@@ -37,10 +46,7 @@ function pluginBuildApp() {
|
|
|
37
46
|
{
|
|
38
47
|
name: 'vike:build:pluginBuildApp',
|
|
39
48
|
apply: 'build',
|
|
40
|
-
|
|
41
|
-
const vikeConfig = await getVikeConfigInternal();
|
|
42
|
-
if (!vikeConfig.config.vite6BuilderApp)
|
|
43
|
-
return;
|
|
49
|
+
config(config) {
|
|
44
50
|
return {
|
|
45
51
|
environments: {
|
|
46
52
|
ssr: {
|
|
@@ -53,6 +59,7 @@ function pluginBuildApp() {
|
|
|
53
59
|
client: {
|
|
54
60
|
consumer: 'client',
|
|
55
61
|
build: {
|
|
62
|
+
outDir: resolveOutDir(config, false),
|
|
56
63
|
copyPublicDir: true,
|
|
57
64
|
ssr: false,
|
|
58
65
|
},
|
|
@@ -61,5 +68,107 @@ function pluginBuildApp() {
|
|
|
61
68
|
};
|
|
62
69
|
},
|
|
63
70
|
},
|
|
71
|
+
{
|
|
72
|
+
name: 'vike:build:pluginBuildApp:autoFullBuild:pre',
|
|
73
|
+
apply: 'build',
|
|
74
|
+
enforce: 'pre',
|
|
75
|
+
async configResolved(config_) {
|
|
76
|
+
config = config_;
|
|
77
|
+
await abortViteBuildSsr();
|
|
78
|
+
},
|
|
79
|
+
// TO-DO/eventually: stop using this writeBundle() hack and, instead, use the buildApp() implementation above.
|
|
80
|
+
// - Could it cause issues if a tool uses the writeBundle() hack together with getVikeConfig() ?
|
|
81
|
+
writeBundle: {
|
|
82
|
+
/* We can't use this because it breaks Vite's logging. TO-DO/eventually: try again with latest Vite version.
|
|
83
|
+
sequential: true,
|
|
84
|
+
order: 'pre',
|
|
85
|
+
*/
|
|
86
|
+
async handler(options, bundle) {
|
|
87
|
+
try {
|
|
88
|
+
await handleAssetsManifest(config, this.environment, options, bundle);
|
|
89
|
+
await triggerPrerendering(config, this.environment, bundle);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
// We use try-catch also because:
|
|
93
|
+
// - Vite/Rollup swallows errors thrown inside the writeBundle() hook. (It doesn't swallow errors thrown inside the first writeBundle() hook while building the client-side, but it does swallow errors thrown inside the second writeBundle() while building the server-side triggered after Vike calls Vite's `build()` API.)
|
|
94
|
+
// - Avoid Rollup prefixing the error with [vike:build:pluginBuildApp], see for example https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
95
|
+
console.error(err);
|
|
96
|
+
logErrorHint(err);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'vike:build:pluginBuildApp:autoFullBuild:post',
|
|
104
|
+
apply: 'build',
|
|
105
|
+
enforce: 'post',
|
|
106
|
+
closeBundle: {
|
|
107
|
+
sequential: true,
|
|
108
|
+
order: 'post',
|
|
109
|
+
handler() {
|
|
110
|
+
onSetupBuild();
|
|
111
|
+
handleAssetsManifest_assertUsageCssTarget(config, this.environment);
|
|
112
|
+
/* Let vike:build:pluginBuildApp force exit
|
|
113
|
+
runPrerender_forceExit()
|
|
114
|
+
*/
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
64
118
|
];
|
|
65
119
|
}
|
|
120
|
+
async function triggerPrerendering(config, viteEnv, bundle) {
|
|
121
|
+
const vikeConfig = await getVikeConfigInternal();
|
|
122
|
+
if (!isViteServerSide_onlySsrEnv(config, viteEnv))
|
|
123
|
+
return;
|
|
124
|
+
if (isDisabled(vikeConfig))
|
|
125
|
+
return;
|
|
126
|
+
// Workaround for @vitejs/plugin-legacy
|
|
127
|
+
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
128
|
+
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
129
|
+
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
130
|
+
if (!bundle[getManifestFilePathRelative(config.build.manifest)])
|
|
131
|
+
return;
|
|
132
|
+
if (!isPrerenderAutoRunEnabled(vikeConfig))
|
|
133
|
+
return;
|
|
134
|
+
const configInline = getFullBuildInlineConfig(config);
|
|
135
|
+
const res = await runPrerenderFromAutoRun(configInline);
|
|
136
|
+
globalObject.forceExit = res.forceExit;
|
|
137
|
+
assert(wasPrerenderRun());
|
|
138
|
+
}
|
|
139
|
+
async function abortViteBuildSsr() {
|
|
140
|
+
const vikeConfig = await getVikeConfigInternal();
|
|
141
|
+
if (vikeConfig.config.disableAutoFullBuild !== true && isViteCliCall() && getViteConfigFromCli()?.build.ssr) {
|
|
142
|
+
assertWarning(false, `The CLI call ${pc.cyan('$ vite build --ssr')} is superfluous since ${pc.cyan('$ vite build')} also builds the server-side. If you want two separate build steps then use https://vike.dev/disableAutoFullBuild or use Vite's ${pc.cyan('build()')} API.`, { onlyOnce: true });
|
|
143
|
+
process.exit(0);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function isDisabled(vikeConfig) {
|
|
147
|
+
const { disableAutoFullBuild } = vikeConfig.config;
|
|
148
|
+
if (disableAutoFullBuild === undefined || disableAutoFullBuild === 'prerender') {
|
|
149
|
+
const isUserUsingViteApi = !isViteCliCall() && !isVikeCliOrApi();
|
|
150
|
+
return isUserUsingViteApi;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
return disableAutoFullBuild;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function isPrerenderForceExit() {
|
|
157
|
+
return globalObject.forceExit;
|
|
158
|
+
}
|
|
159
|
+
function getFullBuildInlineConfig(config) {
|
|
160
|
+
const configFromCli = !isViteCliCall() ? null : getViteConfigFromCli();
|
|
161
|
+
if (config._viteConfigFromUserEnhanced) {
|
|
162
|
+
return config._viteConfigFromUserEnhanced;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return {
|
|
166
|
+
...configFromCli,
|
|
167
|
+
configFile: configFromCli?.configFile || config.configFile,
|
|
168
|
+
root: config.root,
|
|
169
|
+
build: {
|
|
170
|
+
...configFromCli?.build,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
export { pluginBuildConfig };
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
|
-
import { assert, addOnBeforeLogHook, removeFileExtension, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsImportPathNpmPackage,
|
|
4
|
+
import { assert, addOnBeforeLogHook, removeFileExtension, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsImportPathNpmPackage, requireResolveDistFile, } from '../../utils.js';
|
|
5
5
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
6
6
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
7
|
-
import {
|
|
7
|
+
import { generateVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
8
8
|
import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
9
9
|
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
10
10
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
11
11
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
12
|
-
import {
|
|
13
|
-
import { resolveOutDir } from '../../shared/getOutDirs.js';
|
|
12
|
+
import { isViteServerSide_viteEnvOptional } from '../../shared/isViteServerSide.js';
|
|
14
13
|
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, } from './handleAssetsManifest.js';
|
|
15
|
-
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets.js';
|
|
14
|
+
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
16
15
|
function pluginBuildConfig() {
|
|
17
16
|
let config;
|
|
18
17
|
return [
|
|
@@ -35,14 +34,10 @@ function pluginBuildConfig() {
|
|
|
35
34
|
},
|
|
36
35
|
config: {
|
|
37
36
|
order: 'post',
|
|
38
|
-
async handler(
|
|
37
|
+
async handler() {
|
|
39
38
|
onSetupBuild();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
outDir: resolveOutDir(config),
|
|
43
|
-
...(await handleAssetsManifest_getBuildConfig(config)),
|
|
44
|
-
},
|
|
45
|
-
};
|
|
39
|
+
const build = await handleAssetsManifest_getBuildConfig();
|
|
40
|
+
return { build };
|
|
46
41
|
},
|
|
47
42
|
},
|
|
48
43
|
buildStart() {
|
|
@@ -57,7 +52,7 @@ async function getEntries(config) {
|
|
|
57
52
|
// TO-DO/next-major-release: remove
|
|
58
53
|
const pageFileEntries = await getPageFileEntries(config, resolveIncludeAssetsImportedByServer(vikeConfig.config));
|
|
59
54
|
assertUsage(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
60
|
-
if (
|
|
55
|
+
if (isViteServerSide_viteEnvOptional(config)) {
|
|
61
56
|
const pageEntries = getPageEntries(pageConfigs);
|
|
62
57
|
const entries = {
|
|
63
58
|
...pageFileEntries,
|
|
@@ -76,8 +71,8 @@ async function getEntries(config) {
|
|
|
76
71
|
...clientEntries,
|
|
77
72
|
...pageFileEntries,
|
|
78
73
|
};
|
|
79
|
-
const clientRoutingEntry =
|
|
80
|
-
const serverRoutingEntry =
|
|
74
|
+
const clientRoutingEntry = requireResolveDistFile('dist/esm/client/runtime-client-routing/entry.js');
|
|
75
|
+
const serverRoutingEntry = requireResolveDistFile('dist/esm/client/runtime-server-routing/entry.js');
|
|
81
76
|
if (hasClientRouting) {
|
|
82
77
|
entries['entries/entry-client-routing'] = clientRoutingEntry;
|
|
83
78
|
}
|
|
@@ -130,7 +125,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
130
125
|
// Ensure Rollup creates entries for each page file, see https://github.com/vikejs/vike/issues/350
|
|
131
126
|
// (Otherwise the page files may be missing in the client manifest.json)
|
|
132
127
|
async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
133
|
-
const isForClientSide = !
|
|
128
|
+
const isForClientSide = !isViteServerSide_viteEnvOptional(config);
|
|
134
129
|
const fileTypes = isForClientSide ? ['.page', '.page.client'] : ['.page', '.page.server'];
|
|
135
130
|
if (isForClientSide && includeAssetsImportedByServer) {
|
|
136
131
|
fileTypes.push('.page.server');
|
|
@@ -174,7 +169,7 @@ function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
|
174
169
|
}
|
|
175
170
|
function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
176
171
|
let { pageId } = pageConfig;
|
|
177
|
-
const entryTarget =
|
|
172
|
+
const entryTarget = generateVirtualFileId({ type: 'page-entry', pageId, isForClientSide });
|
|
178
173
|
let entryName = pageId;
|
|
179
174
|
// Avoid:
|
|
180
175
|
// ```
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* We create a file `dist/server/package.json` to support ESM users.
|
|
3
|
-
* Otherwise, following error is thrown:
|
|
4
|
-
* Must use import to load ES Module: dist/server/pageFiles.js
|
|
5
|
-
* require() of ES modules is not supported.
|
|
6
|
-
* require() of dist/server/pageFiles.js from node_modules/vike/dist/esm/node/runtime/page-files/setup.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
|
|
7
|
-
* Reproduction: https://github.com/brillout/vite-plugin-ssr-server-import-syntax
|
|
8
|
-
*/
|
|
9
1
|
export { pluginDistPackageJsonFile };
|
|
10
2
|
import { rollupIsEsm } from '../../shared/rollupIsEsm.js';
|
|
11
|
-
import {
|
|
3
|
+
import { isViteServerSide } from '../../shared/isViteServerSide.js';
|
|
12
4
|
function pluginDistPackageJsonFile() {
|
|
13
5
|
let config;
|
|
14
6
|
return {
|
|
@@ -18,7 +10,7 @@ function pluginDistPackageJsonFile() {
|
|
|
18
10
|
config = config_;
|
|
19
11
|
},
|
|
20
12
|
generateBundle(options, bundle) {
|
|
21
|
-
if (!
|
|
13
|
+
if (!isViteServerSide(config, this.environment))
|
|
22
14
|
return;
|
|
23
15
|
const isEsm = rollupIsEsm(options);
|
|
24
16
|
const fileName = 'package.json';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginModuleBanner };
|
|
2
|
-
import MagicString from 'magic-string';
|
|
3
2
|
import { removeVirtualFileIdPrefix } from '../../utils.js';
|
|
4
|
-
import {
|
|
3
|
+
import { getMagicString } from '../../shared/getMagicString.js';
|
|
4
|
+
import { isViteServerSide_extraSafe } from '../../shared/isViteServerSide.js';
|
|
5
5
|
// Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
|
|
6
6
|
// But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
|
|
7
7
|
function pluginModuleBanner() {
|
|
@@ -16,7 +16,7 @@ function pluginModuleBanner() {
|
|
|
16
16
|
transform: {
|
|
17
17
|
order: 'post',
|
|
18
18
|
handler(code, id, options) {
|
|
19
|
-
if (!
|
|
19
|
+
if (!isViteServerSide_extraSafe(config, this.environment, options) &&
|
|
20
20
|
// Inject module banners if user sets `build.minify` to `false` for inspecting dist/client/
|
|
21
21
|
config.build.minify) {
|
|
22
22
|
return;
|
|
@@ -27,15 +27,12 @@ function pluginModuleBanner() {
|
|
|
27
27
|
if (id.startsWith(config.root))
|
|
28
28
|
id = id.slice(config.root.length + 1);
|
|
29
29
|
id = id.replaceAll('*/', '*\\/'); // https://github.com/vikejs/vike/issues/2377
|
|
30
|
-
const magicString =
|
|
30
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
31
31
|
// Use legal comment so that esbuild doesn't remove it.
|
|
32
32
|
// - Terser still removes the comment, but I guess users use terser to minify JavaScript so I guess it's a good thing that comment is removed.
|
|
33
33
|
// - https://esbuild.github.io/api/#legal-comments
|
|
34
34
|
magicString.prepend(`/*! ${id} [vike:pluginModuleBanner] */\n`);
|
|
35
|
-
return
|
|
36
|
-
code: magicString.toString(),
|
|
37
|
-
map: magicString.generateMap({ hires: true, source: id }),
|
|
38
|
-
};
|
|
35
|
+
return getMagicStringResult();
|
|
39
36
|
},
|
|
40
37
|
},
|
|
41
38
|
};
|
package/dist/esm/node/vite/plugins/pluginBuild/{pluginBuildEntry.d.ts → pluginProdBuildEntry.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { pluginProdBuildEntry };
|
|
2
2
|
export { set_macro_ASSETS_MANIFEST };
|
|
3
3
|
import type { Plugin, Rollup } from 'vite';
|
|
4
4
|
type Bundle = Rollup.OutputBundle;
|
|
5
|
-
declare function
|
|
5
|
+
declare function pluginProdBuildEntry(): Plugin[];
|
|
6
6
|
declare function set_macro_ASSETS_MANIFEST(assetsJsonFilePath: string | undefined, bundle: Bundle, outDir: string): Promise<boolean>;
|
package/dist/esm/node/vite/plugins/pluginBuild/{pluginBuildEntry.js → pluginProdBuildEntry.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { pluginProdBuildEntry };
|
|
2
2
|
export { set_macro_ASSETS_MANIFEST };
|
|
3
3
|
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
|
-
import {
|
|
5
|
-
import { assert, PROJECT_VERSION,
|
|
4
|
+
import { virtualFileIdGlobalEntryServer } from '../../../shared/virtualFileId.js';
|
|
5
|
+
import { assert, PROJECT_VERSION, requireResolveDistFile } from '../../utils.js';
|
|
6
6
|
import fs from 'node:fs/promises';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { isUsingClientRouter } from '../pluginExtractExportNames.js';
|
|
@@ -10,11 +10,11 @@ import { assertBuildInfo } from '../../../runtime/globalContext.js';
|
|
|
10
10
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
11
11
|
import { getViteConfigRuntime } from '../../shared/getViteConfigRuntime.js';
|
|
12
12
|
const ASSETS_MANIFEST = '__VITE_ASSETS_MANIFEST__';
|
|
13
|
-
function
|
|
13
|
+
function pluginProdBuildEntry() {
|
|
14
14
|
let config;
|
|
15
15
|
return [
|
|
16
16
|
{
|
|
17
|
-
name: 'vike:build:
|
|
17
|
+
name: 'vike:build:pluginProdBuildEntry',
|
|
18
18
|
apply: 'build',
|
|
19
19
|
enforce: 'post',
|
|
20
20
|
async configResolved(config_) {
|
|
@@ -39,15 +39,15 @@ function getServerProductionEntryCode(config) {
|
|
|
39
39
|
assertBuildInfo(buildInfo);
|
|
40
40
|
// After the old design is removed, let's maybe simplify and move everything into a single virtual module
|
|
41
41
|
const importerCode = [
|
|
42
|
-
` import {
|
|
43
|
-
` import * as
|
|
42
|
+
` import { setGlobalContext_prodBuildEntry } from '${importPath}';`,
|
|
43
|
+
` import * as virtualFileExportsGlobalEntry from '${virtualFileIdGlobalEntryServer}';`,
|
|
44
44
|
` {`,
|
|
45
|
-
// Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to
|
|
45
|
+
// Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to setGlobalContext_prodBuildEntry()
|
|
46
46
|
// - This workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
47
47
|
` const assetsManifest = ${ASSETS_MANIFEST};`,
|
|
48
48
|
` const buildInfo = ${JSON.stringify(buildInfo, null, 2)};`,
|
|
49
|
-
'
|
|
50
|
-
`
|
|
49
|
+
' setGlobalContext_prodBuildEntry({',
|
|
50
|
+
` virtualFileExportsGlobalEntry,`,
|
|
51
51
|
` assetsManifest,`,
|
|
52
52
|
` buildInfo,`,
|
|
53
53
|
' });',
|
|
@@ -90,14 +90,14 @@ function find_ASSETS_MANIFEST(bundle) {
|
|
|
90
90
|
}
|
|
91
91
|
function getImportPath(config) {
|
|
92
92
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
93
|
-
const filePathAbsolute =
|
|
93
|
+
const filePathAbsolute = requireResolveDistFile('dist/esm/__internal/index.js');
|
|
94
94
|
if (
|
|
95
95
|
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|
|
96
96
|
true) {
|
|
97
97
|
return 'vike/__internal';
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
|
-
const { outDirServer } = getOutDirs(config);
|
|
100
|
+
const { outDirServer } = getOutDirs(config, undefined);
|
|
101
101
|
const filePathRelative = path.posix.relative(outDirServer, filePathAbsolute);
|
|
102
102
|
return filePathRelative;
|
|
103
103
|
}
|
|
@@ -3,16 +3,14 @@ import { pluginBuildApp } from './pluginBuild/pluginBuildApp.js';
|
|
|
3
3
|
import { pluginDistPackageJsonFile } from './pluginBuild/pluginDistPackageJsonFile.js';
|
|
4
4
|
import { pluginSuppressRollupWarning } from './pluginBuild/pluginSuppressRollupWarning.js';
|
|
5
5
|
import { pluginDistFileNames } from './pluginBuild/pluginDistFileNames.js';
|
|
6
|
-
import {
|
|
7
|
-
import { pluginBuildEntry } from './pluginBuild/pluginBuildEntry.js';
|
|
6
|
+
import { pluginProdBuildEntry } from './pluginBuild/pluginProdBuildEntry.js';
|
|
8
7
|
import { pluginBuildConfig } from './pluginBuild/pluginBuildConfig.js';
|
|
9
8
|
import { pluginModuleBanner } from './pluginBuild/pluginModuleBanner.js';
|
|
10
9
|
function pluginBuild() {
|
|
11
10
|
return [
|
|
12
11
|
...pluginBuildConfig(),
|
|
13
12
|
...pluginBuildApp(),
|
|
14
|
-
...
|
|
15
|
-
...pluginBuildEntry(),
|
|
13
|
+
...pluginProdBuildEntry(),
|
|
16
14
|
pluginDistPackageJsonFile(),
|
|
17
15
|
pluginSuppressRollupWarning(),
|
|
18
16
|
pluginDistFileNames(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { determineFsAllowList };
|
|
2
2
|
import { searchForWorkspaceRoot } from 'vite';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { assert, assertPosixPath,
|
|
4
|
+
import { assert, assertPosixPath, getPackageNodeModulesDirectory } from '../../utils.js';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
7
7
|
const importMetaUrl = import.meta.url;
|
|
@@ -18,6 +18,6 @@ async function determineFsAllowList(config) {
|
|
|
18
18
|
// We add it again just to be sure.
|
|
19
19
|
fsAllow.push(searchForWorkspaceRoot(process.cwd()));
|
|
20
20
|
// Add node_modules/vike/
|
|
21
|
-
const
|
|
22
|
-
fsAllow.push(
|
|
21
|
+
const packageNodeModulesDirectory = getPackageNodeModulesDirectory();
|
|
22
|
+
fsAllow.push(packageNodeModulesDirectory);
|
|
23
23
|
}
|
|
@@ -3,7 +3,7 @@ import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
|
3
3
|
import { assert, assertIsImportPathNpmPackage, createDebugger, getNpmPackageName, isArray, isFilePathAbsoluteFilesystem, isVirtualFileId, } from '../../utils.js';
|
|
4
4
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
5
5
|
import { analyzeClientEntries } from '../pluginBuild/pluginBuildConfig.js';
|
|
6
|
-
import {
|
|
6
|
+
import { virtualFileIdGlobalEntryClientCR, virtualFileIdGlobalEntryClientSR } from '../../../shared/virtualFileId.js';
|
|
7
7
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
8
8
|
import { getConfigValueSourcesRelevant } from '../pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
9
9
|
const debug = createDebugger('vike:optimizeDeps');
|
|
@@ -13,8 +13,9 @@ async function determineOptimizeDeps(config) {
|
|
|
13
13
|
const { entriesClient, entriesServer, includeClient, includeServer } = await getPageDeps(config, pageConfigs);
|
|
14
14
|
config.optimizeDeps.include = add(config.optimizeDeps.include, includeClient);
|
|
15
15
|
config.optimizeDeps.entries = add(config.optimizeDeps.entries, entriesClient);
|
|
16
|
-
// Workaround
|
|
17
|
-
// -
|
|
16
|
+
// Workaround for https://github.com/vitejs/vite-plugin-react/issues/650
|
|
17
|
+
// - The issue was closed as completed with https://github.com/vitejs/vite/pull/20495 but it doesn't fix the issue and the workaround is still needed.
|
|
18
|
+
// - TO-DO/eventually: try removing the workaround and see if the CI fails (at test/@cloudflare_vite-plugin/) — maybe the issue will get fixed at some point.
|
|
18
19
|
includeServer.push('react/jsx-dev-runtime');
|
|
19
20
|
for (const envName in config.environments) {
|
|
20
21
|
const env = config.environments[envName];
|
|
@@ -131,9 +132,9 @@ async function getPageDeps(config, pageConfigs) {
|
|
|
131
132
|
const { hasClientRouting, hasServerRouting, clientEntries } = analyzeClientEntries(pageConfigs, config);
|
|
132
133
|
Object.values(clientEntries).forEach((e) => addEntry(e, true));
|
|
133
134
|
if (hasClientRouting)
|
|
134
|
-
addEntry(
|
|
135
|
+
addEntry(virtualFileIdGlobalEntryClientCR, true);
|
|
135
136
|
if (hasServerRouting)
|
|
136
|
-
addEntry(
|
|
137
|
+
addEntry(virtualFileIdGlobalEntryClientSR, true);
|
|
137
138
|
}
|
|
138
139
|
entriesClient = entriesClient;
|
|
139
140
|
entriesServer = entriesServer;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export { pluginEnvVars };
|
|
2
|
-
import MagicString from 'magic-string';
|
|
3
2
|
import { loadEnv } from 'vite';
|
|
4
3
|
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, isNotNullish, lowerFirst, } from '../utils.js';
|
|
5
4
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
6
5
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
7
|
+
import { getMagicString } from '../shared/getMagicString.js';
|
|
9
8
|
// TO-DO/eventually:
|
|
10
9
|
// - Make import.meta.env work inside +config.js
|
|
11
10
|
// - For it to work, we'll probably need the user to define the settings (e.g. `envDir`) for loadEnv() inside vike.config.js instead of vite.config.js
|
|
@@ -37,8 +36,8 @@ function pluginEnvVars() {
|
|
|
37
36
|
if (!code.includes('import.meta.env.'))
|
|
38
37
|
return;
|
|
39
38
|
const isBuild = config.command === 'build';
|
|
40
|
-
const isClientSide = !
|
|
41
|
-
const magicString =
|
|
39
|
+
const isClientSide = !isViteServerSide_extraSafe(config, this.environment, options);
|
|
40
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
42
41
|
// Find & check
|
|
43
42
|
const replacements = Object.entries(envsAll)
|
|
44
43
|
.filter(([key]) => {
|
|
@@ -76,14 +75,11 @@ function pluginEnvVars() {
|
|
|
76
75
|
.filter(isNotNullish);
|
|
77
76
|
// Apply
|
|
78
77
|
replacements.forEach(({ regExpStr, replacement }) => {
|
|
79
|
-
|
|
78
|
+
magicString.replaceAll(new RegExp(regExpStr, 'g'), JSON.stringify(replacement));
|
|
80
79
|
});
|
|
81
80
|
if (!magicString.hasChanged())
|
|
82
81
|
return null;
|
|
83
|
-
return
|
|
84
|
-
code: magicString.toString(),
|
|
85
|
-
map: magicString.generateMap({ hires: true, source: id }),
|
|
86
|
-
};
|
|
82
|
+
return getMagicStringResult();
|
|
87
83
|
},
|
|
88
84
|
};
|
|
89
85
|
}
|