vike 0.4.239-commit-59f1017 → 0.4.239-commit-4d0d950
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/runtime-client-routing/entry.js +5 -0
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/globalContext.js +9 -3
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +1 -0
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/entry.js +5 -0
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +2 -2
- package/dist/esm/client/runtime-server-routing/globalContext.js +7 -3
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +4 -3
- package/dist/esm/client/shared/createGetGlobalContextClient.js +38 -34
- package/dist/esm/node/vite/index.js +34 -15
- package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBaseUrls.js +37 -35
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +82 -80
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +23 -21
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +38 -36
- package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +26 -24
- package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
- package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +87 -65
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +29 -27
- package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +75 -73
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +30 -28
- package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginPreview.js +35 -33
- package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.d.ts +9 -0
- package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.js +45 -0
- package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.js +89 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +50 -48
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +12 -10
- package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
- package/dist/esm/shared/createGlobalContextShared.js +1 -0
- package/dist/esm/shared/route/abort.d.ts +22 -11
- package/dist/esm/shared/route/abort.js +37 -5
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/findPackageJson.js +0 -1
- package/dist/esm/utils/getViteRPC.js +0 -2
- package/dist/esm/utils/requireResolve.js +0 -1
- package/package.json +2 -21
- 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 -778
- 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 -582
- 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 -52
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -357
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -183
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -234
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -256
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -40
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -49
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -111
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -65
- package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -22
- package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
- package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -183
- 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 -111
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -92
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -241
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -113
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -172
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -70
- package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -82
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -95
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -51
- 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 -233
- package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -17
- 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 -43
- package/dist/cjs/utils/warnIfErrorIsNotObject.js +0 -23
- package/dist/esm/node/vite/plugins/pluginBuild.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginBuild.js +0 -20
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -14
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +0 -92
|
@@ -1,102 +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.resolvePointerImport = resolvePointerImport;
|
|
7
|
-
exports.resolvePointerImportData = resolvePointerImportData;
|
|
8
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
-
const utils_js_1 = require("../../utils.js");
|
|
10
|
-
const pointerImports_js_1 = require("./pointerImports.js");
|
|
11
|
-
const getFilePath_js_1 = require("../getFilePath.js");
|
|
12
|
-
function resolvePointerImport(configValue, importerFilePath, userRootDir, configName) {
|
|
13
|
-
if (typeof configValue !== 'string')
|
|
14
|
-
return null;
|
|
15
|
-
const pointerImportData = (0, pointerImports_js_1.parsePointerImportData)(configValue);
|
|
16
|
-
if (!pointerImportData)
|
|
17
|
-
return null;
|
|
18
|
-
const { exportName } = pointerImportData;
|
|
19
|
-
const filePath = resolvePointerImportData(pointerImportData, importerFilePath, userRootDir);
|
|
20
|
-
const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
21
|
-
const fileExportPath = {
|
|
22
|
-
...filePath,
|
|
23
|
-
fileExportName: exportName,
|
|
24
|
-
fileExportPathToShowToUser,
|
|
25
|
-
};
|
|
26
|
-
return { fileExportPath };
|
|
27
|
-
}
|
|
28
|
-
function resolvePointerImportData(pointerImportData, importerFilePath, userRootDir) {
|
|
29
|
-
const { importPath } = pointerImportData;
|
|
30
|
-
(0, pointerImports_js_1.assertPointerImportPath)(importPath);
|
|
31
|
-
const filePathAbsoluteFilesystem = resolveImportPathWithNode(pointerImportData, importerFilePath, userRootDir);
|
|
32
|
-
let filePath;
|
|
33
|
-
(0, utils_js_1.assertPosixPath)(importPath);
|
|
34
|
-
if ((0, utils_js_1.isImportPathRelative)(importPath) || (0, utils_js_1.isFilePathAbsolute)(importPath)) {
|
|
35
|
-
// Pointer imports are included in virtual files, thus relative imports need to be resolved. (Virtual modules cannot contain relative imports.)
|
|
36
|
-
assertUsageResolutionSuccess(filePathAbsoluteFilesystem, pointerImportData, importerFilePath);
|
|
37
|
-
// Pointer imports are included in virtual files, and we need filePathAbsoluteUserRootDir because we didn't find a way to have filesystem absolute import paths in virtual files: https://gist.github.com/brillout/2315231c9a8164f950c64b4b4a7bbd39
|
|
38
|
-
const errSuffix = `outside of the ${userRootDir} directory which is forbidden: make sure your import paths resolve inside the ${userRootDir} directory, or import from an npm package.`;
|
|
39
|
-
const filePathAbsoluteUserRootDir = (0, getFilePath_js_1.getFilePathAbsoluteUserRootDir)({ filePathAbsoluteFilesystem, userRootDir });
|
|
40
|
-
if ((0, utils_js_1.isImportPathRelative)(importPath)) {
|
|
41
|
-
(0, utils_js_1.assertUsage)(filePathAbsoluteUserRootDir, `The relative import ${picocolors_1.default.cyan(importPath)} defined by ${importerFilePath.filePathToShowToUser} resolves to ${filePathAbsoluteFilesystem} ${errSuffix}`);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
(0, utils_js_1.assert)((0, utils_js_1.isFilePathAbsolute)(importPath));
|
|
45
|
-
(0, utils_js_1.assertUsage)(filePathAbsoluteUserRootDir, `The import path ${importPath} defined by ${importerFilePath.filePathToShowToUser} is ${errSuffix}`);
|
|
46
|
-
}
|
|
47
|
-
// Forbid node_modules/ because it's brittle: if node_modules/ lives outside of userRootDir then it crashes.
|
|
48
|
-
(0, utils_js_1.assertUsage)(!filePathAbsoluteUserRootDir.includes('/node_modules/'), `The import path ${importPath} defined by ${importerFilePath.filePathToShowToUser} resolves to ${filePathAbsoluteFilesystem} inside of node_modules/ which is forbidden: use an npm package import instead.`);
|
|
49
|
-
filePath = (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir });
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
(0, utils_js_1.assert)((0, utils_js_1.isImportPathNpmPackageOrPathAlias)(importPath));
|
|
53
|
-
const importPathAbsolute = importPath;
|
|
54
|
-
if (filePathAbsoluteFilesystem) {
|
|
55
|
-
filePath = (0, getFilePath_js_1.getFilePathResolved)({
|
|
56
|
-
userRootDir,
|
|
57
|
-
filePathAbsoluteFilesystem,
|
|
58
|
-
importPathAbsolute,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
// We cannot resolve path aliases defined only in Vite
|
|
63
|
-
filePath = (0, getFilePath_js_1.getFilePathUnresolved)({
|
|
64
|
-
importPathAbsolute,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return filePath;
|
|
69
|
-
}
|
|
70
|
-
function resolveImportPathWithNode(pointerImportData, importerFilePath, userRootDir) {
|
|
71
|
-
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
72
|
-
(0, utils_js_1.assertPosixPath)(importerFilePathAbsolute);
|
|
73
|
-
// filePathAbsoluteFilesystem is null when pointerImportData.importPath is a path alias that Node.js doesn't know about
|
|
74
|
-
const filePathAbsoluteFilesystem = (0, utils_js_1.requireResolveOptional)({
|
|
75
|
-
importPath: pointerImportData.importPath,
|
|
76
|
-
importerFilePath: importerFilePathAbsolute,
|
|
77
|
-
userRootDir,
|
|
78
|
-
});
|
|
79
|
-
if (!filePathAbsoluteFilesystem) {
|
|
80
|
-
(0, utils_js_1.assert)(!(0, utils_js_1.isImportPathRelative)(pointerImportData.importPath));
|
|
81
|
-
// Libraries don't use path aliases => filePathAbsoluteFilesystem should be defined
|
|
82
|
-
(0, utils_js_1.assert)(!importerFilePathAbsolute.includes('node_modules'));
|
|
83
|
-
}
|
|
84
|
-
return filePathAbsoluteFilesystem;
|
|
85
|
-
}
|
|
86
|
-
function assertUsageResolutionSuccess(filePathAbsoluteFilesystem, pointerImportData, importerFilePath) {
|
|
87
|
-
const { importPath: importPath, importStringWasGenerated, importString } = pointerImportData;
|
|
88
|
-
const { filePathToShowToUser } = importerFilePath;
|
|
89
|
-
if (!filePathAbsoluteFilesystem) {
|
|
90
|
-
const importPathString = picocolors_1.default.code(`${importPath}`);
|
|
91
|
-
const errIntro = importStringWasGenerated
|
|
92
|
-
? `The import path ${importPathString} in ${filePathToShowToUser}`
|
|
93
|
-
: `The import ${picocolors_1.default.code(importString)} defined by ${filePathToShowToUser}`;
|
|
94
|
-
const errIntro2 = `${errIntro} couldn't be resolved: does ${importPathString}`;
|
|
95
|
-
if ((0, utils_js_1.isImportPathRelative)(importPath)) {
|
|
96
|
-
(0, utils_js_1.assertUsage)(false, `${errIntro2} point to an existing file?`);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
(0, utils_js_1.assertUsage)(false, `${errIntro2} exist?`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,425 +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.transpileAndExecuteFile = transpileAndExecuteFile;
|
|
7
|
-
exports.getConfigBuildErrorFormatted = getConfigBuildErrorFormatted;
|
|
8
|
-
exports.getConfigExecutionErrorIntroMsg = getConfigExecutionErrorIntroMsg;
|
|
9
|
-
exports.isTemporaryBuildFile = isTemporaryBuildFile;
|
|
10
|
-
const esbuild_1 = require("esbuild");
|
|
11
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
|
-
const import_1 = require("@brillout/import");
|
|
15
|
-
const utils_js_1 = require("../../utils.js");
|
|
16
|
-
const pointerImports_js_1 = require("./pointerImports.js");
|
|
17
|
-
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
18
|
-
const getFilePath_js_1 = require("../getFilePath.js");
|
|
19
|
-
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
20
|
-
installSourceMapSupport();
|
|
21
|
-
const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
22
|
-
const debugEsbuildResolve = (0, utils_js_1.createDebugger)('vike:esbuild-resolve');
|
|
23
|
-
if (debugEsbuildResolve.isActivated)
|
|
24
|
-
debugEsbuildResolve('esbuild version', esbuild_1.version);
|
|
25
|
-
async function transpileAndExecuteFile(filePath, userRootDir, isExtensionConfig, esbuildCache) {
|
|
26
|
-
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
27
|
-
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
28
|
-
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
29
|
-
if (esbuildCache.transpileCache[filePathAbsoluteFilesystem]) {
|
|
30
|
-
return await esbuildCache.transpileCache[filePathAbsoluteFilesystem];
|
|
31
|
-
}
|
|
32
|
-
const { promise, resolve } = (0, utils_js_1.genPromise)();
|
|
33
|
-
esbuildCache.transpileCache[filePathAbsoluteFilesystem] = promise;
|
|
34
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isPlainScriptFile)(filePathAbsoluteFilesystem), `${filePathToShowToUserResolved} has file extension .${fileExtension} but a config file can only be a JavaScript/TypeScript file`);
|
|
35
|
-
const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
|
|
36
|
-
if (isHeader) {
|
|
37
|
-
(0, utils_js_1.assertWarning)(false, `${picocolors_1.default.cyan('.h.js')} files are deprecated: simply renaming ${filePathToShowToUserResolved} to ${removeHeaderFileExtension(filePathToShowToUserResolved)} is usually enough, although you may occasionally need to use ${picocolors_1.default.cyan("with { type: 'pointer' }")} as explained at https://vike.dev/config#pointer-imports`, { onlyOnce: true });
|
|
38
|
-
}
|
|
39
|
-
let fileExports;
|
|
40
|
-
if (isExtensionConfig && !isHeader && fileExtension.endsWith('js')) {
|
|
41
|
-
// This doesn't track dependencies => we should never use this for user land configs
|
|
42
|
-
fileExports = await executeFile(filePathAbsoluteFilesystem, filePath);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
const transformImports = isHeader ? 'all' : true;
|
|
46
|
-
const code = await transpileFile(filePath, transformImports, userRootDir, esbuildCache);
|
|
47
|
-
fileExports = await executeTranspiledFile(filePath, code);
|
|
48
|
-
}
|
|
49
|
-
resolve({ fileExports });
|
|
50
|
-
return { fileExports };
|
|
51
|
-
}
|
|
52
|
-
async function transpileFile(filePath, transformImports, userRootDir, esbuildCache) {
|
|
53
|
-
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
54
|
-
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
55
|
-
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
56
|
-
esbuildCache.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
57
|
-
if (debug.isActivated)
|
|
58
|
-
debug('transpile', filePathToShowToUserResolved);
|
|
59
|
-
let { code, pointerImports } = await transpileWithEsbuild(filePath, userRootDir, transformImports, esbuildCache);
|
|
60
|
-
if (debug.isActivated)
|
|
61
|
-
debug(`code, post esbuild (${filePathToShowToUserResolved})`, code);
|
|
62
|
-
let isImportTransformed = false;
|
|
63
|
-
if (transformImports) {
|
|
64
|
-
const codeMod = (0, pointerImports_js_1.transformPointerImports)(code, filePathToShowToUserResolved, pointerImports);
|
|
65
|
-
if (codeMod) {
|
|
66
|
-
code = codeMod;
|
|
67
|
-
isImportTransformed = true;
|
|
68
|
-
if (debug.isActivated)
|
|
69
|
-
debug(`code, post pointer imports transform (${filePathToShowToUserResolved})`, code);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!isImportTransformed) {
|
|
73
|
-
if (debug.isActivated)
|
|
74
|
-
debug(`code, no pointer imports (${filePathToShowToUserResolved})`);
|
|
75
|
-
}
|
|
76
|
-
return code;
|
|
77
|
-
}
|
|
78
|
-
async function transpileWithEsbuild(filePath, userRootDir, transformImports, esbuildCache) {
|
|
79
|
-
const entryFilePath = filePath.filePathAbsoluteFilesystem;
|
|
80
|
-
const entryFileDir = node_path_1.default.posix.dirname(entryFilePath);
|
|
81
|
-
const options = {
|
|
82
|
-
platform: 'node',
|
|
83
|
-
entryPoints: [entryFilePath],
|
|
84
|
-
sourcemap: 'inline',
|
|
85
|
-
write: false,
|
|
86
|
-
target: ['node14.18', 'node16'],
|
|
87
|
-
outfile: node_path_1.default.posix.join(
|
|
88
|
-
// Needed for correct inline source map
|
|
89
|
-
entryFileDir,
|
|
90
|
-
// `write: false` => no file is actually emitted
|
|
91
|
-
'NEVER_EMITTED.js'),
|
|
92
|
-
logLevel: 'silent',
|
|
93
|
-
format: 'esm',
|
|
94
|
-
absWorkingDir: userRootDir,
|
|
95
|
-
// Disable tree-shaking to avoid dead-code elimination, so that unused imports aren't removed.
|
|
96
|
-
// Esbuild still sometimes removes unused imports because of TypeScript: https://github.com/evanw/esbuild/issues/3034
|
|
97
|
-
treeShaking: false,
|
|
98
|
-
minify: false,
|
|
99
|
-
metafile: true,
|
|
100
|
-
bundle: true,
|
|
101
|
-
};
|
|
102
|
-
const pointerImports = {};
|
|
103
|
-
options.plugins = [
|
|
104
|
-
// Determine whether an import should be:
|
|
105
|
-
// - A pointer import
|
|
106
|
-
// - Externalized
|
|
107
|
-
{
|
|
108
|
-
name: 'vike-esbuild',
|
|
109
|
-
setup(build) {
|
|
110
|
-
// https://github.com/brillout/esbuild-playground
|
|
111
|
-
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
112
|
-
if (args.kind !== 'import-statement')
|
|
113
|
-
return;
|
|
114
|
-
// Avoid infinite loop: https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
115
|
-
const useEsbuildResolver = 'useEsbuildResolver';
|
|
116
|
-
if (args.pluginData?.[useEsbuildResolver])
|
|
117
|
-
return;
|
|
118
|
-
const { path, ...opts } = args;
|
|
119
|
-
opts.pluginData = { [useEsbuildResolver]: true };
|
|
120
|
-
let resolved = await build.resolve(path, opts);
|
|
121
|
-
if (debugEsbuildResolve.isActivated)
|
|
122
|
-
debugEsbuildResolve('args', args);
|
|
123
|
-
if (debugEsbuildResolve.isActivated)
|
|
124
|
-
debugEsbuildResolve('resolved', resolved);
|
|
125
|
-
// Temporary workaround for https://github.com/evanw/esbuild/issues/3973
|
|
126
|
-
// - Still required for esbuild@0.24.0 (November 2024).
|
|
127
|
-
// - Let's try to remove this workaround again later.
|
|
128
|
-
if (resolved.errors.length > 0) {
|
|
129
|
-
const resolvedWithNode = (0, utils_js_1.requireResolveOptionalDir)({
|
|
130
|
-
importPath: path,
|
|
131
|
-
importerDir: (0, utils_js_1.toPosixPath)(args.resolveDir),
|
|
132
|
-
userRootDir,
|
|
133
|
-
});
|
|
134
|
-
if (debugEsbuildResolve.isActivated)
|
|
135
|
-
debugEsbuildResolve('resolvedWithNode', resolvedWithNode);
|
|
136
|
-
if (resolvedWithNode)
|
|
137
|
-
resolved = { path: resolvedWithNode };
|
|
138
|
-
}
|
|
139
|
-
if (resolved.errors && resolved.errors.length > 0) {
|
|
140
|
-
/* We could do the following to let Node.js throw the error, but we don't because the error shown by esbuild is prettier: the Node.js error refers to the transpiled [build-f7i251e0iwnw]+config.ts.mjs whereas esbuild refers to the source +config.ts file.
|
|
141
|
-
pointerImports[args.path] = false
|
|
142
|
-
return { external: true }
|
|
143
|
-
*/
|
|
144
|
-
// Let esbuild throw the error
|
|
145
|
-
cleanEsbuildErrors(resolved.errors);
|
|
146
|
-
return resolved;
|
|
147
|
-
}
|
|
148
|
-
(0, utils_js_1.assert)(resolved.path);
|
|
149
|
-
const importPathResolved = (0, utils_js_1.toPosixPath)(resolved.path);
|
|
150
|
-
const importPathOriginal = args.path;
|
|
151
|
-
// Esbuild resolves path aliases.
|
|
152
|
-
// - Enabling us to use:
|
|
153
|
-
// - assertIsImportPathNpmPackage()
|
|
154
|
-
// - isImportPathNpmPackage(str, { cannotBePathAlias: true })
|
|
155
|
-
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(importPathResolved);
|
|
156
|
-
// Should be remove this? See comment below.
|
|
157
|
-
const isVikeExtensionImport = (path.startsWith('vike-') && path.endsWith('/config')) || importPathResolved.endsWith('+config.js');
|
|
158
|
-
const isPointerImport = transformImports === 'all' ||
|
|
159
|
-
// .jsx, .vue, .svg, ... => obviously not config code => pointer import
|
|
160
|
-
!(0, utils_js_1.isPlainScriptFile)(importPathResolved) ||
|
|
161
|
-
// Import of a Vike extension config => make it a pointer import because we want to show nice error messages (that can display whether a config has been set by the user or by a Vike extension).
|
|
162
|
-
// - Should we stop doing this? (And instead let Node.js directly load Vike extensions.)
|
|
163
|
-
// - In principle, we can use the setting 'name' value of Vike extensions.
|
|
164
|
-
// - vike@0.4.162 started soft-requiring Vike extensions to set the name config.
|
|
165
|
-
// - In practice, it seems like it requires some (non-trivial?) refactoring.
|
|
166
|
-
isVikeExtensionImport;
|
|
167
|
-
(0, utils_js_1.assertPosixPath)(importPathResolved);
|
|
168
|
-
// `isNpmPkgImport` => `importPathOriginal` is most likely an npm package import, but it can also be a path alias that a) looks like an npm package import and b) resolves outside of `userRootDir`.
|
|
169
|
-
const isNpmPkgImport = (() => {
|
|
170
|
-
if (importPathResolved.includes('/node_modules/')) {
|
|
171
|
-
// So far I can't think of a use case where this assertion would fail, but let's eventually remove it to avoid artificially restricting the user.
|
|
172
|
-
(0, utils_js_1.assert)((0, utils_js_1.isImportPathNpmPackageOrPathAlias)(importPathOriginal));
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
// Linked npm packages
|
|
176
|
-
if (
|
|
177
|
-
// Assuming path aliases usually resolve inside `userRootDir`.
|
|
178
|
-
// - This isn't always the case: https://github.com/vikejs/vike/issues/2326
|
|
179
|
-
!importPathResolved.startsWith(userRootDir) &&
|
|
180
|
-
// False positive if `importPathOriginal` is a path alias that a) looks like an npm package import and b) resolves outside of `userRootDir` => we then we wrongfully assume that `importPathOriginal` is an npm package import.
|
|
181
|
-
(0, utils_js_1.isImportPathNpmPackageOrPathAlias)(importPathOriginal)) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
return false;
|
|
185
|
-
})();
|
|
186
|
-
const isExternal = isPointerImport ||
|
|
187
|
-
// Performance: npm package imports can be externalized. (We could as well let esbuild transpile /node_modules/ code but it's useless as /node_modules/ code is already built. It would unnecessarily slow down transpilation.)
|
|
188
|
-
isNpmPkgImport;
|
|
189
|
-
if (!isExternal) {
|
|
190
|
-
// User-land config code (i.e. not runtime code) => let esbuild transpile it
|
|
191
|
-
(0, utils_js_1.assert)(!isPointerImport && !isNpmPkgImport);
|
|
192
|
-
if (debug.isActivated)
|
|
193
|
-
debug('onResolved()', { args, resolved, isPointerImport, isExternal });
|
|
194
|
-
return resolved;
|
|
195
|
-
}
|
|
196
|
-
let importPathTranspiled;
|
|
197
|
-
(0, utils_js_1.assertPosixPath)(importPathOriginal);
|
|
198
|
-
if ((0, utils_js_1.isImportPathRelative)(importPathOriginal)) {
|
|
199
|
-
importPathTranspiled = importPathResolved;
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
// `importPathOriginal` is either:
|
|
203
|
-
// - Npm package import
|
|
204
|
-
// - Path alias
|
|
205
|
-
const filePathAbsoluteUserRootDir = (0, getFilePath_js_1.getFilePathAbsoluteUserRootDir)({
|
|
206
|
-
filePathAbsoluteFilesystem: importPathResolved,
|
|
207
|
-
userRootDir,
|
|
208
|
-
});
|
|
209
|
-
if (filePathAbsoluteUserRootDir && !isNpmPkgImport) {
|
|
210
|
-
// `importPathOriginal` is most likely a path alias.
|
|
211
|
-
// - We have to use esbuild's path alias resolution, because:
|
|
212
|
-
// - Vike doesn't resolve path aliases at all.
|
|
213
|
-
// - Node.js doesn't support `tsconfig.js#compilerOptions.paths`.
|
|
214
|
-
// - Esbuild path alias resolution seems reliable, e.g. it supports `tsconfig.js#compilerOptions.paths`.
|
|
215
|
-
importPathTranspiled = importPathResolved;
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
// `importPathOriginal` is most likely an npm package import.
|
|
219
|
-
(0, utils_js_1.assertIsImportPathNpmPackage)(importPathOriginal);
|
|
220
|
-
// For improved error messages, let the resolution be handled by Vike or Node.js.
|
|
221
|
-
importPathTranspiled = importPathOriginal;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (debug.isActivated)
|
|
225
|
-
debug('onResolved()', { args, resolved, importPathTranspiled, isPointerImport, isExternal });
|
|
226
|
-
(0, utils_js_1.assert)(isExternal);
|
|
227
|
-
(0, utils_js_1.assert)(
|
|
228
|
-
// Import of runtime code => handled by Vike
|
|
229
|
-
isPointerImport ||
|
|
230
|
-
// Import of config code => loaded by Node.js at build-time
|
|
231
|
-
isNpmPkgImport);
|
|
232
|
-
pointerImports[importPathTranspiled] = isPointerImport;
|
|
233
|
-
return { external: true, path: importPathTranspiled };
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
// Track dependencies
|
|
238
|
-
{
|
|
239
|
-
name: 'vike:dependency-tracker',
|
|
240
|
-
setup(b) {
|
|
241
|
-
b.onLoad({ filter: /./ }, (args) => {
|
|
242
|
-
// We collect the dependency `args.path` in case the build fails (upon build error => error is thrown => no metafile)
|
|
243
|
-
let { path } = args;
|
|
244
|
-
path = (0, utils_js_1.toPosixPath)(path);
|
|
245
|
-
esbuildCache.vikeConfigDependencies.add(path);
|
|
246
|
-
return undefined;
|
|
247
|
-
});
|
|
248
|
-
/* To exhaustively collect all dependencies upon build failure, we would also need to use onResolve().
|
|
249
|
-
* - Because onLoad() isn't call if the config dependency can't be resolved.
|
|
250
|
-
* - For example, the following breaks auto-reload (the config is stuck in its error state and the user needs to touch the importer for the config to reload):
|
|
251
|
-
* ```bash
|
|
252
|
-
* mv ./some-config-dependency.js /tmp/ && mv /tmp/some-config-dependency.js .
|
|
253
|
-
* ```
|
|
254
|
-
* - But implementing a fix is complex and isn't worth it.
|
|
255
|
-
b.onResolve(...)
|
|
256
|
-
*/
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
];
|
|
260
|
-
let result;
|
|
261
|
-
try {
|
|
262
|
-
result = await (0, esbuild_1.build)(options);
|
|
263
|
-
}
|
|
264
|
-
catch (err) {
|
|
265
|
-
await formatBuildErr(err, filePath);
|
|
266
|
-
throw err;
|
|
267
|
-
}
|
|
268
|
-
// Track dependencies
|
|
269
|
-
(0, utils_js_1.assert)(result.metafile);
|
|
270
|
-
Object.keys(result.metafile.inputs).forEach((filePathRelative) => {
|
|
271
|
-
filePathRelative = (0, utils_js_1.toPosixPath)(filePathRelative);
|
|
272
|
-
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
273
|
-
const filePathAbsoluteFilesystem = node_path_1.default.posix.join(userRootDir, filePathRelative);
|
|
274
|
-
esbuildCache.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
275
|
-
});
|
|
276
|
-
const code = result.outputFiles[0].text;
|
|
277
|
-
(0, utils_js_1.assert)(typeof code === 'string');
|
|
278
|
-
return { code, pointerImports };
|
|
279
|
-
}
|
|
280
|
-
async function executeTranspiledFile(filePath, code) {
|
|
281
|
-
const { filePathAbsoluteFilesystem } = filePath;
|
|
282
|
-
// Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
|
|
283
|
-
// - But seems to break source maps, so I don't think it's worth it
|
|
284
|
-
const filePathTmp = getTemporaryBuildFilePath(filePathAbsoluteFilesystem);
|
|
285
|
-
node_fs_1.default.writeFileSync(filePathTmp, code);
|
|
286
|
-
const clean = () => node_fs_1.default.unlinkSync(filePathTmp);
|
|
287
|
-
let fileExports = {};
|
|
288
|
-
try {
|
|
289
|
-
fileExports = await executeFile(filePathTmp, filePath);
|
|
290
|
-
}
|
|
291
|
-
finally {
|
|
292
|
-
clean();
|
|
293
|
-
}
|
|
294
|
-
return fileExports;
|
|
295
|
-
}
|
|
296
|
-
async function executeFile(filePathToExecuteAbsoluteFilesystem, filePathSourceFile) {
|
|
297
|
-
let fileExports = {};
|
|
298
|
-
try {
|
|
299
|
-
fileExports = await (0, import_1.import_)(filePathToExecuteAbsoluteFilesystem);
|
|
300
|
-
}
|
|
301
|
-
catch (err) {
|
|
302
|
-
triggerPrepareStackTrace(err);
|
|
303
|
-
const errIntroMsg = getErrIntroMsg('execute', filePathSourceFile);
|
|
304
|
-
(0, utils_js_1.assert)((0, utils_js_1.isObject)(err));
|
|
305
|
-
execErrIntroMsg.set(err, errIntroMsg);
|
|
306
|
-
throw err;
|
|
307
|
-
}
|
|
308
|
-
// Return a plain JavaScript object:
|
|
309
|
-
// - import() returns `[Module: null prototype] { default: { onRenderClient: '...' }}`
|
|
310
|
-
// - We don't need this special object.
|
|
311
|
-
fileExports = { ...fileExports };
|
|
312
|
-
return fileExports;
|
|
313
|
-
}
|
|
314
|
-
const formatted = '_formatted';
|
|
315
|
-
function getConfigBuildErrorFormatted(err) {
|
|
316
|
-
if (!(0, utils_js_1.isObject)(err))
|
|
317
|
-
return null;
|
|
318
|
-
if (!(formatted in err))
|
|
319
|
-
return null;
|
|
320
|
-
(0, utils_js_1.assert)(typeof err[formatted] === 'string');
|
|
321
|
-
return err[formatted];
|
|
322
|
-
}
|
|
323
|
-
async function formatBuildErr(err, filePath) {
|
|
324
|
-
(0, utils_js_1.assert)((0, utils_js_1.isObject)(err) && err.errors);
|
|
325
|
-
const msgEsbuild = (await (0, esbuild_1.formatMessages)(err.errors, {
|
|
326
|
-
kind: 'error',
|
|
327
|
-
color: true,
|
|
328
|
-
}))
|
|
329
|
-
.map((m) => m.trim())
|
|
330
|
-
.join('\n');
|
|
331
|
-
const msgIntro = getErrIntroMsg('transpile', filePath);
|
|
332
|
-
err[formatted] = `${msgIntro}\n${msgEsbuild}`;
|
|
333
|
-
}
|
|
334
|
-
const execErrIntroMsg = new WeakMap();
|
|
335
|
-
function getConfigExecutionErrorIntroMsg(err) {
|
|
336
|
-
if (!(0, utils_js_1.isObject)(err))
|
|
337
|
-
return null;
|
|
338
|
-
const errIntroMsg = execErrIntroMsg.get(err);
|
|
339
|
-
return errIntroMsg ?? null;
|
|
340
|
-
}
|
|
341
|
-
function getTemporaryBuildFilePath(filePathAbsoluteFilesystem) {
|
|
342
|
-
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
343
|
-
const dirname = node_path_1.default.posix.dirname(filePathAbsoluteFilesystem);
|
|
344
|
-
const filename = node_path_1.default.posix.basename(filePathAbsoluteFilesystem);
|
|
345
|
-
// Syntax with semicolon `build:${/*...*/}` doesn't work on Windows: https://github.com/vikejs/vike/issues/800#issuecomment-1517329455
|
|
346
|
-
const filePathTmp = node_path_1.default.posix.join(dirname, `${filename}.build-${(0, utils_js_1.getRandomId)()}.mjs`);
|
|
347
|
-
(0, utils_js_1.assert)(isTemporaryBuildFile(filePathTmp));
|
|
348
|
-
return filePathTmp;
|
|
349
|
-
}
|
|
350
|
-
function isTemporaryBuildFile(filePath) {
|
|
351
|
-
(0, utils_js_1.assertPosixPath)(filePath);
|
|
352
|
-
const fileName = node_path_1.default.posix.basename(filePath);
|
|
353
|
-
return /\.build-[a-z0-9]{12}\.mjs$/.test(fileName);
|
|
354
|
-
}
|
|
355
|
-
// TO-DO/next-major-release: remove
|
|
356
|
-
function isHeaderFile(filePath) {
|
|
357
|
-
(0, utils_js_1.assertPosixPath)(filePath);
|
|
358
|
-
const fileExtensions = getFileExtensions(filePath);
|
|
359
|
-
return fileExtensions.includes('h');
|
|
360
|
-
}
|
|
361
|
-
function getFileExtensions(filePath) {
|
|
362
|
-
const fileExtensions = node_path_1.default.posix.basename(filePath).split('.').slice(1);
|
|
363
|
-
return fileExtensions;
|
|
364
|
-
}
|
|
365
|
-
function getFileExtension(filePath) {
|
|
366
|
-
const fileExtensions = node_path_1.default.posix.basename(filePath).split('.').slice(1);
|
|
367
|
-
return fileExtensions.pop();
|
|
368
|
-
}
|
|
369
|
-
function removeHeaderFileExtension(filePath) {
|
|
370
|
-
(0, utils_js_1.assertPosixPath)(filePath);
|
|
371
|
-
const fileName = node_path_1.default.posix.basename(filePath);
|
|
372
|
-
const fileNameParts = fileName.split('.');
|
|
373
|
-
const fileNamePartsMod = fileNameParts.filter((p) => p !== 'h');
|
|
374
|
-
(0, utils_js_1.assert)(fileNamePartsMod.length < fileNameParts.length);
|
|
375
|
-
const fileNameMod = fileNamePartsMod.join('.');
|
|
376
|
-
return node_path_1.default.posix.join(node_path_1.default.posix.dirname(filePath), fileNameMod);
|
|
377
|
-
}
|
|
378
|
-
// Needed for the npm package 'source-map-support'. The Error.prepareStackTrace() hook of 'source-map-support' needs to be called before the file containing the source map is removed. The clean() call above removes the transpiled file from disk but it contains the inline source map.
|
|
379
|
-
function triggerPrepareStackTrace(err) {
|
|
380
|
-
if ((0, utils_js_1.isObject)(err)) {
|
|
381
|
-
// Accessing err.stack triggers prepareStackTrace()
|
|
382
|
-
const { stack } = err;
|
|
383
|
-
// Ensure no compiler removes the line above
|
|
384
|
-
if (1 + 1 === 3)
|
|
385
|
-
console.log('I_AM_NEVER_SHOWN' + stack);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
function getErrIntroMsg(operation, filePath) {
|
|
389
|
-
const { filePathToShowToUserResolved } = filePath;
|
|
390
|
-
const msg = [
|
|
391
|
-
// prettier ignore
|
|
392
|
-
picocolors_1.default.red(`Failed to ${operation}`),
|
|
393
|
-
picocolors_1.default.bold(picocolors_1.default.red(filePathToShowToUserResolved)),
|
|
394
|
-
picocolors_1.default.red(`because:`),
|
|
395
|
-
].join(' ');
|
|
396
|
-
return msg;
|
|
397
|
-
}
|
|
398
|
-
function cleanEsbuildErrors(errors) {
|
|
399
|
-
errors.forEach((e) => (e.notes = e.notes.filter((note) =>
|
|
400
|
-
// Remove note:
|
|
401
|
-
// ```shell
|
|
402
|
-
// You can mark the path "#root/renderer/onRenderHtml_typo" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
|
|
403
|
-
// ```
|
|
404
|
-
//
|
|
405
|
-
// From error:
|
|
406
|
-
// ```shell
|
|
407
|
-
// ✘ [ERROR] Could not resolve "#root/renderer/onRenderHtml_typo" [plugin vike-esbuild]
|
|
408
|
-
//
|
|
409
|
-
// renderer/+config.h.js:1:29:
|
|
410
|
-
// 1 │ import { onRenderHtml } from "#root/renderer/onRenderHtml_typo"
|
|
411
|
-
// ╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
412
|
-
//
|
|
413
|
-
// You can mark the path "#root/renderer/onRenderHtml_typo" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
|
|
414
|
-
//
|
|
415
|
-
// ```
|
|
416
|
-
!note.text.includes('as external to exclude it from the bundle'))));
|
|
417
|
-
}
|
|
418
|
-
function installSourceMapSupport() {
|
|
419
|
-
// Don't break Vitest's source mapping
|
|
420
|
-
if ((0, utils_js_1.isVitest)())
|
|
421
|
-
return;
|
|
422
|
-
// How about other test runners?
|
|
423
|
-
// Should we call installSourceMapSupport() lazily in transpileAndExecuteFile() instead?
|
|
424
|
-
source_map_support_1.default.install();
|
|
425
|
-
}
|