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
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Romuald Brillout
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.route = route;
|
|
4
|
+
exports.getPagesAndRoutes = getPagesAndRoutes;
|
|
5
|
+
exports.getPageFilesAllSafe = getPageFilesAllSafe;
|
|
4
6
|
const index_js_1 = require("../shared/route/index.js");
|
|
5
7
|
const getPageFiles_js_1 = require("../shared/getPageFiles.js");
|
|
6
8
|
const globalContext_js_1 = require("../node/runtime/globalContext.js");
|
|
@@ -25,7 +27,6 @@ async function getPagesAndRoutes() {
|
|
|
25
27
|
allPageIds
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
|
-
exports.getPagesAndRoutes = getPagesAndRoutes;
|
|
29
30
|
// TODO: make it cleaner once the internal refactoring about global configs is done.
|
|
30
31
|
// Demo usage: https://github.com/vikejs/vike/pull/1823
|
|
31
32
|
async function getPageFilesAllSafe(isProduction) {
|
|
@@ -34,10 +35,8 @@ async function getPageFilesAllSafe(isProduction) {
|
|
|
34
35
|
const pageFilesAll = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
|
|
35
36
|
return pageFilesAll;
|
|
36
37
|
}
|
|
37
|
-
exports.getPageFilesAllSafe = getPageFilesAllSafe;
|
|
38
38
|
async function route(pageContext) {
|
|
39
39
|
const pageContextFromRoute = await (0, index_js_1.route)(pageContext);
|
|
40
40
|
// Old interface
|
|
41
41
|
return { pageContextAddendum: pageContextFromRoute };
|
|
42
42
|
}
|
|
43
|
-
exports.route = route;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onLoad =
|
|
3
|
+
exports.onLoad = onLoad;
|
|
4
4
|
const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
|
|
5
5
|
function onLoad() {
|
|
6
6
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
7
7
|
}
|
|
8
|
-
exports.onLoad = onLoad;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// TODO/v1-release: remove this file
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createPageRenderer =
|
|
4
|
+
exports.createPageRenderer = createPageRenderer;
|
|
5
5
|
//import { SsrEnv, setSsrEnv } from './ssrEnv.js'
|
|
6
6
|
const renderPage_js_1 = require("./runtime/renderPage.js");
|
|
7
7
|
const utils_js_1 = require("./runtime/utils.js");
|
|
@@ -10,7 +10,6 @@ function createPageRenderer(options) {
|
|
|
10
10
|
showWarnings(options);
|
|
11
11
|
return renderPage_js_1.renderPage;
|
|
12
12
|
}
|
|
13
|
-
exports.createPageRenderer = createPageRenderer;
|
|
14
13
|
function showWarnings(options) {
|
|
15
14
|
(0, utils_js_1.assertWarning)(false, '`createPageRenderer()` is outdated, use `renderPage()` instead. See https://vike.dev/renderPage', { onlyOnce: true, showStackTrace: true });
|
|
16
15
|
const { viteDevServer, root, outDir, isProduction, base, baseAssets } = options;
|
|
@@ -3,7 +3,9 @@ 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.version =
|
|
6
|
+
exports.version = void 0;
|
|
7
|
+
exports.plugin = plugin;
|
|
8
|
+
exports.ssr = plugin;
|
|
7
9
|
exports.default = plugin;
|
|
8
10
|
var utils_js_1 = require("./utils.js");
|
|
9
11
|
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return utils_js_1.PROJECT_VERSION; } });
|
|
@@ -60,8 +62,6 @@ function plugin(vikeConfig) {
|
|
|
60
62
|
];
|
|
61
63
|
return plugins;
|
|
62
64
|
}
|
|
63
|
-
exports.plugin = plugin;
|
|
64
|
-
exports.ssr = plugin;
|
|
65
65
|
// Enable `const vike = require('vike/plugin')`.
|
|
66
66
|
// - This lives at the end of the file to ensure it happens after all assignments to `exports`.
|
|
67
67
|
// - This is only used for the CJS build; we wrap it in a try-catch for the ESM build.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onLoad =
|
|
3
|
+
exports.onLoad = onLoad;
|
|
4
4
|
const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
|
|
5
5
|
const assertIsNotProductionRuntime_js_1 = require("../../utils/assertIsNotProductionRuntime.js");
|
|
6
6
|
const assertNodeVersion_js_1 = require("../../utils/assertNodeVersion.js");
|
|
@@ -10,4 +10,3 @@ function onLoad() {
|
|
|
10
10
|
// Ensure we don't bloat the server runtime with heavy plugin dependencies such as esbuild
|
|
11
11
|
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
12
12
|
}
|
|
13
|
-
exports.onLoad = onLoad;
|
|
@@ -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.autoFullBuild =
|
|
6
|
+
exports.autoFullBuild = autoFullBuild;
|
|
7
7
|
const vite_1 = require("vite");
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
9
|
const runPrerender_js_1 = require("../../prerender/runPrerender.js");
|
|
@@ -59,7 +59,6 @@ function autoFullBuild() {
|
|
|
59
59
|
}
|
|
60
60
|
];
|
|
61
61
|
}
|
|
62
|
-
exports.autoFullBuild = autoFullBuild;
|
|
63
62
|
async function triggerFullBuild(config, configVike, bundle) {
|
|
64
63
|
if (config.build.ssr)
|
|
65
64
|
return; // already triggered
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.baseUrls =
|
|
3
|
+
exports.baseUrls = baseUrls;
|
|
4
4
|
const resolveBase_js_1 = require("../plugins/config/resolveBase.js");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
@@ -40,4 +40,3 @@ function baseUrls(configVike) {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
exports.baseUrls = baseUrls;
|
|
@@ -3,7 +3,8 @@ 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.
|
|
6
|
+
exports.fixServerAssets = fixServerAssets;
|
|
7
|
+
exports.fixServerAssets_isEnabled = fixServerAssets_isEnabled;
|
|
7
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const fs_1 = require("fs");
|
|
@@ -22,7 +23,6 @@ function fixServerAssets_isEnabled() {
|
|
|
22
23
|
// Shall we allow the user to toggle between the two workarounds? E.g. based on https://vike.dev/includeAssetsImportedByServer.
|
|
23
24
|
return true;
|
|
24
25
|
}
|
|
25
|
-
exports.fixServerAssets_isEnabled = fixServerAssets_isEnabled;
|
|
26
26
|
/** https://github.com/vikejs/vike/issues/1339 */
|
|
27
27
|
async function fixServerAssets(config) {
|
|
28
28
|
const outDirs = (0, utils_js_1.getOutDirs)(config);
|
|
@@ -32,7 +32,6 @@ async function fixServerAssets(config) {
|
|
|
32
32
|
await copyAssets(filesToCopy, config);
|
|
33
33
|
return clientManifestMod;
|
|
34
34
|
}
|
|
35
|
-
exports.fixServerAssets = fixServerAssets;
|
|
36
35
|
async function loadManifest(outDir) {
|
|
37
36
|
const manifestFilePath = path_1.default.posix.join(outDir, buildConfig_js_1.manifestTempFile);
|
|
38
37
|
const manifestFileContent = await promises_1.default.readFile(manifestFilePath, 'utf-8');
|
|
@@ -3,7 +3,10 @@ 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.manifestTempFile =
|
|
6
|
+
exports.manifestTempFile = void 0;
|
|
7
|
+
exports.buildConfig = buildConfig;
|
|
8
|
+
exports.assertRollupInput = assertRollupInput;
|
|
9
|
+
exports.analyzeClientEntries = analyzeClientEntries;
|
|
7
10
|
const utils_js_1 = require("../utils.js");
|
|
8
11
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
9
12
|
const findPageFiles_js_1 = require("../shared/findPageFiles.js");
|
|
@@ -104,7 +107,6 @@ function buildConfig() {
|
|
|
104
107
|
}
|
|
105
108
|
];
|
|
106
109
|
}
|
|
107
|
-
exports.buildConfig = buildConfig;
|
|
108
110
|
async function getEntries(config) {
|
|
109
111
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
110
112
|
const pageFileEntries = await getPageFileEntries(config, configVike.includeAssetsImportedByServer); // TODO/v1-release: remove
|
|
@@ -181,7 +183,6 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
181
183
|
});
|
|
182
184
|
return { hasClientRouting, hasServerRouting, clientEntries };
|
|
183
185
|
}
|
|
184
|
-
exports.analyzeClientEntries = analyzeClientEntries;
|
|
185
186
|
// Ensure Rollup creates entries for each page file, see https://github.com/vikejs/vike/issues/350
|
|
186
187
|
// (Otherwise the page files may be missing in the client manifest.json)
|
|
187
188
|
async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
@@ -281,4 +282,3 @@ function assertRollupInput(config) {
|
|
|
281
282
|
const htmlInput = htmlInputs[0];
|
|
282
283
|
(0, utils_js_1.assertUsage)(htmlInput === undefined, `The entry ${htmlInput} of config build.rollupOptions.input is an HTML entry which is forbidden when using Vike, instead follow https://vike.dev/add`);
|
|
283
284
|
}
|
|
284
|
-
exports.assertRollupInput = assertRollupInput;
|
|
@@ -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.assertResolveAlias =
|
|
6
|
+
exports.assertResolveAlias = assertResolveAlias;
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
9
|
// Recommend users to avoid un-distinguishable path aliases.
|
|
@@ -77,7 +77,6 @@ function assertResolveAlias(config) {
|
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
exports.assertResolveAlias = assertResolveAlias;
|
|
81
80
|
function getAliases(config) {
|
|
82
81
|
const { alias } = config.resolve;
|
|
83
82
|
if (!(0, utils_js_1.isArray)(alias)) {
|
|
@@ -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.commonConfig =
|
|
6
|
+
exports.commonConfig = commonConfig;
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
8
|
const buildConfig_js_1 = require("./buildConfig.js");
|
|
9
9
|
const require_shim_1 = require("@brillout/require-shim");
|
|
@@ -39,7 +39,6 @@ function commonConfig() {
|
|
|
39
39
|
}
|
|
40
40
|
];
|
|
41
41
|
}
|
|
42
|
-
exports.commonConfig = commonConfig;
|
|
43
42
|
function overrideViteDefaultPort(config) {
|
|
44
43
|
var _a, _b;
|
|
45
44
|
// @ts-ignore
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertVikeConfig =
|
|
3
|
+
exports.assertVikeConfig = assertVikeConfig;
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
5
|
function assertVikeConfig(vikeConfig, wrongUsageMsg) {
|
|
6
6
|
const wrongUsageError = checkConfigVike(vikeConfig);
|
|
@@ -8,7 +8,6 @@ function assertVikeConfig(vikeConfig, wrongUsageMsg) {
|
|
|
8
8
|
(0, utils_js_1.assertUsage)(false, wrongUsageMsg(wrongUsageError));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
exports.assertVikeConfig = assertVikeConfig;
|
|
12
11
|
function checkConfigVike(configVike) {
|
|
13
12
|
(0, utils_js_1.assert)((0, utils_js_1.isObject)(configVike));
|
|
14
13
|
{
|
|
@@ -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.resolveVikeConfig =
|
|
6
|
+
exports.resolveVikeConfig = resolveVikeConfig;
|
|
7
7
|
const assertVikeConfig_js_1 = require("./assertVikeConfig.js");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
9
|
const pickFirst_js_1 = require("./pickFirst.js");
|
|
@@ -21,7 +21,6 @@ function resolveVikeConfig(vikeConfig) {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
exports.resolveVikeConfig = resolveVikeConfig;
|
|
25
24
|
async function getConfigVikPromise(vikeConfig, config) {
|
|
26
25
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
27
26
|
const fromViteConfig = (config.vike ?? {});
|
|
@@ -3,7 +3,8 @@ 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.
|
|
6
|
+
exports.resolveBase = resolveBase;
|
|
7
|
+
exports.resolveBaseFromUserConfig = resolveBaseFromUserConfig;
|
|
7
8
|
const utils_js_1 = require("../../utils.js");
|
|
8
9
|
const pickFirst_js_1 = require("./pickFirst.js");
|
|
9
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -16,11 +17,9 @@ function resolveBase(configs, config) {
|
|
|
16
17
|
(0, utils_js_1.assert)(baseOriginal === null || typeof baseOriginal == 'string');
|
|
17
18
|
return resolve(baseOriginal, baseServer, baseAssets);
|
|
18
19
|
}
|
|
19
|
-
exports.resolveBase = resolveBase;
|
|
20
20
|
function resolveBaseFromUserConfig(config, configVike) {
|
|
21
21
|
return resolve(config.base ?? null, configVike?.baseServer ?? null, configVike?.baseAssets ?? null);
|
|
22
22
|
}
|
|
23
|
-
exports.resolveBaseFromUserConfig = resolveBaseFromUserConfig;
|
|
24
23
|
function resolve(base, baseServer_, baseAssets_) {
|
|
25
24
|
{
|
|
26
25
|
const wrongBase = (val) => `should start with ${picocolors_1.default.cyan('/')}, ${picocolors_1.default.cyan('http://')}, or ${picocolors_1.default.cyan('https://')} (it's ${picocolors_1.default.cyan(val)} instead)`;
|
|
@@ -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.determineFsAllowList =
|
|
6
|
+
exports.determineFsAllowList = determineFsAllowList;
|
|
7
7
|
const vite_1 = require("vite");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const utils_js_1 = require("../../utils.js");
|
|
@@ -32,4 +32,3 @@ async function determineFsAllowList(config) {
|
|
|
32
32
|
fsAllow.push(vikeRoot);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
exports.determineFsAllowList = determineFsAllowList;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.determineOptimizeDeps =
|
|
3
|
+
exports.determineOptimizeDeps = determineOptimizeDeps;
|
|
4
4
|
const findPageFiles_js_1 = require("../../shared/findPageFiles.js");
|
|
5
5
|
const utils_js_1 = require("../../utils.js");
|
|
6
6
|
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
@@ -30,7 +30,6 @@ async function determineOptimizeDeps(config, isDev) {
|
|
|
30
30
|
'config.optimizeDeps.include': config.optimizeDeps.include
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
exports.determineOptimizeDeps = determineOptimizeDeps;
|
|
34
33
|
async function getPageDeps(config, pageConfigs, isDev) {
|
|
35
34
|
let entries = [];
|
|
36
35
|
let include = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.devConfig =
|
|
3
|
+
exports.devConfig = devConfig;
|
|
4
4
|
const determineOptimizeDeps_js_1 = require("./determineOptimizeDeps.js");
|
|
5
5
|
const determineFsAllowList_js_1 = require("./determineFsAllowList.js");
|
|
6
6
|
const addSsrMiddleware_js_1 = require("../../shared/addSsrMiddleware.js");
|
|
@@ -100,4 +100,3 @@ function devConfig() {
|
|
|
100
100
|
}
|
|
101
101
|
];
|
|
102
102
|
}
|
|
103
|
-
exports.devConfig = devConfig;
|
|
@@ -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.distFileNames =
|
|
6
|
+
exports.distFileNames = distFileNames;
|
|
7
7
|
// Attempt to preserve file structure of `.page.js` files:
|
|
8
8
|
// - https://github.com/vikejs/vike/commit/11a4c49e5403aa7c37c8020c462b499425b41854
|
|
9
9
|
// - Blocker: https://github.com/rollup/rollup/issues/4724
|
|
@@ -99,7 +99,6 @@ function distFileNames() {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
exports.distFileNames = distFileNames;
|
|
103
102
|
function getIdHash(id) {
|
|
104
103
|
return crypto_1.default.createHash('md5').update(id).digest('hex').slice(0, 8);
|
|
105
104
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.envVarsPlugin =
|
|
3
|
+
exports.envVarsPlugin = envVarsPlugin;
|
|
4
4
|
const vite_1 = require("vite");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
@@ -78,7 +78,6 @@ function envVarsPlugin() {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
exports.envVarsPlugin = envVarsPlugin;
|
|
82
81
|
function applyEnvVar(envStatementRegEx, envVal, code) {
|
|
83
82
|
return code.replace(envStatementRegEx, JSON.stringify(envVal));
|
|
84
83
|
}
|
|
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.extractAssetsRE =
|
|
8
|
+
exports.extractAssetsRE = void 0;
|
|
9
|
+
exports.extractAssetsPlugin = extractAssetsPlugin;
|
|
9
10
|
const utils_js_1 = require("../utils.js");
|
|
10
11
|
const extractAssetsQuery_js_1 = require("../../shared/extractAssetsQuery.js");
|
|
11
12
|
const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
@@ -147,7 +148,6 @@ function extractAssetsPlugin() {
|
|
|
147
148
|
}
|
|
148
149
|
];
|
|
149
150
|
}
|
|
150
|
-
exports.extractAssetsPlugin = extractAssetsPlugin;
|
|
151
151
|
function emptyModule(file, importer) {
|
|
152
152
|
debugOperation('NUKED', file, importer);
|
|
153
153
|
return (0, utils_js_1.resolveVirtualFileId)(EMPTY_MODULE_ID);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractExportNamesRE =
|
|
3
|
+
exports.extractExportNamesRE = void 0;
|
|
4
|
+
exports.extractExportNamesPlugin = extractExportNamesPlugin;
|
|
5
|
+
exports.isUsingClientRouter = isUsingClientRouter;
|
|
4
6
|
const utils_js_1 = require("../utils.js");
|
|
5
7
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
6
8
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
@@ -31,7 +33,6 @@ function extractExportNamesPlugin() {
|
|
|
31
33
|
}
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
|
-
exports.extractExportNamesPlugin = extractExportNamesPlugin;
|
|
35
36
|
async function getExtractExportNamesCode(src, isClientSide, isProduction, id) {
|
|
36
37
|
const { exportNames, wildcardReExports } = await (0, parseEsModule_js_1.getExportNames)(src);
|
|
37
38
|
if (isClientSide && exportNames.includes('clientRouting')) {
|
|
@@ -90,4 +91,3 @@ function injectHmr(code, isClientSide, isProduction) {
|
|
|
90
91
|
function isUsingClientRouter() {
|
|
91
92
|
return globalObject.usesClientRouter === true;
|
|
92
93
|
}
|
|
93
|
-
exports.isUsingClientRouter = isUsingClientRouter;
|
|
@@ -3,109 +3,130 @@ 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.fileEnv =
|
|
6
|
+
exports.fileEnv = fileEnv;
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
8
|
const extractAssetsPlugin_js_1 = require("./extractAssetsPlugin.js");
|
|
9
9
|
const extractExportNamesPlugin_js_1 = require("./extractExportNamesPlugin.js");
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
11
|
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
12
|
+
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
13
|
+
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
12
14
|
function fileEnv() {
|
|
13
15
|
let config;
|
|
14
|
-
let
|
|
16
|
+
let viteDevServer;
|
|
15
17
|
return {
|
|
16
18
|
name: 'vike:fileEnv',
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return;
|
|
61
|
-
const isServerSide = options?.ssr;
|
|
62
|
-
const envActual = isServerSide ? 'server' : 'client';
|
|
63
|
-
const envExpect = isServerSide ? 'client' : 'server';
|
|
64
|
-
const suffix = `.${envExpect}.`;
|
|
65
|
-
// Everything is good
|
|
66
|
-
if (!modulePath.includes(suffix))
|
|
19
|
+
load(id, options) {
|
|
20
|
+
// 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.
|
|
21
|
+
if (!viteDevServer)
|
|
22
|
+
return;
|
|
23
|
+
if (skip(id))
|
|
24
|
+
return;
|
|
25
|
+
const moduleInfo = viteDevServer.moduleGraph.getModuleById(id);
|
|
26
|
+
(0, utils_js_1.assert)(moduleInfo);
|
|
27
|
+
const importers = Array.from(moduleInfo.importers)
|
|
28
|
+
.map((m) => m.id)
|
|
29
|
+
.filter((id) => id !== null);
|
|
30
|
+
assertFileEnv(id, !!options?.ssr, importers,
|
|
31
|
+
// 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).
|
|
32
|
+
true);
|
|
33
|
+
},
|
|
34
|
+
// 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.
|
|
35
|
+
async transform(code, id, options) {
|
|
36
|
+
// In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
|
|
37
|
+
if (viteDevServer)
|
|
38
|
+
return;
|
|
39
|
+
if (skip(id))
|
|
40
|
+
return;
|
|
41
|
+
const isServerSide = !!options?.ssr;
|
|
42
|
+
if (!isWrongEnv(id, isServerSide))
|
|
43
|
+
return;
|
|
44
|
+
const { importers } = this.getModuleInfo(id);
|
|
45
|
+
// Throwing a verbose error doesn't waste client-side KBs as dynamic imports are code splitted.
|
|
46
|
+
const errMsg = getErrorMessage(id, isServerSide, importers, false, true);
|
|
47
|
+
// We have to inject empty exports to avoid Rollup complaining about missing exports, see https://gist.github.com/brillout/5ea45776e65bd65100a52ecd7bfda3ff
|
|
48
|
+
const { exportNames } = await (0, parseEsModule_js_1.getExportNames)(code);
|
|
49
|
+
return (0, rollupSourceMap_js_1.sourceMapRemove)([
|
|
50
|
+
`throw new Error(${JSON.stringify(errMsg)});`,
|
|
51
|
+
...exportNames.map((name) => name === 'default' ? 'export default undefined;' : `export const ${name} = undefined;`)
|
|
52
|
+
].join('\n'));
|
|
53
|
+
},
|
|
54
|
+
generateBundle() {
|
|
55
|
+
Array.from(this.getModuleIds())
|
|
56
|
+
.filter((id) => !skip(id))
|
|
57
|
+
.forEach((moduleId) => {
|
|
58
|
+
const { importers, dynamicImporters } = this.getModuleInfo(moduleId);
|
|
59
|
+
if (importers.length === 0) {
|
|
60
|
+
// Dynamic imports can only be verified at runtime
|
|
61
|
+
(0, utils_js_1.assert)(dynamicImporters.length > 0);
|
|
67
62
|
return;
|
|
68
|
-
// Show error message
|
|
69
|
-
let errMsg;
|
|
70
|
-
let modulePathPretty = (0, getFilePath_js_1.getModuleFilePathAbsolute)(moduleId, config);
|
|
71
|
-
modulePathPretty = modulePathPretty.replaceAll(suffix, picocolors_1.default.bold(suffix));
|
|
72
|
-
errMsg = `${(0, utils_js_1.capitalizeFirstLetter)(envExpect)}-only file ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
|
|
73
|
-
if (importer &&
|
|
74
|
-
// Don't show Vike's virtual modules that import the entry plus files such as /pages/about/+Page.js
|
|
75
|
-
!importer.includes('virtual:vike:') &&
|
|
76
|
-
// I don't know why and who sets importer to '<stdin>' (I guess Vite?)
|
|
77
|
-
importer !== '<stdin>') {
|
|
78
|
-
const importerPath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(importer, config);
|
|
79
|
-
errMsg += ` by ${importerPath}`;
|
|
80
|
-
}
|
|
81
|
-
if (isDev) {
|
|
82
|
-
errMsg += ' and, therefore, Vike will prevent building your app for production.';
|
|
83
|
-
(0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
|
|
84
63
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
}
|
|
64
|
+
assertFileEnv(moduleId, !!config.build.ssr, importers, false);
|
|
65
|
+
});
|
|
89
66
|
},
|
|
90
67
|
configResolved(config_) {
|
|
91
68
|
config = config_;
|
|
92
69
|
},
|
|
93
|
-
configureServer() {
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
// Ensure this plugin works
|
|
97
|
-
transform(_code, id, options) {
|
|
98
|
-
if (isDev)
|
|
99
|
-
return;
|
|
100
|
-
// TODO/v1-release: remove
|
|
101
|
-
if (extractAssetsPlugin_js_1.extractAssetsRE.test(id) || extractExportNamesPlugin_js_1.extractExportNamesRE.test(id))
|
|
102
|
-
return;
|
|
103
|
-
if (id.split('?')[0].endsWith('.css'))
|
|
104
|
-
return;
|
|
105
|
-
const isServerSide = options?.ssr;
|
|
106
|
-
const envWrong = isServerSide ? 'client' : 'server';
|
|
107
|
-
(0, utils_js_1.assert)(!id.includes(`.${envWrong}.`));
|
|
70
|
+
configureServer(viteDevServer_) {
|
|
71
|
+
viteDevServer = viteDevServer_;
|
|
108
72
|
}
|
|
109
73
|
};
|
|
74
|
+
function assertFileEnv(moduleId, isServerSide, importers, onlyWarn) {
|
|
75
|
+
if (!isWrongEnv(moduleId, isServerSide))
|
|
76
|
+
return;
|
|
77
|
+
const errMsg = getErrorMessage(moduleId, isServerSide, importers, onlyWarn, false);
|
|
78
|
+
if (onlyWarn) {
|
|
79
|
+
(0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
(0, utils_js_1.assertUsage)(false, errMsg);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function getErrorMessage(moduleId, isServerSide, importers, onlyWarn, noColor) {
|
|
86
|
+
const modulePath = getModulePath(moduleId);
|
|
87
|
+
const envActual = isServerSide ? 'server' : 'client';
|
|
88
|
+
const envExpect = isServerSide ? 'client' : 'server';
|
|
89
|
+
let errMsg;
|
|
90
|
+
let modulePathPretty = (0, getFilePath_js_1.getModuleFilePathAbsolute)(modulePath, config);
|
|
91
|
+
if (!noColor) {
|
|
92
|
+
const suffix = getSuffix(envExpect);
|
|
93
|
+
modulePathPretty = modulePathPretty.replaceAll(suffix, picocolors_1.default.bold(suffix));
|
|
94
|
+
}
|
|
95
|
+
errMsg = `${(0, utils_js_1.capitalizeFirstLetter)(envExpect)}-only file ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
|
|
96
|
+
if (importers.length > 0) {
|
|
97
|
+
const importPaths = importers.map((importer) => (0, getFilePath_js_1.getModuleFilePathAbsolute)(importer, config));
|
|
98
|
+
errMsg += ` by ${(0, utils_js_1.joinEnglish)(importPaths, 'and')}`;
|
|
99
|
+
}
|
|
100
|
+
if (onlyWarn) {
|
|
101
|
+
errMsg += ' and, therefore, Vike will prevent building your app for production.';
|
|
102
|
+
}
|
|
103
|
+
return errMsg;
|
|
104
|
+
}
|
|
105
|
+
function isWrongEnv(moduleId, isServerSide) {
|
|
106
|
+
const modulePath = getModulePath(moduleId);
|
|
107
|
+
const suffixWrong = getSuffix(isServerSide ? 'client' : 'server');
|
|
108
|
+
return modulePath.includes(suffixWrong);
|
|
109
|
+
}
|
|
110
|
+
function skip(id) {
|
|
111
|
+
// TODO/v1-release: remove
|
|
112
|
+
if (extractAssetsPlugin_js_1.extractAssetsRE.test(id) || extractExportNamesPlugin_js_1.extractExportNamesRE.test(id))
|
|
113
|
+
return true;
|
|
114
|
+
if (!id.includes(getSuffix('client')) && !id.includes(getSuffix('server')))
|
|
115
|
+
return true;
|
|
116
|
+
if (getModulePath(id).endsWith('.css'))
|
|
117
|
+
return true;
|
|
118
|
+
// Apply `.server.js` and `.client.js` only to user files
|
|
119
|
+
if (id.includes('/node_modules/'))
|
|
120
|
+
return true;
|
|
121
|
+
// Only user files
|
|
122
|
+
if (!id.startsWith(config.root))
|
|
123
|
+
return true;
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
function getSuffix(env) {
|
|
127
|
+
return `.${env}.`;
|
|
128
|
+
}
|
|
129
|
+
function getModulePath(moduleId) {
|
|
130
|
+
return moduleId.split('?')[0];
|
|
131
|
+
}
|
|
110
132
|
}
|
|
111
|
-
exports.fileEnv = fileEnv;
|