vike 0.4.195-commit-3f77496 → 0.4.195-commit-f7e91ba
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/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 +4 -5
- 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 +1 -2
- 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 +5 -6
- 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 +1 -2
- 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 +2 -2
- 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 +1 -2
- 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/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/runtime/html/stream.d.ts +0 -1
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +0 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +6 -6
- 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/projectInfo.d.ts +1 -1
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -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,
|
|
@@ -78,7 +78,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
|
|
|
78
78
|
_urlRewrite: null;
|
|
79
79
|
_httpRequestId: number | null;
|
|
80
80
|
_usesClientRouter: boolean;
|
|
81
|
-
_pageContextAlreadyProvidedByOnPrerenderHook?: true
|
|
81
|
+
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
82
82
|
is404: null | boolean;
|
|
83
83
|
} & {
|
|
84
84
|
isClientSideNavigation: boolean;
|
|
@@ -129,7 +129,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
|
|
|
129
129
|
_urlRewrite: null;
|
|
130
130
|
_httpRequestId: number | null;
|
|
131
131
|
_usesClientRouter: boolean;
|
|
132
|
-
_pageContextAlreadyProvidedByOnPrerenderHook?: true
|
|
132
|
+
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
133
133
|
is404: null | boolean;
|
|
134
134
|
} & {
|
|
135
135
|
isClientSideNavigation: boolean;
|
|
@@ -181,8 +181,8 @@ declare function prerender404Page(renderContext: RenderContext, pageContextInit_
|
|
|
181
181
|
_urlRewrite: null;
|
|
182
182
|
_httpRequestId: number | null;
|
|
183
183
|
_usesClientRouter: boolean;
|
|
184
|
-
_pageContextAlreadyProvidedByOnPrerenderHook?: true
|
|
185
|
-
is404:
|
|
184
|
+
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
185
|
+
is404: null | boolean;
|
|
186
186
|
} & {
|
|
187
187
|
isClientSideNavigation: boolean;
|
|
188
188
|
_urlHandler: null;
|
|
@@ -232,8 +232,8 @@ declare function prerender404Page(renderContext: RenderContext, pageContextInit_
|
|
|
232
232
|
_urlRewrite: null;
|
|
233
233
|
_httpRequestId: number | null;
|
|
234
234
|
_usesClientRouter: boolean;
|
|
235
|
-
_pageContextAlreadyProvidedByOnPrerenderHook?: true
|
|
236
|
-
is404:
|
|
235
|
+
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
236
|
+
is404: null | boolean;
|
|
237
237
|
} & {
|
|
238
238
|
isClientSideNavigation: boolean;
|
|
239
239
|
_urlHandler: null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.195-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.195-commit-f7e91ba";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.195-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.195-commit-f7e91ba';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.195-commit-
|
|
3
|
+
"version": "0.4.195-commit-f7e91ba",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
"semver": "^7.6.3",
|
|
243
243
|
"sirv": "^2.0.4",
|
|
244
244
|
"source-map-support": "^0.5.21",
|
|
245
|
-
"typescript": "^5.
|
|
245
|
+
"typescript": "^5.6.2",
|
|
246
246
|
"vite": "^5.4.0"
|
|
247
247
|
},
|
|
248
248
|
"scripts": {
|