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
|
@@ -6,6 +6,6 @@ import { type ScrollPosition } from './history.js';
|
|
|
6
6
|
type ScrollTarget = undefined | {
|
|
7
7
|
preserveScroll: boolean;
|
|
8
8
|
} | ScrollPosition;
|
|
9
|
-
declare function setScrollPosition(scrollTarget: ScrollTarget): void;
|
|
9
|
+
declare function setScrollPosition(scrollTarget: ScrollTarget, url?: string): void;
|
|
10
10
|
declare function scrollToHashOrTop(hash: null | string): void;
|
|
11
11
|
declare function autoSaveScrollPosition(): void;
|
|
@@ -2,8 +2,12 @@ export { setScrollPosition };
|
|
|
2
2
|
export { autoSaveScrollPosition };
|
|
3
3
|
export { scrollToHashOrTop };
|
|
4
4
|
import { assert, onPageHide, sleep, throttle } from './utils.js';
|
|
5
|
-
import { saveScrollPosition } from './history.js';
|
|
6
|
-
function setScrollPosition(scrollTarget) {
|
|
5
|
+
import { replaceHistoryStateOriginal, saveScrollPosition } from './history.js';
|
|
6
|
+
function setScrollPosition(scrollTarget, url) {
|
|
7
|
+
if (!scrollTarget && url && hasTextFragment(url)) {
|
|
8
|
+
scrollToTextFragment(url);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
7
11
|
if (scrollTarget && 'x' in scrollTarget) {
|
|
8
12
|
setScroll(scrollTarget);
|
|
9
13
|
return;
|
|
@@ -14,6 +18,21 @@ function setScrollPosition(scrollTarget) {
|
|
|
14
18
|
const hash = getUrlHash();
|
|
15
19
|
scrollToHashOrTop(hash);
|
|
16
20
|
}
|
|
21
|
+
// https://github.com/vikejs/vike/issues/2114
|
|
22
|
+
// https://github.com/WICG/scroll-to-text-fragment/issues/261
|
|
23
|
+
function scrollToTextFragment(url) {
|
|
24
|
+
const stateOriginal = window.history.state;
|
|
25
|
+
replaceHistoryStateOriginal(null, url);
|
|
26
|
+
// We need `history.state===null` before location.replace() so that our 'popstate' handling is correct
|
|
27
|
+
assert(window.history.state === null);
|
|
28
|
+
// - Chrome's location.replace() keeps the current state (`history.state===stateOriginal`)
|
|
29
|
+
// - Firefox's location.replace() replaces the current state with `null` (`history.state===null`)
|
|
30
|
+
window.location.replace(url);
|
|
31
|
+
replaceHistoryStateOriginal(stateOriginal, url);
|
|
32
|
+
}
|
|
33
|
+
function hasTextFragment(url) {
|
|
34
|
+
return url.includes('#') && url.includes(':~:text');
|
|
35
|
+
}
|
|
17
36
|
// Replicates the browser's native behavior
|
|
18
37
|
function scrollToHashOrTop(hash) {
|
|
19
38
|
if (!hash) {
|
|
@@ -45,9 +64,14 @@ function scrollToTop() {
|
|
|
45
64
|
* - Let's remove it and see if users complain?
|
|
46
65
|
*/
|
|
47
66
|
function setScroll(scrollPosition) {
|
|
48
|
-
const scroll = () =>
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
const scroll = () => {
|
|
68
|
+
// `window.scrollTo()` respects the CSS `scroll-behavior: smooth` property
|
|
69
|
+
window.scrollTo(scrollPosition.x, scrollPosition.y);
|
|
70
|
+
};
|
|
71
|
+
const done = () => {
|
|
72
|
+
return window.scrollX === scrollPosition.x && window.scrollY === scrollPosition.y;
|
|
73
|
+
};
|
|
74
|
+
// In principle, this `done()` call should force the repaint to be finished, but that doesn't seem to be the case with `Firefox 97.0.1`.
|
|
51
75
|
if (done())
|
|
52
76
|
return;
|
|
53
77
|
scroll();
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { skipLink };
|
|
2
2
|
export { isSameAsCurrentUrl };
|
|
3
|
-
export { isSamePageHashLink };
|
|
4
3
|
declare function skipLink(linkTag: HTMLElement): boolean;
|
|
5
|
-
declare function isSamePageHashLink(href: string): boolean;
|
|
6
4
|
declare function isSameAsCurrentUrl(href: string): boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { skipLink };
|
|
2
2
|
export { isSameAsCurrentUrl };
|
|
3
|
-
export { isSamePageHashLink };
|
|
4
3
|
import { normalizeClientSideUrl } from '../shared/normalizeClientSideUrl.js';
|
|
5
4
|
import { getBaseServer } from './getBaseServer.js';
|
|
6
5
|
import { assert, parseUrl, isBaseServer, isUrl, isUrlExternal } from './utils.js';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { getPageContext };
|
|
2
2
|
import { assertUsage, assertWarning, objectAssign } from './utils.js';
|
|
3
3
|
import { getPageContextSerializedInHtml } from '../shared/getPageContextSerializedInHtml.js';
|
|
4
|
-
import { getPageFilesAll, setPageFiles } from '../../shared/getPageFiles/getPageFiles.js';
|
|
5
4
|
import { loadUserFilesClientSide } from '../shared/loadUserFilesClientSide.js';
|
|
6
5
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
6
|
+
import { getPageConfigsRuntime } from '../../shared/getPageConfigsRuntime.js';
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
import * as
|
|
8
|
+
import * as virtualFileExports from 'virtual:vike:importUserCode:client:server-routing';
|
|
9
|
+
const { pageFilesAll, pageConfigs } = getPageConfigsRuntime(virtualFileExports);
|
|
9
10
|
const urlFirst = getCurrentUrl({ withoutHash: true });
|
|
10
|
-
setPageFiles(pageFilesExports);
|
|
11
11
|
async function getPageContext() {
|
|
12
12
|
const pageContext = getPageContextSerializedInHtml();
|
|
13
13
|
objectAssign(pageContext, {
|
|
@@ -26,7 +26,6 @@ function assertPristineUrl() {
|
|
|
26
26
|
}
|
|
27
27
|
async function loadPageUserFiles(pageId) {
|
|
28
28
|
const pageContextAddendum = {};
|
|
29
|
-
const { pageFilesAll, pageConfigs } = await getPageFilesAll(true);
|
|
30
29
|
objectAssign(pageContextAddendum, {
|
|
31
30
|
_pageFilesAll: pageFilesAll,
|
|
32
31
|
_pageConfigs: pageConfigs
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { loadUserFilesClientSide };
|
|
2
2
|
export { isErrorFetchingStaticAssets };
|
|
3
|
-
import { getPageFilesClientSide
|
|
3
|
+
import { getPageFilesClientSide } from '../../shared/getPageFiles.js';
|
|
4
|
+
import { getPageConfigUserFriendlyOld } from '../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
4
5
|
import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
|
|
5
6
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
6
7
|
import { objectAssign } from '../server-routing-runtime/utils.js';
|
|
@@ -29,7 +30,7 @@ async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
|
|
|
29
30
|
}
|
|
30
31
|
throw err;
|
|
31
32
|
}
|
|
32
|
-
const pageContextExports =
|
|
33
|
+
const pageContextExports = getPageConfigUserFriendlyOld(pageFilesClientSide, pageConfigLoaded);
|
|
33
34
|
const pageContextAddendum = {};
|
|
34
35
|
objectAssign(pageContextAddendum, pageContextExports);
|
|
35
36
|
objectAssign(pageContextAddendum, { _pageFilesLoaded: pageFilesClientSide });
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
export { build };
|
|
2
|
-
import { type Rollup } from 'vite';
|
|
3
2
|
import type { APIOptions } from './types.js';
|
|
4
|
-
type RollupOutput = Rollup.RollupOutput | Rollup.RollupOutput[] | Rollup.RollupWatcher;
|
|
5
3
|
/**
|
|
6
4
|
* Programmatically trigger `$ vike build`
|
|
7
5
|
*
|
|
8
6
|
* https://vike.dev/api#build
|
|
9
7
|
*/
|
|
10
|
-
declare function build(options?: APIOptions): Promise<{
|
|
11
|
-
rollupOutputClient: RollupOutput;
|
|
12
|
-
rollupOutputServer: RollupOutput;
|
|
13
|
-
}>;
|
|
8
|
+
declare function build(options?: APIOptions): Promise<{}>;
|
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
export { build };
|
|
2
2
|
import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
3
|
-
import { build as buildVite } from 'vite';
|
|
4
|
-
import
|
|
3
|
+
import { build as buildVite, version } from 'vite';
|
|
4
|
+
import assert from 'assert';
|
|
5
|
+
import { isVikeCli } from '../cli/context.js';
|
|
6
|
+
import { isPrerendering } from '../prerender/context.js';
|
|
7
|
+
import { assertVersion } from './utils.js';
|
|
5
8
|
/**
|
|
6
9
|
* Programmatically trigger `$ vike build`
|
|
7
10
|
*
|
|
8
11
|
* https://vike.dev/api#build
|
|
9
12
|
*/
|
|
10
13
|
async function build(options = {}) {
|
|
11
|
-
const { viteConfigEnhanced,
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
await
|
|
14
|
+
const { viteConfigEnhanced, vikeConfig } = await prepareViteApiCall(options.viteConfig, 'build');
|
|
15
|
+
// Pass it to autoFullBuild()
|
|
16
|
+
if (viteConfigEnhanced)
|
|
17
|
+
viteConfigEnhanced._viteConfigEnhanced = viteConfigEnhanced;
|
|
18
|
+
if (vikeConfig.global.config.viteEnvironmentAPI) {
|
|
19
|
+
assertVersion('Vite', version, '6.0.0');
|
|
20
|
+
const { createBuilder } = await import('vite');
|
|
21
|
+
const builder = await createBuilder(viteConfigEnhanced);
|
|
22
|
+
await builder.buildApp();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// This buildVite() call does everything:
|
|
26
|
+
// 1. Build client-side
|
|
27
|
+
// 2. Build server-side
|
|
28
|
+
// > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L90
|
|
29
|
+
// 3. Pre-render (if enabled)
|
|
30
|
+
// > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L98
|
|
31
|
+
// > We purposely don't start the pre-rendering in this `build()` function but in a Rollup hook instead.
|
|
32
|
+
// > Rationale: https://github.com/vikejs/vike/issues/2123
|
|
33
|
+
await buildVite(viteConfigEnhanced);
|
|
34
|
+
// After pre-rendering, when using the Vike CLI, the process is forcefully exited at the end of the buildVite() call above.
|
|
35
|
+
if (isVikeCli() && isPrerendering())
|
|
36
|
+
assert(false);
|
|
20
37
|
}
|
|
21
38
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
rollupOutputClient: outputClient,
|
|
26
|
-
rollupOutputServer: outputServer
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function setSSR(viteConfig) {
|
|
30
|
-
return {
|
|
31
|
-
...viteConfig,
|
|
32
|
-
build: {
|
|
33
|
-
...viteConfig?.build,
|
|
34
|
-
ssr: true
|
|
35
|
-
}
|
|
39
|
+
/* We don't return `viteConfig` because `viteConfigEnhanced` is `InlineConfig` not `ResolvedConfig`
|
|
40
|
+
viteConfig: viteConfigEnhanced,
|
|
41
|
+
*/
|
|
36
42
|
};
|
|
37
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { setOperation };
|
|
2
|
-
export { clearOperation };
|
|
3
1
|
export { isVikeCliOrApi };
|
|
2
|
+
export { setContextApiOperation };
|
|
3
|
+
export { clearContextApiOperation };
|
|
4
4
|
import type { Operation } from './types.js';
|
|
5
5
|
declare function isVikeCliOrApi(): boolean;
|
|
6
|
-
declare function
|
|
7
|
-
declare function
|
|
6
|
+
declare function setContextApiOperation(operation: Operation): void;
|
|
7
|
+
declare function clearContextApiOperation(): void;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
// export { getOperation }
|
|
2
|
-
export { setOperation };
|
|
3
|
-
export { clearOperation };
|
|
4
1
|
export { isVikeCliOrApi };
|
|
2
|
+
export { setContextApiOperation };
|
|
3
|
+
export { clearContextApiOperation };
|
|
5
4
|
import { assert, getGlobalObject } from './utils.js';
|
|
6
|
-
const globalObject = getGlobalObject('context.ts', {
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
function getOperation() {
|
|
5
|
+
const globalObject = getGlobalObject('api/context.ts', {});
|
|
6
|
+
function getApiOperation() {
|
|
10
7
|
assert(globalObject.apiOperation);
|
|
11
8
|
return globalObject.apiOperation;
|
|
12
9
|
}
|
|
@@ -14,10 +11,10 @@ function isVikeCliOrApi() {
|
|
|
14
11
|
// The CLI uses the API
|
|
15
12
|
return !!globalObject.apiOperation;
|
|
16
13
|
}
|
|
17
|
-
function
|
|
14
|
+
function setContextApiOperation(operation) {
|
|
18
15
|
assert(!globalObject.apiOperation);
|
|
19
16
|
globalObject.apiOperation = operation;
|
|
20
17
|
}
|
|
21
|
-
function
|
|
18
|
+
function clearContextApiOperation() {
|
|
22
19
|
globalObject.apiOperation = undefined;
|
|
23
20
|
}
|
|
@@ -4,10 +4,11 @@ export { assertViteRoot };
|
|
|
4
4
|
export { normalizeViteRoot };
|
|
5
5
|
import type { InlineConfig, ResolvedConfig } from 'vite';
|
|
6
6
|
import type { Operation } from './types.js';
|
|
7
|
-
|
|
7
|
+
import { type VikeConfigObject } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
8
|
+
declare function prepareViteApiCall(viteConfigFromOptions: InlineConfig | undefined, operation: Operation): Promise<{
|
|
9
|
+
vikeConfig: VikeConfigObject;
|
|
8
10
|
viteConfigEnhanced: InlineConfig | undefined;
|
|
9
|
-
vikeConfigGlobal: import("../plugin/plugins/importUserCode/v1-design/getVikeConfig.js").VikeConfigGlobal;
|
|
10
11
|
}>;
|
|
11
|
-
declare function getViteRoot(operation:
|
|
12
|
+
declare function getViteRoot(operation: Operation): Promise<string>;
|
|
12
13
|
declare function normalizeViteRoot(root: string): string;
|
|
13
14
|
declare function assertViteRoot(root: string, config: ResolvedConfig): void;
|
|
@@ -4,40 +4,41 @@ export { assertViteRoot };
|
|
|
4
4
|
export { normalizeViteRoot };
|
|
5
5
|
// TODO: enable Vike extensions to add Vite plugins
|
|
6
6
|
import { loadConfigFromFile, mergeConfig, resolveConfig } from 'vite';
|
|
7
|
-
import {
|
|
7
|
+
import { clearContextApiOperation, setContextApiOperation } from './context.js';
|
|
8
8
|
import { getVikeConfig2 } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import { assert, assertUsage, getGlobalObject, isObject, toPosixPath } from './utils.js';
|
|
11
11
|
import pc from '@brillout/picocolors';
|
|
12
12
|
import { clearGlobalContext } from '../runtime/globalContext.js';
|
|
13
13
|
const globalObject = getGlobalObject('prepareViteApiCall.ts', {});
|
|
14
|
-
async function prepareViteApiCall(
|
|
14
|
+
async function prepareViteApiCall(viteConfigFromOptions, operation) {
|
|
15
15
|
clear();
|
|
16
|
-
|
|
17
|
-
return enhanceViteConfig(
|
|
16
|
+
setContextApiOperation(operation);
|
|
17
|
+
return enhanceViteConfig(viteConfigFromOptions, operation);
|
|
18
18
|
}
|
|
19
19
|
// For subsequent API calls, e.g. calling prerender() after build()
|
|
20
20
|
function clear() {
|
|
21
|
-
|
|
21
|
+
clearContextApiOperation();
|
|
22
22
|
clearGlobalContext();
|
|
23
23
|
}
|
|
24
|
-
async function enhanceViteConfig(
|
|
25
|
-
const viteInfo = await getInfoFromVite(
|
|
24
|
+
async function enhanceViteConfig(viteConfigFromOptions, operation) {
|
|
25
|
+
const viteInfo = await getInfoFromVite(viteConfigFromOptions, operation);
|
|
26
26
|
await assertViteRoot2(viteInfo.root, viteInfo.viteConfigEnhanced, operation);
|
|
27
27
|
const vikeConfig = await getVikeConfig2(viteInfo.root, operation === 'dev', viteInfo.vikeVitePluginOptions);
|
|
28
28
|
const viteConfigEnhanced = addViteSettingsSetByVikeConfig(viteInfo.viteConfigEnhanced, vikeConfig);
|
|
29
29
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
vikeConfig,
|
|
31
|
+
viteConfigEnhanced
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
function addViteSettingsSetByVikeConfig(viteConfigEnhanced, vikeConfig) {
|
|
35
|
-
const viteConfigs = vikeConfig.global.
|
|
35
|
+
const viteConfigs = vikeConfig.global._from.configsCumulative.vite;
|
|
36
36
|
if (!viteConfigs)
|
|
37
37
|
return viteConfigEnhanced;
|
|
38
38
|
viteConfigs.values.forEach((v) => {
|
|
39
39
|
assertUsage(isObject(v.value), `${v.definedAt} should be an object`);
|
|
40
40
|
viteConfigEnhanced = mergeConfig(viteConfigEnhanced ?? {}, v.value);
|
|
41
|
+
assertUsage(findVikeVitePlugin(v.value), "Using the +vite setting to add Vike's Vite plugin is forbidden");
|
|
41
42
|
});
|
|
42
43
|
return viteConfigEnhanced;
|
|
43
44
|
}
|
|
@@ -47,13 +48,14 @@ async function getViteRoot(operation) {
|
|
|
47
48
|
assert(globalObject.root);
|
|
48
49
|
return globalObject.root;
|
|
49
50
|
}
|
|
50
|
-
async function getInfoFromVite(
|
|
51
|
-
const
|
|
52
|
-
const root = normalizeViteRoot(
|
|
51
|
+
async function getInfoFromVite(viteConfigFromOptions, operation) {
|
|
52
|
+
const viteConfigFromUserViteFile = await loadViteConfigFile(viteConfigFromOptions, operation);
|
|
53
|
+
const root = normalizeViteRoot(viteConfigFromUserViteFile?.root ?? viteConfigFromOptions?.root ?? process.cwd());
|
|
53
54
|
globalObject.root = root;
|
|
54
55
|
let vikeVitePluginOptions;
|
|
55
|
-
let viteConfigEnhanced =
|
|
56
|
-
|
|
56
|
+
let viteConfigEnhanced = viteConfigFromOptions;
|
|
57
|
+
// If Vike's Vite plugin is found in both viteConfigFromOptions and viteConfigFromUserViteFile then Vike will later throw an error
|
|
58
|
+
const found = findVikeVitePlugin(viteConfigFromOptions) || findVikeVitePlugin(viteConfigFromUserViteFile);
|
|
57
59
|
if (found) {
|
|
58
60
|
vikeVitePluginOptions = found.vikeVitePluginOptions;
|
|
59
61
|
}
|
|
@@ -62,20 +64,20 @@ async function getInfoFromVite(viteConfig, operation) {
|
|
|
62
64
|
// Using a dynamic import because the script calling the Vike API may not live in the same place as vite.config.js, thus vike/plugin may resolved to two different node_modules/vike directories.
|
|
63
65
|
const { plugin: vikePlugin } = await import('../plugin/index.js');
|
|
64
66
|
viteConfigEnhanced = {
|
|
65
|
-
...
|
|
66
|
-
plugins: [...(
|
|
67
|
+
...viteConfigFromOptions,
|
|
68
|
+
plugins: [...(viteConfigFromOptions?.plugins ?? []), vikePlugin()]
|
|
67
69
|
};
|
|
68
|
-
const res = findVikeVitePlugin(viteConfigEnhanced
|
|
70
|
+
const res = findVikeVitePlugin(viteConfigEnhanced);
|
|
69
71
|
assert(res);
|
|
70
72
|
vikeVitePluginOptions = res.vikeVitePluginOptions;
|
|
71
73
|
}
|
|
72
74
|
assert(vikeVitePluginOptions);
|
|
73
75
|
return { root, vikeVitePluginOptions, viteConfigEnhanced };
|
|
74
76
|
}
|
|
75
|
-
function findVikeVitePlugin(
|
|
77
|
+
function findVikeVitePlugin(viteConfig) {
|
|
76
78
|
let vikeVitePluginOptions;
|
|
77
79
|
let vikeVitePuginFound = false;
|
|
78
|
-
plugins
|
|
80
|
+
viteConfig?.plugins?.forEach((p) => {
|
|
79
81
|
if (p && '__vikeVitePluginOptions' in p) {
|
|
80
82
|
vikeVitePuginFound = true;
|
|
81
83
|
const options = p.__vikeVitePluginOptions;
|
|
@@ -88,8 +90,8 @@ function findVikeVitePlugin(plugins) {
|
|
|
88
90
|
return { vikeVitePluginOptions };
|
|
89
91
|
}
|
|
90
92
|
// Copied from https://github.com/vitejs/vite/blob/4f5845a3182fc950eb9cd76d7161698383113b18/packages/vite/src/node/config.ts#L961-L1005
|
|
91
|
-
async function loadViteConfigFile(
|
|
92
|
-
const [inlineConfig, command, defaultMode, _defaultNodeEnv, isPreview] = getResolveConfigArgs(
|
|
93
|
+
async function loadViteConfigFile(viteConfigFromOptions, operation) {
|
|
94
|
+
const [inlineConfig, command, defaultMode, _defaultNodeEnv, isPreview] = getResolveConfigArgs(viteConfigFromOptions, operation);
|
|
93
95
|
let config = inlineConfig;
|
|
94
96
|
let mode = inlineConfig.mode || defaultMode;
|
|
95
97
|
const configEnv = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from '../../utils/assert.js';
|
|
2
2
|
export * from '../../utils/getGlobalObject.js';
|
|
3
|
-
export * from '../../utils/
|
|
3
|
+
export * from '../../utils/path.js';
|
|
4
4
|
export * from '../../utils/isObject.js';
|
|
5
|
+
export * from '../../utils/assertVersion.js';
|
|
@@ -4,5 +4,6 @@ import { onLoad } from './onLoad.js';
|
|
|
4
4
|
onLoad();
|
|
5
5
|
export * from '../../utils/assert.js';
|
|
6
6
|
export * from '../../utils/getGlobalObject.js';
|
|
7
|
-
export * from '../../utils/
|
|
7
|
+
export * from '../../utils/path.js';
|
|
8
8
|
export * from '../../utils/isObject.js';
|
|
9
|
+
export * from '../../utils/assertVersion.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { isVikeCli };
|
|
2
|
+
export { setContextCliCommand };
|
|
3
|
+
import { assert, getGlobalObject } from './utils.js';
|
|
4
|
+
const globalObject = getGlobalObject('cli/context.ts', {});
|
|
5
|
+
function getCliCommand() {
|
|
6
|
+
return globalObject.cliCommand;
|
|
7
|
+
}
|
|
8
|
+
function isVikeCli() {
|
|
9
|
+
return !!globalObject.cliCommand;
|
|
10
|
+
}
|
|
11
|
+
function setContextCliCommand(command) {
|
|
12
|
+
assert(!globalObject.cliCommand);
|
|
13
|
+
globalObject.cliCommand = command;
|
|
14
|
+
}
|
|
@@ -2,9 +2,11 @@ import { projectInfo } from './utils.js';
|
|
|
2
2
|
import { dev, build, preview } from '../api/index.js';
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
import { parseCli } from './parseCli.js';
|
|
5
|
+
import { setContextCliCommand } from './context.js';
|
|
5
6
|
cli();
|
|
6
7
|
async function cli() {
|
|
7
8
|
const { command } = parseCli();
|
|
9
|
+
setContextCliCommand(command);
|
|
8
10
|
if (command === 'dev') {
|
|
9
11
|
await cmdDev();
|
|
10
12
|
}
|
|
@@ -2,6 +2,34 @@ export default plugin;
|
|
|
2
2
|
export { plugin };
|
|
3
3
|
export { plugin as ssr };
|
|
4
4
|
export type { VikeVitePluginOptions as UserConfig };
|
|
5
|
+
export type { VikeVitePluginOptions };
|
|
5
6
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
6
|
-
import type { VikeVitePluginOptions } from './plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
declare function plugin(vikeVitePluginOptions?: VikeVitePluginOptions): any;
|
|
8
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
9
|
+
type VikeVitePluginOptions = {
|
|
10
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
11
|
+
prerender?: boolean | {
|
|
12
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
13
|
+
noExtraDir?: boolean;
|
|
14
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
15
|
+
parallel?: boolean | number;
|
|
16
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
17
|
+
partial?: boolean;
|
|
18
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
19
|
+
disableAutoRun?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
22
|
+
disableAutoFullBuild?: boolean | 'prerender';
|
|
23
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
24
|
+
baseServer?: string;
|
|
25
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
26
|
+
baseAssets?: string;
|
|
27
|
+
/** @deprecated It's now `true` by default. You can remove this option. */
|
|
28
|
+
includeAssetsImportedByServer?: boolean;
|
|
29
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
30
|
+
redirects?: Record<string, string>;
|
|
31
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
32
|
+
trailingSlash?: boolean;
|
|
33
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
34
|
+
disableUrlNormalization?: boolean;
|
|
35
|
+
};
|
|
@@ -3,8 +3,7 @@ export { plugin };
|
|
|
3
3
|
// TODO/v1-release: remove
|
|
4
4
|
export { plugin as ssr };
|
|
5
5
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
6
|
-
import {
|
|
7
|
-
import { assertUsage, assertVersion, markSetup_vikeVitePlugin } from './utils.js';
|
|
6
|
+
import { assertUsage } from './utils.js';
|
|
8
7
|
import { buildConfig } from './plugins/buildConfig.js';
|
|
9
8
|
import { previewConfig } from './plugins/previewConfig.js';
|
|
10
9
|
import { autoFullBuild } from './plugins/autoFullBuild.js';
|
|
@@ -24,11 +23,11 @@ import { envVarsPlugin } from './plugins/envVars.js';
|
|
|
24
23
|
import pc from '@brillout/picocolors';
|
|
25
24
|
import { fileEnv } from './plugins/fileEnv.js';
|
|
26
25
|
import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.js';
|
|
27
|
-
import { resolveClientEntriesDev } from './resolveClientEntriesDev.js';
|
|
26
|
+
import { resolveClientEntriesDev } from './shared/resolveClientEntriesDev.js';
|
|
28
27
|
import { workaroundCssModuleHmr } from './plugins/workaroundCssModuleHmr.js';
|
|
29
28
|
import { workaroundVite6HmrRegression } from './plugins/workaroundVite6HmrRegression.js';
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
import { buildApp } from './plugins/buildApp.js';
|
|
30
|
+
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
32
31
|
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
33
32
|
// Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
|
|
34
33
|
function plugin(vikeVitePluginOptions = {}) {
|
|
@@ -37,6 +36,7 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
37
36
|
importUserCode(),
|
|
38
37
|
...devConfig(),
|
|
39
38
|
...buildConfig(),
|
|
39
|
+
...buildApp(),
|
|
40
40
|
previewConfig(),
|
|
41
41
|
...autoFullBuild(),
|
|
42
42
|
packageJsonFile(),
|
|
@@ -63,10 +63,6 @@ Object.defineProperty(plugin, 'apply', {
|
|
|
63
63
|
assertUsage(false, `Add ${pc.cyan('vike()')} instead of ${pc.cyan('vike')} to vite.config.js#plugins (i.e. call the function and add the return value instead of adding the function itself)`, { showStackTrace: true });
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
// package.json#peerDependencies isn't enough as users can ignore it
|
|
67
|
-
function assertViteVersion() {
|
|
68
|
-
assertVersion('Vite', version, '5.1.0');
|
|
69
|
-
}
|
|
70
66
|
// Ensures following works: `const vike = require('vike/plugin')` / `import vike from 'vike/plugin'`
|
|
71
67
|
// - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
|
|
72
68
|
try {
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export { onLoad };
|
|
2
2
|
import { assertIsNotBrowser } from '../../utils/assertIsNotBrowser.js';
|
|
3
|
-
import { assertIsNotProductionRuntime } from '../../utils/assertSetup.js';
|
|
3
|
+
import { assertIsNotProductionRuntime, markSetup_vikeVitePlugin } from '../../utils/assertSetup.js';
|
|
4
4
|
import { assertNodeVersion } from '../../utils/assertNodeVersion.js';
|
|
5
|
+
import { assertVersion } from '../../utils/assertVersion.js';
|
|
6
|
+
import { version } from 'vite';
|
|
5
7
|
function onLoad() {
|
|
8
|
+
markSetup_vikeVitePlugin();
|
|
6
9
|
assertIsNotBrowser();
|
|
7
10
|
assertNodeVersion();
|
|
8
|
-
//
|
|
11
|
+
// package.json#peerDependencies isn't enough as users often ignore it
|
|
12
|
+
assertVersion('Vite', version, '5.1.0');
|
|
13
|
+
// Ensure we don't bloat the server runtime with heavy dependencies such Vite and esbuild
|
|
9
14
|
assertIsNotProductionRuntime();
|
|
10
15
|
}
|