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,190 +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.getFilesystemRouteString = getFilesystemRouteString;
|
|
7
|
-
exports.getFilesystemRouteDefinedBy = getFilesystemRouteDefinedBy;
|
|
8
|
-
exports.isInherited = isInherited;
|
|
9
|
-
exports.getLocationId = getLocationId;
|
|
10
|
-
exports.sortAfterInheritanceOrder = sortAfterInheritanceOrder;
|
|
11
|
-
exports.applyFilesystemRoutingRootEffect = applyFilesystemRoutingRootEffect;
|
|
12
|
-
exports.getLogicalPath = getLogicalPath;
|
|
13
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
|
-
const utils_js_1 = require("../../utils.js");
|
|
15
|
-
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
16
|
-
/**
|
|
17
|
-
* `getLocationId('/pages/some-page/+Page.js')` => `'/pages/some-page'`
|
|
18
|
-
* `getLocationId('/renderer/+config.js')` => `'/renderer'`
|
|
19
|
-
*
|
|
20
|
-
* The value `locationId` is always a user-land path, because Filesystem Routing/Inheritance only applies to the user-land (Vike never uses Filesystem Routing/Inheritance for `node_modules/**`).
|
|
21
|
-
*/
|
|
22
|
-
function getLocationId(
|
|
23
|
-
// We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.js` that extends the Vike extension.
|
|
24
|
-
filePathAbsoluteUserRootDir) {
|
|
25
|
-
(0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
|
|
26
|
-
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
27
|
-
const locationId = removeFilename(filePathAbsoluteUserRootDir);
|
|
28
|
-
assertLocationId(locationId);
|
|
29
|
-
return locationId;
|
|
30
|
-
}
|
|
31
|
-
/** Filesystem Routing: get the URL */
|
|
32
|
-
function getFilesystemRouteString(locationId) {
|
|
33
|
-
return getLogicalPath(locationId, ['renderer', 'pages', 'src', 'index'], true);
|
|
34
|
-
}
|
|
35
|
-
/** Filesystem Inheritance: get the apply root */
|
|
36
|
-
function getInheritanceRoot(locationId) {
|
|
37
|
-
return getLogicalPath(locationId, [
|
|
38
|
-
'renderer',
|
|
39
|
-
// Enable hooks defined by vike-{react,vue,solid} such as +onBeforeRenderClient to be defined at the root directory. In other words, avoid following error:
|
|
40
|
-
// ```bash
|
|
41
|
-
// [11:09:43.072][/test-preview.test.ts][npm run preview][stderr] Error: [vike][Wrong Usage] /+onBeforeRenderClient.ts sets the value of the config onBeforeRenderClient which is a custom config that is defined with https://vike.dev/meta at a path that doesn't apply to / — see https://vike.dev/config#inheritance
|
|
42
|
-
// ```
|
|
43
|
-
'pages',
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* getLogicalPath('/pages/some-page', ['pages']) => '/some-page'
|
|
48
|
-
*/
|
|
49
|
-
function getLogicalPath(locationId, ignoredDirs, removeParenthesesDirs) {
|
|
50
|
-
let logicalPath = removeIgnoredDirectories(locationId, ignoredDirs, removeParenthesesDirs);
|
|
51
|
-
assertIsPath(logicalPath);
|
|
52
|
-
return logicalPath;
|
|
53
|
-
}
|
|
54
|
-
// See getPlusFilesRelevant() and getPlusFilesOrdered()
|
|
55
|
-
function sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage) {
|
|
56
|
-
assertLocationId(locationId1);
|
|
57
|
-
assertLocationId(locationId2);
|
|
58
|
-
if (locationId1 === locationId2)
|
|
59
|
-
return 0;
|
|
60
|
-
const inheritanceRoot1 = getInheritanceRoot(locationId1);
|
|
61
|
-
const inheritanceRoot2 = getInheritanceRoot(locationId2);
|
|
62
|
-
const inheritanceRootPage = getInheritanceRoot(locationIdPage);
|
|
63
|
-
// Only works if both locationId1 and locationId2 are inherited by the same page
|
|
64
|
-
(0, utils_js_1.assert)(isInherited(locationId1, locationIdPage));
|
|
65
|
-
(0, utils_js_1.assert)(isInherited(locationId2, locationIdPage));
|
|
66
|
-
// Equivalent assertion (see isInherited() implementation)
|
|
67
|
-
(0, utils_js_1.assert)(startsWith(inheritanceRootPage, inheritanceRoot1));
|
|
68
|
-
(0, utils_js_1.assert)(startsWith(inheritanceRootPage, inheritanceRoot2));
|
|
69
|
-
if (inheritanceRoot1 !== inheritanceRoot2) {
|
|
70
|
-
// Should be true since locationId1 and locationId2 are both inherited by the same page
|
|
71
|
-
(0, utils_js_1.assert)(startsWith(inheritanceRoot1, inheritanceRoot2) || startsWith(inheritanceRoot2, inheritanceRoot1));
|
|
72
|
-
(0, utils_js_1.assert)(inheritanceRoot1.length !== inheritanceRoot2.length);
|
|
73
|
-
return (0, utils_js_1.higherFirst)((inheritanceRoot) => inheritanceRoot.length)(inheritanceRoot1, inheritanceRoot2);
|
|
74
|
-
}
|
|
75
|
-
// locationId1 first, i.e. `indexOf(locationId1) < indexOf(locationId2)`
|
|
76
|
-
const locationId1First = -1;
|
|
77
|
-
// locationId2 first, i.e. `indexOf(locationId2) < indexOf(locationId1)`
|
|
78
|
-
const locationId2First = 1;
|
|
79
|
-
if (locationIsRendererDir(locationId1) !== locationIsRendererDir(locationId2)) {
|
|
80
|
-
return locationIsRendererDir(locationId1) ? locationId2First : locationId1First;
|
|
81
|
-
}
|
|
82
|
-
// Doesn't have any function beyond making the order deterministic
|
|
83
|
-
// - Although we make /src/renderer/+config.js override /renderer/+config.js which potentially can make somewhat sense (e.g. when ejecting a renderer)
|
|
84
|
-
if (locationId1.length !== locationId2.length) {
|
|
85
|
-
return (0, utils_js_1.higherFirst)((locationId) => locationId.length)(locationId1, locationId2);
|
|
86
|
-
}
|
|
87
|
-
return locationId1 > locationId2 ? locationId1First : locationId2First;
|
|
88
|
-
}
|
|
89
|
-
function locationIsRendererDir(locationId) {
|
|
90
|
-
return locationId.split('/').includes('renderer');
|
|
91
|
-
}
|
|
92
|
-
/** Whether configs defined at `locationId1` also apply at `locationId2` */
|
|
93
|
-
function isInherited(locationId1, locationId2) {
|
|
94
|
-
const inheritanceRoot1 = getInheritanceRoot(locationId1);
|
|
95
|
-
const inheritanceRoot2 = getInheritanceRoot(locationId2);
|
|
96
|
-
return startsWith(inheritanceRoot2, inheritanceRoot1);
|
|
97
|
-
}
|
|
98
|
-
function removeIgnoredDirectories(somePath, ignoredDirs, removeParenthesesDirs) {
|
|
99
|
-
(0, utils_js_1.assertPosixPath)(somePath);
|
|
100
|
-
somePath = somePath
|
|
101
|
-
.split('/')
|
|
102
|
-
.filter((dir) => {
|
|
103
|
-
if (ignoredDirs.includes(dir)) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
if (removeParenthesesDirs && dir.startsWith('(') && dir.endsWith(')')) {
|
|
107
|
-
assertRedundantParentheses(dir, ignoredDirs, somePath);
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
})
|
|
112
|
-
.join('/');
|
|
113
|
-
if (somePath === '')
|
|
114
|
-
somePath = '/';
|
|
115
|
-
return somePath;
|
|
116
|
-
}
|
|
117
|
-
function assertRedundantParentheses(dir, ignoredDirs, somePath) {
|
|
118
|
-
const dirWithoutParentheses = dir.slice(1, -1);
|
|
119
|
-
if (!ignoredDirs.includes(dirWithoutParentheses)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const dirnameActual = dir;
|
|
123
|
-
const dirnameCorrect = dirWithoutParentheses;
|
|
124
|
-
const dirpathActual = somePath.slice(0, somePath.indexOf(dirnameActual) + dirnameActual.length);
|
|
125
|
-
const dirpathCorrect = dirpathActual.replaceAll(dirnameActual, dirnameCorrect);
|
|
126
|
-
const logDir = (d) => picocolors_1.default.bold(d + '/');
|
|
127
|
-
(0, utils_js_1.assertWarning)(false, [
|
|
128
|
-
`The directories ${logDir(dirnameCorrect)} are always ignored by Vike's Filesystem Routing`,
|
|
129
|
-
'(https://vike.dev/filesystem-routing):',
|
|
130
|
-
`rename directory ${logDir(dirpathActual)} to ${logDir(dirpathCorrect)}`,
|
|
131
|
-
].join(' '), { onlyOnce: true });
|
|
132
|
-
}
|
|
133
|
-
function removeFilename(filePathAbsoluteUserRootDir) {
|
|
134
|
-
const filePathParts = filePathAbsoluteUserRootDir.split('/');
|
|
135
|
-
{
|
|
136
|
-
const filename = filePathParts.slice(-1)[0];
|
|
137
|
-
(0, utils_js_1.assert)(filename.includes('.'));
|
|
138
|
-
}
|
|
139
|
-
let locationId = filePathParts.slice(0, -1).join('/');
|
|
140
|
-
if (locationId === '')
|
|
141
|
-
locationId = '/';
|
|
142
|
-
assertLocationId(locationId);
|
|
143
|
-
return locationId;
|
|
144
|
-
}
|
|
145
|
-
function getFilesystemRouteDefinedBy(locationId) {
|
|
146
|
-
if (locationId === '/')
|
|
147
|
-
return locationId;
|
|
148
|
-
(0, utils_js_1.assert)(!locationId.endsWith('/'));
|
|
149
|
-
const routeFilesystemDefinedBy = locationId + '/';
|
|
150
|
-
return routeFilesystemDefinedBy;
|
|
151
|
-
}
|
|
152
|
-
function applyFilesystemRoutingRootEffect(routeFilesystem, filesystemRoutingRootEffect) {
|
|
153
|
-
const { before, after } = filesystemRoutingRootEffect;
|
|
154
|
-
(0, utils_js_1.assert)(after.startsWith('/'));
|
|
155
|
-
(0, utils_js_1.assert)(routeFilesystem.startsWith(before));
|
|
156
|
-
routeFilesystem = after + '/' + routeFilesystem.slice(before.length);
|
|
157
|
-
routeFilesystem = '/' + routeFilesystem.split('/').filter(Boolean).join('/');
|
|
158
|
-
return routeFilesystem;
|
|
159
|
-
}
|
|
160
|
-
function assertLocationId(locationId) {
|
|
161
|
-
(0, utils_js_1.assert)(locationId.startsWith('/'));
|
|
162
|
-
(0, utils_js_1.assert)(!locationId.endsWith('/') || locationId === '/');
|
|
163
|
-
}
|
|
164
|
-
function assertIsPath(logicalPath) {
|
|
165
|
-
(0, utils_js_1.assert)(logicalPath.startsWith('/'));
|
|
166
|
-
(0, utils_js_1.assert)(!logicalPath.endsWith('/') || logicalPath === '/');
|
|
167
|
-
}
|
|
168
|
-
/** Whether `inheritanceRoot1` starts with `inheritanceRoot2` */
|
|
169
|
-
function startsWith(inheritanceRoot1, inheritanceRoot2) {
|
|
170
|
-
assertIsPath(inheritanceRoot1);
|
|
171
|
-
assertIsPath(inheritanceRoot2);
|
|
172
|
-
const segments1 = inheritanceRoot1.split('/').filter(Boolean);
|
|
173
|
-
const segments2 = inheritanceRoot2.split('/').filter(Boolean);
|
|
174
|
-
for (const i in segments2) {
|
|
175
|
-
const segment1 = segments1[i];
|
|
176
|
-
const segment2 = segments2[i];
|
|
177
|
-
if (segment1 !== segment2) {
|
|
178
|
-
/* This assertion fails for:
|
|
179
|
-
```
|
|
180
|
-
inheritanceRoot1: '/pages/about2'
|
|
181
|
-
inheritanceRoot2: '/pages/about'
|
|
182
|
-
```
|
|
183
|
-
assert(!inheritanceRoot1.startsWith(inheritanceRoot2))
|
|
184
|
-
*/
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
(0, utils_js_1.assert)(inheritanceRoot1.startsWith(inheritanceRoot2));
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
@@ -1,17 +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.getConfigFileExport = getConfigFileExport;
|
|
7
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
|
-
const assertPlusFileExport_js_1 = require("../../../../shared/page-configs/assertPlusFileExport.js");
|
|
9
|
-
const utils_js_1 = require("../../utils.js");
|
|
10
|
-
function getConfigFileExport(fileExports, filePathToShowToUser) {
|
|
11
|
-
(0, assertPlusFileExport_js_1.assertPlusFileExport)(fileExports, filePathToShowToUser, 'config');
|
|
12
|
-
const usesNamedExport = !!fileExports.config;
|
|
13
|
-
const fileExport = usesNamedExport ? fileExports.config : fileExports.default;
|
|
14
|
-
const exportName = picocolors_1.default.cyan(usesNamedExport ? 'export { config }' : 'export default');
|
|
15
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(fileExport), `The ${exportName} of ${filePathToShowToUser} should be an object (but it's ${picocolors_1.default.cyan(`typeof exportedValue === ${JSON.stringify(typeof fileExport)}`)} instead)`);
|
|
16
|
-
return fileExport;
|
|
17
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPlusFilesAll = getPlusFilesAll;
|
|
4
|
-
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
const configDefinitionsBuiltIn_js_1 = require("./configDefinitionsBuiltIn.js");
|
|
6
|
-
const filesystemRouting_js_1 = require("./filesystemRouting.js");
|
|
7
|
-
const crawlPlusFiles_js_1 = require("./crawlPlusFiles.js");
|
|
8
|
-
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
9
|
-
const loadFileAtConfigTime_js_1 = require("./loadFileAtConfigTime.js");
|
|
10
|
-
const resolvePointerImport_js_1 = require("./resolvePointerImport.js");
|
|
11
|
-
const getFilePath_js_1 = require("../getFilePath.js");
|
|
12
|
-
const assertExtensions_js_1 = require("./assertExtensions.js");
|
|
13
|
-
async function getPlusFilesAll(userRootDir, esbuildCache) {
|
|
14
|
-
const plusFiles = await findPlusFiles(userRootDir);
|
|
15
|
-
const configFiles = [];
|
|
16
|
-
const valueFiles = [];
|
|
17
|
-
plusFiles.forEach((f) => {
|
|
18
|
-
if ((0, crawlPlusFiles_js_1.getPlusFileValueConfigName)(f.filePathAbsoluteFilesystem) === 'config') {
|
|
19
|
-
configFiles.push(f);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
valueFiles.push(f);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
let plusFilesAll = {};
|
|
26
|
-
await Promise.all([
|
|
27
|
-
// Config files
|
|
28
|
-
...configFiles.map(async (filePath) => {
|
|
29
|
-
const { filePathAbsoluteUserRootDir } = filePath;
|
|
30
|
-
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
31
|
-
const { configFile, extendsConfigs } = await (0, loadFileAtConfigTime_js_1.loadConfigFile)(filePath, userRootDir, [], false, esbuildCache);
|
|
32
|
-
(0, utils_js_1.assert)(filePath.filePathAbsoluteUserRootDir);
|
|
33
|
-
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir);
|
|
34
|
-
const plusFile = getPlusFileFromConfigFile(configFile, false, locationId, userRootDir);
|
|
35
|
-
plusFilesAll[locationId] = plusFilesAll[locationId] ?? [];
|
|
36
|
-
plusFilesAll[locationId].push(plusFile);
|
|
37
|
-
extendsConfigs.forEach((extendsConfig) => {
|
|
38
|
-
/* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
|
|
39
|
-
```js
|
|
40
|
-
// /pages/admin/+config.js
|
|
41
|
-
|
|
42
|
-
import vikeVue from 'vike-vue/config'
|
|
43
|
-
// Should only apply to /pages/admin/**
|
|
44
|
-
export default { extends: [vikeVue] }
|
|
45
|
-
```
|
|
46
|
-
```js
|
|
47
|
-
// /pages/marketing/+config.js
|
|
48
|
-
|
|
49
|
-
import vikeReact from 'vike-react/config'
|
|
50
|
-
// Should only apply to /pages/marketing/**
|
|
51
|
-
export default { extends: [vikeReact] }
|
|
52
|
-
```
|
|
53
|
-
*/
|
|
54
|
-
const plusFile = getPlusFileFromConfigFile(extendsConfig, true, locationId, userRootDir);
|
|
55
|
-
(0, assertExtensions_js_1.assertExtensionsConventions)(plusFile);
|
|
56
|
-
plusFilesAll[locationId].push(plusFile);
|
|
57
|
-
});
|
|
58
|
-
}),
|
|
59
|
-
// Value files
|
|
60
|
-
...valueFiles.map(async (filePath) => {
|
|
61
|
-
const { filePathAbsoluteUserRootDir } = filePath;
|
|
62
|
-
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
63
|
-
const configName = (0, crawlPlusFiles_js_1.getPlusFileValueConfigName)(filePathAbsoluteUserRootDir);
|
|
64
|
-
(0, utils_js_1.assert)(configName);
|
|
65
|
-
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir);
|
|
66
|
-
const plusFile = {
|
|
67
|
-
locationId,
|
|
68
|
-
filePath,
|
|
69
|
-
isConfigFile: false,
|
|
70
|
-
isNotLoaded: true,
|
|
71
|
-
configName,
|
|
72
|
-
};
|
|
73
|
-
plusFilesAll[locationId] = plusFilesAll[locationId] ?? [];
|
|
74
|
-
plusFilesAll[locationId].push(plusFile);
|
|
75
|
-
// We don't have access to the custom config definitions defined by the user yet.
|
|
76
|
-
// - If `configDef` is `undefined` => we load the file +{configName}.js later.
|
|
77
|
-
// - We already need to load +meta.js here (to get the custom config definitions defined by the user)
|
|
78
|
-
await (0, loadFileAtConfigTime_js_1.loadValueFile)(plusFile, configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn, userRootDir, esbuildCache);
|
|
79
|
-
}),
|
|
80
|
-
]);
|
|
81
|
-
// Make lists element order deterministic
|
|
82
|
-
Object.entries(plusFilesAll).forEach(([_locationId, plusFiles]) => {
|
|
83
|
-
plusFiles.sort(sortMakeDeterministic);
|
|
84
|
-
});
|
|
85
|
-
assertPlusFiles(plusFilesAll);
|
|
86
|
-
return plusFilesAll;
|
|
87
|
-
}
|
|
88
|
-
function assertPlusFiles(plusFilesAll) {
|
|
89
|
-
const plusFiles = Object.values(plusFilesAll).flat();
|
|
90
|
-
// The earlier we call it the better, so that +require can be used by Vike extensions to depend on new Vike features
|
|
91
|
-
(0, assertExtensions_js_1.assertExtensionsRequire)(plusFiles);
|
|
92
|
-
}
|
|
93
|
-
function getPlusFileFromConfigFile(configFile, isExtensionConfig, locationId, userRootDir) {
|
|
94
|
-
const { fileExports, filePath, extendsFilePaths } = configFile;
|
|
95
|
-
const fileExportsByConfigName = {};
|
|
96
|
-
const pointerImportsByConfigName = {};
|
|
97
|
-
const fileExport = (0, getConfigFileExport_js_1.getConfigFileExport)(fileExports, filePath.filePathToShowToUser);
|
|
98
|
-
Object.entries(fileExport).forEach(([configName, configValue]) => {
|
|
99
|
-
fileExportsByConfigName[configName] = configValue;
|
|
100
|
-
const pointerImport = (0, resolvePointerImport_js_1.resolvePointerImport)(configValue, configFile.filePath, userRootDir, configName);
|
|
101
|
-
if (pointerImport) {
|
|
102
|
-
pointerImportsByConfigName[configName] = {
|
|
103
|
-
...pointerImport,
|
|
104
|
-
fileExportValueLoaded: false,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
const plusFile = {
|
|
109
|
-
locationId,
|
|
110
|
-
filePath,
|
|
111
|
-
fileExportsByConfigName,
|
|
112
|
-
pointerImportsByConfigName,
|
|
113
|
-
isConfigFile: true,
|
|
114
|
-
isExtensionConfig,
|
|
115
|
-
extendsFilePaths,
|
|
116
|
-
};
|
|
117
|
-
return plusFile;
|
|
118
|
-
}
|
|
119
|
-
// Make order deterministic (no other purpose)
|
|
120
|
-
function sortMakeDeterministic(plusFile1, plusFile2) {
|
|
121
|
-
return plusFile1.filePath.filePathAbsoluteVite < plusFile2.filePath.filePathAbsoluteVite ? -1 : 1;
|
|
122
|
-
}
|
|
123
|
-
async function findPlusFiles(userRootDir) {
|
|
124
|
-
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir);
|
|
125
|
-
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
126
|
-
return plusFiles;
|
|
127
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Files loaded at config time:
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.loadPointerImport = loadPointerImport;
|
|
8
|
-
exports.loadValueFile = loadValueFile;
|
|
9
|
-
exports.loadConfigFile = loadConfigFile;
|
|
10
|
-
const utils_js_1 = require("../../utils.js");
|
|
11
|
-
const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
|
|
12
|
-
const resolveVikeConfigInternal_js_1 = require("../resolveVikeConfigInternal.js");
|
|
13
|
-
const assertPlusFileExport_js_1 = require("../../../../shared/page-configs/assertPlusFileExport.js");
|
|
14
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
|
-
const pointerImports_js_1 = require("./pointerImports.js");
|
|
16
|
-
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
17
|
-
const resolvePointerImport_js_1 = require("./resolvePointerImport.js");
|
|
18
|
-
const getConfigDefinedAt_js_1 = require("../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
19
|
-
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
20
|
-
// Load pointer import
|
|
21
|
-
async function loadPointerImport(pointerImport, userRootDir, configName, configDefinitions, esbuildCache) {
|
|
22
|
-
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
23
|
-
if (configName === 'extends')
|
|
24
|
-
return;
|
|
25
|
-
const configDef = (0, resolveVikeConfigInternal_js_1.getConfigDefinitionOptional)(configDefinitions, configName);
|
|
26
|
-
// Only load pointer import if `env.config===true`
|
|
27
|
-
if (!configDef || !shouldBeLoadableAtBuildTime(configDef))
|
|
28
|
-
return;
|
|
29
|
-
const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', configName, pointerImport.fileExportPath);
|
|
30
|
-
(0, utils_js_1.assertUsage)(pointerImport.fileExportPath.filePathAbsoluteFilesystem, `${configDefinedAt} cannot be defined over an aliased import`);
|
|
31
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(pointerImport.fileExportPath, userRootDir, false, esbuildCache);
|
|
32
|
-
const fileExportValue = fileExports[pointerImport.fileExportPath.fileExportName];
|
|
33
|
-
pointerImport.fileExportValueLoaded = true;
|
|
34
|
-
(0, utils_js_1.assert)(pointerImport.fileExportValueLoaded);
|
|
35
|
-
pointerImport.fileExportValue = fileExportValue;
|
|
36
|
-
}
|
|
37
|
-
// Load +{configName}.js
|
|
38
|
-
async function loadValueFile(interfaceValueFile, configDefinitions, userRootDir, esbuildCache) {
|
|
39
|
-
const { configName } = interfaceValueFile;
|
|
40
|
-
const configDef = (0, resolveVikeConfigInternal_js_1.getConfigDefinitionOptional)(configDefinitions, configName);
|
|
41
|
-
// Only load value files with `env.config===true`
|
|
42
|
-
if (!configDef || !shouldBeLoadableAtBuildTime(configDef))
|
|
43
|
-
return;
|
|
44
|
-
interfaceValueFile.isNotLoaded = false;
|
|
45
|
-
(0, utils_js_1.assert)(!interfaceValueFile.isNotLoaded);
|
|
46
|
-
interfaceValueFile.fileExportsByConfigName = {};
|
|
47
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(interfaceValueFile.filePath, userRootDir, false, esbuildCache);
|
|
48
|
-
const { filePathToShowToUser } = interfaceValueFile.filePath;
|
|
49
|
-
(0, assertPlusFileExport_js_1.assertPlusFileExport)(fileExports, filePathToShowToUser, configName);
|
|
50
|
-
Object.entries(fileExports).forEach(([exportName, configValue]) => {
|
|
51
|
-
const configName_ = exportName === 'default' ? configName : exportName;
|
|
52
|
-
interfaceValueFile.fileExportsByConfigName[configName_] = configValue;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
// Load +config.js, including all its extends pointer imports
|
|
56
|
-
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig, esbuildCache) {
|
|
57
|
-
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
58
|
-
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
59
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, userRootDir, isExtensionConfig, esbuildCache);
|
|
60
|
-
const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [...visited, filePathAbsoluteFilesystem], esbuildCache);
|
|
61
|
-
const configFile = {
|
|
62
|
-
fileExports,
|
|
63
|
-
filePath: configFilePath,
|
|
64
|
-
extendsFilePaths,
|
|
65
|
-
};
|
|
66
|
-
return { configFile, extendsConfigs };
|
|
67
|
-
}
|
|
68
|
-
function assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem) {
|
|
69
|
-
const idx = visited.indexOf(filePathAbsoluteFilesystem);
|
|
70
|
-
if (idx === -1)
|
|
71
|
-
return;
|
|
72
|
-
const loop = visited.slice(idx);
|
|
73
|
-
(0, utils_js_1.assert)(loop[0] === filePathAbsoluteFilesystem);
|
|
74
|
-
(0, utils_js_1.assertUsage)(idx === -1, `Infinite extends loop ${[...loop, filePathAbsoluteFilesystem].join('>')}`);
|
|
75
|
-
}
|
|
76
|
-
async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir, visited, esbuildCache) {
|
|
77
|
-
const { extendsPointerImportData, extendsConfigs } = getExtendsPointerImportData(configFileExports, configFilePath);
|
|
78
|
-
const extendsConfigFiles = [];
|
|
79
|
-
extendsPointerImportData.map((pointerImportData) => {
|
|
80
|
-
const filePath = (0, resolvePointerImport_js_1.resolvePointerImportData)(pointerImportData, configFilePath, userRootDir);
|
|
81
|
-
(0, utils_js_1.assert)(filePath.filePathAbsoluteFilesystem);
|
|
82
|
-
extendsConfigFiles.push(filePath);
|
|
83
|
-
});
|
|
84
|
-
const results = await Promise.all(extendsConfigFiles.map(async (configFilePath) => await loadConfigFile(configFilePath, userRootDir, visited, true, esbuildCache)));
|
|
85
|
-
results.forEach((result) => {
|
|
86
|
-
extendsConfigs.push(result.configFile);
|
|
87
|
-
extendsConfigs.push(...result.extendsConfigs);
|
|
88
|
-
});
|
|
89
|
-
const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
|
|
90
|
-
return { extendsConfigs, extendsFilePaths };
|
|
91
|
-
}
|
|
92
|
-
function getExtendsPointerImportData(configFileExports, configFilePath) {
|
|
93
|
-
const { filePathToShowToUser } = configFilePath;
|
|
94
|
-
const configFileExport = (0, getConfigFileExport_js_1.getConfigFileExport)(configFileExports, filePathToShowToUser);
|
|
95
|
-
const extendsConfigs = [];
|
|
96
|
-
const extendsPointerImportData = [];
|
|
97
|
-
if ('extends' in configFileExport) {
|
|
98
|
-
const extendsValue = configFileExport.extends;
|
|
99
|
-
const extendList = [];
|
|
100
|
-
const wrongUsage = `${filePathToShowToUser} sets the config ${picocolors_1.default.cyan('extends')} to an invalid value, see https://vike.dev/extends`;
|
|
101
|
-
if (typeof extendsValue === 'string') {
|
|
102
|
-
extendList.push(extendsValue);
|
|
103
|
-
}
|
|
104
|
-
else if ((0, utils_js_1.isArrayOfStrings)(extendsValue)) {
|
|
105
|
-
extendList.push(...extendsValue);
|
|
106
|
-
}
|
|
107
|
-
else if ((0, utils_js_1.isObject)(extendsValue)) {
|
|
108
|
-
/* If we want to implement this then we need to make filePath optional
|
|
109
|
-
extendsConfigs.push({
|
|
110
|
-
fileExports: extendsValue,
|
|
111
|
-
filePath: null,
|
|
112
|
-
})
|
|
113
|
-
*/
|
|
114
|
-
(0, utils_js_1.assertUsage)(false, wrongUsage);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
(0, utils_js_1.assertUsage)(false, wrongUsage);
|
|
118
|
-
}
|
|
119
|
-
extendsPointerImportData.push(...extendList.map((importString) => {
|
|
120
|
-
const pointerImportData = (0, pointerImports_js_1.parsePointerImportData)(importString);
|
|
121
|
-
(0, utils_js_1.assertUsage)(pointerImportData, wrongUsage);
|
|
122
|
-
return pointerImportData;
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
return { extendsPointerImportData, extendsConfigs };
|
|
126
|
-
}
|
|
127
|
-
function shouldBeLoadableAtBuildTime(configDef) {
|
|
128
|
-
return !!configDef.env.config && !configDef._valueIsFilePath;
|
|
129
|
-
}
|
|
@@ -1,195 +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.transformPointerImports = transformPointerImports;
|
|
7
|
-
exports.parsePointerImportData = parsePointerImportData;
|
|
8
|
-
exports.isPointerImportData = isPointerImportData;
|
|
9
|
-
exports.assertPointerImportPath = assertPointerImportPath;
|
|
10
|
-
// Playground: https://github.com/brillout/acorn-playground
|
|
11
|
-
// Notes about `with { type: 'pointer' }`
|
|
12
|
-
// - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
13
|
-
// - Acorn support for import attributes: https://github.com/acornjs/acorn/issues/983
|
|
14
|
-
// - Acorn plugin: https://github.com/acornjs/acorn/issues/983
|
|
15
|
-
// - Isn't stage 4 yet: https://github.com/tc39/proposal-import-attributes
|
|
16
|
-
// - Using a import path suffix such as `import { Layout } from './Layout?real` breaks TypeScript, and TypeScript isn't working on supporting query params: https://github.com/microsoft/TypeScript/issues/10988#issuecomment-867135453
|
|
17
|
-
// - Node.js >=21 supports import attributes: https://nodejs.org/api/esm.html#import-attributes
|
|
18
|
-
// - Esbuid supports
|
|
19
|
-
// - Blocker: https://github.com/evanw/esbuild/issues/3646
|
|
20
|
-
// - Ugly hack to make it work: https://github.com/brillout/esbuild-playground/tree/experiment/import-attribute
|
|
21
|
-
// - Discussion with esbuild maintainer: https://github.com/evanw/esbuild/issues/3384
|
|
22
|
-
// - Using a magic comment `// @vike-real-import` is probably a bad idea:
|
|
23
|
-
// - Esbuild removes comments: https://github.com/evanw/esbuild/issues/1439#issuecomment-877656182
|
|
24
|
-
// - Using source maps to track these magic comments is brittle (source maps can easily break)
|
|
25
|
-
const acorn_1 = require("acorn");
|
|
26
|
-
const utils_js_1 = require("../../utils.js");
|
|
27
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
28
|
-
function transformPointerImports(code, filePathToShowToUser2, pointerImports,
|
|
29
|
-
// For ./transformPointerImports.spec.ts
|
|
30
|
-
skipWarnings) {
|
|
31
|
-
const spliceOperations = [];
|
|
32
|
-
// Performance trick
|
|
33
|
-
if (!code.includes('import'))
|
|
34
|
-
return null;
|
|
35
|
-
const imports = getImports(code);
|
|
36
|
-
if (imports.length === 0)
|
|
37
|
-
return null;
|
|
38
|
-
imports.forEach((node) => {
|
|
39
|
-
if (node.type !== 'ImportDeclaration')
|
|
40
|
-
return;
|
|
41
|
-
const importPath = node.source.value;
|
|
42
|
-
(0, utils_js_1.assert)(typeof importPath === 'string');
|
|
43
|
-
if (pointerImports !== 'all') {
|
|
44
|
-
(0, utils_js_1.assert)(importPath in pointerImports);
|
|
45
|
-
const isPointerImport = pointerImports[importPath];
|
|
46
|
-
(0, utils_js_1.assert)(isPointerImport === true || isPointerImport === false);
|
|
47
|
-
if (!isPointerImport)
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const { start, end } = node;
|
|
51
|
-
const importStatementCode = code.slice(start, end);
|
|
52
|
-
/* Pointer import without importing any value => doesn't make sense and doesn't have any effect.
|
|
53
|
-
```js
|
|
54
|
-
// Useless
|
|
55
|
-
import './some.css'
|
|
56
|
-
// Useless
|
|
57
|
-
import './Layout.jsx'
|
|
58
|
-
``` */
|
|
59
|
-
if (node.specifiers.length === 0) {
|
|
60
|
-
const isWarning = !utils_js_1.styleFileRE.test(importPath);
|
|
61
|
-
let quote = indent(importStatementCode);
|
|
62
|
-
if (isWarning) {
|
|
63
|
-
quote = picocolors_1.default.cyan(quote);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
quote = picocolors_1.default.bold(picocolors_1.default.red(quote));
|
|
67
|
-
}
|
|
68
|
-
const errMsg = [
|
|
69
|
-
`The following import in ${filePathToShowToUser2} has no effect:`,
|
|
70
|
-
quote,
|
|
71
|
-
'See https://vike.dev/config#pointer-imports',
|
|
72
|
-
].join('\n');
|
|
73
|
-
if (!skipWarnings) {
|
|
74
|
-
if (!isWarning) {
|
|
75
|
-
(0, utils_js_1.assertUsage)(false, errMsg);
|
|
76
|
-
}
|
|
77
|
-
(0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
let replacement = '';
|
|
81
|
-
node.specifiers.forEach((specifier) => {
|
|
82
|
-
(0, utils_js_1.assert)(specifier.type === 'ImportSpecifier' ||
|
|
83
|
-
specifier.type === 'ImportDefaultSpecifier' ||
|
|
84
|
-
specifier.type === 'ImportNamespaceSpecifier');
|
|
85
|
-
const importLocalName = specifier.local.name;
|
|
86
|
-
const exportName = (() => {
|
|
87
|
-
if (specifier.type === 'ImportDefaultSpecifier')
|
|
88
|
-
return 'default';
|
|
89
|
-
if (specifier.type === 'ImportNamespaceSpecifier')
|
|
90
|
-
return '*';
|
|
91
|
-
{
|
|
92
|
-
const imported = specifier.imported;
|
|
93
|
-
if (imported)
|
|
94
|
-
return imported.name;
|
|
95
|
-
}
|
|
96
|
-
return importLocalName;
|
|
97
|
-
})();
|
|
98
|
-
const importString = serializePointerImportData({ importPath, exportName, importStringWasGenerated: true });
|
|
99
|
-
replacement += `const ${importLocalName} = '${importString}';`;
|
|
100
|
-
});
|
|
101
|
-
spliceOperations.push({
|
|
102
|
-
start,
|
|
103
|
-
end,
|
|
104
|
-
replacement,
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
const codeMod = spliceMany(code, spliceOperations);
|
|
108
|
-
return codeMod;
|
|
109
|
-
}
|
|
110
|
-
function getImports(code) {
|
|
111
|
-
const { body } = (0, acorn_1.parse)(code, {
|
|
112
|
-
ecmaVersion: 'latest',
|
|
113
|
-
sourceType: 'module',
|
|
114
|
-
// https://github.com/acornjs/acorn/issues/1136
|
|
115
|
-
});
|
|
116
|
-
const imports = [];
|
|
117
|
-
body.forEach((node) => {
|
|
118
|
-
if (node.type === 'ImportDeclaration')
|
|
119
|
-
imports.push(node);
|
|
120
|
-
});
|
|
121
|
-
return imports;
|
|
122
|
-
}
|
|
123
|
-
const import_ = 'import';
|
|
124
|
-
const SEP = ':';
|
|
125
|
-
const zeroWidthSpace = '\u200b';
|
|
126
|
-
function serializePointerImportData({ importPath, exportName, importStringWasGenerated, }) {
|
|
127
|
-
const tag = importStringWasGenerated ? zeroWidthSpace : '';
|
|
128
|
-
// `import:${importPath}:${importPath}`
|
|
129
|
-
return `${tag}${import_}${SEP}${importPath}${SEP}${exportName}`;
|
|
130
|
-
}
|
|
131
|
-
function isPointerImportData(str) {
|
|
132
|
-
return str.startsWith(import_ + SEP) || str.startsWith(zeroWidthSpace + import_ + SEP);
|
|
133
|
-
}
|
|
134
|
-
function parsePointerImportData(importString) {
|
|
135
|
-
if (!isPointerImportData(importString)) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
let importStringWasGenerated = false;
|
|
139
|
-
if (importString.startsWith(zeroWidthSpace)) {
|
|
140
|
-
importStringWasGenerated = true;
|
|
141
|
-
(0, utils_js_1.assert)(zeroWidthSpace.length === 1);
|
|
142
|
-
importString = importString.slice(1);
|
|
143
|
-
}
|
|
144
|
-
const parts = importString.split(SEP).slice(1);
|
|
145
|
-
if (!importStringWasGenerated && parts.length === 1) {
|
|
146
|
-
const exportName = 'default';
|
|
147
|
-
const importPath = parts[0];
|
|
148
|
-
return { importPath, exportName, importStringWasGenerated, importString };
|
|
149
|
-
}
|
|
150
|
-
(0, utils_js_1.assert)(parts.length >= 2);
|
|
151
|
-
const exportName = parts[parts.length - 1];
|
|
152
|
-
const importPath = parts.slice(0, -1).join(SEP);
|
|
153
|
-
if (importPath.startsWith('.') && !(importPath.startsWith('./') || importPath.startsWith('../'))) {
|
|
154
|
-
(0, utils_js_1.assert)(!importStringWasGenerated);
|
|
155
|
-
(0, utils_js_1.assertUsage)(false, `Invalid relative import path ${picocolors_1.default.code(importPath)} defined by ${picocolors_1.default.code(JSON.stringify(importString))} because it should start with ${picocolors_1.default.code('./')} or ${picocolors_1.default.code('../')}, or use an npm package import instead.`);
|
|
156
|
-
}
|
|
157
|
-
assertPointerImportPath(importPath);
|
|
158
|
-
return { importPath, exportName, importStringWasGenerated, importString };
|
|
159
|
-
}
|
|
160
|
-
// `importPath` is one of the following:
|
|
161
|
-
// - A relative import path
|
|
162
|
-
// - An npm package import
|
|
163
|
-
// - A filesystem absolute path, see transpileWithEsbuild()
|
|
164
|
-
function assertPointerImportPath(importPath) {
|
|
165
|
-
return (0, utils_js_1.isImportPath)(importPath) || (0, utils_js_1.isFilePathAbsolute)(importPath);
|
|
166
|
-
}
|
|
167
|
-
function spliceMany(str, operations) {
|
|
168
|
-
let strMod = '';
|
|
169
|
-
let endPrev;
|
|
170
|
-
operations.forEach(({ start, end, replacement }) => {
|
|
171
|
-
if (endPrev !== undefined) {
|
|
172
|
-
(0, utils_js_1.assert)(endPrev < start);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
endPrev = 0;
|
|
176
|
-
}
|
|
177
|
-
const replaced = str.slice(start, end);
|
|
178
|
-
strMod +=
|
|
179
|
-
str.slice(endPrev, start) +
|
|
180
|
-
replacement +
|
|
181
|
-
// Preserve number of lines for source map
|
|
182
|
-
Array(replaced.split('\n').length - replacement.split('\n').length)
|
|
183
|
-
.fill('\n')
|
|
184
|
-
.join('');
|
|
185
|
-
endPrev = end;
|
|
186
|
-
});
|
|
187
|
-
strMod += str.slice(endPrev, str.length);
|
|
188
|
-
return strMod;
|
|
189
|
-
}
|
|
190
|
-
function indent(str) {
|
|
191
|
-
return str
|
|
192
|
-
.split('\n')
|
|
193
|
-
.map((s) => ` ${s}`)
|
|
194
|
-
.join('\n');
|
|
195
|
-
}
|