vike 0.4.195 → 0.4.196
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/LICENSE.md +9 -0
- package/dist/cjs/__internal/index.js +3 -4
- package/dist/cjs/node/cli/onLoad.js +1 -2
- package/dist/cjs/node/createPageRenderer.js +1 -2
- package/dist/cjs/node/plugin/index.js +3 -3
- package/dist/cjs/node/plugin/onLoad.js +1 -2
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +1 -2
- package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -2
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +2 -3
- package/dist/cjs/node/plugin/plugins/buildConfig.js +4 -4
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +1 -2
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -2
- package/dist/cjs/node/plugin/plugins/config/assertVikeConfig.js +1 -2
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -2
- package/dist/cjs/node/plugin/plugins/config/pickFirst.js +1 -2
- package/dist/cjs/node/plugin/plugins/config/resolveBase.js +2 -3
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -2
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -2
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -2
- package/dist/cjs/node/plugin/plugins/distFileNames.js +1 -2
- package/dist/cjs/node/plugin/plugins/envVars.js +1 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +3 -3
- package/dist/cjs/node/plugin/plugins/fileEnv.js +109 -88
- package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +1 -2
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +2 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/addImportStatement.js +1 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +1 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +2 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +1 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +6 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +8 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +3 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +3 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +5 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +1 -2
- package/dist/cjs/node/plugin/plugins/packageJsonFile.js +1 -2
- package/dist/cjs/node/plugin/plugins/previewConfig.js +1 -2
- package/dist/cjs/node/plugin/plugins/removeRequireHookPlugin.js +1 -2
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -2
- package/dist/cjs/node/plugin/plugins/suppressRollupWarning.js +1 -2
- package/dist/cjs/node/plugin/plugins/workaroundCssModuleHmr.js +1 -2
- package/dist/cjs/node/plugin/resolveClientEntriesDev.js +1 -2
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +1 -2
- package/dist/cjs/node/plugin/shared/findPageFiles.js +1 -2
- package/dist/cjs/node/plugin/shared/getAssetsDir.js +1 -2
- package/dist/cjs/node/plugin/shared/getFilePath.js +8 -9
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +2 -3
- package/dist/cjs/node/plugin/shared/isAsset.js +1 -2
- package/dist/cjs/node/plugin/shared/isViteCliCall.js +2 -3
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +4 -5
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +4 -5
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +6 -7
- package/dist/cjs/node/plugin/shared/loggerVite/removeSuperfluousViteLog.js +3 -4
- package/dist/cjs/node/plugin/shared/loggerVite.js +1 -2
- package/dist/cjs/node/plugin/shared/parseEsModule.js +2 -3
- package/dist/cjs/node/plugin/shared/rollupIsEsm.js +1 -2
- package/dist/cjs/node/plugin/shared/rollupSourceMap.js +2 -3
- package/dist/cjs/node/prerender/runPrerender.js +4 -5
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +2 -3
- package/dist/cjs/node/runtime/globalContext.js +13 -14
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -2
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +1 -2
- package/dist/cjs/node/runtime/html/injectAssets/inferHtmlTags.js +4 -4
- package/dist/cjs/node/runtime/html/injectAssets/injectAssets__public.js +1 -2
- package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +6 -7
- package/dist/cjs/node/runtime/html/injectAssets/mergeScriptTags.js +1 -2
- package/dist/cjs/node/runtime/html/injectAssets/sanitizeJson.js +1 -2
- package/dist/cjs/node/runtime/html/injectAssets.js +2 -3
- package/dist/cjs/node/runtime/html/renderHtml.js +5 -6
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +2 -3
- package/dist/cjs/node/runtime/html/stream/react-streaming.js +3 -4
- package/dist/cjs/node/runtime/html/stream.js +21 -22
- package/dist/cjs/node/runtime/onLoad.js +1 -2
- package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +1 -2
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +5 -6
- package/dist/cjs/node/runtime/renderPage/assertArguments.js +1 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +1 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +1 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +19 -8
- package/dist/cjs/node/runtime/renderPage/debugPageFiles.js +1 -2
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +1 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +1 -2
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +1 -2
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -3
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +1 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +1 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +1 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +1 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +2 -3
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +2 -3
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +1 -2
- package/dist/cjs/node/runtime/renderPage/inferMediaType.js +1 -2
- package/dist/cjs/node/runtime/renderPage/isNewError.js +2 -3
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -2
- package/dist/cjs/node/runtime/renderPage/log404/index.js +2 -3
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +2 -3
- package/dist/cjs/node/runtime/renderPage/loggerProd.js +2 -3
- package/dist/cjs/node/runtime/renderPage/loggerRuntime.js +2 -2
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +1 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +5 -6
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +2 -3
- package/dist/cjs/node/runtime/renderPage.js +8 -8
- package/dist/cjs/node/shared/assertPluginManifest.js +1 -2
- package/dist/cjs/node/shared/assertRuntimeManifest.js +1 -2
- package/dist/cjs/node/shared/assertV1Design.js +1 -2
- package/dist/cjs/node/shared/extractAssetsQuery.js +2 -3
- package/dist/cjs/node/shared/getConfigVike.js +1 -2
- package/dist/cjs/node/shared/isErrorDebug.js +1 -2
- package/dist/cjs/node/shared/prependEntriesDir.js +1 -2
- package/dist/cjs/node/shared/virtual-files/virtualFileImportUserCode.js +2 -2
- package/dist/cjs/node/shared/virtual-files/virtualFilePageConfigValuesAll.js +2 -3
- package/dist/cjs/shared/addIs404ToPageProps.js +1 -2
- package/dist/cjs/shared/assertHookReturnedObject.js +1 -2
- package/dist/cjs/shared/assertOnBeforeRenderHookReturn.js +1 -2
- package/dist/cjs/shared/assertPageContextProvidedByUser.js +1 -2
- package/dist/cjs/shared/assertPageFilePath.js +1 -2
- package/dist/cjs/shared/determinePageIdOld.js +1 -2
- package/dist/cjs/shared/error-page.js +3 -4
- package/dist/cjs/shared/getPageContextRequestUrl.js +2 -2
- package/dist/cjs/shared/getPageContextUrlComputed.js +2 -3
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +4 -5
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +1 -2
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +2 -3
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/getExportNames.js +1 -2
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +2 -3
- package/dist/cjs/shared/getPageFiles/analyzePageServerSide.js +1 -2
- package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +3 -3
- package/dist/cjs/shared/getPageFiles/fileTypes.js +3 -3
- package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +2 -3
- package/dist/cjs/shared/getPageFiles/getExports.js +1 -2
- package/dist/cjs/shared/getPageFiles/getPageFileObject.js +1 -2
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +1 -2
- package/dist/cjs/shared/getPageFiles/setPageFiles.js +3 -4
- package/dist/cjs/shared/hooks/executeHook.js +4 -5
- package/dist/cjs/shared/hooks/getHook.js +6 -7
- package/dist/cjs/shared/modifyUrl.js +1 -2
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -2
- package/dist/cjs/shared/page-configs/findPageConfig.js +1 -2
- package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +3 -4
- package/dist/cjs/shared/page-configs/getConfigValue.js +2 -3
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +1 -2
- package/dist/cjs/shared/page-configs/getExportPath.js +1 -2
- package/dist/cjs/shared/page-configs/helpers.js +3 -4
- package/dist/cjs/shared/page-configs/loadConfigValues.js +1 -2
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -3
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +1 -2
- package/dist/cjs/shared/route/abort.js +9 -10
- package/dist/cjs/shared/route/debug.js +1 -2
- package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +1 -2
- package/dist/cjs/shared/route/executeGuardHook.js +1 -2
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -2
- package/dist/cjs/shared/route/index.js +1 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -2
- package/dist/cjs/shared/route/resolvePrecedence.js +1 -2
- package/dist/cjs/shared/route/resolveRoute.js +1 -2
- package/dist/cjs/shared/route/resolveRouteFunction.js +4 -5
- package/dist/cjs/shared/route/resolveRouteString.js +6 -7
- package/dist/cjs/shared/route/resolveUrlPathname.js +1 -2
- package/dist/cjs/shared/sortPageContext.js +1 -2
- package/dist/cjs/types/defineConfig.js +1 -2
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +10 -11
- package/dist/cjs/utils/assertIsBrowser.js +1 -2
- package/dist/cjs/utils/assertIsNotBrowser.js +1 -2
- package/dist/cjs/utils/assertIsNotProductionRuntime.js +6 -6
- package/dist/cjs/utils/assertKeys.js +1 -2
- package/dist/cjs/utils/assertNodeEnv.js +5 -6
- package/dist/cjs/utils/assertNodeVersion.js +1 -2
- package/dist/cjs/utils/assertRoutingType.js +3 -4
- package/dist/cjs/utils/assertSingleInstance.js +3 -4
- package/dist/cjs/utils/assertVersion.js +2 -3
- package/dist/cjs/utils/augmentType.js +1 -2
- package/dist/cjs/utils/capitalizeFirstLetter.js +1 -2
- package/dist/cjs/utils/cast.js +2 -3
- package/dist/cjs/utils/changeEnumerable.js +1 -2
- package/dist/cjs/utils/checkType.js +2 -3
- package/dist/cjs/utils/compareString.js +1 -2
- package/dist/cjs/utils/createErrorWithCleanStackTrace.js +1 -2
- package/dist/cjs/utils/debug.js +2 -3
- package/dist/cjs/utils/deepEqual.js +1 -2
- package/dist/cjs/utils/escapeHtml.js +1 -2
- package/dist/cjs/utils/escapeRegex.js +1 -2
- package/dist/cjs/utils/filesystemPathHandling.js +2 -3
- package/dist/cjs/utils/findFile.js +1 -2
- package/dist/cjs/utils/findPackageJson.js +1 -2
- package/dist/cjs/utils/formatHintLog.js +1 -2
- package/dist/cjs/utils/freezePartial.js +1 -2
- package/dist/cjs/utils/genPromise.js +1 -2
- package/dist/cjs/utils/getCurrentUrl.js +1 -2
- package/dist/cjs/utils/getFileExtension.js +1 -2
- package/dist/cjs/utils/getGlobalObject.js +2 -3
- package/dist/cjs/utils/getMostSimilar.js +1 -2
- package/dist/cjs/utils/getOutDirs.js +2 -3
- package/dist/cjs/utils/getPropAccessNotation.js +1 -2
- package/dist/cjs/utils/getRandomId.js +1 -2
- package/dist/cjs/utils/getTerminWidth.js +1 -2
- package/dist/cjs/utils/getValuePrintable.js +1 -2
- package/dist/cjs/utils/hasProp.js +1 -2
- package/dist/cjs/utils/humanizeTime.js +1 -2
- package/dist/cjs/utils/includes.js +1 -2
- package/dist/cjs/utils/injectRollupInputs.js +2 -3
- package/dist/cjs/utils/isArray.js +1 -2
- package/dist/cjs/utils/isArrayOfStrings.js +1 -2
- package/dist/cjs/utils/isBrowser.js +1 -2
- package/dist/cjs/utils/isCallable.js +1 -2
- package/dist/cjs/utils/isDev.js +2 -3
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -3
- package/dist/cjs/utils/isHtml.js +1 -2
- package/dist/cjs/utils/isNodeJS.js +1 -2
- package/dist/cjs/utils/isNpmPackage.js +5 -6
- package/dist/cjs/utils/isObject.js +1 -2
- package/dist/cjs/utils/isObjectOfStrings.js +1 -2
- package/dist/cjs/utils/isObjectWithKeys.js +1 -2
- package/dist/cjs/utils/isPlainObject.js +1 -2
- package/dist/cjs/utils/isPromise.js +1 -2
- package/dist/cjs/utils/isPropertyGetter.js +1 -2
- package/dist/cjs/utils/isReact.js +1 -2
- package/dist/cjs/utils/isSameErrorMessage.js +1 -2
- package/dist/cjs/utils/isScriptFile.js +4 -4
- package/dist/cjs/utils/isVikeReactApp.js +1 -2
- package/dist/cjs/utils/isVitest.js +1 -2
- package/dist/cjs/utils/joinEnglish.js +1 -2
- package/dist/cjs/utils/normalizeHeaders.js +1 -2
- package/dist/cjs/utils/objectAssign.js +1 -2
- package/dist/cjs/utils/objectDefineProperty.js +1 -2
- package/dist/cjs/utils/objectEntries.js +1 -2
- package/dist/cjs/utils/objectEntriesForEach.js +1 -2
- package/dist/cjs/utils/objectFromEntries.js +1 -2
- package/dist/cjs/utils/objectKeys.js +1 -2
- package/dist/cjs/utils/onPageVisibilityChange.js +2 -3
- package/dist/cjs/utils/pLimit.js +1 -2
- package/dist/cjs/utils/parseUrl-extras.js +8 -9
- package/dist/cjs/utils/parseUrl.js +11 -12
- package/dist/cjs/utils/path-shim.js +1 -2
- package/dist/cjs/utils/redirectHard.js +1 -2
- package/dist/cjs/utils/removeEmptyLines.js +1 -2
- package/dist/cjs/utils/removeFileExtention.js +1 -2
- package/dist/cjs/utils/requireResolve.js +1 -2
- package/dist/cjs/utils/sleep.js +1 -2
- package/dist/cjs/utils/slice.js +1 -2
- package/dist/cjs/utils/sorter.js +5 -6
- package/dist/cjs/utils/stringifyStringArray.js +1 -2
- package/dist/cjs/utils/stripAnsi.js +1 -2
- package/dist/cjs/utils/throttle.js +1 -2
- package/dist/cjs/utils/trimWithAnsi.js +2 -3
- package/dist/cjs/utils/truncateString.js +1 -2
- package/dist/cjs/utils/unique.js +1 -2
- package/dist/cjs/utils/urlToFile.js +2 -2
- package/dist/cjs/utils/virtual-files.js +3 -4
- package/dist/cjs/utils/viteIsSSR.js +2 -3
- package/dist/cjs/utils/warnIfErrorIsNotObject.js +1 -2
- package/dist/esm/client/client-routing-runtime/installClientRouter.js +2 -4
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +2 -2
- package/dist/esm/client/client-routing-runtime/navigate.js +3 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +2 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +39 -12
- package/dist/esm/client/client-routing-runtime/skipLink.js +1 -1
- package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/utils.js +1 -0
- package/dist/esm/node/plugin/plugins/fileEnv.js +109 -87
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/debug.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +6 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +1 -2
- package/dist/esm/node/runtime/html/stream.d.ts +0 -1
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +5 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +15 -3
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +0 -1
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +6 -6
- package/dist/esm/node/runtime/renderPage.js +6 -6
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/page-configs/Config.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/debugGlob.d.ts +2 -2
- package/dist/esm/utils/genPromise.d.ts +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +6 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throttle =
|
|
3
|
+
exports.throttle = throttle;
|
|
4
4
|
function throttle(func, waitTime) {
|
|
5
5
|
let isQueued = false;
|
|
6
6
|
return () => {
|
|
@@ -13,4 +13,3 @@ function throttle(func, waitTime) {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
exports.throttle = throttle;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.trimWithAnsi = trimWithAnsi;
|
|
4
|
+
exports.trimWithAnsiTrailOnly = trimWithAnsiTrailOnly;
|
|
4
5
|
const assert_js_1 = require("./assert.js");
|
|
5
6
|
const stripAnsi_js_1 = require("./stripAnsi.js");
|
|
6
7
|
const whitespaceRegex = /(\s+)/; // Capturing parathesis so that split preserves seperator
|
|
@@ -10,14 +11,12 @@ function trimWithAnsi(str) {
|
|
|
10
11
|
str = trimWithAnsiTrailOnly(str);
|
|
11
12
|
return str;
|
|
12
13
|
}
|
|
13
|
-
exports.trimWithAnsi = trimWithAnsi;
|
|
14
14
|
function trimWithAnsiHead(str) {
|
|
15
15
|
return trim(str, false);
|
|
16
16
|
}
|
|
17
17
|
function trimWithAnsiTrailOnly(str) {
|
|
18
18
|
return trim(str, true);
|
|
19
19
|
}
|
|
20
|
-
exports.trimWithAnsiTrailOnly = trimWithAnsiTrailOnly;
|
|
21
20
|
function trim(str, trail) {
|
|
22
21
|
let parts = str.split(whitespaceRegex);
|
|
23
22
|
if (trail)
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.truncateString =
|
|
6
|
+
exports.truncateString = truncateString;
|
|
7
7
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
8
|
const assert_js_1 = require("./assert.js");
|
|
9
9
|
function truncateString(str, lenMax) {
|
|
@@ -21,4 +21,3 @@ function truncateString(str, lenMax) {
|
|
|
21
21
|
return str;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
exports.truncateString = truncateString;
|
package/dist/cjs/utils/unique.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.baseServer =
|
|
3
|
+
exports.baseServer = void 0;
|
|
4
|
+
exports.urlToFile = urlToFile;
|
|
4
5
|
const assert_js_1 = require("./assert.js");
|
|
5
6
|
const parseUrl_js_1 = require("./parseUrl.js");
|
|
6
7
|
const slice_js_1 = require("./slice.js");
|
|
@@ -33,4 +34,3 @@ function urlToFile(url, fileExtension, doNotCreateExtraDirectory) {
|
|
|
33
34
|
const fileUrl = `${pathnameModified}${searchOriginal || ''}${hashOriginal || ''}`;
|
|
34
35
|
return fileUrl;
|
|
35
36
|
}
|
|
36
|
-
exports.urlToFile = urlToFile;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isVirtualFileId = isVirtualFileId;
|
|
4
|
+
exports.getVirtualFileId = getVirtualFileId;
|
|
5
|
+
exports.resolveVirtualFileId = resolveVirtualFileId;
|
|
4
6
|
const assert_js_1 = require("./assert.js");
|
|
5
7
|
const idBase = 'virtual:vike:';
|
|
6
8
|
// https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
|
|
@@ -13,7 +15,6 @@ function isVirtualFileId(id) {
|
|
|
13
15
|
(0, assert_js_1.assert)(!id.includes(idBase));
|
|
14
16
|
return false;
|
|
15
17
|
}
|
|
16
|
-
exports.isVirtualFileId = isVirtualFileId;
|
|
17
18
|
function getVirtualFileId(id) {
|
|
18
19
|
if (id.startsWith(tag)) {
|
|
19
20
|
id = id.slice(tag.length);
|
|
@@ -21,7 +22,6 @@ function getVirtualFileId(id) {
|
|
|
21
22
|
(0, assert_js_1.assert)(!id.startsWith(tag));
|
|
22
23
|
return id;
|
|
23
24
|
}
|
|
24
|
-
exports.getVirtualFileId = getVirtualFileId;
|
|
25
25
|
function resolveVirtualFileId(id) {
|
|
26
26
|
(0, assert_js_1.assert)(isVirtualFileId(id));
|
|
27
27
|
if (!id.startsWith(tag)) {
|
|
@@ -30,4 +30,3 @@ function resolveVirtualFileId(id) {
|
|
|
30
30
|
(0, assert_js_1.assert)(id.startsWith(tag));
|
|
31
31
|
return id;
|
|
32
32
|
}
|
|
33
|
-
exports.resolveVirtualFileId = resolveVirtualFileId;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.viteIsSSR = viteIsSSR;
|
|
4
|
+
exports.viteIsSSR_options = viteIsSSR_options;
|
|
4
5
|
const assert_js_1 = require("./assert.js");
|
|
5
6
|
const isObject_js_1 = require("./isObject.js");
|
|
6
7
|
function viteIsSSR(config) {
|
|
7
8
|
return !!config?.build?.ssr;
|
|
8
9
|
}
|
|
9
|
-
exports.viteIsSSR = viteIsSSR;
|
|
10
10
|
// https://github.com/vitejs/vite/discussions/5109#discussioncomment-1450726
|
|
11
11
|
function viteIsSSR_options(options) {
|
|
12
12
|
if (options === undefined) {
|
|
@@ -20,4 +20,3 @@ function viteIsSSR_options(options) {
|
|
|
20
20
|
}
|
|
21
21
|
(0, assert_js_1.assert)(false);
|
|
22
22
|
}
|
|
23
|
-
exports.viteIsSSR_options = viteIsSSR_options;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.warnIfErrorIsNotObject =
|
|
6
|
+
exports.warnIfErrorIsNotObject = warnIfErrorIsNotObject;
|
|
7
7
|
const assert_js_1 = require("./assert.js");
|
|
8
8
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
9
9
|
const isObject_js_1 = require("./isObject.js");
|
|
@@ -21,4 +21,3 @@ function warnIfErrorIsNotObject(err) {
|
|
|
21
21
|
(0, assert_js_1.assertWarning)(false, `One of your hooks threw an error ${picocolors_1.default.cyan('throw someValue')} but ${picocolors_1.default.cyan('someValue')} isn't an object (it's ${picocolors_1.default.cyan(`typeof someValue === ${typeof err}`)} instead). Make sure thrown values are always wrapped with ${picocolors_1.default.cyan('new Error()')}, in other words: ${picocolors_1.default.cyan('throw someValue')} should be replaced with ${picocolors_1.default.cyan('throw new Error(someValue)')}. The thrown value is printed above.`, { onlyOnce: false });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
exports.warnIfErrorIsNotObject = warnIfErrorIsNotObject;
|
|
@@ -16,15 +16,13 @@ async function installClientRouter() {
|
|
|
16
16
|
// Preserve stack track
|
|
17
17
|
await renderPromise;
|
|
18
18
|
}
|
|
19
|
-
function render() {
|
|
19
|
+
async function render() {
|
|
20
20
|
assert(getRenderCount() === 0);
|
|
21
|
-
|
|
21
|
+
await renderPageClientSide({
|
|
22
22
|
scrollTarget: { preserveScroll: true },
|
|
23
23
|
isBackwardNavigation: null,
|
|
24
24
|
isClientSideNavigation: false
|
|
25
25
|
});
|
|
26
|
-
assert(getRenderCount() === 1);
|
|
27
|
-
return renderPromise;
|
|
28
26
|
}
|
|
29
27
|
function initHistoryAndScroll() {
|
|
30
28
|
setupNativeScrollRestoration();
|
|
@@ -7,6 +7,6 @@ async function isClientSideRoutable(pageId, pageContext) {
|
|
|
7
7
|
sharedPageFilesAlreadyLoaded: false
|
|
8
8
|
});
|
|
9
9
|
const pageConfig = findPageConfig(pageContext._pageConfigs, pageId);
|
|
10
|
-
const {
|
|
11
|
-
return
|
|
10
|
+
const { isClientRuntimeLoaded, isClientRouting } = analyzeClientSide(pageConfig, pageContext._pageFilesAll, pageId);
|
|
11
|
+
return isClientRuntimeLoaded && isClientRouting;
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { navigate };
|
|
2
2
|
export { reload };
|
|
3
|
-
import { renderPageClientSide } from './renderPageClientSide.js';
|
|
3
|
+
import { firstRenderStartPromise, renderPageClientSide } from './renderPageClientSide.js';
|
|
4
4
|
import { assertClientRouting, assertUsageUrlPathname, getCurrentUrl } from './utils.js';
|
|
5
5
|
assertClientRouting();
|
|
6
6
|
/** Programmatically navigate to a new page.
|
|
@@ -13,6 +13,8 @@ assertClientRouting();
|
|
|
13
13
|
*/
|
|
14
14
|
async function navigate(url, { keepScrollPosition = false, overwriteLastHistoryEntry = false } = {}) {
|
|
15
15
|
assertUsageUrlPathname(url, '[navigate(url)] url');
|
|
16
|
+
// If `hydrationCanBeAborted === false` (e.g. Vue) then we can apply navigate() only after hydration is done
|
|
17
|
+
await firstRenderStartPromise;
|
|
16
18
|
const scrollTarget = { preserveScroll: keepScrollPosition };
|
|
17
19
|
await renderPageClientSide({
|
|
18
20
|
scrollTarget,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { renderPageClientSide };
|
|
2
2
|
export { getRenderCount };
|
|
3
3
|
export { disableClientRouting };
|
|
4
|
+
export { firstRenderStartPromise };
|
|
4
5
|
import { type PageContextFromRewrite } from '../../shared/route/abort.js';
|
|
5
6
|
import { type ScrollTarget } from './setScrollPosition.js';
|
|
7
|
+
declare const firstRenderStartPromise: Promise<void>;
|
|
6
8
|
type RenderArgs = {
|
|
7
9
|
scrollTarget: ScrollTarget;
|
|
8
10
|
isBackwardNavigation: boolean | null;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { renderPageClientSide };
|
|
2
2
|
export { getRenderCount };
|
|
3
3
|
export { disableClientRouting };
|
|
4
|
-
|
|
4
|
+
export { firstRenderStartPromise };
|
|
5
|
+
import { assert, getCurrentUrl, isSameErrorMessage, objectAssign, redirectHard, getGlobalObject, executeHook, hasProp, augmentType, genPromise } from './utils.js';
|
|
5
6
|
import { getPageContextFromHooks_isHydration, getPageContextFromHooks_isNotHydration, getPageContextFromHooks_serialized } from './getPageContextFromHooks.js';
|
|
6
7
|
import { createPageContext } from './createPageContext.js';
|
|
7
8
|
import { addLinkPrefetchHandlers } from './prefetch.js';
|
|
@@ -17,7 +18,15 @@ import { setScrollPosition } from './setScrollPosition.js';
|
|
|
17
18
|
import { updateState } from './onBrowserHistoryNavigation.js';
|
|
18
19
|
import { browserNativeScrollRestoration_disable, setInitialRenderIsDone } from './scrollRestoration.js';
|
|
19
20
|
import { getErrorPageId } from '../../shared/error-page.js';
|
|
20
|
-
const globalObject = getGlobalObject('renderPageClientSide.ts',
|
|
21
|
+
const globalObject = getGlobalObject('renderPageClientSide.ts', (() => {
|
|
22
|
+
const { promise: firstRenderStartPromise, resolve: firstRenderStartPromiseResolve } = genPromise();
|
|
23
|
+
return {
|
|
24
|
+
renderCounter: 0,
|
|
25
|
+
firstRenderStartPromise,
|
|
26
|
+
firstRenderStartPromiseResolve
|
|
27
|
+
};
|
|
28
|
+
})());
|
|
29
|
+
const { firstRenderStartPromise } = globalObject;
|
|
21
30
|
async function renderPageClientSide(renderArgs) {
|
|
22
31
|
const { scrollTarget, urlOriginal = getCurrentUrl(), overwriteLastHistoryEntry = false, isBackwardNavigation, pageContextsFromRewrite = [], redirectCount = 0, isUserLandPushStateNavigation, isClientSideNavigation = true } = renderArgs;
|
|
23
32
|
const { previousPageContext } = globalObject;
|
|
@@ -31,6 +40,9 @@ async function renderPageClientSide(renderArgs) {
|
|
|
31
40
|
redirectHard(urlOriginal);
|
|
32
41
|
return;
|
|
33
42
|
}
|
|
43
|
+
globalObject.firstRenderStartPromiseResolve();
|
|
44
|
+
if (isRenderOutdated())
|
|
45
|
+
return;
|
|
34
46
|
await renderPageNominal();
|
|
35
47
|
return;
|
|
36
48
|
async function renderPageNominal() {
|
|
@@ -81,20 +93,27 @@ async function renderPageClientSide(renderArgs) {
|
|
|
81
93
|
}
|
|
82
94
|
if (isRenderOutdated())
|
|
83
95
|
return;
|
|
84
|
-
let isClientRoutable;
|
|
85
96
|
if (!pageContextFromRoute._pageId) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
/*
|
|
98
|
+
// We don't use the client router to render the 404 page:
|
|
99
|
+
// - So that the +redirects setting (https://vike.dev/redirects) can be applied.
|
|
100
|
+
// - This is the main argument.
|
|
101
|
+
// - See also failed CI: https://github.com/vikejs/vike/pull/1871
|
|
102
|
+
// - So that server-side error tracking can track 404 links?
|
|
103
|
+
// - We do use the client router for rendering the error page, so I don't think this is much of an argument.
|
|
104
|
+
await renderErrorPage({ is404: true })
|
|
105
|
+
*/
|
|
106
|
+
redirectHard(urlOriginal);
|
|
107
|
+
return;
|
|
92
108
|
}
|
|
109
|
+
assert(hasProp(pageContextFromRoute, '_pageId', 'string')); // Help TS
|
|
110
|
+
const isClientRoutable = await isClientSideRoutable(pageContextFromRoute._pageId, pageContext);
|
|
111
|
+
if (isRenderOutdated())
|
|
112
|
+
return;
|
|
93
113
|
if (!isClientRoutable) {
|
|
94
114
|
redirectHard(urlOriginal);
|
|
95
115
|
return;
|
|
96
116
|
}
|
|
97
|
-
assert(hasProp(pageContextFromRoute, '_pageId', 'string')); // Help TS
|
|
98
117
|
const isSamePage = pageContextFromRoute._pageId &&
|
|
99
118
|
previousPageContext?._pageId &&
|
|
100
119
|
pageContextFromRoute._pageId === previousPageContext._pageId;
|
|
@@ -208,9 +227,10 @@ async function renderPageClientSide(renderArgs) {
|
|
|
208
227
|
const pageContext = await getPageContextBegin();
|
|
209
228
|
if (isRenderOutdated())
|
|
210
229
|
return;
|
|
211
|
-
if (args.
|
|
230
|
+
if (args.is404)
|
|
231
|
+
objectAssign(pageContext, { is404: true });
|
|
232
|
+
if (args.pageContextError)
|
|
212
233
|
objectAssign(pageContext, args.pageContextError);
|
|
213
|
-
}
|
|
214
234
|
if ('err' in args) {
|
|
215
235
|
const { err } = args;
|
|
216
236
|
assert(!('errorWhileRendering' in pageContext));
|
|
@@ -266,6 +286,13 @@ async function renderPageClientSide(renderArgs) {
|
|
|
266
286
|
objectAssign(pageContext, {
|
|
267
287
|
_pageId: errorPageId
|
|
268
288
|
});
|
|
289
|
+
const isClientRoutable = await isClientSideRoutable(pageContext._pageId, pageContext);
|
|
290
|
+
if (isRenderOutdated())
|
|
291
|
+
return;
|
|
292
|
+
if (!isClientRoutable) {
|
|
293
|
+
redirectHard(urlOriginal);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
269
296
|
try {
|
|
270
297
|
objectAssign(pageContext, await loadUserFilesClientSide(pageContext._pageId, pageContext._pageFilesAll, pageContext._pageConfigs));
|
|
271
298
|
}
|
|
@@ -34,7 +34,7 @@ function isHashUrl(url) {
|
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
36
|
const removeHash = (url) => url.split('#')[0];
|
|
37
|
-
if (url.includes('#') && removeHash(url) === removeHash(window.location.
|
|
37
|
+
if (url.includes('#') && removeHash(url) === removeHash(window.location.pathname)) {
|
|
38
38
|
return true;
|
|
39
39
|
}
|
|
40
40
|
return false;
|
|
@@ -1,105 +1,127 @@
|
|
|
1
1
|
export { fileEnv };
|
|
2
|
-
import { assert, assertUsage, assertWarning, capitalizeFirstLetter } from '../utils.js';
|
|
2
|
+
import { assert, assertUsage, assertWarning, capitalizeFirstLetter, joinEnglish } from '../utils.js';
|
|
3
3
|
import { extractAssetsRE } from './extractAssetsPlugin.js';
|
|
4
4
|
import { extractExportNamesRE } from './extractExportNamesPlugin.js';
|
|
5
5
|
import pc from '@brillout/picocolors';
|
|
6
6
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
7
|
+
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
8
|
+
import { getExportNames } from '../shared/parseEsModule.js';
|
|
7
9
|
function fileEnv() {
|
|
8
10
|
let config;
|
|
9
|
-
let
|
|
11
|
+
let viteDevServer;
|
|
10
12
|
return {
|
|
11
13
|
name: 'vike:fileEnv',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return;
|
|
56
|
-
const isServerSide = options?.ssr;
|
|
57
|
-
const envActual = isServerSide ? 'server' : 'client';
|
|
58
|
-
const envExpect = isServerSide ? 'client' : 'server';
|
|
59
|
-
const suffix = `.${envExpect}.`;
|
|
60
|
-
// Everything is good
|
|
61
|
-
if (!modulePath.includes(suffix))
|
|
14
|
+
load(id, options) {
|
|
15
|
+
// In build, we use generateBundle() instead of the load() hook. Using load() works for dynamic imports in dev thanks to Vite's lazy transpiling, but it doesn't work in build because Rollup transpiles any dynamically imported module even if it's never actually imported.
|
|
16
|
+
if (!viteDevServer)
|
|
17
|
+
return;
|
|
18
|
+
if (skip(id))
|
|
19
|
+
return;
|
|
20
|
+
const moduleInfo = viteDevServer.moduleGraph.getModuleById(id);
|
|
21
|
+
assert(moduleInfo);
|
|
22
|
+
const importers = Array.from(moduleInfo.importers)
|
|
23
|
+
.map((m) => m.id)
|
|
24
|
+
.filter((id) => id !== null);
|
|
25
|
+
assertFileEnv(id, !!options?.ssr, importers,
|
|
26
|
+
// In dev, we only show a warning because we don't want to disrupt when the user plays with settings such as [ssr](https://vike.dev/ssr).
|
|
27
|
+
true);
|
|
28
|
+
},
|
|
29
|
+
// In production, we have to use transform() to replace modules with a runtime error because generateBundle() doesn't work for dynamic imports. In production, dynamic imports can only be verified at runtime.
|
|
30
|
+
async transform(code, id, options) {
|
|
31
|
+
// In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
|
|
32
|
+
if (viteDevServer)
|
|
33
|
+
return;
|
|
34
|
+
if (skip(id))
|
|
35
|
+
return;
|
|
36
|
+
const isServerSide = !!options?.ssr;
|
|
37
|
+
if (!isWrongEnv(id, isServerSide))
|
|
38
|
+
return;
|
|
39
|
+
const { importers } = this.getModuleInfo(id);
|
|
40
|
+
// Throwing a verbose error doesn't waste client-side KBs as dynamic imports are code splitted.
|
|
41
|
+
const errMsg = getErrorMessage(id, isServerSide, importers, false, true);
|
|
42
|
+
// We have to inject empty exports to avoid Rollup complaining about missing exports, see https://gist.github.com/brillout/5ea45776e65bd65100a52ecd7bfda3ff
|
|
43
|
+
const { exportNames } = await getExportNames(code);
|
|
44
|
+
return sourceMapRemove([
|
|
45
|
+
`throw new Error(${JSON.stringify(errMsg)});`,
|
|
46
|
+
...exportNames.map((name) => name === 'default' ? 'export default undefined;' : `export const ${name} = undefined;`)
|
|
47
|
+
].join('\n'));
|
|
48
|
+
},
|
|
49
|
+
generateBundle() {
|
|
50
|
+
Array.from(this.getModuleIds())
|
|
51
|
+
.filter((id) => !skip(id))
|
|
52
|
+
.forEach((moduleId) => {
|
|
53
|
+
const { importers, dynamicImporters } = this.getModuleInfo(moduleId);
|
|
54
|
+
if (importers.length === 0) {
|
|
55
|
+
// Dynamic imports can only be verified at runtime
|
|
56
|
+
assert(dynamicImporters.length > 0);
|
|
62
57
|
return;
|
|
63
|
-
// Show error message
|
|
64
|
-
let errMsg;
|
|
65
|
-
let modulePathPretty = getModuleFilePathAbsolute(moduleId, config);
|
|
66
|
-
modulePathPretty = modulePathPretty.replaceAll(suffix, pc.bold(suffix));
|
|
67
|
-
errMsg = `${capitalizeFirstLetter(envExpect)}-only file ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
|
|
68
|
-
if (importer &&
|
|
69
|
-
// Don't show Vike's virtual modules that import the entry plus files such as /pages/about/+Page.js
|
|
70
|
-
!importer.includes('virtual:vike:') &&
|
|
71
|
-
// I don't know why and who sets importer to '<stdin>' (I guess Vite?)
|
|
72
|
-
importer !== '<stdin>') {
|
|
73
|
-
const importerPath = getModuleFilePathAbsolute(importer, config);
|
|
74
|
-
errMsg += ` by ${importerPath}`;
|
|
75
|
-
}
|
|
76
|
-
if (isDev) {
|
|
77
|
-
errMsg += ' and, therefore, Vike will prevent building your app for production.';
|
|
78
|
-
assertWarning(false, errMsg, { onlyOnce: true });
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
assertUsage(false, errMsg);
|
|
82
58
|
}
|
|
83
|
-
|
|
59
|
+
assertFileEnv(moduleId, !!config.build.ssr, importers, false);
|
|
60
|
+
});
|
|
84
61
|
},
|
|
85
62
|
configResolved(config_) {
|
|
86
63
|
config = config_;
|
|
87
64
|
},
|
|
88
|
-
configureServer() {
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
// Ensure this plugin works
|
|
92
|
-
transform(_code, id, options) {
|
|
93
|
-
if (isDev)
|
|
94
|
-
return;
|
|
95
|
-
// TODO/v1-release: remove
|
|
96
|
-
if (extractAssetsRE.test(id) || extractExportNamesRE.test(id))
|
|
97
|
-
return;
|
|
98
|
-
if (id.split('?')[0].endsWith('.css'))
|
|
99
|
-
return;
|
|
100
|
-
const isServerSide = options?.ssr;
|
|
101
|
-
const envWrong = isServerSide ? 'client' : 'server';
|
|
102
|
-
assert(!id.includes(`.${envWrong}.`));
|
|
65
|
+
configureServer(viteDevServer_) {
|
|
66
|
+
viteDevServer = viteDevServer_;
|
|
103
67
|
}
|
|
104
68
|
};
|
|
69
|
+
function assertFileEnv(moduleId, isServerSide, importers, onlyWarn) {
|
|
70
|
+
if (!isWrongEnv(moduleId, isServerSide))
|
|
71
|
+
return;
|
|
72
|
+
const errMsg = getErrorMessage(moduleId, isServerSide, importers, onlyWarn, false);
|
|
73
|
+
if (onlyWarn) {
|
|
74
|
+
assertWarning(false, errMsg, { onlyOnce: true });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
assertUsage(false, errMsg);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function getErrorMessage(moduleId, isServerSide, importers, onlyWarn, noColor) {
|
|
81
|
+
const modulePath = getModulePath(moduleId);
|
|
82
|
+
const envActual = isServerSide ? 'server' : 'client';
|
|
83
|
+
const envExpect = isServerSide ? 'client' : 'server';
|
|
84
|
+
let errMsg;
|
|
85
|
+
let modulePathPretty = getModuleFilePathAbsolute(modulePath, config);
|
|
86
|
+
if (!noColor) {
|
|
87
|
+
const suffix = getSuffix(envExpect);
|
|
88
|
+
modulePathPretty = modulePathPretty.replaceAll(suffix, pc.bold(suffix));
|
|
89
|
+
}
|
|
90
|
+
errMsg = `${capitalizeFirstLetter(envExpect)}-only file ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
|
|
91
|
+
if (importers.length > 0) {
|
|
92
|
+
const importPaths = importers.map((importer) => getModuleFilePathAbsolute(importer, config));
|
|
93
|
+
errMsg += ` by ${joinEnglish(importPaths, 'and')}`;
|
|
94
|
+
}
|
|
95
|
+
if (onlyWarn) {
|
|
96
|
+
errMsg += ' and, therefore, Vike will prevent building your app for production.';
|
|
97
|
+
}
|
|
98
|
+
return errMsg;
|
|
99
|
+
}
|
|
100
|
+
function isWrongEnv(moduleId, isServerSide) {
|
|
101
|
+
const modulePath = getModulePath(moduleId);
|
|
102
|
+
const suffixWrong = getSuffix(isServerSide ? 'client' : 'server');
|
|
103
|
+
return modulePath.includes(suffixWrong);
|
|
104
|
+
}
|
|
105
|
+
function skip(id) {
|
|
106
|
+
// TODO/v1-release: remove
|
|
107
|
+
if (extractAssetsRE.test(id) || extractExportNamesRE.test(id))
|
|
108
|
+
return true;
|
|
109
|
+
if (!id.includes(getSuffix('client')) && !id.includes(getSuffix('server')))
|
|
110
|
+
return true;
|
|
111
|
+
if (getModulePath(id).endsWith('.css'))
|
|
112
|
+
return true;
|
|
113
|
+
// Apply `.server.js` and `.client.js` only to user files
|
|
114
|
+
if (id.includes('/node_modules/'))
|
|
115
|
+
return true;
|
|
116
|
+
// Only user files
|
|
117
|
+
if (!id.startsWith(config.root))
|
|
118
|
+
return true;
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
function getSuffix(env) {
|
|
122
|
+
return `.${env}.`;
|
|
123
|
+
}
|
|
124
|
+
function getModulePath(moduleId) {
|
|
125
|
+
return moduleId.split('?')[0];
|
|
126
|
+
}
|
|
105
127
|
}
|
|
@@ -72,7 +72,6 @@ ${await getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, c
|
|
|
72
72
|
fileTypes
|
|
73
73
|
.filter((fileType) => fileType !== '.css')
|
|
74
74
|
.forEach((fileType) => {
|
|
75
|
-
assert(fileType !== '.css');
|
|
76
75
|
const { includeImport, includeExportNames } = determineInjection({
|
|
77
76
|
fileType,
|
|
78
77
|
isForClientSide,
|
|
@@ -28,7 +28,7 @@ const configDefinitionsBuiltIn = {
|
|
|
28
28
|
env: { server: true, client: true }
|
|
29
29
|
},
|
|
30
30
|
passToClient: {
|
|
31
|
-
env: { server: true
|
|
31
|
+
env: { server: true },
|
|
32
32
|
cumulative: true
|
|
33
33
|
},
|
|
34
34
|
route: {
|
|
@@ -76,7 +76,11 @@ const configDefinitionsBuiltIn = {
|
|
|
76
76
|
meta: {
|
|
77
77
|
env: { config: true }
|
|
78
78
|
},
|
|
79
|
-
|
|
79
|
+
// Whether the page loads:
|
|
80
|
+
// - Vike's client runtime
|
|
81
|
+
// - User's client hooks
|
|
82
|
+
// In other words, whether the page is "HTML-only" (https://vike.dev/render-modes). HTML-only pages shouldn't load the client runtime nor client hooks.
|
|
83
|
+
isClientRuntimeLoaded: {
|
|
80
84
|
env: { server: true, client: true },
|
|
81
85
|
eager: true,
|
|
82
86
|
_computed: (configValueSources) => {
|
|
@@ -176,12 +176,11 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
176
176
|
}
|
|
177
177
|
if (debug.isActivated)
|
|
178
178
|
debug('onResolved()', { args, resolved, importPathTranspiled, isPointerImport, isExternal });
|
|
179
|
-
pointerImports[importPathTranspiled] = isPointerImport;
|
|
180
179
|
if (isExternal) {
|
|
180
|
+
pointerImports[importPathTranspiled] = isPointerImport;
|
|
181
181
|
return { external: true, path: importPathTranspiled };
|
|
182
182
|
}
|
|
183
183
|
else {
|
|
184
|
-
resolved.path = importPathTranspiled;
|
|
185
184
|
return resolved;
|
|
186
185
|
}
|
|
187
186
|
});
|