vike 0.4.237-commit-8749e81 → 0.4.237-commit-92dc549
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/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage.js +12 -7
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +12 -11
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +8 -7
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +5 -5
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildEntry.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +2 -10
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +51 -21
- package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +1 -1
- package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +8 -6
- package/dist/cjs/node/vite/shared/getOutDirs.js +9 -6
- package/dist/cjs/node/vite/shared/{isViteServerBuild.js → isViteServerSide.js} +15 -15
- package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +6 -4
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +20 -36
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +5 -4
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +42 -44
- package/dist/cjs/types/VikeGlobalInternal.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertVersion.js +2 -0
- package/dist/cjs/utils/debug.js +4 -4
- package/dist/cjs/utils/getGlobalObject.js +8 -15
- package/dist/cjs/utils/isScriptFile.js +1 -1
- package/dist/cjs/utils/path.js +5 -5
- package/dist/cjs/utils/requireResolve.js +13 -12
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +2 -3
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage.d.ts +7 -4
- package/dist/esm/node/runtime/renderPage.js +12 -7
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +13 -12
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +9 -8
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +6 -6
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildEntry.js +2 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +2 -10
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
- package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +3 -3
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +2 -2
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +2 -2
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +2 -2
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.d.ts +5 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +52 -22
- package/dist/esm/node/vite/shared/getClientEntrySrcDev.js +2 -2
- package/dist/esm/node/vite/shared/getHttpRequestAsyncStore.js +9 -7
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.js +9 -6
- package/dist/esm/node/vite/shared/isViteServerSide.d.ts +18 -0
- package/dist/esm/node/vite/shared/{isViteServerBuild.js → isViteServerSide.js} +15 -17
- package/dist/esm/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +7 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.d.ts +3 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +21 -37
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +6 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +2 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +43 -45
- package/dist/esm/types/VikeGlobalInternal.d.ts +4 -0
- package/dist/esm/types/VikeGlobalInternal.js +1 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertVersion.js +2 -0
- package/dist/esm/utils/debug.js +3 -3
- package/dist/esm/utils/getGlobalObject.d.ts +6 -5
- package/dist/esm/utils/getGlobalObject.js +8 -15
- package/dist/esm/utils/isScriptFile.d.ts +1 -1
- package/dist/esm/utils/isScriptFile.js +1 -1
- package/dist/esm/utils/path.d.ts +2 -0
- package/dist/esm/utils/path.js +5 -5
- package/dist/esm/utils/requireResolve.d.ts +4 -4
- package/dist/esm/utils/requireResolve.js +13 -12
- package/package.json +2 -2
- package/dist/esm/node/vite/shared/isViteServerBuild.d.ts +0 -18
- /package/dist/cjs/utils/{getTerminWidth.js → getTerminalWidth.js} +0 -0
- /package/dist/esm/utils/{getTerminWidth.d.ts → getTerminalWidth.d.ts} +0 -0
- /package/dist/esm/utils/{getTerminWidth.js → getTerminalWidth.js} +0 -0
|
@@ -19,7 +19,10 @@ import { handleErrorWithoutErrorPage } from './renderPage/handleErrorWithoutErro
|
|
|
19
19
|
import { loadPageConfigsLazyServerSideAndExecHook } from './renderPage/loadPageConfigsLazyServerSide.js';
|
|
20
20
|
import { resolveRedirects } from './renderPage/resolveRedirects.js';
|
|
21
21
|
import { getVikeConfigError } from '../shared/getVikeConfigError.js';
|
|
22
|
-
const globalObject = getGlobalObject('runtime/renderPage.ts', {
|
|
22
|
+
const globalObject = getGlobalObject('runtime/renderPage.ts', {
|
|
23
|
+
httpRequestsCount: 0,
|
|
24
|
+
asyncHookWrapper: getFallbackAsyncHookWrapper(),
|
|
25
|
+
});
|
|
23
26
|
// `renderPage()` calls `renderPageNominal()` while ensuring that errors are `console.error(err)` instead of `throw err`, so that Vike never triggers a server shut down. (Throwing an error in an Express.js middleware shuts down the whole Express.js server.)
|
|
24
27
|
async function renderPage(pageContextInit) {
|
|
25
28
|
assertArguments(...arguments);
|
|
@@ -32,19 +35,21 @@ async function renderPage(pageContextInit) {
|
|
|
32
35
|
const httpRequestId = getRequestId();
|
|
33
36
|
const urlOriginalPretty = getUrlPretty(pageContextInit.urlOriginal);
|
|
34
37
|
logHttpRequest(urlOriginalPretty, httpRequestId);
|
|
35
|
-
const { pageContextReturn } = await asyncHookWrapper(httpRequestId, () => renderPagePrepare(pageContextInit, httpRequestId));
|
|
38
|
+
const { pageContextReturn } = await globalObject.asyncHookWrapper(httpRequestId, () => renderPagePrepare(pageContextInit, httpRequestId));
|
|
36
39
|
logHttpResponse(urlOriginalPretty, httpRequestId, pageContextReturn);
|
|
37
40
|
checkType(pageContextReturn);
|
|
38
41
|
assert(pageContextReturn.httpResponse);
|
|
39
42
|
return pageContextReturn;
|
|
40
43
|
}
|
|
41
|
-
// Fallback wrapper if node:async_hooks isn't available
|
|
42
|
-
let asyncHookWrapper = async (_httpRequestId, ret) => ({
|
|
43
|
-
pageContextReturn: await ret(),
|
|
44
|
-
});
|
|
45
44
|
// Add node:async_hooks wrapper
|
|
46
45
|
function renderPage_addAsyncHookwrapper(wrapper) {
|
|
47
|
-
asyncHookWrapper = wrapper;
|
|
46
|
+
globalObject.asyncHookWrapper = wrapper;
|
|
47
|
+
}
|
|
48
|
+
// Fallback wrapper if node:async_hooks isn't available
|
|
49
|
+
function getFallbackAsyncHookWrapper() {
|
|
50
|
+
return async (_httpRequestId, ret) => ({
|
|
51
|
+
pageContextReturn: await ret(),
|
|
52
|
+
});
|
|
48
53
|
}
|
|
49
54
|
async function renderPagePrepare(pageContextInit, httpRequestId) {
|
|
50
55
|
// Invalid config
|
|
@@ -44,7 +44,7 @@ export * from '../../utils/isHtml.js';
|
|
|
44
44
|
export * from '../../utils/warnIfErrorIsNotObject.js';
|
|
45
45
|
export * from '../../utils/virtualFileId.js';
|
|
46
46
|
export * from '../../utils/stripAnsi.js';
|
|
47
|
-
export * from '../../utils/
|
|
47
|
+
export * from '../../utils/getTerminalWidth.js';
|
|
48
48
|
export * from '../../utils/truncateString.js';
|
|
49
49
|
export * from '../../utils/formatHintLog.js';
|
|
50
50
|
export * from '../../utils/joinEnglish.js';
|
|
@@ -48,7 +48,7 @@ export * from '../../utils/isHtml.js';
|
|
|
48
48
|
export * from '../../utils/warnIfErrorIsNotObject.js';
|
|
49
49
|
export * from '../../utils/virtualFileId.js';
|
|
50
50
|
export * from '../../utils/stripAnsi.js';
|
|
51
|
-
export * from '../../utils/
|
|
51
|
+
export * from '../../utils/getTerminalWidth.js';
|
|
52
52
|
export * from '../../utils/truncateString.js';
|
|
53
53
|
export * from '../../utils/formatHintLog.js';
|
|
54
54
|
export * from '../../utils/joinEnglish.js';
|
|
@@ -7,17 +7,18 @@ import fs from 'node:fs/promises';
|
|
|
7
7
|
import fs_sync from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { existsSync } from 'node:fs';
|
|
10
|
-
import { assert,
|
|
10
|
+
import { assert, assertWarning, getGlobalObject, isEqualStringList, isObject, pLimit, unique } from '../../utils.js';
|
|
11
11
|
import { parseVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
12
12
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
13
13
|
import pc from '@brillout/picocolors';
|
|
14
14
|
import { getVikeConfigInternal, isV1Design } from '../../shared/resolveVikeConfigInternal.js';
|
|
15
15
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
16
|
-
import {
|
|
16
|
+
import { isViteServerSide_onlySsrEnv, isViteServerSide, isViteServerSide_withoutEnv, } from '../../shared/isViteServerSide.js';
|
|
17
17
|
import { set_macro_ASSETS_MANIFEST } from './pluginBuildEntry.js';
|
|
18
18
|
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const globalObject = getGlobalObject('build/handleAssetsManifest.ts', {
|
|
20
|
+
assetsJsonFilePath: undefined,
|
|
21
|
+
});
|
|
21
22
|
// true => use workaround config.build.ssrEmitAssets
|
|
22
23
|
// false => use workaround extractAssets plugin
|
|
23
24
|
function handleAssetsManifest_isFixEnabled(config) {
|
|
@@ -219,7 +220,7 @@ const targets = [];
|
|
|
219
220
|
function handleAssetsManifest_assertUsageCssTarget(config, env) {
|
|
220
221
|
if (!handleAssetsManifest_isFixEnabled(config))
|
|
221
222
|
return;
|
|
222
|
-
const isServerSide =
|
|
223
|
+
const isServerSide = isViteServerSide(config, env);
|
|
223
224
|
assert(typeof isServerSide === 'boolean');
|
|
224
225
|
assert(config.build.target !== undefined);
|
|
225
226
|
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
@@ -290,25 +291,25 @@ async function handleAssetsManifest_getBuildConfig(config) {
|
|
|
290
291
|
copyPublicDir: vikeConfig.config.vite6BuilderApp
|
|
291
292
|
? // Already set by vike:build:pluginBuildApp
|
|
292
293
|
undefined
|
|
293
|
-
: !
|
|
294
|
+
: !isViteServerSide_withoutEnv(config),
|
|
294
295
|
};
|
|
295
296
|
}
|
|
296
297
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
297
|
-
const isSsrEnv =
|
|
298
|
+
const isSsrEnv = isViteServerSide_onlySsrEnv(config, viteEnv);
|
|
298
299
|
if (isSsrEnv) {
|
|
299
|
-
assert(!assetsJsonFilePath);
|
|
300
|
+
assert(!globalObject.assetsJsonFilePath);
|
|
300
301
|
const outDirs = getOutDirs(config, viteEnv);
|
|
301
|
-
assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
302
|
-
await writeAssetsManifestFile(assetsJsonFilePath, config);
|
|
302
|
+
globalObject.assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
303
|
+
await writeAssetsManifestFile(globalObject.assetsJsonFilePath, config);
|
|
303
304
|
}
|
|
304
|
-
if (
|
|
305
|
+
if (isViteServerSide(config, viteEnv)) {
|
|
305
306
|
const outDir = options.dir;
|
|
306
307
|
assert(outDir);
|
|
307
308
|
// Replace __VITE_ASSETS_MANIFEST__ in server builds
|
|
308
309
|
// - Always replace it in dist/server/
|
|
309
310
|
// - Also in some other server builds such as dist/vercel/ from vike-vercel
|
|
310
311
|
// - Don't replace it in dist/rsc/ from vike-react-rsc since __VITE_ASSETS_MANIFEST__ doesn't exist there
|
|
311
|
-
const noop = await set_macro_ASSETS_MANIFEST(assetsJsonFilePath, bundle, outDir);
|
|
312
|
+
const noop = await set_macro_ASSETS_MANIFEST(globalObject.assetsJsonFilePath, bundle, outDir);
|
|
312
313
|
if (isSsrEnv)
|
|
313
314
|
assert(!noop); // dist/server should always contain __VITE_ASSETS_MANIFEST__
|
|
314
315
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginAutoFullBuild };
|
|
2
2
|
export { isPrerenderForceExit };
|
|
3
3
|
import { build } from 'vite';
|
|
4
|
-
import { assert,
|
|
4
|
+
import { assert, assertWarning, getGlobalObject, onSetupBuild } from '../../utils.js';
|
|
5
5
|
import { isPrerenderAutoRunEnabled, wasPrerenderRun } from '../../../prerender/context.js';
|
|
6
6
|
import { isViteCliCall, getViteConfigFromCli } from '../../shared/isViteCliCall.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
@@ -9,11 +9,12 @@ import { logErrorHint } from '../../../runtime/renderPage/logErrorHint.js';
|
|
|
9
9
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
10
10
|
import { isVikeCliOrApi } from '../../../api/context.js';
|
|
11
11
|
import { handleAssetsManifest, handleAssetsManifest_assertUsageCssTarget } from './handleAssetsManifest.js';
|
|
12
|
-
import {
|
|
12
|
+
import { isViteClientSide, isViteServerSide_onlySsrEnv } from '../../shared/isViteServerSide.js';
|
|
13
13
|
import { runPrerender_forceExit, runPrerenderFromAutoRun } from '../../../prerender/runPrerenderEntry.js';
|
|
14
14
|
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const globalObject = getGlobalObject('build/pluginAutoFullBuild.ts', {
|
|
16
|
+
forceExit: false,
|
|
17
|
+
});
|
|
17
18
|
function pluginAutoFullBuild() {
|
|
18
19
|
let config;
|
|
19
20
|
return [
|
|
@@ -57,7 +58,7 @@ function pluginAutoFullBuild() {
|
|
|
57
58
|
onSetupBuild();
|
|
58
59
|
handleAssetsManifest_assertUsageCssTarget(config, this.environment);
|
|
59
60
|
const vikeConfig = await getVikeConfigInternal();
|
|
60
|
-
if (forceExit &&
|
|
61
|
+
if (globalObject.forceExit &&
|
|
61
62
|
// Let vike:build:pluginBuildApp force exit
|
|
62
63
|
!vikeConfig.config.vite6BuilderApp) {
|
|
63
64
|
runPrerender_forceExit();
|
|
@@ -74,7 +75,7 @@ async function triggerFullBuild(config, viteEnv, bundle) {
|
|
|
74
75
|
const isBuilderApp = vikeConfig.config.vite6BuilderApp;
|
|
75
76
|
// If builder.buildApp() => trigger at end of `this.environment.name === 'ssr'`.
|
|
76
77
|
// Else => trigger at end of client-side build.
|
|
77
|
-
if (isBuilderApp ? !
|
|
78
|
+
if (isBuilderApp ? !isViteServerSide_onlySsrEnv(config, viteEnv) : !isViteClientSide(config, viteEnv))
|
|
78
79
|
return;
|
|
79
80
|
if (isEntirelyDisabled(vikeConfig))
|
|
80
81
|
return;
|
|
@@ -93,7 +94,7 @@ async function triggerFullBuild(config, viteEnv, bundle) {
|
|
|
93
94
|
}
|
|
94
95
|
if (isPrerenderAutoRunEnabled(vikeConfig)) {
|
|
95
96
|
const res = await runPrerenderFromAutoRun(configInline);
|
|
96
|
-
forceExit = res.forceExit;
|
|
97
|
+
globalObject.forceExit = res.forceExit;
|
|
97
98
|
assert(wasPrerenderRun());
|
|
98
99
|
}
|
|
99
100
|
}
|
|
@@ -124,7 +125,7 @@ function isEntirelyDisabled(vikeConfig) {
|
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
function isPrerenderForceExit() {
|
|
127
|
-
return forceExit;
|
|
128
|
+
return globalObject.forceExit;
|
|
128
129
|
}
|
|
129
130
|
function getFullBuildInlineConfig(config) {
|
|
130
131
|
const configFromCli = !isViteCliCall() ? null : getViteConfigFromCli();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginBuildConfig };
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
|
-
import { assert, addOnBeforeLogHook, removeFileExtension, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsImportPathNpmPackage,
|
|
4
|
+
import { assert, addOnBeforeLogHook, removeFileExtension, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsImportPathNpmPackage, requireResolveDistFile, } from '../../utils.js';
|
|
5
5
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
6
6
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
7
7
|
import { generateVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
@@ -9,7 +9,7 @@ import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
|
9
9
|
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
10
10
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
11
11
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
12
|
-
import {
|
|
12
|
+
import { isViteServerSide_withoutEnv } from '../../shared/isViteServerSide.js';
|
|
13
13
|
import { resolveOutDir_configEnvironment } from '../../shared/getOutDirs.js';
|
|
14
14
|
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, } from './handleAssetsManifest.js';
|
|
15
15
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
@@ -66,7 +66,7 @@ async function getEntries(config) {
|
|
|
66
66
|
// TO-DO/next-major-release: remove
|
|
67
67
|
const pageFileEntries = await getPageFileEntries(config, resolveIncludeAssetsImportedByServer(vikeConfig.config));
|
|
68
68
|
assertUsage(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
69
|
-
if (
|
|
69
|
+
if (isViteServerSide_withoutEnv(config)) {
|
|
70
70
|
const pageEntries = getPageEntries(pageConfigs);
|
|
71
71
|
const entries = {
|
|
72
72
|
...pageFileEntries,
|
|
@@ -85,8 +85,8 @@ async function getEntries(config) {
|
|
|
85
85
|
...clientEntries,
|
|
86
86
|
...pageFileEntries,
|
|
87
87
|
};
|
|
88
|
-
const clientRoutingEntry =
|
|
89
|
-
const serverRoutingEntry =
|
|
88
|
+
const clientRoutingEntry = requireResolveDistFile('dist/esm/client/runtime-client-routing/entry.js');
|
|
89
|
+
const serverRoutingEntry = requireResolveDistFile('dist/esm/client/runtime-server-routing/entry.js');
|
|
90
90
|
if (hasClientRouting) {
|
|
91
91
|
entries['entries/entry-client-routing'] = clientRoutingEntry;
|
|
92
92
|
}
|
|
@@ -139,7 +139,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
139
139
|
// Ensure Rollup creates entries for each page file, see https://github.com/vikejs/vike/issues/350
|
|
140
140
|
// (Otherwise the page files may be missing in the client manifest.json)
|
|
141
141
|
async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
142
|
-
const isForClientSide = !
|
|
142
|
+
const isForClientSide = !isViteServerSide_withoutEnv(config);
|
|
143
143
|
const fileTypes = isForClientSide ? ['.page', '.page.client'] : ['.page', '.page.server'];
|
|
144
144
|
if (isForClientSide && includeAssetsImportedByServer) {
|
|
145
145
|
fileTypes.push('.page.server');
|
|
@@ -2,7 +2,7 @@ export { pluginBuildEntry };
|
|
|
2
2
|
export { set_macro_ASSETS_MANIFEST };
|
|
3
3
|
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
4
|
import { virtualFileIdGlobalEntryServer } from '../../../shared/virtualFileId.js';
|
|
5
|
-
import { assert, PROJECT_VERSION,
|
|
5
|
+
import { assert, PROJECT_VERSION, requireResolveDistFile } from '../../utils.js';
|
|
6
6
|
import fs from 'node:fs/promises';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { isUsingClientRouter } from '../pluginExtractExportNames.js';
|
|
@@ -90,7 +90,7 @@ function find_ASSETS_MANIFEST(bundle) {
|
|
|
90
90
|
}
|
|
91
91
|
function getImportPath(config) {
|
|
92
92
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
93
|
-
const filePathAbsolute =
|
|
93
|
+
const filePathAbsolute = requireResolveDistFile('dist/esm/__internal/index.js');
|
|
94
94
|
if (
|
|
95
95
|
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|
|
96
96
|
true) {
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* We create a file `dist/server/package.json` to support ESM users.
|
|
3
|
-
* Otherwise, following error is thrown:
|
|
4
|
-
* Must use import to load ES Module: dist/server/pageFiles.js
|
|
5
|
-
* require() of ES modules is not supported.
|
|
6
|
-
* require() of dist/server/pageFiles.js from node_modules/vike/dist/esm/node/runtime/page-files/setup.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
|
|
7
|
-
* Reproduction: https://github.com/brillout/vite-plugin-ssr-server-import-syntax
|
|
8
|
-
*/
|
|
9
1
|
export { pluginDistPackageJsonFile };
|
|
10
2
|
import { rollupIsEsm } from '../../shared/rollupIsEsm.js';
|
|
11
|
-
import {
|
|
3
|
+
import { isViteServerSide } from '../../shared/isViteServerSide.js';
|
|
12
4
|
function pluginDistPackageJsonFile() {
|
|
13
5
|
let config;
|
|
14
6
|
return {
|
|
@@ -18,7 +10,7 @@ function pluginDistPackageJsonFile() {
|
|
|
18
10
|
config = config_;
|
|
19
11
|
},
|
|
20
12
|
generateBundle(options, bundle) {
|
|
21
|
-
if (!
|
|
13
|
+
if (!isViteServerSide(config, this.environment))
|
|
22
14
|
return;
|
|
23
15
|
const isEsm = rollupIsEsm(options);
|
|
24
16
|
const fileName = 'package.json';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginModuleBanner };
|
|
2
2
|
import { removeVirtualFileIdPrefix } from '../../utils.js';
|
|
3
3
|
import { getMagicString } from '../../shared/getMagicString.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isViteServerSide_extraSafe } from '../../shared/isViteServerSide.js';
|
|
5
5
|
// Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
|
|
6
6
|
// But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
|
|
7
7
|
function pluginModuleBanner() {
|
|
@@ -16,7 +16,7 @@ function pluginModuleBanner() {
|
|
|
16
16
|
transform: {
|
|
17
17
|
order: 'post',
|
|
18
18
|
handler(code, id, options) {
|
|
19
|
-
if (!
|
|
19
|
+
if (!isViteServerSide_extraSafe(config, options, this.environment) &&
|
|
20
20
|
// Inject module banners if user sets `build.minify` to `false` for inspecting dist/client/
|
|
21
21
|
config.build.minify) {
|
|
22
22
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { determineFsAllowList };
|
|
2
2
|
import { searchForWorkspaceRoot } from 'vite';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { assert, assertPosixPath,
|
|
4
|
+
import { assert, assertPosixPath, getPackageNodeModulesDirectory } from '../../utils.js';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
7
7
|
const importMetaUrl = import.meta.url;
|
|
@@ -18,6 +18,6 @@ async function determineFsAllowList(config) {
|
|
|
18
18
|
// We add it again just to be sure.
|
|
19
19
|
fsAllow.push(searchForWorkspaceRoot(process.cwd()));
|
|
20
20
|
// Add node_modules/vike/
|
|
21
|
-
const
|
|
22
|
-
fsAllow.push(
|
|
21
|
+
const packageNodeModulesDirectory = getPackageNodeModulesDirectory();
|
|
22
|
+
fsAllow.push(packageNodeModulesDirectory);
|
|
23
23
|
}
|
|
@@ -3,7 +3,7 @@ import { loadEnv } from 'vite';
|
|
|
3
3
|
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, isNotNullish, lowerFirst, } from '../utils.js';
|
|
4
4
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
5
5
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
6
|
-
import {
|
|
6
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
7
7
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
8
8
|
// TO-DO/eventually:
|
|
9
9
|
// - Make import.meta.env work inside +config.js
|
|
@@ -36,7 +36,7 @@ function pluginEnvVars() {
|
|
|
36
36
|
if (!code.includes('import.meta.env.'))
|
|
37
37
|
return;
|
|
38
38
|
const isBuild = config.command === 'build';
|
|
39
|
-
const isClientSide = !
|
|
39
|
+
const isClientSide = !isViteServerSide_extraSafe(config, options, this.environment);
|
|
40
40
|
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
41
41
|
// Find & check
|
|
42
42
|
const replacements = Object.entries(envsAll)
|
|
@@ -15,7 +15,7 @@ import { handleAssetsManifest_isFixEnabled } from './pluginBuild/handleAssetsMan
|
|
|
15
15
|
import { getVikeConfigInternal } from '../shared/resolveVikeConfigInternal.js';
|
|
16
16
|
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
17
17
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
18
|
-
import {
|
|
18
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
19
19
|
import { resolveIncludeAssetsImportedByServer } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
20
20
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
21
21
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
@@ -45,7 +45,7 @@ function pluginExtractAssets() {
|
|
|
45
45
|
}
|
|
46
46
|
const includeAssetsImportedByServer = resolveIncludeAssetsImportedByServer(vikeConfig.config);
|
|
47
47
|
assert(includeAssetsImportedByServer);
|
|
48
|
-
assert(!
|
|
48
|
+
assert(!isViteServerSide_extraSafe(config, options, this.environment));
|
|
49
49
|
const importStatements = await getImportStatements(src);
|
|
50
50
|
const moduleNames = getImportedModules(importStatements);
|
|
51
51
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
@@ -62,7 +62,7 @@ function pluginExtractAssets() {
|
|
|
62
62
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
63
63
|
enforce: 'pre',
|
|
64
64
|
async resolveId(source, importer, options) {
|
|
65
|
-
if (
|
|
65
|
+
if (isViteServerSide_extraSafe(config, options, this.environment)) {
|
|
66
66
|
// When building for the server, there should never be a `?extractAssets` query
|
|
67
67
|
assert(!extractAssetsRE.test(source));
|
|
68
68
|
assert(importer === undefined || !extractAssetsRE.test(importer));
|
|
@@ -4,7 +4,7 @@ export { extractExportNamesRE };
|
|
|
4
4
|
import { assert, getFileExtension, createDebugger, getGlobalObject, assertUsage, rollupSourceMapRemove, } from '../utils.js';
|
|
5
5
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
6
6
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
|
-
import {
|
|
7
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
8
8
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
9
9
|
const debug = createDebugger('vike:pluginExtractExportNames');
|
|
10
10
|
const globalObject = getGlobalObject('plugins/pluginExtractExportNames.ts', {});
|
|
@@ -16,7 +16,7 @@ function pluginExtractExportNames() {
|
|
|
16
16
|
enforce: 'post',
|
|
17
17
|
async transform(src, id, options) {
|
|
18
18
|
id = normalizeId(id);
|
|
19
|
-
const isClientSide = !
|
|
19
|
+
const isClientSide = !isViteServerSide_extraSafe(config, options, this.environment);
|
|
20
20
|
if (extractExportNamesRE.test(id)) {
|
|
21
21
|
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
22
22
|
debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { pluginNonRunnableDev };
|
|
2
|
-
import { createViteRPC, assertIsNotProductionRuntime,
|
|
2
|
+
import { createViteRPC, assertIsNotProductionRuntime, requireResolveDistFile, isRunnableDevEnvironment, } from '../utils.js';
|
|
3
3
|
import { retrievePageAssetsDev } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsDev.js';
|
|
4
4
|
import { getViteConfigRuntime } from '../shared/getViteConfigRuntime.js';
|
|
5
5
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
@@ -18,7 +18,7 @@ function getViteRpcFunctions(viteDevServer) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
function pluginNonRunnableDev() {
|
|
21
|
-
const runtimeGlobalContextFilePath =
|
|
21
|
+
const runtimeGlobalContextFilePath = requireResolveDistFile('dist/esm/node/runtime/globalContext.js');
|
|
22
22
|
let config;
|
|
23
23
|
return {
|
|
24
24
|
name: 'vike:pluginNonRunnableDev',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginReplaceConstants };
|
|
2
2
|
import { assert, assertPosixPath } from '../utils.js';
|
|
3
3
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
5
5
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
6
6
|
function pluginReplaceConstants() {
|
|
7
7
|
let config;
|
|
@@ -33,7 +33,7 @@ function pluginReplaceConstants() {
|
|
|
33
33
|
const constantsMap = [];
|
|
34
34
|
constantsMap.push({
|
|
35
35
|
constants: ['pageContext.isClientSide', 'globalContext.isClientSide', 'pageContext.globalContext.isClientSide'],
|
|
36
|
-
replacement: !
|
|
36
|
+
replacement: !isViteServerSide_extraSafe(config, options, this.environment),
|
|
37
37
|
});
|
|
38
38
|
constantsMap.forEach(({ constants, replacement }) => {
|
|
39
39
|
if (!constants.some((c) => code.includes(c)))
|
package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js
CHANGED
|
@@ -7,13 +7,13 @@ import path from 'node:path';
|
|
|
7
7
|
import { generateVirtualFileGlobalEntry } from './generateVirtualFileGlobalEntry.js';
|
|
8
8
|
import { getVikeConfigInternal, isV1Design as isV1Design_ } from '../../shared/resolveVikeConfigInternal.js';
|
|
9
9
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
10
|
-
import {
|
|
10
|
+
import { isViteServerSide_extraSafe } from '../../shared/isViteServerSide.js';
|
|
11
11
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
12
12
|
async function generateVirtualFileGlobalEntryWithOldDesign(id, options, config, env, isDev) {
|
|
13
13
|
const idParsed = parseVirtualFileId(id);
|
|
14
14
|
assert(idParsed && idParsed.type === 'global-entry');
|
|
15
15
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
16
|
-
assert(isForClientSide === !
|
|
16
|
+
assert(isForClientSide === !isViteServerSide_extraSafe(config, options, env));
|
|
17
17
|
const code = await getCode(config, isForClientSide, isClientRouting, isDev, id);
|
|
18
18
|
return code;
|
|
19
19
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { getConfigValueSourcesRelevant };
|
|
2
|
+
export { getConfigValueSourceRelevantAnyEnv };
|
|
2
3
|
export { isRuntimeEnvMatch };
|
|
4
|
+
export { isConfigSourceValueNull };
|
|
3
5
|
export type { RuntimeEnv };
|
|
4
6
|
import type { ConfigEnvInternal, ConfigValueSource, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../../types/PageConfig.js';
|
|
5
7
|
type RuntimeEnv = {
|
|
@@ -9,6 +11,8 @@ type RuntimeEnv = {
|
|
|
9
11
|
} | {
|
|
10
12
|
isForConfig: true;
|
|
11
13
|
};
|
|
14
|
+
type PageConfigPartial = Pick<PageConfigBuildTime | PageConfigGlobalBuildTime, 'configValueSources' | 'configDefinitions'>;
|
|
12
15
|
declare function getConfigValueSourcesRelevant(configName: string, runtimeEnv: RuntimeEnv, pageConfig: PageConfigPartial): ConfigValueSource[];
|
|
16
|
+
declare function getConfigValueSourceRelevantAnyEnv(configName: string, pageConfig: PageConfigPartial): null | ConfigValueSource;
|
|
13
17
|
declare function isRuntimeEnvMatch(configEnv: ConfigEnvInternal, runtimeEnv: RuntimeEnv): boolean;
|
|
14
|
-
|
|
18
|
+
declare function isConfigSourceValueNull(source: ConfigValueSource): boolean | null;
|
|
@@ -1,28 +1,47 @@
|
|
|
1
1
|
export { getConfigValueSourcesRelevant };
|
|
2
|
+
export { getConfigValueSourceRelevantAnyEnv };
|
|
2
3
|
export { isRuntimeEnvMatch };
|
|
3
|
-
|
|
4
|
+
export { isConfigSourceValueNull };
|
|
5
|
+
import { assert, assertIsNotBrowser } from '../../utils.js';
|
|
6
|
+
assertIsNotBrowser();
|
|
4
7
|
function getConfigValueSourcesRelevant(configName, runtimeEnv, pageConfig) {
|
|
5
8
|
const configDef = pageConfig.configDefinitions[configName];
|
|
6
9
|
assert(configDef);
|
|
7
10
|
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
8
11
|
if (!sourcesRelevant)
|
|
9
12
|
return [];
|
|
10
|
-
|
|
13
|
+
// Ignore configs with value `undefined`
|
|
14
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
|
|
15
|
+
// Environment filtering
|
|
16
|
+
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
17
|
+
// Overriding - non-cumulative configs
|
|
18
|
+
if (!configDef.cumulative && sourcesRelevant.length > 1) {
|
|
11
19
|
const source = sourcesRelevant[0];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
assert(sourcesRelevant.length === 0);
|
|
17
|
-
}
|
|
20
|
+
assert(source);
|
|
21
|
+
sourcesRelevant = [source];
|
|
18
22
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
sourcesRelevant = sourcesRelevant
|
|
23
|
+
// Overriding - cumulative configs
|
|
24
|
+
if (configDef.cumulative && sourcesRelevant.length > 0) {
|
|
25
|
+
sourcesRelevant = applyFilenameSuffix(sourcesRelevant);
|
|
22
26
|
}
|
|
23
|
-
sourcesRelevant = sourcesRelevant.filter((source) => isRuntimeEnvMatch(source.configEnv, runtimeEnv));
|
|
24
27
|
return sourcesRelevant;
|
|
25
28
|
}
|
|
29
|
+
function getConfigValueSourceRelevantAnyEnv(configName, pageConfig) {
|
|
30
|
+
const configDef = pageConfig.configDefinitions[configName];
|
|
31
|
+
assert(configDef);
|
|
32
|
+
assert(!configDef.cumulative); // So far, this function is only used by non-cumulative configs
|
|
33
|
+
let sourcesRelevant = pageConfig.configValueSources[configName];
|
|
34
|
+
if (!sourcesRelevant)
|
|
35
|
+
return null;
|
|
36
|
+
// Ignore configs with value `undefined`
|
|
37
|
+
sourcesRelevant = sourcesRelevant.filter((source) => !isConfigSourceValueUndefined(source));
|
|
38
|
+
const source = sourcesRelevant[0];
|
|
39
|
+
if (!source)
|
|
40
|
+
return null;
|
|
41
|
+
if (isConfigSourceValueNull(source))
|
|
42
|
+
return null;
|
|
43
|
+
return source;
|
|
44
|
+
}
|
|
26
45
|
function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
27
46
|
if ('isForConfig' in runtimeEnv)
|
|
28
47
|
return !!configEnv.config;
|
|
@@ -52,14 +71,25 @@ function isRuntimeEnvMatch(configEnv, runtimeEnv) {
|
|
|
52
71
|
}
|
|
53
72
|
return true;
|
|
54
73
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
// Setting a config to `undefined` should be equivalent to not setting it at all
|
|
75
|
+
function isConfigSourceValueUndefined(source) {
|
|
76
|
+
if (!source.valueIsLoaded)
|
|
77
|
+
return null;
|
|
78
|
+
return source.value === undefined;
|
|
79
|
+
}
|
|
80
|
+
// Setting a config to `null` enables the user to suppress inherited config by overriding it with `null` (this only works when setting the config value to `null` inside a +config.js file — it doesn't work when setting the config value to `null` with a +{configName}.js file).
|
|
81
|
+
function isConfigSourceValueNull(source) {
|
|
82
|
+
if (!source.valueIsLoaded)
|
|
83
|
+
return null;
|
|
84
|
+
return source.value === null;
|
|
85
|
+
}
|
|
86
|
+
function applyFilenameSuffix(sourcesRelevant) {
|
|
87
|
+
const getFileName = (source) => source.plusFile?.filePath.fileName ?? '';
|
|
88
|
+
// Apply `clear`: truncate at first clear file
|
|
89
|
+
const clearIndex = sourcesRelevant.findIndex((source) => getFileName(source).includes('.clear.'));
|
|
90
|
+
if (clearIndex !== -1)
|
|
91
|
+
sourcesRelevant = sourcesRelevant.slice(0, clearIndex + 1);
|
|
92
|
+
// Apply `default`: exclude defaults if any non-defaults exist, otherwise keep only first default
|
|
93
|
+
const nonDefaults = sourcesRelevant.filter((source) => !getFileName(source).includes('.default.'));
|
|
94
|
+
return nonDefaults.length > 0 ? nonDefaults : sourcesRelevant.slice(0, 1);
|
|
65
95
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getClientEntrySrcDev };
|
|
2
|
-
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsImportPathNpmPackage, assertIsNotProductionRuntime, requireResolveNpmPackage,
|
|
2
|
+
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsImportPathNpmPackage, assertIsNotProductionRuntime, requireResolveNpmPackage, requireResolveDistFile, } from '../utils.js';
|
|
3
3
|
assertIsNotProductionRuntime();
|
|
4
4
|
function getClientEntrySrcDev(clientEntry, viteDevServer) {
|
|
5
5
|
let userRootDir = viteDevServer.config.root;
|
|
@@ -23,7 +23,7 @@ function getClientEntrySrcDev(clientEntry, viteDevServer) {
|
|
|
23
23
|
else {
|
|
24
24
|
if (clientEntry.startsWith('@@vike/')) {
|
|
25
25
|
assert(clientEntry.endsWith('.js'));
|
|
26
|
-
filePath =
|
|
26
|
+
filePath = requireResolveDistFile(`dist/esm/${clientEntry.replace('@@vike/dist/esm/', '')}`);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
assertIsImportPathNpmPackage(clientEntry);
|
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
export { getHttpRequestAsyncStore };
|
|
10
10
|
export { installHttpRequestAsyncStore };
|
|
11
11
|
import { renderPage_addAsyncHookwrapper } from '../../runtime/renderPage.js';
|
|
12
|
-
import { assert, assertIsNotProductionRuntime, isObject, unique } from '../utils.js';
|
|
12
|
+
import { assert, assertIsNotProductionRuntime, getGlobalObject, isObject, unique } from '../utils.js';
|
|
13
13
|
import { getConfigBuildErrorFormatted } from './resolveVikeConfigInternal/transpileAndExecuteFile.js';
|
|
14
14
|
import { logErrorDebugNote } from './loggerNotProd.js';
|
|
15
15
|
import { isEquivalentErrorWithCodeSnippet } from './loggerNotProd/errorWithCodeSnippet.js';
|
|
16
16
|
import { isDeepStrictEqual } from 'node:util';
|
|
17
17
|
assertIsNotProductionRuntime();
|
|
18
|
-
|
|
18
|
+
const globalObject = getGlobalObject('getHttpRequestAsyncStore.ts', {
|
|
19
|
+
asyncLocalStorage: null,
|
|
20
|
+
});
|
|
19
21
|
async function installHttpRequestAsyncStore() {
|
|
20
22
|
let mod;
|
|
21
23
|
try {
|
|
@@ -24,9 +26,9 @@ async function installHttpRequestAsyncStore() {
|
|
|
24
26
|
catch {
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
|
-
asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
29
|
+
globalObject.asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
28
30
|
renderPage_addAsyncHookwrapper(async (httpRequestId, renderPage) => {
|
|
29
|
-
assert(asyncLocalStorage);
|
|
31
|
+
assert(globalObject.asyncLocalStorage);
|
|
30
32
|
const loggedErrors = new Set();
|
|
31
33
|
const markErrorAsLogged = (err) => {
|
|
32
34
|
loggedErrors.add(err);
|
|
@@ -49,15 +51,15 @@ async function installHttpRequestAsyncStore() {
|
|
|
49
51
|
shouldErrorBeSwallowed,
|
|
50
52
|
errorDebugNoteAlreadyShown: false,
|
|
51
53
|
};
|
|
52
|
-
const pageContextReturn = await asyncLocalStorage.run(store, renderPage);
|
|
54
|
+
const pageContextReturn = await globalObject.asyncLocalStorage.run(store, renderPage);
|
|
53
55
|
return { pageContextReturn };
|
|
54
56
|
});
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
59
|
function getHttpRequestAsyncStore() {
|
|
58
|
-
if (asyncLocalStorage === null)
|
|
60
|
+
if (globalObject.asyncLocalStorage === null)
|
|
59
61
|
return null;
|
|
60
|
-
const store = asyncLocalStorage.getStore();
|
|
62
|
+
const store = globalObject.asyncLocalStorage.getStore();
|
|
61
63
|
assert(store === undefined || isObject(store));
|
|
62
64
|
return store;
|
|
63
65
|
}
|
|
@@ -3,7 +3,7 @@ export { resolveOutDir };
|
|
|
3
3
|
export { resolveOutDir_configEnvironment };
|
|
4
4
|
export type { OutDirs };
|
|
5
5
|
import type { UserConfig, ResolvedConfig, EnvironmentOptions } from 'vite';
|
|
6
|
-
import { ViteEnv } from './
|
|
6
|
+
import { ViteEnv } from './isViteServerSide.js';
|
|
7
7
|
type OutDirs = {
|
|
8
8
|
/** Absolute path to `outDir` */
|
|
9
9
|
outDirRoot: string;
|