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
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
|
}
|
|
@@ -15,8 +15,8 @@ import { handleAssetsManifest_isFixEnabled } from './pluginBuild/handleAssetsMan
|
|
|
15
15
|
import { getVikeConfigInternal } from '../shared/resolveVikeConfigInternal.js';
|
|
16
16
|
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
17
17
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
18
|
-
import {
|
|
19
|
-
import { resolveIncludeAssetsImportedByServer } from '../../runtime/renderPage/getPageAssets.js';
|
|
18
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
19
|
+
import { resolveIncludeAssetsImportedByServer } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
20
20
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
21
21
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
22
22
|
const urlRE = /(\?|&)url(?:&|$)/;
|
|
@@ -45,7 +45,7 @@ function pluginExtractAssets() {
|
|
|
45
45
|
}
|
|
46
46
|
const includeAssetsImportedByServer = resolveIncludeAssetsImportedByServer(vikeConfig.config);
|
|
47
47
|
assert(includeAssetsImportedByServer);
|
|
48
|
-
assert(!
|
|
48
|
+
assert(!isViteServerSide_extraSafe(config, this.environment, options));
|
|
49
49
|
const importStatements = await getImportStatements(src);
|
|
50
50
|
const moduleNames = getImportedModules(importStatements);
|
|
51
51
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
@@ -62,7 +62,7 @@ function pluginExtractAssets() {
|
|
|
62
62
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
63
63
|
enforce: 'pre',
|
|
64
64
|
async resolveId(source, importer, options) {
|
|
65
|
-
if (
|
|
65
|
+
if (isViteServerSide_extraSafe(config, this.environment, options)) {
|
|
66
66
|
// When building for the server, there should never be a `?extractAssets` query
|
|
67
67
|
assert(!extractAssetsRE.test(source));
|
|
68
68
|
assert(importer === undefined || !extractAssetsRE.test(importer));
|
|
@@ -139,7 +139,7 @@ function pluginExtractAssets() {
|
|
|
139
139
|
async configResolved(config_) {
|
|
140
140
|
config = config_;
|
|
141
141
|
vikeConfig = await getVikeConfigInternal();
|
|
142
|
-
isFixEnabled = handleAssetsManifest_isFixEnabled(
|
|
142
|
+
isFixEnabled = handleAssetsManifest_isFixEnabled();
|
|
143
143
|
if (!isFixEnabled) {
|
|
144
144
|
// https://github.com/vikejs/vike/issues/1060
|
|
145
145
|
assertUsage(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
|
|
@@ -4,18 +4,19 @@ export { extractExportNamesRE };
|
|
|
4
4
|
import { assert, getFileExtension, createDebugger, getGlobalObject, assertUsage, rollupSourceMapRemove, } from '../utils.js';
|
|
5
5
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
6
6
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
|
-
import {
|
|
7
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
8
8
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
9
9
|
const debug = createDebugger('vike:pluginExtractExportNames');
|
|
10
10
|
const globalObject = getGlobalObject('plugins/pluginExtractExportNames.ts', {});
|
|
11
11
|
function pluginExtractExportNames() {
|
|
12
12
|
let isDev = false;
|
|
13
|
+
let config;
|
|
13
14
|
return {
|
|
14
15
|
name: 'vike:pluginExtractExportNames',
|
|
15
16
|
enforce: 'post',
|
|
16
17
|
async transform(src, id, options) {
|
|
17
18
|
id = normalizeId(id);
|
|
18
|
-
const isClientSide = !
|
|
19
|
+
const isClientSide = !isViteServerSide_extraSafe(config, this.environment, options);
|
|
19
20
|
if (extractExportNamesRE.test(id)) {
|
|
20
21
|
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
21
22
|
debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
|
|
@@ -25,6 +26,9 @@ function pluginExtractExportNames() {
|
|
|
25
26
|
configureServer() {
|
|
26
27
|
isDev = true;
|
|
27
28
|
},
|
|
29
|
+
configResolved(config_) {
|
|
30
|
+
config = config_;
|
|
31
|
+
},
|
|
28
32
|
config() {
|
|
29
33
|
if (debug.isActivated) {
|
|
30
34
|
return { logLevel: 'silent' };
|
|
@@ -7,6 +7,7 @@ import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
|
7
7
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
8
8
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
9
9
|
import { isV1Design } from '../shared/resolveVikeConfigInternal.js';
|
|
10
|
+
import { isViteServerSide, isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
10
11
|
function pluginFileEnv() {
|
|
11
12
|
let config;
|
|
12
13
|
let viteDevServer;
|
|
@@ -28,7 +29,7 @@ function pluginFileEnv() {
|
|
|
28
29
|
const importers = Array.from(moduleInfo.importers)
|
|
29
30
|
.map((m) => m.id)
|
|
30
31
|
.filter((id) => id !== null);
|
|
31
|
-
assertFileEnv(id,
|
|
32
|
+
assertFileEnv(id, isViteServerSide_extraSafe(config, this.environment, options), importers,
|
|
32
33
|
// In dev, we only show a warning because we don't want to disrupt when the user plays with settings such as [ssr](https://vike.dev/ssr).
|
|
33
34
|
true);
|
|
34
35
|
},
|
|
@@ -40,7 +41,7 @@ function pluginFileEnv() {
|
|
|
40
41
|
return;
|
|
41
42
|
if (skip(id))
|
|
42
43
|
return;
|
|
43
|
-
const isServerSide =
|
|
44
|
+
const isServerSide = isViteServerSide_extraSafe(config, this.environment, options);
|
|
44
45
|
if (!isWrongEnv(id, isServerSide))
|
|
45
46
|
return;
|
|
46
47
|
const { importers } = this.getModuleInfo(id);
|
|
@@ -66,7 +67,7 @@ function pluginFileEnv() {
|
|
|
66
67
|
*/
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
|
-
assertFileEnv(moduleId,
|
|
70
|
+
assertFileEnv(moduleId, isViteServerSide(config, this.environment), importers, false);
|
|
70
71
|
});
|
|
71
72
|
},
|
|
72
73
|
configResolved(config_) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { pluginNonRunnableDev };
|
|
2
|
-
import { createViteRPC, assertIsNotProductionRuntime,
|
|
3
|
-
import {
|
|
4
|
-
import { retrieveAssetsDev } from '../../runtime/renderPage/getPageAssets/retrieveAssetsDev.js';
|
|
2
|
+
import { createViteRPC, assertIsNotProductionRuntime, requireResolveDistFile, isRunnableDevEnvironment, } from '../utils.js';
|
|
3
|
+
import { retrievePageAssetsDev } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsDev.js';
|
|
5
4
|
import { getViteConfigRuntime } from '../shared/getViteConfigRuntime.js';
|
|
6
5
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
7
6
|
assertIsNotProductionRuntime();
|
|
@@ -10,11 +9,8 @@ function getViteRpcFunctions(viteDevServer) {
|
|
|
10
9
|
async transformIndexHtmlRPC(html) {
|
|
11
10
|
return await viteDevServer.transformIndexHtml('/', html);
|
|
12
11
|
},
|
|
13
|
-
// TODO/now: dedupe retrievePageAssetsDevRPC and retrievePageAssetsDev()
|
|
14
12
|
async retrievePageAssetsDevRPC(clientDependencies, clientEntries) {
|
|
15
|
-
|
|
16
|
-
const assetUrls = await retrieveAssetsDev(clientDependencies, viteDevServer);
|
|
17
|
-
return { clientEntriesSrc, assetUrls };
|
|
13
|
+
return await retrievePageAssetsDev(viteDevServer, clientDependencies, clientEntries);
|
|
18
14
|
},
|
|
19
15
|
async getViteConfigRuntimeRPC() {
|
|
20
16
|
return getViteConfigRuntime(viteDevServer.config);
|
|
@@ -22,7 +18,8 @@ function getViteRpcFunctions(viteDevServer) {
|
|
|
22
18
|
};
|
|
23
19
|
}
|
|
24
20
|
function pluginNonRunnableDev() {
|
|
25
|
-
const
|
|
21
|
+
const distFileIsNonRunnableDev = requireResolveDistFile('dist/esm/utils/isNonRunnableDev.js');
|
|
22
|
+
const distFileGlobalContext = requireResolveDistFile('dist/esm/node/runtime/globalContext.js');
|
|
26
23
|
let config;
|
|
27
24
|
return {
|
|
28
25
|
name: 'vike:pluginNonRunnableDev',
|
|
@@ -35,14 +32,17 @@ function pluginNonRunnableDev() {
|
|
|
35
32
|
transform(code, id) {
|
|
36
33
|
if (!config._isDev)
|
|
37
34
|
return;
|
|
38
|
-
if (id !==
|
|
35
|
+
if (id !== distFileIsNonRunnableDev && id !== distFileGlobalContext)
|
|
36
|
+
return;
|
|
37
|
+
if (isRunnableDevEnvironment(this.environment))
|
|
39
38
|
return;
|
|
40
|
-
const isNonRunnableDev = !isRunnableDevEnvironment(this.environment);
|
|
41
39
|
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
42
|
-
if (
|
|
40
|
+
if (id === distFileIsNonRunnableDev) {
|
|
41
|
+
magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(true));
|
|
42
|
+
}
|
|
43
|
+
if (id === distFileGlobalContext) {
|
|
43
44
|
magicString.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
|
|
44
45
|
}
|
|
45
|
-
magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(isNonRunnableDev));
|
|
46
46
|
return getMagicStringResult();
|
|
47
47
|
},
|
|
48
48
|
};
|
|
@@ -5,7 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import { addSsrMiddleware } from '../shared/addSsrMiddleware.js';
|
|
6
6
|
import pc from '@brillout/picocolors';
|
|
7
7
|
import { logDockerHint } from './pluginDev.js';
|
|
8
|
-
import { getOutDirs
|
|
8
|
+
import { getOutDirs } from '../shared/getOutDirs.js';
|
|
9
9
|
import sirv from 'sirv';
|
|
10
10
|
import { getVikeConfigInternal } from '../shared/resolveVikeConfigInternal.js';
|
|
11
11
|
function pluginPreview() {
|
|
@@ -14,12 +14,9 @@ function pluginPreview() {
|
|
|
14
14
|
return {
|
|
15
15
|
name: 'vike:pluginPreview',
|
|
16
16
|
apply: applyPreview,
|
|
17
|
-
config(
|
|
17
|
+
config() {
|
|
18
18
|
return {
|
|
19
19
|
appType: 'custom',
|
|
20
|
-
build: {
|
|
21
|
-
outDir: resolveOutDir(config),
|
|
22
|
-
},
|
|
23
20
|
};
|
|
24
21
|
},
|
|
25
22
|
async configResolved(config_) {
|
|
@@ -46,7 +43,7 @@ function pluginPreview() {
|
|
|
46
43
|
},
|
|
47
44
|
};
|
|
48
45
|
function assertDist(isPrerenderingEnabledForAllPages) {
|
|
49
|
-
const { outDirRoot, outDirClient, outDirServer } = getOutDirs(config);
|
|
46
|
+
const { outDirRoot, outDirClient, outDirServer } = getOutDirs(config, undefined);
|
|
50
47
|
const dirS = [outDirRoot, outDirClient];
|
|
51
48
|
if (!isPrerenderingEnabledForAllPages)
|
|
52
49
|
dirS.push(outDirServer);
|
|
@@ -55,11 +52,11 @@ function pluginPreview() {
|
|
|
55
52
|
});
|
|
56
53
|
}
|
|
57
54
|
function addStaticAssetsMiddleware(middlewares) {
|
|
58
|
-
const { outDirClient } = getOutDirs(config);
|
|
55
|
+
const { outDirClient } = getOutDirs(config, undefined);
|
|
59
56
|
middlewares.use(sirv(outDirClient));
|
|
60
57
|
}
|
|
61
58
|
function addStatic404Middleware(middlewares) {
|
|
62
|
-
const { outDirClient } = getOutDirs(config);
|
|
59
|
+
const { outDirClient } = getOutDirs(config, undefined);
|
|
63
60
|
middlewares.use(config.base, (_, res, next) => {
|
|
64
61
|
const file = path.posix.join(outDirClient, './404.html');
|
|
65
62
|
if (fs.existsSync(file)) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { pluginReplaceConstants };
|
|
2
|
-
import MagicString from 'magic-string';
|
|
3
2
|
import { assert, assertPosixPath } from '../utils.js';
|
|
4
3
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
5
|
+
import { getMagicString } from '../shared/getMagicString.js';
|
|
7
6
|
function pluginReplaceConstants() {
|
|
8
7
|
let config;
|
|
9
8
|
return {
|
|
@@ -30,24 +29,21 @@ function pluginReplaceConstants() {
|
|
|
30
29
|
// @ts-expect-error
|
|
31
30
|
if (config._skipVikeReplaceConstants?.(id))
|
|
32
31
|
return;
|
|
33
|
-
const magicString =
|
|
32
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
34
33
|
const constantsMap = [];
|
|
35
34
|
constantsMap.push({
|
|
36
35
|
constants: ['pageContext.isClientSide', 'globalContext.isClientSide', 'pageContext.globalContext.isClientSide'],
|
|
37
|
-
replacement: !
|
|
36
|
+
replacement: !isViteServerSide_extraSafe(config, this.environment, options),
|
|
38
37
|
});
|
|
39
38
|
constantsMap.forEach(({ constants, replacement }) => {
|
|
40
39
|
if (!constants.some((c) => code.includes(c)))
|
|
41
40
|
return;
|
|
42
41
|
const regExp = getConstantRegExp(constants);
|
|
43
|
-
|
|
42
|
+
magicString.replaceAll(regExp, JSON.stringify(replacement));
|
|
44
43
|
});
|
|
45
44
|
if (!magicString.hasChanged())
|
|
46
45
|
return null;
|
|
47
|
-
return
|
|
48
|
-
code: magicString.toString(),
|
|
49
|
-
map: magicString.generateMap({ hires: true, source: id }),
|
|
50
|
-
};
|
|
46
|
+
return getMagicStringResult();
|
|
51
47
|
},
|
|
52
48
|
};
|
|
53
49
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { pluginSetGlobalContext };
|
|
2
|
-
import { setGlobalContext_viteDevServer, setGlobalContext_viteConfig,
|
|
2
|
+
import { setGlobalContext_viteDevServer, setGlobalContext_viteConfig, setGlobalContext_isProductionAccordingToVite, } from '../../runtime/globalContext.js';
|
|
3
3
|
import { isDevCheck, markSetup_isViteDev, markSetup_viteDevServer, markSetup_vitePreviewServer } from '../utils.js';
|
|
4
4
|
import { reloadVikeConfig } from '../shared/resolveVikeConfigInternal.js';
|
|
5
5
|
import { getViteConfigRuntime } from '../shared/getViteConfigRuntime.js';
|
|
@@ -27,7 +27,7 @@ function pluginSetGlobalContext() {
|
|
|
27
27
|
order: 'pre',
|
|
28
28
|
handler(_, env) {
|
|
29
29
|
const isViteDev = isDevCheck(env);
|
|
30
|
-
|
|
30
|
+
setGlobalContext_isProductionAccordingToVite(!isViteDev);
|
|
31
31
|
markSetup_isViteDev(isViteDev);
|
|
32
32
|
},
|
|
33
33
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import {
|
|
1
|
+
export { generateVirtualFileGlobalEntry };
|
|
2
|
+
import { generateVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
3
3
|
import { debug } from './debug.js';
|
|
4
4
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
5
5
|
import { serializeConfigValues } from '../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
6
|
-
async function
|
|
6
|
+
async function generateVirtualFileGlobalEntry(isForClientSide, isDev, id, isClientRouting) {
|
|
7
7
|
const vikeConfig = await getVikeConfigInternal(true);
|
|
8
8
|
const { _pageConfigs: pageConfigs, _pageConfigGlobal: pageConfigGlobal } = vikeConfig;
|
|
9
9
|
return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
|
|
@@ -34,9 +34,8 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
34
34
|
lines.push(` pageId: ${JSON.stringify(pageId)},`);
|
|
35
35
|
lines.push(` isErrorPage: ${JSON.stringify(isErrorPage)},`);
|
|
36
36
|
lines.push(` routeFilesystem: ${JSON.stringify(routeFilesystem)},`);
|
|
37
|
-
const virtualFileId = JSON.stringify(
|
|
38
|
-
|
|
39
|
-
lines.push(` loadConfigLazy: ${load},`);
|
|
37
|
+
const virtualFileId = JSON.stringify(generateVirtualFileId({ type: 'page-entry', pageId, isForClientSide }));
|
|
38
|
+
lines.push(` loadVirtualFilePageEntry: () => ({ moduleId: ${virtualFileId}, moduleExportsPromise: import(${virtualFileId}) }),`);
|
|
40
39
|
lines.push(` configValuesSerialized: {`);
|
|
41
40
|
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, { isForClientSide, isClientRouting, isDev }, ' ', true));
|
|
42
41
|
lines.push(` },`);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { generateVirtualFileGlobalEntryWithOldDesign };
|
|
2
|
+
import type { ResolvedConfig } from 'vite';
|
|
3
|
+
import type { Environment } from 'vite';
|
|
4
|
+
declare function generateVirtualFileGlobalEntryWithOldDesign(id: string, options: {
|
|
5
|
+
ssr?: boolean;
|
|
6
|
+
} | undefined, config: ResolvedConfig, env: Environment, isDev: boolean): Promise<string>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { generateVirtualFileGlobalEntryWithOldDesign };
|
|
2
2
|
import { assert, assertPosixPath, scriptFileExtensionPattern, debugGlob, isVersionOrAbove, assertWarning, } from '../../utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { parseVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
4
4
|
import { version as viteVersion } from 'vite';
|
|
5
5
|
import { fileTypes } from '../../../../shared/getPageFiles/fileTypes.js';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
-
import {
|
|
7
|
+
import { generateVirtualFileGlobalEntry } from './generateVirtualFileGlobalEntry.js';
|
|
8
8
|
import { getVikeConfigInternal, isV1Design as isV1Design_ } from '../../shared/resolveVikeConfigInternal.js';
|
|
9
9
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
10
|
-
import {
|
|
11
|
-
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets.js';
|
|
12
|
-
async function
|
|
13
|
-
const idParsed =
|
|
14
|
-
assert(idParsed);
|
|
10
|
+
import { isViteServerSide_extraSafe } from '../../shared/isViteServerSide.js';
|
|
11
|
+
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
12
|
+
async function generateVirtualFileGlobalEntryWithOldDesign(id, options, config, env, isDev) {
|
|
13
|
+
const idParsed = parseVirtualFileId(id);
|
|
14
|
+
assert(idParsed && idParsed.type === 'global-entry');
|
|
15
15
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
16
|
-
assert(isForClientSide === !
|
|
16
|
+
assert(isForClientSide === !isViteServerSide_extraSafe(config, env, options));
|
|
17
17
|
const code = await getCode(config, isForClientSide, isClientRouting, isDev, id);
|
|
18
18
|
return code;
|
|
19
19
|
}
|
|
@@ -66,7 +66,7 @@ export const pageFilesExportNamesEager = {};
|
|
|
66
66
|
export const pageFilesList = [];
|
|
67
67
|
export const neverLoaded = {};
|
|
68
68
|
|
|
69
|
-
${await
|
|
69
|
+
${await generateVirtualFileGlobalEntry(isForClientSide, isDev, id, isClientRouting)}
|
|
70
70
|
|
|
71
71
|
`;
|
|
72
72
|
// We still use import.meta.glob() when using th V1 design in order to not break the V1 design deprecation warning
|
|
@@ -168,7 +168,7 @@ function getGlobRoots(config) {
|
|
|
168
168
|
const globRoots = [
|
|
169
169
|
{
|
|
170
170
|
includeDir: '/',
|
|
171
|
-
excludeDir: path.posix.relative(config.root, getOutDirs(config).outDirRoot),
|
|
171
|
+
excludeDir: path.posix.relative(config.root, getOutDirs(config, undefined).outDirRoot),
|
|
172
172
|
},
|
|
173
173
|
];
|
|
174
174
|
return globRoots;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
export {
|
|
2
|
-
// TODO/now: rename file to generateVirtualFileEntryPage.ts
|
|
1
|
+
export { generateVirtualFilePageEntry };
|
|
3
2
|
import { assert, getProjectError } from '../../utils.js';
|
|
4
|
-
import {
|
|
3
|
+
import { parseVirtualFileId, generateVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
5
4
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
6
5
|
import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
7
6
|
import { debug } from './debug.js';
|
|
8
7
|
import { serializeConfigValues } from '../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
9
8
|
import { handleAssetsManifest_isFixEnabled } from '../pluginBuild/handleAssetsManifest.js';
|
|
10
9
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
11
|
-
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets.js';
|
|
12
|
-
async function
|
|
13
|
-
const result =
|
|
14
|
-
assert(result);
|
|
10
|
+
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
11
|
+
async function generateVirtualFilePageEntry(id, isDev) {
|
|
12
|
+
const result = parseVirtualFileId(id);
|
|
13
|
+
assert(result && result.type === 'page-entry');
|
|
15
14
|
/* This assertion fails when using includeAssetsImportedByServer
|
|
16
15
|
{
|
|
17
16
|
const isForClientSide = !config.build.ssr
|
|
@@ -33,11 +32,11 @@ async function getVirtualFilePageConfigLazy(id, isDev, config) {
|
|
|
33
32
|
throw getProjectError('Outdated request');
|
|
34
33
|
//*/
|
|
35
34
|
}
|
|
36
|
-
const code =
|
|
35
|
+
const code = getCode(pageConfig, isForClientSide, pageId, resolveIncludeAssetsImportedByServer(vikeConfig.config), isDev);
|
|
37
36
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
38
37
|
return code;
|
|
39
38
|
}
|
|
40
|
-
function
|
|
39
|
+
function getCode(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
41
40
|
const lines = [];
|
|
42
41
|
const importStatements = [];
|
|
43
42
|
const filesEnv = new Map();
|
|
@@ -45,8 +44,8 @@ function getLoadConfigLazy(pageConfig, isForClientSide, pageId, includeAssetsImp
|
|
|
45
44
|
lines.push('export const configValuesSerialized = {');
|
|
46
45
|
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, { isForClientSide, isClientRouting, isDev }, '', false));
|
|
47
46
|
lines.push('};');
|
|
48
|
-
if (!handleAssetsManifest_isFixEnabled(
|
|
49
|
-
importStatements.push(`import '${extractAssetsAddQuery(
|
|
47
|
+
if (!handleAssetsManifest_isFixEnabled() && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
48
|
+
importStatements.push(`import '${extractAssetsAddQuery(generateVirtualFileId({ type: 'page-entry', pageId, isForClientSide: false }))}'`);
|
|
50
49
|
}
|
|
51
50
|
const code = [...importStatements, ...lines].join('\n');
|
|
52
51
|
return code;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { getConfigValueSourcesRelevant };
|
|
2
|
+
export { getConfigValueSourceRelevantAnyEnv };
|
|
2
3
|
export { isRuntimeEnvMatch };
|
|
4
|
+
export { isConfigSourceValueNull };
|
|
3
5
|
export type { RuntimeEnv };
|
|
4
6
|
import type { ConfigEnvInternal, ConfigValueSource, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../../types/PageConfig.js';
|
|
5
7
|
type RuntimeEnv = {
|
|
@@ -9,6 +11,8 @@ type RuntimeEnv = {
|
|
|
9
11
|
} | {
|
|
10
12
|
isForConfig: true;
|
|
11
13
|
};
|
|
14
|
+
type PageConfigPartial = Pick<PageConfigBuildTime | PageConfigGlobalBuildTime, 'configValueSources' | 'configDefinitions'>;
|
|
12
15
|
declare function getConfigValueSourcesRelevant(configName: string, runtimeEnv: RuntimeEnv, pageConfig: PageConfigPartial): ConfigValueSource[];
|
|
16
|
+
declare function getConfigValueSourceRelevantAnyEnv(configName: string, pageConfig: PageConfigPartial): null | ConfigValueSource;
|
|
13
17
|
declare function isRuntimeEnvMatch(configEnv: ConfigEnvInternal, runtimeEnv: RuntimeEnv): boolean;
|
|
14
|
-
|
|
18
|
+
declare function isConfigSourceValueNull(source: ConfigValueSource): boolean | null;
|