vike 0.4.239 → 0.4.240-commit-a80417c
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/esm/client/index.d.ts +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-client-routing/entry.js +5 -3
- package/dist/esm/client/runtime-client-routing/getBaseServer.js +0 -1
- package/dist/esm/client/runtime-client-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +2 -2
- package/dist/esm/client/runtime-client-routing/{globalContext.js → getGlobalContextClientInternal.js} +8 -4
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +6 -6
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/runtime-client-routing/isClientSideRoutable.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +4 -4
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +102 -77
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-server-routing/entry.js +5 -3
- package/dist/esm/client/runtime-server-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +2 -2
- package/dist/esm/client/runtime-server-routing/getGlobalContextClientInternal.js +6 -0
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +1 -1
- package/dist/esm/client/shared/{createGetGlobalContextClient.d.ts → getGlobalContextClientInternalShared.d.ts} +11 -8
- package/dist/esm/client/shared/getGlobalContextClientInternalShared.js +66 -0
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +1 -3
- package/dist/esm/node/prerender/runPrerender.d.ts +4 -2
- package/dist/esm/node/prerender/runPrerender.js +5 -2
- package/dist/esm/node/runtime/globalContext.d.ts +15 -2
- package/dist/esm/node/runtime/globalContext.js +46 -32
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +4 -2
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +4 -2
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +8 -4
- package/dist/esm/node/runtime/renderPage.d.ts +4 -2
- package/dist/esm/node/vite/index.js +42 -18
- package/dist/esm/node/vite/onLoad.js +1 -1
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/handleAssetsManifest.d.ts +4 -0
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/handleAssetsManifest.js +21 -6
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildApp.js +24 -20
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildConfig.js +20 -6
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginDistFileNames.d.ts +1 -1
- package/dist/esm/node/vite/plugins/build/pluginDistFileNames.js +253 -0
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginDistPackageJsonFile.d.ts +1 -1
- package/dist/esm/node/vite/plugins/build/pluginDistPackageJsonFile.js +40 -0
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginModuleBanner.d.ts +1 -1
- package/dist/esm/node/vite/plugins/build/pluginModuleBanner.js +49 -0
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginProdBuildEntry.js +4 -2
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginSuppressRollupWarning.d.ts +1 -1
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginSuppressRollupWarning.js +27 -23
- package/dist/esm/node/vite/plugins/non-runnable-dev/pluginReplaceConstantsNonRunnableDev.d.ts +7 -0
- package/dist/esm/node/vite/plugins/non-runnable-dev/pluginReplaceConstantsNonRunnableDev.js +47 -0
- package/dist/esm/node/vite/plugins/{pluginNonRunnableDev.d.ts → non-runnable-dev/pluginViteRPC.d.ts} +3 -7
- package/dist/esm/node/vite/plugins/non-runnable-dev/pluginViteRPC.js +30 -0
- package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBaseUrls.js +39 -33
- package/dist/esm/node/vite/plugins/pluginCommon.js +8 -28
- package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +1 -1
- package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +108 -92
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +39 -23
- package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +117 -92
- package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginPreview.js +38 -30
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsEnvVars.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsEnvVars.js +127 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.d.ts +17 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.js +52 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsPageContext.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsPageContext.js +89 -0
- package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +67 -47
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +13 -9
- package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
- package/dist/esm/node/vite/shared/getMagicString.d.ts +1 -1
- package/dist/esm/node/vite/shared/getMagicString.js +2 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +2 -2
- package/dist/esm/shared/createGlobalContextShared.d.ts +4 -4
- package/dist/esm/shared/route/abort.d.ts +23 -11
- package/dist/esm/shared/route/abort.js +45 -5
- package/dist/esm/shared/route/index.js +13 -4
- package/dist/esm/shared/route/utils.d.ts +1 -0
- package/dist/esm/shared/route/utils.js +1 -0
- package/dist/esm/types/Config.d.ts +1 -1
- package/dist/esm/types/PageContext.d.ts +8 -8
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +1 -0
- package/dist/esm/utils/debug.d.ts +5 -3
- package/dist/esm/utils/debug.js +30 -16
- package/dist/esm/utils/findPackageJson.js +0 -1
- package/dist/esm/utils/getGlobalObject.d.ts +5 -1
- package/dist/esm/utils/getGlobalObject.js +5 -1
- package/dist/esm/utils/getViteRPC.js +0 -2
- package/dist/esm/utils/isDev.js +3 -1
- package/dist/esm/utils/isNonRunnableDev.js +2 -2
- package/dist/esm/utils/requireResolve.js +1 -2
- package/dist/esm/utils/virtualFileId.d.ts +4 -0
- package/dist/esm/utils/virtualFileId.js +14 -11
- package/package.json +8 -27
- package/dist/cjs/__internal/index.js +0 -35
- package/dist/cjs/client/runtime-client-routing/globalContext.js +0 -49
- package/dist/cjs/client/runtime-client-routing/prefetch/PrefetchSetting.js +0 -2
- package/dist/cjs/client/runtime-server-routing/globalContext.js +0 -41
- package/dist/cjs/client/runtime-server-routing/onLoad.js +0 -7
- package/dist/cjs/client/runtime-server-routing/utils.js +0 -34
- package/dist/cjs/client/shared/createGetGlobalContextClient.js +0 -65
- package/dist/cjs/client/shared/getJsonSerializedInHtml.js +0 -40
- package/dist/cjs/client/shared/preparePageContextForPublicUsageClientShared.js +0 -41
- package/dist/cjs/client/shared/utils.js +0 -23
- package/dist/cjs/node/api/build.js +0 -24
- package/dist/cjs/node/api/context.js +0 -23
- package/dist/cjs/node/api/dev.js +0 -18
- package/dist/cjs/node/api/index.js +0 -44
- package/dist/cjs/node/api/onLoad.js +0 -9
- package/dist/cjs/node/api/prepareViteApiCall.js +0 -206
- package/dist/cjs/node/api/prerender.js +0 -18
- package/dist/cjs/node/api/preview.js +0 -38
- package/dist/cjs/node/api/types.js +0 -2
- package/dist/cjs/node/api/utils.js +0 -27
- package/dist/cjs/node/cli/context.js +0 -17
- package/dist/cjs/node/cli/entry.js +0 -121
- package/dist/cjs/node/cli/index.js +0 -12
- package/dist/cjs/node/cli/onLoad.js +0 -9
- package/dist/cjs/node/cli/parseCli.js +0 -95
- package/dist/cjs/node/cli/utils.js +0 -24
- package/dist/cjs/node/client/router.js +0 -19
- package/dist/cjs/node/createPageRenderer.js +0 -132
- package/dist/cjs/node/importBuild.js +0 -3
- package/dist/cjs/node/prerender/context.js +0 -26
- package/dist/cjs/node/prerender/index.js +0 -12
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +0 -66
- package/dist/cjs/node/prerender/runPrerender.js +0 -777
- package/dist/cjs/node/prerender/runPrerenderEntry.js +0 -55
- package/dist/cjs/node/prerender/utils.js +0 -37
- package/dist/cjs/node/runtime/globalContext.js +0 -572
- package/dist/cjs/node/runtime/index-deprecated.js +0 -33
- package/dist/cjs/node/runtime/index.js +0 -74
- package/dist/cjs/node/runtime/loggerRuntime.js +0 -17
- package/dist/cjs/node/runtime/onLoad.js +0 -29
- package/dist/cjs/node/runtime/page-files/setup.js +0 -5
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +0 -71
- package/dist/cjs/node/runtime/renderPage/assertArguments.js +0 -42
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +0 -51
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +0 -114
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +0 -59
- package/dist/cjs/node/runtime/renderPage/csp.js +0 -47
- package/dist/cjs/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +0 -31
- package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +0 -120
- package/dist/cjs/node/runtime/renderPage/execHookServer.js +0 -8
- package/dist/cjs/node/runtime/renderPage/getCacheControl.js +0 -24
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +0 -20
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +0 -137
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +0 -125
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.js +0 -86
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.js +0 -77
- package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +0 -36
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +0 -50
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +0 -41
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +0 -68
- package/dist/cjs/node/runtime/renderPage/headersResponse.js +0 -48
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/getHtmlTags.js +0 -269
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/getViteDevScript.js +0 -32
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/inferHtmlTags.js +0 -55
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectAssets__public.js +0 -31
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectHtmlTags.js +0 -161
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/mergeScriptTags.js +0 -73
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/sanitizeJson.js +0 -8
- package/dist/cjs/node/runtime/renderPage/html/injectAssets.js +0 -93
- package/dist/cjs/node/runtime/renderPage/html/propKeys.js +0 -47
- package/dist/cjs/node/runtime/renderPage/html/renderHtml.js +0 -245
- package/dist/cjs/node/runtime/renderPage/html/serializeContext.js +0 -189
- package/dist/cjs/node/runtime/renderPage/html/stream/react-streaming.js +0 -36
- package/dist/cjs/node/runtime/renderPage/html/stream.js +0 -829
- package/dist/cjs/node/runtime/renderPage/inferMediaType.js +0 -81
- package/dist/cjs/node/runtime/renderPage/isFontFallback.js +0 -29
- package/dist/cjs/node/runtime/renderPage/isNewError.js +0 -25
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +0 -124
- package/dist/cjs/node/runtime/renderPage/log404/index.js +0 -154
- package/dist/cjs/node/runtime/renderPage/logErrorHint/errors.js +0 -20
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +0 -200
- package/dist/cjs/node/runtime/renderPage/loggerProd.js +0 -34
- package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +0 -10
- package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +0 -83
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +0 -71
- package/dist/cjs/node/runtime/renderPage.js +0 -502
- package/dist/cjs/node/runtime/universal-middleware.js +0 -20
- package/dist/cjs/node/runtime/utils.js +0 -83
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -27
- package/dist/cjs/node/runtime-dev/index.js +0 -42
- package/dist/cjs/node/shared/assertV1Design.js +0 -30
- package/dist/cjs/node/shared/extractAssetsQuery.js +0 -29
- package/dist/cjs/node/shared/getVikeConfigError.js +0 -22
- package/dist/cjs/node/shared/isErrorDebug.js +0 -7
- package/dist/cjs/node/shared/prependEntriesDir.js +0 -13
- package/dist/cjs/node/shared/resolveBase.js +0 -35
- package/dist/cjs/node/shared/utils.js +0 -35
- package/dist/cjs/node/shared/virtualFileId.js +0 -110
- package/dist/cjs/node/vite/index.js +0 -69
- package/dist/cjs/node/vite/onLoad.js +0 -21
- package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +0 -48
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -342
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -179
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -220
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -254
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -36
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -41
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -109
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -63
- package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -21
- package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
- package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -197
- package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -28
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +0 -163
- package/dist/cjs/node/vite/plugins/pluginDev.js +0 -107
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -87
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -227
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -99
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -149
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -52
- package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -76
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -69
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -49
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/debug.js +0 -5
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +0 -56
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +0 -190
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +0 -54
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +0 -97
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +0 -215
- package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -15
- package/dist/cjs/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +0 -35
- package/dist/cjs/node/vite/shared/addSsrMiddleware.js +0 -60
- package/dist/cjs/node/vite/shared/findPageFiles.js +0 -25
- package/dist/cjs/node/vite/shared/getAssetsDir.js +0 -10
- package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +0 -42
- package/dist/cjs/node/vite/shared/getEnvVarObject.js +0 -37
- package/dist/cjs/node/vite/shared/getFilePath.js +0 -172
- package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +0 -125
- package/dist/cjs/node/vite/shared/getMagicString.js +0 -18
- package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +0 -10
- package/dist/cjs/node/vite/shared/getOutDirs.js +0 -146
- package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +0 -21
- package/dist/cjs/node/vite/shared/isAsset.js +0 -40
- package/dist/cjs/node/vite/shared/isViteCliCall.js +0 -83
- package/dist/cjs/node/vite/shared/isViteServerSide.js +0 -68
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +0 -15
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelSolid.js +0 -15
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +0 -38
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx1.js +0 -26
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx2.js +0 -85
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errPostcss.js +0 -30
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwc.js +0 -19
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwcBig.js +0 -19
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +0 -29
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueHtml.js +0 -13
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueJavascript.js +0 -15
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +0 -162
- package/dist/cjs/node/vite/shared/loggerNotProd/log.js +0 -102
- package/dist/cjs/node/vite/shared/loggerNotProd.js +0 -208
- package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +0 -26
- package/dist/cjs/node/vite/shared/loggerVite.js +0 -54
- package/dist/cjs/node/vite/shared/normalizeId.js +0 -9
- package/dist/cjs/node/vite/shared/parseEsModule.js +0 -33
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/assertExtensions.js +0 -136
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -262
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles/ignorePatternsBuiltIn.js +0 -18
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +0 -252
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +0 -190
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getConfigFileExport.js +0 -17
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getPlusFilesAll.js +0 -127
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.js +0 -129
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/pointerImports.js +0 -195
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +0 -102
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +0 -425
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +0 -1151
- package/dist/cjs/node/vite/shared/rollupIsEsm.js +0 -15
- package/dist/cjs/node/vite/utils.js +0 -45
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -4
- package/dist/cjs/shared/RenderErrorPage.js +0 -6
- package/dist/cjs/shared/abort.js +0 -16
- package/dist/cjs/shared/addIs404ToPageProps.js +0 -18
- package/dist/cjs/shared/assertHookReturnedObject.js +0 -21
- package/dist/cjs/shared/assertOnBeforeRenderHookReturn.js +0 -21
- package/dist/cjs/shared/assertPageContextProvidedByUser.js +0 -20
- package/dist/cjs/shared/createGlobalContextShared.js +0 -109
- package/dist/cjs/shared/createPageContextShared.js +0 -17
- package/dist/cjs/shared/determinePageIdOld.js +0 -11
- package/dist/cjs/shared/error-page.js +0 -40
- package/dist/cjs/shared/getPageContext.js +0 -6
- package/dist/cjs/shared/getPageContextRequestUrl.js +0 -16
- package/dist/cjs/shared/getPageContextUrlComputed.js +0 -132
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +0 -19
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/ClientDependency.js +0 -2
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +0 -50
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +0 -30
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/getExportNames.js +0 -15
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +0 -59
- package/dist/cjs/shared/getPageFiles/analyzePageServerSide.js +0 -22
- package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +0 -24
- package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -52
- package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -102
- package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -56
- package/dist/cjs/shared/getPageFiles/parseVirtualFileExportsGlobalEntry.js +0 -100
- package/dist/cjs/shared/getPageFiles.js +0 -7
- package/dist/cjs/shared/getProxyForPublicUsage.js +0 -56
- package/dist/cjs/shared/hooks/execHook.js +0 -147
- package/dist/cjs/shared/hooks/getHook.js +0 -173
- package/dist/cjs/shared/htmlElementIds.js +0 -5
- package/dist/cjs/shared/misc/isServerSideError.js +0 -4
- package/dist/cjs/shared/misc/pageContextInitIsPassedToClient.js +0 -4
- package/dist/cjs/shared/modifyUrl.js +0 -28
- package/dist/cjs/shared/modifyUrlSameOrigin.js +0 -47
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +0 -42
- package/dist/cjs/shared/page-configs/findPageConfig.js +0 -10
- package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +0 -65
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -68
- package/dist/cjs/shared/page-configs/getConfigValueRuntime.js +0 -10
- package/dist/cjs/shared/page-configs/getConfigValueTyped.js +0 -32
- package/dist/cjs/shared/page-configs/getExportPath.js +0 -29
- package/dist/cjs/shared/page-configs/helpers.js +0 -27
- package/dist/cjs/shared/page-configs/loadAndParseVirtualFilePageEntry.js +0 -25
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +0 -287
- package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +0 -2
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -1
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigsSerialized.js +0 -145
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +0 -290
- package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +0 -10
- package/dist/cjs/shared/preparePageContextForPublicUsage.js +0 -80
- package/dist/cjs/shared/route/abort.js +0 -178
- package/dist/cjs/shared/route/debug.js +0 -23
- package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +0 -52
- package/dist/cjs/shared/route/execHookGuard.js +0 -37
- package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -84
- package/dist/cjs/shared/route/index.js +0 -107
- package/dist/cjs/shared/route/loadPageRoutes.js +0 -197
- package/dist/cjs/shared/route/noRouteMatch.js +0 -4
- package/dist/cjs/shared/route/resolvePrecedence.js +0 -93
- package/dist/cjs/shared/route/resolveRoute.js +0 -20
- package/dist/cjs/shared/route/resolveRouteFunction.js +0 -73
- package/dist/cjs/shared/route/resolveRouteString.js +0 -153
- package/dist/cjs/shared/route/resolveUrlPathname.js +0 -47
- package/dist/cjs/shared/route/routing.js +0 -9
- package/dist/cjs/shared/route/utils.js +0 -40
- package/dist/cjs/shared/utils.js +0 -49
- package/dist/cjs/types/Config/ConfigResolved.js +0 -2
- package/dist/cjs/types/Config.js +0 -2
- package/dist/cjs/types/FilePath.js +0 -2
- package/dist/cjs/types/PageConfig.js +0 -2
- package/dist/cjs/types/PageContext.js +0 -2
- package/dist/cjs/types/VikeGlobalInternal.js +0 -2
- package/dist/cjs/types/VikeNamespace.js +0 -2
- package/dist/cjs/types/ViteManifest.js +0 -2
- package/dist/cjs/types/defineConfig.js +0 -6
- package/dist/cjs/types/index-dreprecated.js +0 -3
- package/dist/cjs/types/index.js +0 -5
- package/dist/cjs/utils/PROJECT_VERSION.js +0 -5
- package/dist/cjs/utils/PromiseType.js +0 -2
- package/dist/cjs/utils/assert.js +0 -211
- package/dist/cjs/utils/assertIsBrowser.js +0 -8
- package/dist/cjs/utils/assertIsNotBrowser.js +0 -9
- package/dist/cjs/utils/assertKeys.js +0 -27
- package/dist/cjs/utils/assertNodeVersion.js +0 -14
- package/dist/cjs/utils/assertRoutingType.js +0 -29
- package/dist/cjs/utils/assertSetup.js +0 -171
- package/dist/cjs/utils/assertSingleInstance.js +0 -110
- package/dist/cjs/utils/assertVersion.js +0 -60
- package/dist/cjs/utils/capitalizeFirstLetter.js +0 -9
- package/dist/cjs/utils/cast.js +0 -6
- package/dist/cjs/utils/catchInfiniteLoop.js +0 -34
- package/dist/cjs/utils/changeEnumerable.js +0 -8
- package/dist/cjs/utils/checkType.js +0 -6
- package/dist/cjs/utils/compareString.js +0 -10
- package/dist/cjs/utils/createErrorWithCleanStackTrace.js +0 -39
- package/dist/cjs/utils/debug.js +0 -178
- package/dist/cjs/utils/debugGlob.js +0 -6
- package/dist/cjs/utils/deepEqual.js +0 -10
- package/dist/cjs/utils/escapeHtml.js +0 -13
- package/dist/cjs/utils/escapeRegex.js +0 -7
- package/dist/cjs/utils/findFile.js +0 -30
- package/dist/cjs/utils/findPackageJson.js +0 -18
- package/dist/cjs/utils/formatHintLog.js +0 -17
- package/dist/cjs/utils/freezePartial.js +0 -35
- package/dist/cjs/utils/genPromise.js +0 -51
- package/dist/cjs/utils/getFileExtension.js +0 -16
- package/dist/cjs/utils/getGlobalObject.js +0 -15
- package/dist/cjs/utils/getMostSimilar.js +0 -68
- package/dist/cjs/utils/getPropAccessNotation.js +0 -9
- package/dist/cjs/utils/getRandomId.js +0 -14
- package/dist/cjs/utils/getTerminalWidth.js +0 -7
- package/dist/cjs/utils/getValuePrintable.js +0 -10
- package/dist/cjs/utils/getViteRPC.js +0 -79
- package/dist/cjs/utils/hasProp.js +0 -50
- package/dist/cjs/utils/humanizeTime.js +0 -24
- package/dist/cjs/utils/includes.js +0 -13
- package/dist/cjs/utils/injectRollupInputs.js +0 -29
- package/dist/cjs/utils/isArray.js +0 -7
- package/dist/cjs/utils/isArrayOfStrings.js +0 -7
- package/dist/cjs/utils/isBrowser.js +0 -8
- package/dist/cjs/utils/isCallable.js +0 -6
- package/dist/cjs/utils/isDev.js +0 -20
- package/dist/cjs/utils/isDocker.js +0 -45
- package/dist/cjs/utils/isEqualStringList.js +0 -13
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +0 -66
- package/dist/cjs/utils/isHtml.js +0 -9
- package/dist/cjs/utils/isImportPath.js +0 -21
- package/dist/cjs/utils/isNodeJS.js +0 -16
- package/dist/cjs/utils/isNonRunnableDev.js +0 -12
- package/dist/cjs/utils/isNullish.js +0 -16
- package/dist/cjs/utils/isObject.js +0 -6
- package/dist/cjs/utils/isObjectOfStrings.js +0 -7
- package/dist/cjs/utils/isObjectWithKeys.js +0 -15
- package/dist/cjs/utils/isPlainObject.js +0 -19
- package/dist/cjs/utils/isPromise.js +0 -7
- package/dist/cjs/utils/isPropertyGetter.js +0 -7
- package/dist/cjs/utils/isReact.js +0 -23
- package/dist/cjs/utils/isRunnableDevEnvironment.js +0 -9
- package/dist/cjs/utils/isSameErrorMessage.js +0 -9
- package/dist/cjs/utils/isScriptFile.js +0 -67
- package/dist/cjs/utils/isVikeReactApp.js +0 -8
- package/dist/cjs/utils/isVitest.js +0 -6
- package/dist/cjs/utils/joinEnglish.js +0 -14
- package/dist/cjs/utils/normalizeHeaders.js +0 -17
- package/dist/cjs/utils/objectAssign.js +0 -14
- package/dist/cjs/utils/objectAssignSafe.js +0 -7
- package/dist/cjs/utils/objectDefineProperty.js +0 -7
- package/dist/cjs/utils/objectEntries.js +0 -8
- package/dist/cjs/utils/objectEntriesForEach.js +0 -7
- package/dist/cjs/utils/objectFilter.js +0 -10
- package/dist/cjs/utils/objectFromEntries.js +0 -7
- package/dist/cjs/utils/objectKeys.js +0 -9
- package/dist/cjs/utils/objectReplace.js +0 -9
- package/dist/cjs/utils/onPageVisibilityChange.js +0 -18
- package/dist/cjs/utils/pLimit.js +0 -134
- package/dist/cjs/utils/parseNpmPackage.js +0 -106
- package/dist/cjs/utils/parseUrl-extras.js +0 -110
- package/dist/cjs/utils/parseUrl.js +0 -338
- package/dist/cjs/utils/path.js +0 -59
- package/dist/cjs/utils/pick.js +0 -12
- package/dist/cjs/utils/preservePropertyGetters.js +0 -30
- package/dist/cjs/utils/redirectHard.js +0 -6
- package/dist/cjs/utils/removeEmptyLines.js +0 -9
- package/dist/cjs/utils/removeFileExtension.js +0 -6
- package/dist/cjs/utils/requireResolve.js +0 -214
- package/dist/cjs/utils/rollupSourceMap.js +0 -19
- package/dist/cjs/utils/sleep.js +0 -6
- package/dist/cjs/utils/slice.js +0 -35
- package/dist/cjs/utils/sorter.js +0 -117
- package/dist/cjs/utils/stringifyStringArray.js +0 -6
- package/dist/cjs/utils/stripAnsi.js +0 -21
- package/dist/cjs/utils/styleFileRE.js +0 -6
- package/dist/cjs/utils/throttle.js +0 -15
- package/dist/cjs/utils/trackLogs.js +0 -31
- package/dist/cjs/utils/trimWithAnsi.js +0 -40
- package/dist/cjs/utils/truncateString.js +0 -23
- package/dist/cjs/utils/unique.js +0 -6
- package/dist/cjs/utils/updateType.js +0 -9
- package/dist/cjs/utils/urlToFile.js +0 -36
- package/dist/cjs/utils/virtualFileId.js +0 -39
- package/dist/cjs/utils/warnIfErrorIsNotObject.js +0 -23
- package/dist/esm/client/runtime-server-routing/globalContext.js +0 -5
- package/dist/esm/client/shared/createGetGlobalContextClient.js +0 -65
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -249
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -34
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -39
- package/dist/esm/node/vite/plugins/pluginBuild.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginBuild.js +0 -19
- package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +0 -85
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +0 -50
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +0 -67
- package/dist/esm/shared/route/debug.d.ts +0 -6
- package/dist/esm/shared/route/debug.js +0 -21
- /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildApp.d.ts +0 -0
- /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildConfig.d.ts +0 -0
- /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginProdBuildEntry.d.ts +0 -0
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pluginBuildConfig = pluginBuildConfig;
|
|
4
|
-
exports.assertRollupInput = assertRollupInput;
|
|
5
|
-
exports.analyzeClientEntries = analyzeClientEntries;
|
|
6
|
-
const utils_js_1 = require("../../utils.js");
|
|
7
|
-
const resolveVikeConfigInternal_js_1 = require("../../shared/resolveVikeConfigInternal.js");
|
|
8
|
-
const findPageFiles_js_1 = require("../../shared/findPageFiles.js");
|
|
9
|
-
const virtualFileId_js_1 = require("../../../shared/virtualFileId.js");
|
|
10
|
-
const extractAssetsQuery_js_1 = require("../../../shared/extractAssetsQuery.js");
|
|
11
|
-
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
12
|
-
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
13
|
-
const getConfigValueBuildTime_js_1 = require("../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
14
|
-
const isViteServerSide_js_1 = require("../../shared/isViteServerSide.js");
|
|
15
|
-
const handleAssetsManifest_js_1 = require("./handleAssetsManifest.js");
|
|
16
|
-
const retrievePageAssetsProd_js_1 = require("../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js");
|
|
17
|
-
function pluginBuildConfig() {
|
|
18
|
-
let config;
|
|
19
|
-
return [
|
|
20
|
-
{
|
|
21
|
-
name: 'vike:build:pluginBuildConfig',
|
|
22
|
-
apply: 'build',
|
|
23
|
-
enforce: 'post',
|
|
24
|
-
configResolved: {
|
|
25
|
-
order: 'post',
|
|
26
|
-
async handler(config_) {
|
|
27
|
-
(0, utils_js_1.onSetupBuild)();
|
|
28
|
-
config = config_;
|
|
29
|
-
assertRollupInput(config);
|
|
30
|
-
const entries = await getEntries(config);
|
|
31
|
-
(0, utils_js_1.assert)(Object.keys(entries).length > 0);
|
|
32
|
-
config.build.rollupOptions.input = (0, utils_js_1.injectRollupInputs)(entries, config);
|
|
33
|
-
addLogHook();
|
|
34
|
-
(0, handleAssetsManifest_js_1.handleAssetsManifest_assertUsageCssCodeSplit)(config);
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
config: {
|
|
38
|
-
order: 'post',
|
|
39
|
-
async handler() {
|
|
40
|
-
(0, utils_js_1.onSetupBuild)();
|
|
41
|
-
const build = await (0, handleAssetsManifest_js_1.handleAssetsManifest_getBuildConfig)();
|
|
42
|
-
return { build };
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
buildStart() {
|
|
46
|
-
(0, utils_js_1.onSetupBuild)();
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
];
|
|
50
|
-
}
|
|
51
|
-
async function getEntries(config) {
|
|
52
|
-
const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
|
|
53
|
-
const { _pageConfigs: pageConfigs } = vikeConfig;
|
|
54
|
-
// TO-DO/next-major-release: remove
|
|
55
|
-
const pageFileEntries = await getPageFileEntries(config, (0, retrievePageAssetsProd_js_1.resolveIncludeAssetsImportedByServer)(vikeConfig.config));
|
|
56
|
-
(0, utils_js_1.assertUsage)(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
57
|
-
if ((0, isViteServerSide_js_1.isViteServerSide_viteEnvOptional)(config)) {
|
|
58
|
-
const pageEntries = getPageEntries(pageConfigs);
|
|
59
|
-
const entries = {
|
|
60
|
-
...pageFileEntries,
|
|
61
|
-
// Ensure Rollup generates a bundle per page: https://github.com/vikejs/vike/issues/349#issuecomment-1166247275
|
|
62
|
-
...pageEntries,
|
|
63
|
-
};
|
|
64
|
-
return entries;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
let { hasClientRouting, hasServerRouting, clientEntries } = analyzeClientEntries(pageConfigs, config);
|
|
68
|
-
if (Object.entries(pageFileEntries).length > 0) {
|
|
69
|
-
hasClientRouting = true;
|
|
70
|
-
hasServerRouting = true;
|
|
71
|
-
}
|
|
72
|
-
const entries = {
|
|
73
|
-
...clientEntries,
|
|
74
|
-
...pageFileEntries,
|
|
75
|
-
};
|
|
76
|
-
const clientRoutingEntry = (0, utils_js_1.requireResolveDistFile)('dist/esm/client/runtime-client-routing/entry.js');
|
|
77
|
-
const serverRoutingEntry = (0, utils_js_1.requireResolveDistFile)('dist/esm/client/runtime-server-routing/entry.js');
|
|
78
|
-
if (hasClientRouting) {
|
|
79
|
-
entries['entries/entry-client-routing'] = clientRoutingEntry;
|
|
80
|
-
}
|
|
81
|
-
if (hasServerRouting) {
|
|
82
|
-
entries['entries/entry-server-routing'] = serverRoutingEntry;
|
|
83
|
-
}
|
|
84
|
-
return entries;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function getPageEntries(pageConfigs) {
|
|
88
|
-
const pageEntries = {};
|
|
89
|
-
pageConfigs.forEach((pageConfig) => {
|
|
90
|
-
const { entryName, entryTarget } = getEntryFromPageConfig(pageConfig, false);
|
|
91
|
-
pageEntries[entryName] = entryTarget;
|
|
92
|
-
});
|
|
93
|
-
return pageEntries;
|
|
94
|
-
}
|
|
95
|
-
function analyzeClientEntries(pageConfigs, config) {
|
|
96
|
-
let hasClientRouting = false;
|
|
97
|
-
let hasServerRouting = false;
|
|
98
|
-
let clientEntries = {};
|
|
99
|
-
let clientEntryList = [];
|
|
100
|
-
pageConfigs.forEach((pageConfig) => {
|
|
101
|
-
const configValue = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'clientRouting', 'boolean');
|
|
102
|
-
if (configValue?.value) {
|
|
103
|
-
hasClientRouting = true;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
hasServerRouting = true;
|
|
107
|
-
}
|
|
108
|
-
{
|
|
109
|
-
// Ensure Rollup generates a bundle per page: https://github.com/vikejs/vike/issues/349#issuecomment-1166247275
|
|
110
|
-
const { entryName, entryTarget } = getEntryFromPageConfig(pageConfig, true);
|
|
111
|
-
clientEntries[entryName] = entryTarget;
|
|
112
|
-
}
|
|
113
|
-
{
|
|
114
|
-
const clientEntry = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, 'client', 'string')?.value ?? null;
|
|
115
|
-
if (clientEntry) {
|
|
116
|
-
clientEntryList.push(clientEntry);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
clientEntryList = (0, utils_js_1.unique)(clientEntryList);
|
|
121
|
-
clientEntryList.forEach((clientEntry) => {
|
|
122
|
-
const { entryName, entryTarget } = getEntryFromClientEntry(clientEntry, config);
|
|
123
|
-
clientEntries[entryName] = entryTarget;
|
|
124
|
-
});
|
|
125
|
-
return { hasClientRouting, hasServerRouting, clientEntries };
|
|
126
|
-
}
|
|
127
|
-
// Ensure Rollup creates entries for each page file, see https://github.com/vikejs/vike/issues/350
|
|
128
|
-
// (Otherwise the page files may be missing in the client manifest.json)
|
|
129
|
-
async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
130
|
-
const isForClientSide = !(0, isViteServerSide_js_1.isViteServerSide_viteEnvOptional)(config);
|
|
131
|
-
const fileTypes = isForClientSide ? ['.page', '.page.client'] : ['.page', '.page.server'];
|
|
132
|
-
if (isForClientSide && includeAssetsImportedByServer) {
|
|
133
|
-
fileTypes.push('.page.server');
|
|
134
|
-
}
|
|
135
|
-
let pageFiles = await (0, findPageFiles_js_1.findPageFiles)(config, fileTypes, false);
|
|
136
|
-
const pageFileEntries = {};
|
|
137
|
-
pageFiles = (0, utils_js_1.unique)(pageFiles);
|
|
138
|
-
pageFiles.forEach((pageFile) => {
|
|
139
|
-
let addExtractAssetsQuery = false;
|
|
140
|
-
if (isForClientSide && pageFile.includes('.page.server.')) {
|
|
141
|
-
(0, utils_js_1.assert)(includeAssetsImportedByServer);
|
|
142
|
-
addExtractAssetsQuery = true;
|
|
143
|
-
}
|
|
144
|
-
const { entryName, entryTarget } = getEntryFromClientEntry(pageFile, config, addExtractAssetsQuery);
|
|
145
|
-
pageFileEntries[entryName] = entryTarget;
|
|
146
|
-
});
|
|
147
|
-
return pageFileEntries;
|
|
148
|
-
}
|
|
149
|
-
function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
150
|
-
if (!clientEntry.startsWith('/')) {
|
|
151
|
-
(0, utils_js_1.assertIsImportPathNpmPackage)(clientEntry);
|
|
152
|
-
const entryTarget = clientEntry;
|
|
153
|
-
const entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(clientEntry);
|
|
154
|
-
return { entryName, entryTarget };
|
|
155
|
-
}
|
|
156
|
-
const filePathAbsoluteUserRootDir = clientEntry;
|
|
157
|
-
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
158
|
-
const filePath = (0, getFilePath_js_1.getFilePathResolved)({
|
|
159
|
-
filePathAbsoluteUserRootDir,
|
|
160
|
-
userRootDir: config.root,
|
|
161
|
-
});
|
|
162
|
-
let entryTarget = filePath.filePathAbsoluteFilesystem;
|
|
163
|
-
if (addExtractAssetsQuery)
|
|
164
|
-
entryTarget = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(entryTarget);
|
|
165
|
-
let entryName = filePathAbsoluteUserRootDir;
|
|
166
|
-
if (addExtractAssetsQuery)
|
|
167
|
-
entryName = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(entryName);
|
|
168
|
-
entryName = (0, utils_js_1.removeFileExtension)(entryName);
|
|
169
|
-
entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(entryName);
|
|
170
|
-
return { entryName, entryTarget };
|
|
171
|
-
}
|
|
172
|
-
function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
173
|
-
let { pageId } = pageConfig;
|
|
174
|
-
const entryTarget = (0, virtualFileId_js_1.generateVirtualFileId)({ type: 'page-entry', pageId, isForClientSide });
|
|
175
|
-
let entryName = pageId;
|
|
176
|
-
// Avoid:
|
|
177
|
-
// ```
|
|
178
|
-
// dist/client/assets/entries/.Dp9wM6PK.js
|
|
179
|
-
// dist/server/entries/.mjs
|
|
180
|
-
// ```
|
|
181
|
-
if (entryName === '/')
|
|
182
|
-
entryName = 'root';
|
|
183
|
-
entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(entryName);
|
|
184
|
-
(0, utils_js_1.assert)(!entryName.endsWith('/'));
|
|
185
|
-
return { entryName, entryTarget };
|
|
186
|
-
}
|
|
187
|
-
function addLogHook() {
|
|
188
|
-
const tty = process.stdout.isTTY && !process.env.CI; // Equals https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts#L27
|
|
189
|
-
if (!tty)
|
|
190
|
-
return;
|
|
191
|
-
let lastLog = null;
|
|
192
|
-
['stdout', 'stderr'].forEach((stdName) => {
|
|
193
|
-
var methodOriginal = process[stdName].write;
|
|
194
|
-
process[stdName].write = function (...args) {
|
|
195
|
-
lastLog = String(args[0]);
|
|
196
|
-
return methodOriginal.apply(process[stdName], args);
|
|
197
|
-
};
|
|
198
|
-
});
|
|
199
|
-
// Exhaustive list extracted from writeLine() calls at https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts
|
|
200
|
-
// prettier-ignore
|
|
201
|
-
// biome-ignore format:
|
|
202
|
-
const viteTransientLogs = [
|
|
203
|
-
'transforming (',
|
|
204
|
-
'rendering chunks (',
|
|
205
|
-
'computing gzip size ('
|
|
206
|
-
];
|
|
207
|
-
(0, utils_js_1.addOnBeforeLogHook)(() => {
|
|
208
|
-
// Using viteTransientLogs is very conservative as clearing the current line is low risk. (We can assume that important messages, such as errors, include a trailing new line. Usually, only transient messages have no trailing new lines.)
|
|
209
|
-
if (viteTransientLogs.some((s) => lastLog?.startsWith(s))) {
|
|
210
|
-
process.stdout.clearLine(0);
|
|
211
|
-
process.stdout.cursorTo(0);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
function assertRollupInput(config) {
|
|
216
|
-
const userInputs = (0, utils_js_1.normalizeRollupInput)(config.build.rollupOptions.input);
|
|
217
|
-
const htmlInputs = Object.values(userInputs).filter((entry) => entry.endsWith('.html') || entry.endsWith('.htm'));
|
|
218
|
-
const htmlInput = htmlInputs[0];
|
|
219
|
-
(0, utils_js_1.assertUsage)(htmlInput === undefined, `The entry ${htmlInput} of config build.rollupOptions.input is an HTML entry which is forbidden when using Vike, instead follow https://vike.dev/add`);
|
|
220
|
-
}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pluginDistFileNames = pluginDistFileNames;
|
|
7
|
-
// Attempt to preserve file structure of `.page.js` files:
|
|
8
|
-
// - https://github.com/vikejs/vike/commit/11a4c49e5403aa7c37c8020c462b499425b41854
|
|
9
|
-
// - Blocker: https://github.com/rollup/rollup/issues/4724
|
|
10
|
-
const utils_js_1 = require("../../utils.js");
|
|
11
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
13
|
-
const getAssetsDir_js_1 = require("../../shared/getAssetsDir.js");
|
|
14
|
-
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
15
|
-
function pluginDistFileNames() {
|
|
16
|
-
return {
|
|
17
|
-
name: 'vike:build:pluginDistFileNames',
|
|
18
|
-
apply: 'build',
|
|
19
|
-
enforce: 'post',
|
|
20
|
-
configResolved(config) {
|
|
21
|
-
const rollupOutputs = getRollupOutputs(config);
|
|
22
|
-
// We need to support multiple outputs: @vite/plugin-legacy adds an output, see https://github.com/vikejs/vike/issues/477#issuecomment-1406434802
|
|
23
|
-
rollupOutputs.forEach((rollupOutput) => {
|
|
24
|
-
if (!('entryFileNames' in rollupOutput)) {
|
|
25
|
-
rollupOutput.entryFileNames = (chunkInfo) => getEntryFileName(chunkInfo, config, true);
|
|
26
|
-
}
|
|
27
|
-
if (!('chunkFileNames' in rollupOutput)) {
|
|
28
|
-
rollupOutput.chunkFileNames = (chunkInfo) => getChunkFileName(chunkInfo, config);
|
|
29
|
-
}
|
|
30
|
-
if (!('assetFileNames' in rollupOutput)) {
|
|
31
|
-
rollupOutput.assetFileNames = (chunkInfo) => getAssetFileName(chunkInfo, config);
|
|
32
|
-
rollupOutput.assetFileNames.isTheOneSetByVike = true;
|
|
33
|
-
(0, utils_js_1.assert)(rollupOutput.assetFileNames.isTheOneSetByVike);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// If a user needs this:
|
|
37
|
-
// - assertUsage() that the naming provided by the user ends with `.[hash][extname]`
|
|
38
|
-
// - It's needed for getHash() of handleAssetsManifest()
|
|
39
|
-
// - Asset URLs should always contain a hash: it's paramount for caching assets.
|
|
40
|
-
// - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
|
|
41
|
-
(0, utils_js_1.assertUsage)(rollupOutput.assetFileNames.isTheOneSetByVike, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use it.");
|
|
42
|
-
}
|
|
43
|
-
{
|
|
44
|
-
const manualChunksOriginal = rollupOutput.manualChunks;
|
|
45
|
-
rollupOutput.manualChunks = function (id, ...args) {
|
|
46
|
-
if (manualChunksOriginal) {
|
|
47
|
-
if ((0, utils_js_1.isCallable)(manualChunksOriginal)) {
|
|
48
|
-
const result = manualChunksOriginal.call(this, id, ...args);
|
|
49
|
-
if (result !== undefined)
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
(0, utils_js_1.assertUsage)(false, "The Vite's configuration build.rollupOptions.output.manualChunks must be a function. Reach out if you need to set it to another value.");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
|
|
57
|
-
// TO-DO/eventually: let's bundle CSS again once Rolldown replaces Rollup
|
|
58
|
-
if (id.endsWith('.css')) {
|
|
59
|
-
const userRootDir = config.root;
|
|
60
|
-
if (id.startsWith(userRootDir)) {
|
|
61
|
-
(0, utils_js_1.assertPosixPath)(id);
|
|
62
|
-
(0, getFilePath_js_1.assertModuleId)(id);
|
|
63
|
-
let name;
|
|
64
|
-
const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
|
|
65
|
-
if (isNodeModules) {
|
|
66
|
-
name = isNodeModules[1];
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
const filePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
|
|
70
|
-
name = filePath;
|
|
71
|
-
name = name.split('.').slice(0, -1).join('.'); // remove file extension
|
|
72
|
-
name = name.split('/').filter(Boolean).join('_');
|
|
73
|
-
}
|
|
74
|
-
// Make fileHash the same between local development and CI
|
|
75
|
-
const idStable = node_path_1.default.posix.relative(userRootDir, id);
|
|
76
|
-
// Don't remove `?` queries because each `id` should belong to a unique bundle.
|
|
77
|
-
const hash = getIdHash(idStable);
|
|
78
|
-
return `${name}-${hash}`;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
let name;
|
|
82
|
-
const isVirtualModule = id.match(/virtual:([^:]+):/);
|
|
83
|
-
if (isVirtualModule) {
|
|
84
|
-
name = isVirtualModule[1];
|
|
85
|
-
(0, utils_js_1.assert)(name);
|
|
86
|
-
}
|
|
87
|
-
else if (
|
|
88
|
-
// https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
|
|
89
|
-
id.startsWith('/__uno')) {
|
|
90
|
-
name = 'uno';
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
name = 'style';
|
|
94
|
-
}
|
|
95
|
-
const hash = getIdHash(id);
|
|
96
|
-
return `${name}-${hash}`;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function getIdHash(id) {
|
|
106
|
-
return node_crypto_1.default.createHash('md5').update(id).digest('hex').slice(0, 8);
|
|
107
|
-
}
|
|
108
|
-
function getAssetFileName(assetInfo, config) {
|
|
109
|
-
const userRootDir = config.root;
|
|
110
|
-
const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
|
|
111
|
-
const dir = assetsDir + '/static';
|
|
112
|
-
let { name } = assetInfo;
|
|
113
|
-
if (!name) {
|
|
114
|
-
return `${dir}/[name].[hash][extname]`;
|
|
115
|
-
}
|
|
116
|
-
// https://github.com/vikejs/vike/issues/794
|
|
117
|
-
(0, utils_js_1.assertPosixPath)(name);
|
|
118
|
-
name = node_path_1.default.posix.basename(name);
|
|
119
|
-
// dist/client/assets/index.page.server.jsx_extractAssets_lang.e4e33422.css
|
|
120
|
-
// => dist/client/assets/index.page.server.e4e33422.css
|
|
121
|
-
if (
|
|
122
|
-
// Vite 2
|
|
123
|
-
name?.endsWith('_extractAssets_lang.css') ||
|
|
124
|
-
// Vite 3
|
|
125
|
-
name?.endsWith('?extractAssets&lang.css')) {
|
|
126
|
-
name = name.split('.').slice(0, -2).join('.');
|
|
127
|
-
name = clean(name, userRootDir);
|
|
128
|
-
return `${dir}/${name}.[hash][extname]`;
|
|
129
|
-
}
|
|
130
|
-
name = name.split('.').slice(0, -1).join('.');
|
|
131
|
-
name = clean(name, userRootDir);
|
|
132
|
-
return `${dir}/${name}.[hash][extname]`;
|
|
133
|
-
}
|
|
134
|
-
function getChunkFileName(_chunkInfo, config) {
|
|
135
|
-
const isForClientSide = !config.build.ssr;
|
|
136
|
-
let name = 'chunks/chunk-[hash].js';
|
|
137
|
-
if (isForClientSide) {
|
|
138
|
-
const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
|
|
139
|
-
name = `${assetsDir}/${name}`;
|
|
140
|
-
}
|
|
141
|
-
return name;
|
|
142
|
-
}
|
|
143
|
-
function getEntryFileName(chunkInfo, config, isEntry) {
|
|
144
|
-
const userRootDir = config.root;
|
|
145
|
-
const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
|
|
146
|
-
const isForClientSide = !config.build.ssr;
|
|
147
|
-
let { name } = chunkInfo;
|
|
148
|
-
(0, utils_js_1.assertPosixPath)(name);
|
|
149
|
-
name = clean(name, userRootDir, true,
|
|
150
|
-
// Not needed for client-side because dist/ filenames contain `.[hash].js`
|
|
151
|
-
!isForClientSide);
|
|
152
|
-
if (isForClientSide) {
|
|
153
|
-
return `${assetsDir}/${name}.[hash].js`;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
return `${name}.${isEntry ? 'mjs' : 'js'}`;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function removePathSeparators(name) {
|
|
160
|
-
(0, utils_js_1.assertPosixPath)(name);
|
|
161
|
-
(0, utils_js_1.assert)(!name.startsWith('/'), { name });
|
|
162
|
-
const entryDir = 'entries/';
|
|
163
|
-
const hasEntryDir = name.startsWith(entryDir);
|
|
164
|
-
if (hasEntryDir) {
|
|
165
|
-
name = name.slice(entryDir.length);
|
|
166
|
-
(0, utils_js_1.assert)(!name.startsWith('/'));
|
|
167
|
-
}
|
|
168
|
-
name = name.split('/').join('_');
|
|
169
|
-
if (hasEntryDir) {
|
|
170
|
-
name = `${entryDir}${name}`;
|
|
171
|
-
}
|
|
172
|
-
return name;
|
|
173
|
-
}
|
|
174
|
-
function removeUserRootDir(name, userRootDir) {
|
|
175
|
-
if (name.startsWith(userRootDir)) {
|
|
176
|
-
name = name.slice(userRootDir.length);
|
|
177
|
-
if (name.startsWith('/'))
|
|
178
|
-
name = name.slice(1);
|
|
179
|
-
}
|
|
180
|
-
(0, utils_js_1.assert)(!name.startsWith('/'), { name });
|
|
181
|
-
return name;
|
|
182
|
-
}
|
|
183
|
-
function clean(name, userRootDir, removePathSep, fixGlob) {
|
|
184
|
-
name = removeUserRootDir(name, userRootDir);
|
|
185
|
-
name = fixExtractAssetsQuery(name);
|
|
186
|
-
if (fixGlob) {
|
|
187
|
-
name = workaroundGlob(name);
|
|
188
|
-
}
|
|
189
|
-
name = replaceNonLatinCharacters(name);
|
|
190
|
-
if (removePathSep) {
|
|
191
|
-
name = removePathSeparators(name);
|
|
192
|
-
}
|
|
193
|
-
name = removeLeadingUnderscoreInFilename(name);
|
|
194
|
-
name = removeUnderscoreDoublets(name);
|
|
195
|
-
// Avoid:
|
|
196
|
-
// ```
|
|
197
|
-
// dist/client/assets/entries/.Dp9wM6PK.js
|
|
198
|
-
// dist/server/entries/.mjs
|
|
199
|
-
// ```
|
|
200
|
-
(0, utils_js_1.assert)(!name.endsWith('/'));
|
|
201
|
-
return name;
|
|
202
|
-
}
|
|
203
|
-
function fixExtractAssetsQuery(name) {
|
|
204
|
-
name = name.replace(/\.[^\.]*_extractAssets_lang$/, '.extractAssets');
|
|
205
|
-
return name;
|
|
206
|
-
}
|
|
207
|
-
function removeUnderscoreDoublets(name) {
|
|
208
|
-
name = name.split(/__+/).join('_');
|
|
209
|
-
return name;
|
|
210
|
-
}
|
|
211
|
-
function replaceNonLatinCharacters(name) {
|
|
212
|
-
name = name.split('+').join('');
|
|
213
|
-
name = name.replace(/[^a-zA-Z0-9\/\._]/g, '-');
|
|
214
|
-
return name;
|
|
215
|
-
}
|
|
216
|
-
// Remove leading `_` from filename
|
|
217
|
-
// - GitHub Pages treat URLs with filename starting with `_` differently (removing the need for workaround of creating a .jekyll file)
|
|
218
|
-
function removeLeadingUnderscoreInFilename(name) {
|
|
219
|
-
(0, utils_js_1.assertPosixPath)(name);
|
|
220
|
-
const paths = name.split('/');
|
|
221
|
-
{
|
|
222
|
-
const last = paths.length - 1;
|
|
223
|
-
let filename = paths[last];
|
|
224
|
-
if (filename.startsWith('_')) {
|
|
225
|
-
filename = filename.slice(1);
|
|
226
|
-
paths[last] = filename;
|
|
227
|
-
name = paths.join('/');
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return name;
|
|
231
|
-
}
|
|
232
|
-
// Ensure import.meta.glob() doesn't match dist/ files
|
|
233
|
-
function workaroundGlob(name) {
|
|
234
|
-
// V1 design
|
|
235
|
-
name = name.split('+').join('');
|
|
236
|
-
['client', 'server', 'route'].forEach((env) => {
|
|
237
|
-
name = name.split(`.page.${env}`).join(`-page-${env}`);
|
|
238
|
-
});
|
|
239
|
-
name = name.split('.page.').join('-page.');
|
|
240
|
-
name = name.replace(/\.page$/, '-page');
|
|
241
|
-
return name;
|
|
242
|
-
}
|
|
243
|
-
function getRollupOutputs(config) {
|
|
244
|
-
var _a, _b;
|
|
245
|
-
// @ts-expect-error is read-only
|
|
246
|
-
config.build ?? (config.build = {});
|
|
247
|
-
(_a = config.build).rollupOptions ?? (_a.rollupOptions = {});
|
|
248
|
-
(_b = config.build.rollupOptions).output ?? (_b.output = {});
|
|
249
|
-
const { output } = config.build.rollupOptions;
|
|
250
|
-
if (!(0, utils_js_1.isArray)(output)) {
|
|
251
|
-
return [output];
|
|
252
|
-
}
|
|
253
|
-
return output;
|
|
254
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pluginDistPackageJsonFile = pluginDistPackageJsonFile;
|
|
4
|
-
const rollupIsEsm_js_1 = require("../../shared/rollupIsEsm.js");
|
|
5
|
-
const isViteServerSide_js_1 = require("../../shared/isViteServerSide.js");
|
|
6
|
-
function pluginDistPackageJsonFile() {
|
|
7
|
-
let config;
|
|
8
|
-
return {
|
|
9
|
-
name: 'vike:build:pluginDistPackageJsonFile',
|
|
10
|
-
apply: 'build',
|
|
11
|
-
configResolved(config_) {
|
|
12
|
-
config = config_;
|
|
13
|
-
},
|
|
14
|
-
generateBundle(options, bundle) {
|
|
15
|
-
if (!(0, isViteServerSide_js_1.isViteServerSide)(config, this.environment))
|
|
16
|
-
return;
|
|
17
|
-
const isEsm = (0, rollupIsEsm_js_1.rollupIsEsm)(options);
|
|
18
|
-
const fileName = 'package.json';
|
|
19
|
-
if (bundle[fileName])
|
|
20
|
-
return; // E.g. already generated by Telefunc / vike
|
|
21
|
-
this.emitFile({
|
|
22
|
-
fileName,
|
|
23
|
-
type: 'asset',
|
|
24
|
-
source: getPackageJsonContent(isEsm),
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function getPackageJsonContent(isEsm) {
|
|
30
|
-
if (isEsm) {
|
|
31
|
-
return `{ "type": "module" }`;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return `{ "type": "commonjs" }`;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pluginModuleBanner = pluginModuleBanner;
|
|
4
|
-
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
const getMagicString_js_1 = require("../../shared/getMagicString.js");
|
|
6
|
-
const isViteServerSide_js_1 = require("../../shared/isViteServerSide.js");
|
|
7
|
-
// Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
|
|
8
|
-
// But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
|
|
9
|
-
function pluginModuleBanner() {
|
|
10
|
-
let config;
|
|
11
|
-
return {
|
|
12
|
-
name: 'vike:build:pluginModuleBanner',
|
|
13
|
-
enforce: 'post',
|
|
14
|
-
apply: 'build',
|
|
15
|
-
configResolved(config_) {
|
|
16
|
-
config = config_;
|
|
17
|
-
},
|
|
18
|
-
transform: {
|
|
19
|
-
order: 'post',
|
|
20
|
-
handler(code, id, options) {
|
|
21
|
-
if (!(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options) &&
|
|
22
|
-
// Inject module banners if user sets `build.minify` to `false` for inspecting dist/client/
|
|
23
|
-
config.build.minify) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (id.startsWith('\0'))
|
|
27
|
-
id = id;
|
|
28
|
-
id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
|
|
29
|
-
if (id.startsWith(config.root))
|
|
30
|
-
id = id.slice(config.root.length + 1);
|
|
31
|
-
id = id.replaceAll('*/', '*\\/'); // https://github.com/vikejs/vike/issues/2377
|
|
32
|
-
const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
|
|
33
|
-
// Use legal comment so that esbuild doesn't remove it.
|
|
34
|
-
// - Terser still removes the comment, but I guess users use terser to minify JavaScript so I guess it's a good thing that comment is removed.
|
|
35
|
-
// - https://esbuild.github.io/api/#legal-comments
|
|
36
|
-
magicString.prepend(`/*! ${id} [vike:pluginModuleBanner] */\n`);
|
|
37
|
-
return getMagicStringResult();
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pluginProdBuildEntry = pluginProdBuildEntry;
|
|
7
|
-
exports.set_macro_ASSETS_MANIFEST = set_macro_ASSETS_MANIFEST;
|
|
8
|
-
const plugin_1 = require("@brillout/vite-plugin-server-entry/plugin");
|
|
9
|
-
const virtualFileId_js_1 = require("../../../shared/virtualFileId.js");
|
|
10
|
-
const utils_js_1 = require("../../utils.js");
|
|
11
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
12
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
-
const pluginExtractExportNames_js_1 = require("../pluginExtractExportNames.js");
|
|
14
|
-
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
15
|
-
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
16
|
-
const getViteConfigRuntime_js_1 = require("../../shared/getViteConfigRuntime.js");
|
|
17
|
-
const ASSETS_MANIFEST = '__VITE_ASSETS_MANIFEST__';
|
|
18
|
-
function pluginProdBuildEntry() {
|
|
19
|
-
let config;
|
|
20
|
-
return [
|
|
21
|
-
{
|
|
22
|
-
name: 'vike:build:pluginProdBuildEntry',
|
|
23
|
-
apply: 'build',
|
|
24
|
-
enforce: 'post',
|
|
25
|
-
async configResolved(config_) {
|
|
26
|
-
config = config_;
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
...(0, plugin_1.serverProductionEntryPlugin)({
|
|
30
|
-
getServerProductionEntry: () => {
|
|
31
|
-
return getServerProductionEntryCode(config);
|
|
32
|
-
},
|
|
33
|
-
libraryName: 'Vike',
|
|
34
|
-
}),
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
function getServerProductionEntryCode(config) {
|
|
38
|
-
const importPath = getImportPath(config);
|
|
39
|
-
const buildInfo = {
|
|
40
|
-
versionAtBuildTime: utils_js_1.PROJECT_VERSION,
|
|
41
|
-
usesClientRouter: (0, pluginExtractExportNames_js_1.isUsingClientRouter)(), // TO-DO/next-major-release: remove
|
|
42
|
-
viteConfigRuntime: (0, getViteConfigRuntime_js_1.getViteConfigRuntime)(config),
|
|
43
|
-
};
|
|
44
|
-
(0, globalContext_js_1.assertBuildInfo)(buildInfo);
|
|
45
|
-
// After the old design is removed, let's maybe simplify and move everything into a single virtual module
|
|
46
|
-
const importerCode = [
|
|
47
|
-
` import { setGlobalContext_prodBuildEntry } from '${importPath}';`,
|
|
48
|
-
` import * as virtualFileExportsGlobalEntry from '${virtualFileId_js_1.virtualFileIdGlobalEntryServer}';`,
|
|
49
|
-
` {`,
|
|
50
|
-
// Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to setGlobalContext_prodBuildEntry()
|
|
51
|
-
// - This workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
52
|
-
` const assetsManifest = ${ASSETS_MANIFEST};`,
|
|
53
|
-
` const buildInfo = ${JSON.stringify(buildInfo, null, 2)};`,
|
|
54
|
-
' setGlobalContext_prodBuildEntry({',
|
|
55
|
-
` virtualFileExportsGlobalEntry,`,
|
|
56
|
-
` assetsManifest,`,
|
|
57
|
-
` buildInfo,`,
|
|
58
|
-
' });',
|
|
59
|
-
` }`,
|
|
60
|
-
'',
|
|
61
|
-
].join('\n');
|
|
62
|
-
return importerCode;
|
|
63
|
-
}
|
|
64
|
-
// Set the value of the ASSETS_MANIFEST constant inside dist/server/entry.js (or dist/server/index.js)
|
|
65
|
-
async function set_macro_ASSETS_MANIFEST(assetsJsonFilePath, bundle, outDir) {
|
|
66
|
-
(0, utils_js_1.assert)(outDir);
|
|
67
|
-
const chunkPath = find_ASSETS_MANIFEST(bundle);
|
|
68
|
-
// Some server builds don't contain __VITE_ASSETS_MANIFEST__ such as dist/rsc/ from vike-react-rsc
|
|
69
|
-
if (!chunkPath) {
|
|
70
|
-
const noop = true; // no operation
|
|
71
|
-
return noop;
|
|
72
|
-
}
|
|
73
|
-
(0, utils_js_1.assert)(assetsJsonFilePath);
|
|
74
|
-
const chunkFilePath = node_path_1.default.join(outDir, chunkPath);
|
|
75
|
-
const [assetsJsonString, chunkFileContent] = await Promise.all([
|
|
76
|
-
await promises_1.default.readFile(assetsJsonFilePath, 'utf8'),
|
|
77
|
-
await promises_1.default.readFile(chunkFilePath, 'utf8'),
|
|
78
|
-
]);
|
|
79
|
-
const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MANIFEST, assetsJsonString);
|
|
80
|
-
(0, utils_js_1.assert)(serverEntryFileContentPatched !== chunkFileContent);
|
|
81
|
-
await promises_1.default.writeFile(chunkFilePath, serverEntryFileContentPatched);
|
|
82
|
-
const noop = false;
|
|
83
|
-
return noop;
|
|
84
|
-
}
|
|
85
|
-
function find_ASSETS_MANIFEST(bundle) {
|
|
86
|
-
let chunkPath;
|
|
87
|
-
for (const filePath in bundle) {
|
|
88
|
-
const chunk = bundle[filePath];
|
|
89
|
-
if ('code' in chunk && chunk.code.includes(ASSETS_MANIFEST)) {
|
|
90
|
-
(0, utils_js_1.assert)(!chunkPath);
|
|
91
|
-
chunkPath = filePath;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return chunkPath;
|
|
95
|
-
}
|
|
96
|
-
function getImportPath(config) {
|
|
97
|
-
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
98
|
-
const filePathAbsolute = (0, utils_js_1.requireResolveDistFile)('dist/esm/__internal/index.js');
|
|
99
|
-
if (
|
|
100
|
-
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|
|
101
|
-
true) {
|
|
102
|
-
return 'vike/__internal';
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const { outDirServer } = (0, getOutDirs_js_1.getOutDirs)(config, undefined);
|
|
106
|
-
const filePathRelative = node_path_1.default.posix.relative(outDirServer, filePathAbsolute);
|
|
107
|
-
return filePathRelative;
|
|
108
|
-
}
|
|
109
|
-
}
|