vike 0.4.220 → 0.4.221-commit-8577456
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 +5 -23
- package/dist/cjs/node/api/build.js +33 -24
- package/dist/cjs/node/api/context.js +6 -8
- package/dist/cjs/node/api/prepareViteApiCall.js +23 -21
- package/dist/cjs/node/api/prerender.js +1 -0
- package/dist/cjs/node/api/utils.js +2 -1
- package/dist/cjs/node/cli/context.js +16 -0
- package/dist/cjs/node/cli/entry.js +2 -0
- package/dist/cjs/node/cli/utils.js +1 -0
- package/dist/cjs/node/plugin/index.js +4 -8
- package/dist/cjs/node/plugin/onLoad.js +6 -1
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +34 -33
- package/dist/cjs/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildApp.js +72 -0
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +12 -12
- package/dist/cjs/node/plugin/plugins/buildConfig.js +17 -12
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +28 -24
- package/dist/cjs/node/plugin/plugins/commonConfig.js +9 -7
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +7 -4
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +15 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +11 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{assertExtensions.js → getVikeConfig/assertExtensions.js} +41 -36
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +59 -22
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.js → getVikeConfig/getConfigFileExport.js} +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +159 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +40 -23
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +9 -64
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +403 -590
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{debug.js → virtual-files/debug.js} +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.js → virtual-files/getVirtualFilePageConfigValuesAll.js} +12 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.js → virtual-files/getVirtualFilePageConfigs.js} +13 -11
- package/dist/cjs/node/plugin/plugins/packageJsonFile.js +2 -2
- package/dist/cjs/node/plugin/plugins/previewConfig.js +7 -7
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +3 -5
- package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/cjs/node/plugin/shared/getFullBuildInlineConfig.js +20 -0
- package/dist/cjs/{utils → node/plugin/shared}/getOutDirs.js +70 -61
- package/dist/cjs/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
- package/dist/cjs/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
- package/dist/cjs/node/plugin/utils.js +1 -2
- package/dist/cjs/node/prerender/context.js +31 -0
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +46 -0
- package/dist/cjs/node/prerender/runPrerender.js +89 -68
- package/dist/cjs/node/prerender/utils.js +2 -2
- package/dist/cjs/node/runtime/globalContext.js +222 -150
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +11 -7
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +2 -3
- package/dist/cjs/node/runtime/html/injectAssets.js +4 -4
- package/dist/cjs/node/runtime/html/renderHtml.js +4 -5
- package/dist/cjs/node/runtime/page-files/setup.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -3
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +2 -27
- package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +2 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +4 -4
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +3 -5
- package/dist/cjs/node/runtime/renderPage/isFontFallback.js +29 -0
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +5 -4
- package/dist/cjs/node/runtime/renderPage/log404/index.js +1 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +14 -10
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +6 -5
- package/dist/cjs/node/runtime/renderPage.js +31 -29
- package/dist/cjs/node/runtime/utils.js +3 -3
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +5 -3
- package/dist/cjs/node/shared/resolveBase.js +7 -0
- package/dist/cjs/shared/getPageConfigsRuntime.js +20 -0
- package/dist/cjs/shared/getPageContextUrlComputed.js +6 -1
- package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -1
- package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -3
- package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -5
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +4 -3
- package/dist/cjs/shared/getPageFiles.js +1 -3
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +15 -6
- package/dist/cjs/shared/page-configs/loadConfigValues.js +5 -1
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +69 -18
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -0
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +1 -1
- package/dist/cjs/utils/catchInfiniteLoop.js +34 -0
- package/dist/cjs/utils/debug.js +8 -6
- package/dist/cjs/utils/findFile.js +4 -3
- package/dist/cjs/utils/isDev.js +2 -2
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
- package/dist/cjs/utils/makePublicCopy.js +32 -0
- package/dist/cjs/utils/objectAssignSafe.js +7 -0
- package/dist/cjs/utils/path.js +48 -0
- package/dist/cjs/utils/requireResolve.js +3 -3
- package/dist/esm/__internal/index.d.ts +2 -2
- package/dist/esm/__internal/index.js +7 -26
- package/dist/esm/client/client-routing-runtime/createPageContext.js +5 -9
- package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/history.js +23 -18
- package/dist/esm/client/client-routing-runtime/index.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/index.js +0 -1
- package/dist/esm/client/client-routing-runtime/initClientRouter.js +2 -2
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.d.ts +0 -4
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +0 -11
- package/dist/esm/client/client-routing-runtime/initOnPopState.d.ts +0 -10
- package/dist/esm/client/client-routing-runtime/initOnPopState.js +50 -70
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +15 -15
- package/dist/esm/client/client-routing-runtime/scrollRestoration.d.ts +4 -6
- package/dist/esm/client/client-routing-runtime/scrollRestoration.js +17 -12
- package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/setScrollPosition.js +29 -5
- package/dist/esm/client/client-routing-runtime/skipLink.d.ts +0 -2
- package/dist/esm/client/client-routing-runtime/skipLink.js +0 -1
- package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/utils.js +1 -0
- package/dist/esm/client/server-routing-runtime/getPageContext.js +3 -4
- package/dist/esm/client/shared/loadUserFilesClientSide.js +3 -2
- package/dist/esm/node/api/build.d.ts +1 -6
- package/dist/esm/node/api/build.js +31 -25
- package/dist/esm/node/api/context.d.ts +4 -4
- package/dist/esm/node/api/context.js +6 -9
- package/dist/esm/node/api/prepareViteApiCall.d.ts +4 -3
- package/dist/esm/node/api/prepareViteApiCall.js +24 -22
- package/dist/esm/node/api/prerender.js +1 -0
- package/dist/esm/node/api/utils.d.ts +2 -1
- package/dist/esm/node/api/utils.js +2 -1
- package/dist/esm/node/cli/context.d.ts +5 -0
- package/dist/esm/node/cli/context.js +14 -0
- package/dist/esm/node/cli/entry.js +2 -0
- package/dist/esm/node/cli/parseCli.d.ts +3 -1
- package/dist/esm/node/cli/utils.d.ts +1 -0
- package/dist/esm/node/cli/utils.js +1 -0
- package/dist/esm/node/plugin/index.d.ts +29 -1
- package/dist/esm/node/plugin/index.js +5 -9
- package/dist/esm/node/plugin/onLoad.js +7 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +35 -34
- package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/esm/node/plugin/plugins/buildApp.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/buildApp.js +70 -0
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +11 -11
- package/dist/esm/node/plugin/plugins/buildConfig.js +16 -11
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +28 -24
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +8 -2
- package/dist/esm/node/plugin/plugins/commonConfig.js +7 -5
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +6 -3
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +14 -9
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +11 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.d.ts +6 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{assertExtensions.js → getVikeConfig/assertExtensions.js} +41 -36
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +58 -21
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.js → getVikeConfig/getConfigFileExport.js} +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.d.ts +39 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +154 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +15 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +41 -24
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +8 -18
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +10 -65
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +6 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +12 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +10 -122
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +407 -594
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{debug.js → virtual-files/debug.js} +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.js → virtual-files/getVirtualFilePageConfigValuesAll.js} +12 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.js → virtual-files/getVirtualFilePageConfigs.js} +13 -11
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.d.ts → virtual-files/isRuntimeEnvMatch.d.ts} +1 -1
- package/dist/esm/node/plugin/plugins/packageJsonFile.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +5 -5
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +4 -6
- package/dist/esm/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.d.ts +2 -0
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.js +17 -0
- package/dist/esm/{utils → node/plugin/shared}/getOutDirs.d.ts +1 -1
- package/dist/esm/{utils → node/plugin/shared}/getOutDirs.js +52 -43
- package/dist/esm/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
- package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.d.ts +2 -5
- package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +0 -1
- package/dist/esm/node/plugin/utils.js +1 -2
- package/dist/esm/node/prerender/context.d.ts +11 -0
- package/dist/esm/node/prerender/context.js +29 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +12 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +44 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +42 -1
- package/dist/esm/node/prerender/runPrerender.js +90 -69
- package/dist/esm/node/prerender/utils.d.ts +2 -2
- package/dist/esm/node/prerender/utils.js +2 -2
- package/dist/esm/node/runtime/globalContext.d.ts +44 -36
- package/dist/esm/node/runtime/globalContext.js +223 -151
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +11 -7
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +4 -1
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +2 -3
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -0
- package/dist/esm/node/runtime/html/injectAssets.js +4 -4
- package/dist/esm/node/runtime/html/renderHtml.js +4 -5
- package/dist/esm/node/runtime/page-files/setup.js +1 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -3
- package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -26
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +2 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +3 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +4 -4
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +3 -5
- package/dist/esm/node/runtime/renderPage/isFontFallback.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/isFontFallback.js +27 -0
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +6 -5
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/log404/index.js +1 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +26 -10
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +14 -10
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +5 -5
- package/dist/esm/node/runtime/renderPage.js +32 -30
- package/dist/esm/node/runtime/utils.d.ts +3 -3
- package/dist/esm/node/runtime/utils.js +3 -3
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +5 -3
- package/dist/esm/node/shared/resolveBase.d.ts +5 -1
- package/dist/esm/node/shared/resolveBase.js +7 -0
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +13 -0
- package/dist/esm/shared/getPageConfigsRuntime.js +18 -0
- package/dist/esm/shared/getPageContextUrlComputed.js +6 -1
- package/dist/esm/shared/getPageFiles/fileTypes.js +1 -2
- package/dist/esm/shared/getPageFiles/getAllPageIdFiles.js +0 -3
- package/dist/esm/shared/getPageFiles/getPageFileObject.js +0 -5
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +4 -3
- package/dist/esm/shared/getPageFiles.d.ts +0 -1
- package/dist/esm/shared/getPageFiles.js +0 -1
- package/dist/esm/shared/page-configs/Config.d.ts +83 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +30 -18
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +6 -8
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +15 -6
- package/dist/esm/shared/page-configs/loadConfigValues.js +6 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +7 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +70 -19
- package/dist/esm/shared/route/loadPageRoutes.js +1 -0
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -1
- 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 +1 -1
- package/dist/esm/utils/catchInfiniteLoop.d.ts +2 -0
- package/dist/esm/utils/catchInfiniteLoop.js +32 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +8 -6
- package/dist/esm/utils/findFile.js +2 -1
- package/dist/esm/utils/isDev.js +3 -3
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/makePublicCopy.d.ts +3 -0
- package/dist/esm/utils/makePublicCopy.js +30 -0
- package/dist/esm/utils/objectAssignSafe.d.ts +1 -0
- package/dist/esm/utils/objectAssignSafe.js +4 -0
- package/dist/esm/utils/path.d.ts +14 -0
- package/dist/esm/utils/path.js +46 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -17
- package/dist/cjs/node/plugin/plugins/importUserCode/addImportStatement.js +0 -29
- package/dist/cjs/node/prerender/isPrerenderAutoRunEnabled.js +0 -16
- package/dist/cjs/node/shared/assertPluginManifest.js +0 -20
- package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -16
- package/dist/cjs/shared/assertPageFilePath.js +0 -11
- package/dist/cjs/shared/getPageFiles/getPageFiles.js +0 -48
- package/dist/cjs/utils/filesystemPathHandling.js +0 -18
- package/dist/cjs/utils/path-shim.js +0 -19
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -15
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +0 -14
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.js +0 -27
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +0 -5
- package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.d.ts +0 -5
- package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.js +0 -14
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -12
- package/dist/esm/node/shared/assertPluginManifest.js +0 -18
- package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -10
- package/dist/esm/node/shared/assertRuntimeManifest.js +0 -14
- package/dist/esm/shared/assertPageFilePath.d.ts +0 -2
- package/dist/esm/shared/assertPageFilePath.js +0 -9
- package/dist/esm/shared/getPageFiles/getPageFiles.d.ts +0 -15
- package/dist/esm/shared/getPageFiles/getPageFiles.js +0 -46
- package/dist/esm/utils/filesystemPathHandling.d.ts +0 -4
- package/dist/esm/utils/filesystemPathHandling.js +0 -16
- package/dist/esm/utils/path-shim.d.ts +0 -2
- package/dist/esm/utils/path-shim.js +0 -17
- /package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.js → virtual-files/isRuntimeEnvMatch.js} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.d.ts → getVikeConfig/getConfigFileExport.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{debug.d.ts → virtual-files/debug.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.d.ts → virtual-files/getVirtualFilePageConfigValuesAll.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.d.ts → virtual-files/getVirtualFilePageConfigs.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.js → virtual-files/isRuntimeEnvMatch.js} +0 -0
- /package/dist/esm/node/plugin/{resolveClientEntriesDev.d.ts → shared/resolveClientEntriesDev.d.ts} +0 -0
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
// TODO/v1-release: remove this file
|
|
2
|
+
import { getFullBuildInlineConfig } from '../shared/getFullBuildInlineConfig.js';
|
|
2
3
|
export { autoFullBuild };
|
|
3
4
|
import { build } from 'vite';
|
|
4
|
-
import { assertWarning } from '../utils.js';
|
|
5
|
+
import { assert, assertWarning } from '../utils.js';
|
|
5
6
|
import { runPrerenderFromAutoRun, runPrerender_forceExit } from '../../prerender/runPrerender.js';
|
|
6
|
-
import { isPrerenderAutoRunEnabled } from '../../prerender/
|
|
7
|
+
import { isPrerenderAutoRunEnabled } from '../../prerender/context.js';
|
|
7
8
|
import { isViteCliCall, getViteConfigFromCli } from '../shared/isViteCliCall.js';
|
|
8
9
|
import pc from '@brillout/picocolors';
|
|
9
10
|
import { logErrorHint } from '../../runtime/renderPage/logErrorHint.js';
|
|
10
11
|
import { manifestTempFile } from './buildConfig.js';
|
|
11
12
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
13
|
+
import { isVikeCliOrApi } from '../../api/context.js';
|
|
12
14
|
let forceExit = false;
|
|
13
15
|
function autoFullBuild() {
|
|
14
16
|
let config;
|
|
15
|
-
let
|
|
17
|
+
let vikeConfig;
|
|
16
18
|
return [
|
|
17
19
|
{
|
|
18
20
|
name: 'vike:autoFullBuild',
|
|
19
21
|
apply: 'build',
|
|
20
22
|
enforce: 'pre',
|
|
21
23
|
async configResolved(config_) {
|
|
22
|
-
|
|
23
|
-
vikeConfigGlobal = vikeConfig.vikeConfigGlobal;
|
|
24
|
+
vikeConfig = await getVikeConfig(config_);
|
|
24
25
|
config = config_;
|
|
25
|
-
abortViteBuildSsr(
|
|
26
|
+
abortViteBuildSsr(vikeConfig);
|
|
26
27
|
},
|
|
27
28
|
writeBundle: {
|
|
28
29
|
/* We can't use this because it breaks Vite's logging. TODO: try again with latest Vite version.
|
|
@@ -31,7 +32,7 @@ function autoFullBuild() {
|
|
|
31
32
|
*/
|
|
32
33
|
async handler(_options, bundle) {
|
|
33
34
|
try {
|
|
34
|
-
await triggerFullBuild(config,
|
|
35
|
+
await triggerFullBuild(config, vikeConfig, bundle);
|
|
35
36
|
}
|
|
36
37
|
catch (err) {
|
|
37
38
|
// Avoid Rollup prefixing the error with [vike:autoFullBuild], for example see https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
@@ -51,16 +52,17 @@ function autoFullBuild() {
|
|
|
51
52
|
handler() {
|
|
52
53
|
if (forceExit) {
|
|
53
54
|
runPrerender_forceExit();
|
|
55
|
+
assert(false);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
];
|
|
59
61
|
}
|
|
60
|
-
async function triggerFullBuild(config,
|
|
62
|
+
async function triggerFullBuild(config, vikeConfig, bundle) {
|
|
61
63
|
if (config.build.ssr)
|
|
62
64
|
return; // already triggered
|
|
63
|
-
if (isDisabled(
|
|
65
|
+
if (isDisabled(vikeConfig))
|
|
64
66
|
return;
|
|
65
67
|
// Workaround for @vitejs/plugin-legacy
|
|
66
68
|
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
@@ -68,44 +70,43 @@ async function triggerFullBuild(config, vikeConfigGlobal, bundle) {
|
|
|
68
70
|
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
69
71
|
if (!bundle[manifestTempFile])
|
|
70
72
|
return;
|
|
71
|
-
const
|
|
72
|
-
const configInline = {
|
|
73
|
-
...configFromCli,
|
|
74
|
-
configFile: configFromCli?.configFile || config.configFile,
|
|
75
|
-
root: config.root,
|
|
76
|
-
build: {
|
|
77
|
-
...configFromCli?.build
|
|
78
|
-
}
|
|
79
|
-
};
|
|
73
|
+
const configInline = getFullBuildInlineConfig(config);
|
|
80
74
|
try {
|
|
81
|
-
await build(
|
|
82
|
-
...configInline,
|
|
83
|
-
build: {
|
|
84
|
-
...configInline.build,
|
|
85
|
-
ssr: true
|
|
86
|
-
}
|
|
87
|
-
});
|
|
75
|
+
await build(setSSR(configInline));
|
|
88
76
|
}
|
|
89
77
|
catch (err) {
|
|
90
78
|
console.error(err);
|
|
91
79
|
logErrorHint(err);
|
|
92
80
|
process.exit(1);
|
|
93
81
|
}
|
|
94
|
-
if (isPrerenderAutoRunEnabled(
|
|
95
|
-
await runPrerenderFromAutoRun(configInline);
|
|
96
|
-
forceExit =
|
|
82
|
+
if (isPrerenderAutoRunEnabled(vikeConfig)) {
|
|
83
|
+
const res = await runPrerenderFromAutoRun(configInline, config);
|
|
84
|
+
forceExit = res.forceExit;
|
|
97
85
|
}
|
|
98
86
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
87
|
+
function setSSR(configInline) {
|
|
88
|
+
return {
|
|
89
|
+
...configInline,
|
|
90
|
+
build: {
|
|
91
|
+
...configInline.build,
|
|
92
|
+
ssr: true
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function abortViteBuildSsr(vikeConfig) {
|
|
97
|
+
if (vikeConfig.global.config.disableAutoFullBuild !== true && isViteCliCall() && getViteConfigFromCli()?.build.ssr) {
|
|
101
98
|
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 });
|
|
102
99
|
process.exit(0);
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
|
-
function isDisabled(
|
|
106
|
-
const { disableAutoFullBuild } =
|
|
107
|
-
if (
|
|
108
|
-
return
|
|
102
|
+
function isDisabled(vikeConfig) {
|
|
103
|
+
const { disableAutoFullBuild, viteEnvironmentAPI } = vikeConfig.global.config;
|
|
104
|
+
if (viteEnvironmentAPI) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
if (disableAutoFullBuild === undefined || disableAutoFullBuild === 'prerender') {
|
|
108
|
+
const isViteApi = !isViteCliCall() && !isVikeCliOrApi();
|
|
109
|
+
return isViteApi;
|
|
109
110
|
}
|
|
110
111
|
else {
|
|
111
112
|
return disableAutoFullBuild;
|
|
@@ -11,7 +11,7 @@ function baseUrls() {
|
|
|
11
11
|
const isDev = config._isDev;
|
|
12
12
|
assert(typeof isDev === 'boolean');
|
|
13
13
|
const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
|
|
14
|
-
basesResolved = resolveBase(baseViteOriginal, config.vike.
|
|
14
|
+
basesResolved = resolveBase(baseViteOriginal, config.vike.config.baseServer ?? null, config.vike.config.baseAssets ?? null);
|
|
15
15
|
// We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
|
|
16
16
|
process.env.BASE_SERVER = basesResolved.baseServer;
|
|
17
17
|
process.env.BASE_ASSETS = basesResolved.baseAssets;
|
|
@@ -27,7 +27,7 @@ function baseUrls() {
|
|
|
27
27
|
},
|
|
28
28
|
async configResolved(config) {
|
|
29
29
|
const vikeConfig = await getVikeConfig(config);
|
|
30
|
-
const basesResolved2 = resolveBaseFromResolvedConfig(vikeConfig.
|
|
30
|
+
const basesResolved2 = resolveBaseFromResolvedConfig(vikeConfig.global.config.baseServer ?? null, vikeConfig.global.config.baseAssets ?? null, config);
|
|
31
31
|
assert(basesResolved2.baseServer === basesResolved.baseServer);
|
|
32
32
|
assert(basesResolved2.baseAssets === basesResolved.baseAssets);
|
|
33
33
|
/* In dev, Vite seems buggy around setting vite.config.js#base to an absolute URL (e.g. http://localhost:8080/cdn/)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { runPrerender_forceExit, runPrerenderFromAutoRun } from '../../prerender/runPrerender.js';
|
|
2
|
+
export { buildApp };
|
|
3
|
+
import { isPrerenderAutoRunEnabled } from '../../prerender/context.js';
|
|
4
|
+
import { resolveOutDir } from '../shared/getOutDirs.js';
|
|
5
|
+
import { assert } from '../utils.js';
|
|
6
|
+
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
+
import { getFullBuildInlineConfig } from '../shared/getFullBuildInlineConfig.js';
|
|
8
|
+
function buildApp() {
|
|
9
|
+
let config;
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
name: 'vike:buildApp',
|
|
13
|
+
apply: 'build',
|
|
14
|
+
config(config) {
|
|
15
|
+
if (!config.vike.config.viteEnvironmentAPI)
|
|
16
|
+
return;
|
|
17
|
+
return {
|
|
18
|
+
builder: {
|
|
19
|
+
buildApp: async (builder) => {
|
|
20
|
+
assert(builder.environments.client);
|
|
21
|
+
assert(builder.environments.ssr);
|
|
22
|
+
await builder.build(builder.environments.client);
|
|
23
|
+
await builder.build(builder.environments.ssr);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
environments: {
|
|
27
|
+
ssr: {
|
|
28
|
+
consumer: 'server',
|
|
29
|
+
build: {
|
|
30
|
+
outDir: resolveOutDir(config, true),
|
|
31
|
+
ssr: true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
client: {
|
|
35
|
+
consumer: 'client',
|
|
36
|
+
build: {
|
|
37
|
+
copyPublicDir: true,
|
|
38
|
+
ssr: false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'vike:buildApp:prerender',
|
|
47
|
+
apply: 'build',
|
|
48
|
+
enforce: 'pre',
|
|
49
|
+
applyToEnvironment(env) {
|
|
50
|
+
return env.name === 'ssr';
|
|
51
|
+
},
|
|
52
|
+
configResolved(_config) {
|
|
53
|
+
config = _config;
|
|
54
|
+
},
|
|
55
|
+
async writeBundle() {
|
|
56
|
+
if (!config.vike.config.viteEnvironmentAPI)
|
|
57
|
+
return;
|
|
58
|
+
const vikeConfig = await getVikeConfig(config);
|
|
59
|
+
if (!isPrerenderAutoRunEnabled(vikeConfig))
|
|
60
|
+
return;
|
|
61
|
+
const configInline = getFullBuildInlineConfig(config);
|
|
62
|
+
const { forceExit } = await runPrerenderFromAutoRun(configInline, config);
|
|
63
|
+
if (forceExit) {
|
|
64
|
+
runPrerender_forceExit();
|
|
65
|
+
assert(false);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
}
|
|
@@ -2,7 +2,6 @@ export { fixServerAssets };
|
|
|
2
2
|
export { fixServerAssets_isEnabled };
|
|
3
3
|
export { fixServerAssets_assertCssCodeSplit };
|
|
4
4
|
export { fixServerAssets_assertCssTarget };
|
|
5
|
-
export { fixServerAssets_assertCssTarget_populate };
|
|
6
5
|
import { ViteManifest } from '../../../shared/ViteManifest.js';
|
|
7
6
|
import { ResolvedConfig } from 'vite';
|
|
8
7
|
/**
|
|
@@ -18,5 +17,4 @@ declare function fixServerAssets(config: ResolvedConfig): Promise<{
|
|
|
18
17
|
serverManifestMod: ViteManifest;
|
|
19
18
|
}>;
|
|
20
19
|
declare function fixServerAssets_assertCssCodeSplit(config: ResolvedConfig): void;
|
|
21
|
-
declare function fixServerAssets_assertCssTarget_populate(config: ResolvedConfig): void;
|
|
22
20
|
declare function fixServerAssets_assertCssTarget(config: ResolvedConfig): Promise<void>;
|
|
@@ -2,17 +2,18 @@ export { fixServerAssets };
|
|
|
2
2
|
export { fixServerAssets_isEnabled };
|
|
3
3
|
export { fixServerAssets_assertCssCodeSplit };
|
|
4
4
|
export { fixServerAssets_assertCssTarget };
|
|
5
|
-
export { fixServerAssets_assertCssTarget_populate };
|
|
6
5
|
import fs from 'fs/promises';
|
|
7
6
|
import fs_sync from 'fs';
|
|
8
7
|
import path from 'path';
|
|
9
8
|
import { existsSync } from 'fs';
|
|
10
|
-
import { assert, assertWarning,
|
|
9
|
+
import { assert, assertWarning, isEqualStringList, pLimit, unique } from '../../utils.js';
|
|
11
10
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
12
11
|
import { manifestTempFile } from '../buildConfig.js';
|
|
13
12
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
14
13
|
import pc from '@brillout/picocolors';
|
|
15
14
|
import { isV1Design } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
15
|
+
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
16
|
+
import { viteIsSSR } from '../../shared/viteIsSSR.js';
|
|
16
17
|
/**
|
|
17
18
|
* true => use workaround config.build.ssrEmitAssets
|
|
18
19
|
* false => use workaround extractAssets plugin
|
|
@@ -193,17 +194,15 @@ function fixServerAssets_assertCssCodeSplit(config) {
|
|
|
193
194
|
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 });
|
|
194
195
|
}
|
|
195
196
|
const targets = [];
|
|
196
|
-
function fixServerAssets_assertCssTarget_populate(config) {
|
|
197
|
-
const isServerSide = viteIsSSR(config);
|
|
198
|
-
assert(typeof isServerSide === 'boolean');
|
|
199
|
-
assert(config.build.target !== undefined);
|
|
200
|
-
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
201
|
-
}
|
|
202
197
|
async function fixServerAssets_assertCssTarget(config) {
|
|
203
198
|
if (!fixServerAssets_isEnabled())
|
|
204
199
|
return;
|
|
205
200
|
if (!(await isV1Design(config)))
|
|
206
201
|
return;
|
|
202
|
+
const isServerSide = viteIsSSR(config);
|
|
203
|
+
assert(typeof isServerSide === 'boolean');
|
|
204
|
+
assert(config.build.target !== undefined);
|
|
205
|
+
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
207
206
|
const targetsServer = targets.filter((t) => t.isServerSide);
|
|
208
207
|
const targetsClient = targets.filter((t) => !t.isServerSide);
|
|
209
208
|
targetsClient.forEach((targetClient) => {
|
|
@@ -211,9 +210,10 @@ async function fixServerAssets_assertCssTarget(config) {
|
|
|
211
210
|
targetsServer.forEach((targetServer) => {
|
|
212
211
|
const targetCssResolvedServer = resolveCssTarget(targetServer);
|
|
213
212
|
assertWarning(isEqualStringList(targetCssResolvedClient, targetCssResolvedServer), [
|
|
214
|
-
'The CSS browser target should be the same for both client
|
|
215
|
-
`Client
|
|
216
|
-
`Server
|
|
213
|
+
'The CSS browser target should be the same for both client and server, but we got:',
|
|
214
|
+
`Client: ${pc.cyan(JSON.stringify(targetCssResolvedClient))}`,
|
|
215
|
+
`Server: ${pc.cyan(JSON.stringify(targetCssResolvedServer))}`,
|
|
216
|
+
`Different targets leads to CSS duplication, see ${pc.underline('https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979')} for more information.`
|
|
217
217
|
].join('\n'), {
|
|
218
218
|
showStackTrace: true,
|
|
219
219
|
onlyOnce: 'different-css-target'
|
|
@@ -2,7 +2,7 @@ export { buildConfig };
|
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
4
|
export { manifestTempFile };
|
|
5
|
-
import { assert,
|
|
5
|
+
import { assert, addOnBeforeLogHook, removeFileExtention, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsNpmPackageImport } from '../utils.js';
|
|
6
6
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
import { findPageFiles } from '../shared/findPageFiles.js';
|
|
8
8
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
@@ -10,18 +10,19 @@ import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
|
10
10
|
import { createRequire } from 'module';
|
|
11
11
|
import fs from 'fs/promises';
|
|
12
12
|
import path from 'path';
|
|
13
|
-
import { fixServerAssets, fixServerAssets_assertCssCodeSplit, fixServerAssets_assertCssTarget,
|
|
14
|
-
import {
|
|
13
|
+
import { fixServerAssets, fixServerAssets_assertCssCodeSplit, fixServerAssets_assertCssTarget, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
14
|
+
import { set_ASSETS_MANIFEST } from './buildEntry/index.js';
|
|
15
15
|
import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
|
|
16
16
|
import { getFilePathResolved } from '../shared/getFilePath.js';
|
|
17
17
|
import { getConfigValueBuildTime } from '../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
18
|
+
import { getOutDirs, resolveOutDir } from '../shared/getOutDirs.js';
|
|
19
|
+
import { viteIsSSR } from '../shared/viteIsSSR.js';
|
|
18
20
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
19
21
|
const importMetaUrl = import.meta.url;
|
|
20
22
|
const require_ = createRequire(importMetaUrl);
|
|
21
23
|
const manifestTempFile = '_temp_manifest.json';
|
|
22
24
|
function buildConfig() {
|
|
23
25
|
let isServerAssetsFixEnabled;
|
|
24
|
-
let isSsrBuild;
|
|
25
26
|
let outDirs;
|
|
26
27
|
let config;
|
|
27
28
|
return [
|
|
@@ -47,7 +48,6 @@ function buildConfig() {
|
|
|
47
48
|
config.build.ssrEmitAssets = true;
|
|
48
49
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
49
50
|
config.build.cssMinify = 'esbuild';
|
|
50
|
-
fixServerAssets_assertCssTarget_populate(config);
|
|
51
51
|
fixServerAssets_assertCssCodeSplit(config);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -57,12 +57,14 @@ function buildConfig() {
|
|
|
57
57
|
order: 'post',
|
|
58
58
|
handler(config) {
|
|
59
59
|
onSetupBuild();
|
|
60
|
-
isSsrBuild = viteIsSSR(config);
|
|
61
60
|
return {
|
|
62
61
|
build: {
|
|
63
62
|
outDir: resolveOutDir(config),
|
|
64
63
|
manifest: manifestTempFile,
|
|
65
|
-
copyPublicDir:
|
|
64
|
+
copyPublicDir: config.vike.config.viteEnvironmentAPI
|
|
65
|
+
? // Already set by buildApp() plugin
|
|
66
|
+
undefined
|
|
67
|
+
: !viteIsSSR(config)
|
|
66
68
|
}
|
|
67
69
|
};
|
|
68
70
|
}
|
|
@@ -79,14 +81,14 @@ function buildConfig() {
|
|
|
79
81
|
name: 'vike:buildConfig:pre',
|
|
80
82
|
apply: 'build',
|
|
81
83
|
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
82
|
-
// -
|
|
84
|
+
// - set_ASSETS_MANIFEST() needs to be called before dist/server/ code is executed.
|
|
83
85
|
// - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
|
|
84
86
|
enforce: 'pre',
|
|
85
87
|
writeBundle: {
|
|
86
88
|
order: 'pre',
|
|
87
89
|
sequential: true,
|
|
88
90
|
async handler(options, bundle) {
|
|
89
|
-
if (
|
|
91
|
+
if (viteIsSSR(config)) {
|
|
90
92
|
// Ideally we'd move dist/_temp_manifest.json to dist/server/client-assets.json instead of dist/assets.json
|
|
91
93
|
// - But we can't because there is no guarentee whether dist/server/ is generated before or after dist/client/ (generating dist/server/ after dist/client/ erases dist/server/client-assets.json)
|
|
92
94
|
// - We'll able to do so once we replace `$ vite build` with `$ vike build`
|
|
@@ -102,7 +104,7 @@ function buildConfig() {
|
|
|
102
104
|
}
|
|
103
105
|
await fs.rm(clientManifestFilePath);
|
|
104
106
|
await fs.rm(serverManifestFilePath);
|
|
105
|
-
await
|
|
107
|
+
await set_ASSETS_MANIFEST(options, bundle);
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
}
|
|
@@ -112,7 +114,10 @@ function buildConfig() {
|
|
|
112
114
|
async function getEntries(config) {
|
|
113
115
|
const vikeConfig = await getVikeConfig(config);
|
|
114
116
|
const { pageConfigs } = vikeConfig;
|
|
115
|
-
|
|
117
|
+
// TODO/v1-release: remove
|
|
118
|
+
const pageFileEntries = await getPageFileEntries(config,
|
|
119
|
+
// TODO/now: add meta.default
|
|
120
|
+
vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
116
121
|
assertUsage(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
117
122
|
if (viteIsSSR(config)) {
|
|
118
123
|
const pageEntries = getPageEntries(pageConfigs);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { buildEntry };
|
|
2
|
-
export {
|
|
2
|
+
export { set_ASSETS_MANIFEST };
|
|
3
3
|
import type { Plugin, Rollup } from 'vite';
|
|
4
4
|
type Bundle = Rollup.OutputBundle;
|
|
5
5
|
type Options = Rollup.NormalizedOutputOptions;
|
|
6
6
|
declare function buildEntry(): Plugin[];
|
|
7
|
-
/** Set the value of the
|
|
8
|
-
declare function
|
|
7
|
+
/** Set the value of the ASSETS_MANIFEST constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
8
|
+
declare function set_ASSETS_MANIFEST(options: Options, bundle: Bundle): Promise<void>;
|
|
@@ -1,79 +1,83 @@
|
|
|
1
1
|
export { buildEntry };
|
|
2
|
-
export {
|
|
2
|
+
export { set_ASSETS_MANIFEST };
|
|
3
3
|
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
4
|
import { virtualFileIdImportUserCodeServer } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
5
|
-
import {
|
|
6
|
-
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
-
import { assert, getOutDirs, toPosixPath } from '../../utils.js';
|
|
5
|
+
import { assert, projectInfo, toPosixPath } from '../../utils.js';
|
|
8
6
|
import fs from 'fs/promises';
|
|
9
7
|
import path from 'path';
|
|
10
8
|
import { createRequire } from 'module';
|
|
11
9
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
12
10
|
const importMetaUrl = import.meta.url;
|
|
13
11
|
const require_ = createRequire(importMetaUrl);
|
|
14
|
-
|
|
12
|
+
import { isUsingClientRouter } from '../extractExportNamesPlugin.js';
|
|
13
|
+
import { assertBuildInfo, getViteConfigRuntime } from '../../../runtime/globalContext.js';
|
|
14
|
+
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
15
|
+
const ASSETS_MANIFEST = '__VITE_ASSETS_MANIFEST__';
|
|
15
16
|
function buildEntry() {
|
|
16
17
|
let config;
|
|
17
|
-
let vikeConfigGlobal;
|
|
18
18
|
return [
|
|
19
19
|
{
|
|
20
20
|
name: 'vike:buildEntry',
|
|
21
21
|
enforce: 'post',
|
|
22
22
|
async configResolved(config_) {
|
|
23
23
|
config = config_;
|
|
24
|
-
const vikeConfig = await getVikeConfig(config);
|
|
25
|
-
vikeConfigGlobal = vikeConfig.vikeConfigGlobal;
|
|
26
24
|
}
|
|
27
25
|
},
|
|
28
26
|
...serverProductionEntryPlugin({
|
|
29
27
|
getServerProductionEntry: () => {
|
|
30
|
-
return getServerProductionEntryCode(config
|
|
28
|
+
return getServerProductionEntryCode(config);
|
|
31
29
|
},
|
|
32
30
|
libraryName: 'Vike'
|
|
33
31
|
})
|
|
34
32
|
];
|
|
35
33
|
}
|
|
36
|
-
function getServerProductionEntryCode(config
|
|
34
|
+
function getServerProductionEntryCode(config) {
|
|
37
35
|
const importPath = getImportPath(config);
|
|
38
|
-
const
|
|
39
|
-
|
|
36
|
+
const buildInfo = {
|
|
37
|
+
versionAtBuildTime: projectInfo.projectVersion,
|
|
38
|
+
usesClientRouter: isUsingClientRouter(), // TODO/v1-release: remove
|
|
39
|
+
viteConfigRuntime: getViteConfigRuntime(config)
|
|
40
|
+
};
|
|
41
|
+
assertBuildInfo(buildInfo);
|
|
42
|
+
// After the old design is removed, let's maybe simplify and move everything into a single virtual module
|
|
40
43
|
const importerCode = [
|
|
41
44
|
` import { setGlobalContext_buildEntry } from '${importPath}';`,
|
|
42
|
-
` import * as
|
|
45
|
+
` import * as virtualFileExports from '${virtualFileIdImportUserCodeServer}';`,
|
|
43
46
|
` {`,
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
` const
|
|
47
|
+
// Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to setGlobalContext_buildEntry()
|
|
48
|
+
// - This workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
49
|
+
` const assetsManifest = ${ASSETS_MANIFEST};`,
|
|
50
|
+
` const buildInfo = ${JSON.stringify(buildInfo, null, 2)};`,
|
|
47
51
|
' setGlobalContext_buildEntry({',
|
|
48
|
-
`
|
|
52
|
+
` virtualFileExports,`,
|
|
49
53
|
` assetsManifest,`,
|
|
50
|
-
`
|
|
54
|
+
` buildInfo,`,
|
|
51
55
|
' });',
|
|
52
56
|
` }`,
|
|
53
57
|
''
|
|
54
58
|
].join('\n');
|
|
55
59
|
return importerCode;
|
|
56
60
|
}
|
|
57
|
-
/** Set the value of the
|
|
58
|
-
async function
|
|
61
|
+
/** Set the value of the ASSETS_MANIFEST constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
62
|
+
async function set_ASSETS_MANIFEST(options, bundle) {
|
|
59
63
|
const { dir } = options;
|
|
60
64
|
assert(dir);
|
|
61
|
-
const chunkPath =
|
|
65
|
+
const chunkPath = find_ASSETS_MANIFEST(bundle);
|
|
62
66
|
const chunkFilePath = path.join(dir, chunkPath);
|
|
63
67
|
const assetsJsonFilePath = path.join(dir, '..', 'assets.json');
|
|
64
68
|
const [assetsJsonString, chunkFileContent] = await Promise.all([
|
|
65
69
|
await fs.readFile(assetsJsonFilePath, 'utf8'),
|
|
66
70
|
await fs.readFile(chunkFilePath, 'utf8')
|
|
67
71
|
]);
|
|
68
|
-
const serverEntryFileContentPatched = chunkFileContent.replace(
|
|
72
|
+
const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MANIFEST, assetsJsonString);
|
|
69
73
|
assert(serverEntryFileContentPatched !== chunkFileContent);
|
|
70
74
|
await fs.writeFile(chunkFilePath, serverEntryFileContentPatched);
|
|
71
75
|
}
|
|
72
|
-
function
|
|
76
|
+
function find_ASSETS_MANIFEST(bundle) {
|
|
73
77
|
let chunkPath;
|
|
74
78
|
for (const filePath in bundle) {
|
|
75
79
|
const chunk = bundle[filePath];
|
|
76
|
-
if ('code' in chunk && chunk.code.includes(
|
|
80
|
+
if ('code' in chunk && chunk.code.includes(ASSETS_MANIFEST)) {
|
|
77
81
|
assert(!chunkPath);
|
|
78
82
|
chunkPath = filePath;
|
|
79
83
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
export { commonConfig };
|
|
2
|
-
import { type Plugin } from 'vite';
|
|
2
|
+
import { type InlineConfig, type Plugin } from 'vite';
|
|
3
3
|
import { type VikeConfigObject } from './importUserCode/v1-design/getVikeConfig.js';
|
|
4
|
+
import type { PrerenderContextPublic } from '../../prerender/runPrerender.js';
|
|
4
5
|
declare module 'vite' {
|
|
5
6
|
interface UserConfig {
|
|
6
7
|
_isDev?: boolean;
|
|
7
8
|
_vikeVitePluginOptions?: unknown;
|
|
8
9
|
_root?: string;
|
|
9
|
-
|
|
10
|
+
_baseViteOriginal?: string;
|
|
11
|
+
_viteConfigEnhanced?: InlineConfig;
|
|
12
|
+
vike?: {
|
|
13
|
+
config: VikeConfigObject['global']['config'];
|
|
14
|
+
prerenderContext?: PrerenderContextPublic;
|
|
15
|
+
};
|
|
10
16
|
}
|
|
11
17
|
}
|
|
12
18
|
declare function commonConfig(vikeVitePluginOptions: unknown): Plugin[];
|
|
@@ -11,7 +11,7 @@ import { isViteCliCall } from '../shared/isViteCliCall.js';
|
|
|
11
11
|
import { isVikeCliOrApi } from '../../api/context.js';
|
|
12
12
|
import { getVikeConfig2 } from './importUserCode/v1-design/getVikeConfig.js';
|
|
13
13
|
import { assertViteRoot, getViteRoot, normalizeViteRoot } from '../../api/prepareViteApiCall.js';
|
|
14
|
-
import { temp_disablePrerenderAutoRun } from '../../prerender/
|
|
14
|
+
import { isPrerenderEnabled, temp_disablePrerenderAutoRun } from '../../prerender/context.js';
|
|
15
15
|
const pluginName = 'vike:commonConfig';
|
|
16
16
|
function commonConfig(vikeVitePluginOptions) {
|
|
17
17
|
return [
|
|
@@ -30,9 +30,11 @@ function commonConfig(vikeVitePluginOptions) {
|
|
|
30
30
|
_isDev: isDev,
|
|
31
31
|
_root: root,
|
|
32
32
|
_vikeVitePluginOptions: vikeVitePluginOptions,
|
|
33
|
-
vike: vikeConfig,
|
|
34
|
-
// TODO/v1-release: remove
|
|
35
|
-
configVikePromise: Promise.resolve(
|
|
33
|
+
vike: { config: vikeConfig.global.config },
|
|
34
|
+
// TODO/v1-release: remove https://github.com/vikejs/vike/issues/2122
|
|
35
|
+
configVikePromise: Promise.resolve({
|
|
36
|
+
prerender: isPrerenderEnabled(vikeConfig)
|
|
37
|
+
})
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -142,7 +144,7 @@ function assertVikeCliOrApi(config) {
|
|
|
142
144
|
onlyOnce: true
|
|
143
145
|
});
|
|
144
146
|
}
|
|
145
|
-
// TODO/v1-release: remove
|
|
147
|
+
// TODO/v1-release: remove https://github.com/vikejs/vike/issues/2122
|
|
146
148
|
function temp_supportOldInterface(config) {
|
|
147
149
|
if (!('vitePluginSsr' in config))
|
|
148
150
|
return;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// - This appraoch supports import path aliases `vite.config.js#resolve.alias` https://vitejs.dev/config/#resolve-alias
|
|
7
7
|
export { extractAssetsPlugin };
|
|
8
8
|
export { extractAssetsRE };
|
|
9
|
-
import {
|
|
9
|
+
import { assert, assertPosixPath, styleFileRE, createDebugger, isScriptFile, assertUsage } from '../utils.js';
|
|
10
10
|
import { resolveVirtualFileId, isVirtualFileId, getVirtualFileId } from '../../shared/virtual-files.js';
|
|
11
11
|
import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
12
12
|
import { isAsset } from '../shared/isAsset.js';
|
|
@@ -17,6 +17,7 @@ import { fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
|
17
17
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
18
18
|
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
19
19
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
20
|
+
import { viteIsSSR_options } from '../shared/viteIsSSR.js';
|
|
20
21
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
21
22
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
22
23
|
const urlRE = /(\?|&)url(?:&|$)/;
|
|
@@ -43,7 +44,8 @@ function extractAssetsPlugin() {
|
|
|
43
44
|
assertV1Design(vikeConfig.pageConfigs, true);
|
|
44
45
|
assert(false);
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
// TODO/now: add meta.default
|
|
48
|
+
assert(vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
47
49
|
assert(!viteIsSSR_options(options));
|
|
48
50
|
const importStatements = await getImportStatements(src);
|
|
49
51
|
const moduleNames = getImportedModules(importStatements);
|
|
@@ -76,7 +78,8 @@ function extractAssetsPlugin() {
|
|
|
76
78
|
if (!extractAssetsRE.test(importer)) {
|
|
77
79
|
return;
|
|
78
80
|
}
|
|
79
|
-
|
|
81
|
+
// TODO/now: add meta.default
|
|
82
|
+
assert(vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
80
83
|
let resolution = null;
|
|
81
84
|
try {
|
|
82
85
|
resolution = await this.resolve(source, importer, { skipSelf: true, ...options });
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { extractExportNamesPlugin };
|
|
2
2
|
export { isUsingClientRouter };
|
|
3
3
|
export { extractExportNamesRE };
|
|
4
|
-
import { assert, getFileExtension,
|
|
4
|
+
import { assert, getFileExtension, createDebugger, getGlobalObject, assertUsage } from '../utils.js';
|
|
5
5
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
6
6
|
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
7
7
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
8
|
+
import { viteIsSSR_options } from '../shared/viteIsSSR.js';
|
|
8
9
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
9
10
|
const debug = createDebugger('vike:extractExportNames');
|
|
10
11
|
const globalObject = getGlobalObject('extractExportNamesPlugin.ts', {});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getVirtualFileImportUserCode };
|
|
2
2
|
import type { ResolvedConfig } from 'vite';
|
|
3
|
-
import type {
|
|
3
|
+
import type { VikeConfigObject } from './v1-design/getVikeConfig.js';
|
|
4
4
|
declare function getVirtualFileImportUserCode(id: string, options: {
|
|
5
5
|
ssr?: boolean;
|
|
6
|
-
} | undefined,
|
|
6
|
+
} | undefined, vikeConfig: VikeConfigObject, config: ResolvedConfig, isDev: boolean): Promise<string>;
|