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
|
@@ -3,19 +3,22 @@ export { resolveOutDir };
|
|
|
3
3
|
export { resolveOutDir_configEnvironment };
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
5
|
import { assert, assertPosixPath, assertUsage, createDebugger, pathJoin, toPosixPath } from '../utils.js';
|
|
6
|
-
import {
|
|
6
|
+
import { isViteServerSide, isViteServerSide_withoutEnv } from './isViteServerSide.js';
|
|
7
7
|
const debug = createDebugger('vike:outDir');
|
|
8
8
|
function getOutDirs(configGlobal, viteEnv) {
|
|
9
9
|
debug('getOutDirs()', new Error().stack);
|
|
10
10
|
const outDir = getOutDirFromResolvedConfig(configGlobal);
|
|
11
11
|
assertOutDirResolved(outDir, configGlobal, viteEnv);
|
|
12
12
|
const outDirs = getOutDirsAll(outDir, configGlobal.root);
|
|
13
|
+
assertNormalization(outDirs.outDirRoot);
|
|
14
|
+
assertNormalization(outDirs.outDirClient);
|
|
15
|
+
assertNormalization(outDirs.outDirServer);
|
|
13
16
|
return outDirs;
|
|
14
17
|
}
|
|
15
18
|
function resolveOutDir_configEnvironment(configGlobal, envName, configEnv) {
|
|
16
19
|
assert(configGlobal && envName && configEnv);
|
|
17
20
|
const viteEnv = { name: envName, config: configEnv };
|
|
18
|
-
const isServerSide =
|
|
21
|
+
const isServerSide = isViteServerSide(configGlobal, viteEnv);
|
|
19
22
|
return resolveOutDir(configEnv, isServerSide);
|
|
20
23
|
}
|
|
21
24
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
@@ -90,9 +93,9 @@ function getOutDirsAllFromRootNormalized(outDirRoot, root) {
|
|
|
90
93
|
}
|
|
91
94
|
function assertNormalization(outDirAny) {
|
|
92
95
|
assertPosixPath(outDirAny);
|
|
93
|
-
assert(outDirIsAbsolutePath(outDirAny));
|
|
94
|
-
assert(outDirAny.endsWith('/'));
|
|
95
|
-
assert(!outDirAny.endsWith('//'));
|
|
96
|
+
assert(outDirIsAbsolutePath(outDirAny), outDirAny);
|
|
97
|
+
assert(outDirAny.endsWith('/'), outDirAny);
|
|
98
|
+
assert(!outDirAny.endsWith('//'), outDirAny);
|
|
96
99
|
}
|
|
97
100
|
function isOutDirRoot(outDirRot) {
|
|
98
101
|
const p = outDirRot.split('/').filter(Boolean);
|
|
@@ -111,7 +114,7 @@ function assertOutDirResolved(outDir, configGlobal, viteEnv) {
|
|
|
111
114
|
assert('/client'.length === '/server'.length);
|
|
112
115
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
113
116
|
const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
|
|
114
|
-
if (
|
|
117
|
+
if (isViteServerSide_withoutEnv(configGlobal, viteEnv)) {
|
|
115
118
|
assertUsage(outDir.endsWith('/server'), wrongUsage);
|
|
116
119
|
}
|
|
117
120
|
else {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { isViteServerSide };
|
|
2
|
+
export { isViteClientSide };
|
|
3
|
+
export { isViteServerSide_withoutEnv };
|
|
4
|
+
export { isViteServerSide_onlySsrEnv };
|
|
5
|
+
export { isViteServerSide_extraSafe };
|
|
6
|
+
export type { ViteEnv };
|
|
7
|
+
import type { Environment, EnvironmentOptions, ResolvedConfig, UserConfig } from 'vite';
|
|
8
|
+
type ViteEnv = {
|
|
9
|
+
name?: string;
|
|
10
|
+
config: EnvironmentOptions | Environment['config'];
|
|
11
|
+
};
|
|
12
|
+
declare function isViteServerSide_withoutEnv(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv): boolean;
|
|
13
|
+
declare function isViteServerSide(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
|
|
14
|
+
declare function isViteClientSide(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
15
|
+
declare function isViteServerSide_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
16
|
+
declare function isViteServerSide_extraSafe(config: ResolvedConfig, options: {
|
|
17
|
+
ssr?: boolean;
|
|
18
|
+
} | undefined, viteEnv: ViteEnv): boolean;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export { isViteServerBuild_onlySsrEnv };
|
|
7
|
-
export { isViteServerBuild_extraSafe };
|
|
1
|
+
export { isViteServerSide };
|
|
2
|
+
export { isViteClientSide };
|
|
3
|
+
export { isViteServerSide_withoutEnv };
|
|
4
|
+
export { isViteServerSide_onlySsrEnv };
|
|
5
|
+
export { isViteServerSide_extraSafe };
|
|
8
6
|
import { assert } from '../../../utils/assert.js';
|
|
9
|
-
function
|
|
7
|
+
function isViteServerSide_withoutEnv(configGlobal, viteEnv) {
|
|
10
8
|
assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
11
9
|
const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
12
10
|
const isServerSide2 = !viteEnv?.name ? null : viteEnv.name !== 'client'; // I can't think of a use case for creating another client-side environment
|
|
@@ -41,23 +39,23 @@ function isViteServerBuild_withoutEnv(configGlobal, viteEnv) {
|
|
|
41
39
|
}
|
|
42
40
|
return isServerSide4;
|
|
43
41
|
}
|
|
44
|
-
function
|
|
45
|
-
return
|
|
42
|
+
function isViteServerSide(configGlobal, viteEnv) {
|
|
43
|
+
return isViteServerSide_withoutEnv(configGlobal, viteEnv);
|
|
46
44
|
}
|
|
47
|
-
function
|
|
48
|
-
return !
|
|
45
|
+
function isViteClientSide(configGlobal, viteEnv) {
|
|
46
|
+
return !isViteServerSide(configGlobal, viteEnv);
|
|
49
47
|
}
|
|
50
48
|
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
51
|
-
function
|
|
52
|
-
return viteEnv ? viteEnv.name === 'ssr' :
|
|
49
|
+
function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
|
|
50
|
+
return viteEnv.name ? viteEnv.name === 'ssr' : isViteServerSide(configGlobal, viteEnv);
|
|
53
51
|
}
|
|
54
52
|
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
55
|
-
function
|
|
53
|
+
function isViteServerSide_extraSafe(config, options, viteEnv) {
|
|
56
54
|
if (config.command === 'build') {
|
|
57
55
|
const res = config.build.ssr;
|
|
58
56
|
assert(typeof res === 'boolean');
|
|
59
57
|
assert(res === options?.ssr || options?.ssr === undefined);
|
|
60
|
-
assert(res ===
|
|
58
|
+
assert(res === isViteServerSide(config, viteEnv));
|
|
61
59
|
return res;
|
|
62
60
|
}
|
|
63
61
|
else {
|
|
@@ -66,7 +64,7 @@ function isViteServerBuild_extraSafe(config, options, viteEnv) {
|
|
|
66
64
|
/* This assertion can fail, seems to be a Vite bug? It's very unexpected.
|
|
67
65
|
if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
|
|
68
66
|
*/
|
|
69
|
-
assert(res ===
|
|
67
|
+
assert(res === isViteServerSide(config, viteEnv));
|
|
70
68
|
return res;
|
|
71
69
|
}
|
|
72
70
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { removeSuperfluousViteLog };
|
|
2
2
|
export { removeSuperfluousViteLog_enable };
|
|
3
3
|
export { removeSuperfluousViteLog_disable };
|
|
4
|
-
import { assert } from '../../utils.js';
|
|
4
|
+
import { assert, getGlobalObject } from '../../utils.js';
|
|
5
|
+
const globalObject = getGlobalObject('removeSuperfluousViteLog.ts', {
|
|
6
|
+
enabled: false,
|
|
7
|
+
});
|
|
5
8
|
const superfluousLog = 'Forced re-optimization of dependencies';
|
|
6
|
-
let enabled = false;
|
|
7
9
|
function removeSuperfluousViteLog(msg) {
|
|
8
|
-
if (!enabled) {
|
|
10
|
+
if (!globalObject.enabled) {
|
|
9
11
|
return false;
|
|
10
12
|
}
|
|
11
13
|
if (msg.toLowerCase().includes('forced') && msg.toLowerCase().includes('optimization')) {
|
|
@@ -15,8 +17,8 @@ function removeSuperfluousViteLog(msg) {
|
|
|
15
17
|
return false;
|
|
16
18
|
}
|
|
17
19
|
function removeSuperfluousViteLog_enable() {
|
|
18
|
-
enabled = true;
|
|
20
|
+
globalObject.enabled = true;
|
|
19
21
|
}
|
|
20
22
|
function removeSuperfluousViteLog_disable() {
|
|
21
|
-
enabled = false;
|
|
23
|
+
globalObject.enabled = false;
|
|
22
24
|
}
|
|
@@ -4,9 +4,10 @@ export type { ConfigDefinitions };
|
|
|
4
4
|
export type { ConfigDefinitionsInternal };
|
|
5
5
|
export type { ConfigDefinitionInternal };
|
|
6
6
|
export type { ConfigEffect };
|
|
7
|
-
import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath
|
|
7
|
+
import type { ConfigEnvInternal, ConfigEnv, DefinedAtFilePath } from '../../../../types/PageConfig.js';
|
|
8
8
|
import type { Config, ConfigNameBuiltIn, ConfigNameGlobal } from '../../../../types/Config.js';
|
|
9
9
|
import { type ConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
10
|
+
import type { PageConfigBuildTimeBeforeComputed } from '../resolveVikeConfigInternal.js';
|
|
10
11
|
/** The meta definition of a config.
|
|
11
12
|
*
|
|
12
13
|
* https://vike.dev/meta
|
|
@@ -75,7 +76,7 @@ type ConfigEffect = (config: {
|
|
|
75
76
|
}) => Config | undefined;
|
|
76
77
|
/** For Vike internal use */
|
|
77
78
|
type ConfigDefinitionInternal = Omit<ConfigDefinition_, 'env'> & {
|
|
78
|
-
_computed?: (pageConfig:
|
|
79
|
+
_computed?: (pageConfig: PageConfigBuildTimeBeforeComputed) => unknown;
|
|
79
80
|
_valueIsFilePath?: true;
|
|
80
81
|
_userEffectDefinedAtFilePath?: DefinedAtFilePath;
|
|
81
82
|
env: ConfigEnvInternal;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { configDefinitionsBuiltIn };
|
|
2
2
|
import { assert, assertUsage } from '../../utils.js';
|
|
3
3
|
import { getConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
4
|
-
import { getConfigValueSourcesRelevant } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
4
|
+
import { getConfigValueSourceRelevantAnyEnv, getConfigValueSourcesRelevant, isConfigSourceValueNull, } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
5
5
|
const configDefinitionsBuiltIn = {
|
|
6
6
|
onRenderHtml: {
|
|
7
7
|
env: { server: true },
|
|
@@ -108,7 +108,9 @@ const configDefinitionsBuiltIn = {
|
|
|
108
108
|
}, pageConfig))
|
|
109
109
|
.flat(1)
|
|
110
110
|
// Server-only
|
|
111
|
-
.filter((source) => !source.configEnv.client)
|
|
111
|
+
.filter((source) => !source.configEnv.client)
|
|
112
|
+
// Config value isn't `null`
|
|
113
|
+
.filter((source) => !isConfigSourceValueNull(source));
|
|
112
114
|
return sources.length > 0;
|
|
113
115
|
},
|
|
114
116
|
},
|
|
@@ -120,22 +122,19 @@ const configDefinitionsBuiltIn = {
|
|
|
120
122
|
env: { server: true, client: true },
|
|
121
123
|
eager: true,
|
|
122
124
|
_computed: (pageConfig) => {
|
|
123
|
-
const { configValueSources } = pageConfig;
|
|
124
125
|
{
|
|
125
|
-
const source =
|
|
126
|
+
const source = getConfigValueSourceRelevantAnyEnv('clientHooks', pageConfig);
|
|
126
127
|
if (source) {
|
|
127
128
|
assert(source.valueIsLoaded);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
129
|
+
const { value, definedAt } = source;
|
|
130
|
+
const configDefinedAt = getConfigDefinedAt('Config', 'clientHooks', definedAt);
|
|
131
|
+
assertUsage(typeof value === 'boolean', `${configDefinedAt} should be a boolean`);
|
|
132
|
+
return value;
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
|
-
return (isConfigSet(
|
|
137
|
-
isConfigSet(
|
|
138
|
-
!!getConfigEnv(
|
|
135
|
+
return (isConfigSet(pageConfig, 'onRenderClient') &&
|
|
136
|
+
isConfigSet(pageConfig, 'Page') &&
|
|
137
|
+
!!getConfigEnv(pageConfig, 'Page')?.client);
|
|
139
138
|
},
|
|
140
139
|
},
|
|
141
140
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -143,10 +142,7 @@ const configDefinitionsBuiltIn = {
|
|
|
143
142
|
env: { client: true },
|
|
144
143
|
eager: true,
|
|
145
144
|
_computed: (pageConfig) => {
|
|
146
|
-
|
|
147
|
-
return !isConfigSet(configValueSources, 'onBeforeRender')
|
|
148
|
-
? null
|
|
149
|
-
: getConfigEnv(configValueSources, 'onBeforeRender');
|
|
145
|
+
return !isConfigSet(pageConfig, 'onBeforeRender') ? null : getConfigEnv(pageConfig, 'onBeforeRender');
|
|
150
146
|
},
|
|
151
147
|
},
|
|
152
148
|
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
@@ -154,8 +150,7 @@ const configDefinitionsBuiltIn = {
|
|
|
154
150
|
env: { client: true },
|
|
155
151
|
eager: true,
|
|
156
152
|
_computed: (pageConfig) => {
|
|
157
|
-
|
|
158
|
-
return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
|
|
153
|
+
return !isConfigSet(pageConfig, 'data') ? null : getConfigEnv(pageConfig, 'data');
|
|
159
154
|
},
|
|
160
155
|
},
|
|
161
156
|
hooksTimeout: {
|
|
@@ -243,11 +238,11 @@ const configDefinitionsBuiltIn = {
|
|
|
243
238
|
cumulative: true,
|
|
244
239
|
},
|
|
245
240
|
};
|
|
246
|
-
function getConfigEnv(
|
|
247
|
-
const
|
|
248
|
-
if (!
|
|
241
|
+
function getConfigEnv(pageConfig, configName) {
|
|
242
|
+
const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
|
|
243
|
+
if (!source)
|
|
249
244
|
return null;
|
|
250
|
-
const { configEnv } =
|
|
245
|
+
const { configEnv } = source;
|
|
251
246
|
const env = {};
|
|
252
247
|
if (configEnv.client)
|
|
253
248
|
env.client = true;
|
|
@@ -255,18 +250,7 @@ function getConfigEnv(configValueSources, configName) {
|
|
|
255
250
|
env.server = true;
|
|
256
251
|
return env;
|
|
257
252
|
}
|
|
258
|
-
function isConfigSet(
|
|
259
|
-
const source =
|
|
260
|
-
return
|
|
261
|
-
!(source.valueIsLoaded &&
|
|
262
|
-
// Enable users to suppress inherited config by overriding it with `null`
|
|
263
|
-
source.value === null));
|
|
264
|
-
}
|
|
265
|
-
function getConfigValueSource(configValueSources, configName) {
|
|
266
|
-
const sources = configValueSources[configName];
|
|
267
|
-
if (!sources)
|
|
268
|
-
return null;
|
|
269
|
-
const configValueSource = sources[0];
|
|
270
|
-
assert(configValueSource);
|
|
271
|
-
return configValueSource;
|
|
253
|
+
function isConfigSet(pageConfig, configName) {
|
|
254
|
+
const source = getConfigValueSourceRelevantAnyEnv(configName, pageConfig);
|
|
255
|
+
return !!source;
|
|
272
256
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
2
|
export { isPlusFile };
|
|
3
3
|
export { getPlusFileValueConfigName };
|
|
4
|
-
import { assertPosixPath, assert, scriptFileExtensionPattern,
|
|
4
|
+
import { assertPosixPath, assert, scriptFileExtensionPattern, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList, createDebugger, deepEqual, assertUsage, assertFilePathAbsoluteFilesystem, assertWarning, hasProp, isNotNullish, getGlobalObject, } from '../../utils.js';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { glob } from 'tinyglobby';
|
|
7
7
|
import { exec } from 'node:child_process';
|
|
@@ -14,8 +14,9 @@ import { ignorePatternsBuiltIn } from './crawlPlusFiles/ignorePatternsBuiltIn.js
|
|
|
14
14
|
const execA = promisify(exec);
|
|
15
15
|
const debug = createDebugger('vike:crawl');
|
|
16
16
|
assertIsNotProductionRuntime();
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const globalObject = getGlobalObject('getVikeConfig/crawlPlusFiles.ts', {
|
|
18
|
+
gitIsNotUsable: false,
|
|
19
|
+
});
|
|
19
20
|
async function crawlPlusFiles(userRootDir) {
|
|
20
21
|
assertPosixPath(userRootDir);
|
|
21
22
|
assertFilePathAbsoluteFilesystem(userRootDir);
|
|
@@ -48,7 +49,7 @@ async function crawlPlusFiles(userRootDir) {
|
|
|
48
49
|
}
|
|
49
50
|
// Same as tinyglobby() but using `$ git ls-files`
|
|
50
51
|
async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
51
|
-
if (gitIsNotUsable)
|
|
52
|
+
if (globalObject.gitIsNotUsable)
|
|
52
53
|
return null;
|
|
53
54
|
// Preserve UTF-8 file paths.
|
|
54
55
|
// https://github.com/vikejs/vike/issues/1658
|
|
@@ -82,7 +83,7 @@ async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
|
82
83
|
}
|
|
83
84
|
catch (err) {
|
|
84
85
|
if (await isGitNotUsable(userRootDir)) {
|
|
85
|
-
gitIsNotUsable = true;
|
|
86
|
+
globalObject.gitIsNotUsable = true;
|
|
86
87
|
return null;
|
|
87
88
|
}
|
|
88
89
|
throw err;
|
|
@@ -8,6 +8,7 @@ export { getConfVal };
|
|
|
8
8
|
export { getConfigDefinitionOptional };
|
|
9
9
|
export { getVikeConfigFromCliOrEnv };
|
|
10
10
|
export type { VikeConfigInternal };
|
|
11
|
+
export type { PageConfigBuildTimeBeforeComputed };
|
|
11
12
|
export { getVikeConfig };
|
|
12
13
|
export type { VikeConfig };
|
|
13
14
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../types/PageConfig.js';
|
|
@@ -57,6 +58,7 @@ declare function getVikeConfigFromCliOrEnv(): {
|
|
|
57
58
|
configFromCliOptions: import("../../cli/parseCli.js").CliOptions | null;
|
|
58
59
|
configFromEnvVar: Record<string, unknown> | null;
|
|
59
60
|
};
|
|
61
|
+
type PageConfigBuildTimeBeforeComputed = Omit<PageConfigBuildTime, 'configValuesComputed'>;
|
|
60
62
|
declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitionsInternal, configName: string): ConfigDefinitionInternal | null;
|
|
61
63
|
declare function getConfVal(plusFile: PlusFile, configName: string): null | {
|
|
62
64
|
value: unknown;
|
|
@@ -10,7 +10,7 @@ export { getConfigDefinitionOptional };
|
|
|
10
10
|
export { getVikeConfigFromCliOrEnv };
|
|
11
11
|
// Public usage
|
|
12
12
|
export { getVikeConfig };
|
|
13
|
-
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, assertKeys, objectKeys, objectFromEntries, unique, isCallable, makeFirst, lowerFirst, makeLast,
|
|
13
|
+
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, assertKeys, objectKeys, objectFromEntries, unique, isCallable, makeFirst, lowerFirst, makeLast, genPromise, checkType, objectAssign, getGlobalObject, } from '../utils.js';
|
|
14
14
|
import { configDefinitionsBuiltIn, } from './resolveVikeConfigInternal/configDefinitionsBuiltIn.js';
|
|
15
15
|
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, applyFilesystemRoutingRootEffect, } from './resolveVikeConfigInternal/filesystemRouting.js';
|
|
16
16
|
import { getViteDevServer } from '../../runtime/globalContext.js';
|
|
@@ -32,21 +32,19 @@ import { resolvePrerenderConfigGlobal } from '../../prerender/resolvePrerenderCo
|
|
|
32
32
|
import { getProxyForPublicUsage } from '../../../shared/getProxyForPublicUsage.js';
|
|
33
33
|
import { setVikeConfigError } from '../../shared/getVikeConfigError.js';
|
|
34
34
|
assertIsNotProductionRuntime();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let vikeConfigCtx = null; // Information provided by Vite's `config` and Vike's CLI. We could, if we want or need to, completely remove the dependency on Vite.
|
|
46
|
-
let prerenderContext;
|
|
35
|
+
const globalObject = getGlobalObject('vite/shared/resolveVikeConfigInternal.ts', {
|
|
36
|
+
restartVite: false,
|
|
37
|
+
vikeConfigHasBuildError: null,
|
|
38
|
+
isV1Design_: null,
|
|
39
|
+
vikeConfigPromise: null,
|
|
40
|
+
// TO-DO/next-major-release: remove
|
|
41
|
+
vikeConfigSync: null,
|
|
42
|
+
vikeConfigCtx: null, // Information provided by Vite's `config` and Vike's CLI. We could, if we want or need to, completely remove the dependency on Vite.
|
|
43
|
+
prerenderContext: null,
|
|
44
|
+
});
|
|
47
45
|
function reloadVikeConfig() {
|
|
48
|
-
assert(vikeConfigCtx);
|
|
49
|
-
const { userRootDir, vikeVitePluginOptions } = vikeConfigCtx;
|
|
46
|
+
assert(globalObject.vikeConfigCtx);
|
|
47
|
+
const { userRootDir, vikeVitePluginOptions } = globalObject.vikeConfigCtx;
|
|
50
48
|
assert(vikeVitePluginOptions);
|
|
51
49
|
resolveVikeConfigInternal_withErrorHandling(userRootDir, true, vikeVitePluginOptions);
|
|
52
50
|
}
|
|
@@ -54,15 +52,15 @@ async function getVikeConfigInternal(
|
|
|
54
52
|
// I don't remember the logic behind it — neither why we restart Vite's dev server, nor why we sometimes don't.
|
|
55
53
|
// TO-DO/eventually: re-think all that. Some + settings are expected to influence Vite's config (restarting Vite's dev server is needed) while some don't.
|
|
56
54
|
doNotRestartViteOnError = false) {
|
|
57
|
-
assert(vikeConfigCtx);
|
|
58
|
-
const { userRootDir, isDev, vikeVitePluginOptions } = vikeConfigCtx;
|
|
55
|
+
assert(globalObject.vikeConfigCtx);
|
|
56
|
+
const { userRootDir, isDev, vikeVitePluginOptions } = globalObject.vikeConfigCtx;
|
|
59
57
|
const vikeConfig = await getOrResolveVikeConfig(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError);
|
|
60
58
|
return vikeConfig;
|
|
61
59
|
}
|
|
62
60
|
// TO-DO/next-major-release: remove
|
|
63
61
|
function getVikeConfigInternalSync() {
|
|
64
|
-
assert(vikeConfigSync);
|
|
65
|
-
return vikeConfigSync;
|
|
62
|
+
assert(globalObject.vikeConfigSync);
|
|
63
|
+
return globalObject.vikeConfigSync;
|
|
66
64
|
}
|
|
67
65
|
// TO-DO/eventually: this maybe(/probably?) isn't safe against race conditions upon file changes in development, thus:
|
|
68
66
|
// - Like getGlobalContext() and getGlobalContextSync() — make getVikeConfig() async and provide a getVikeConfigSync() while discourage using it
|
|
@@ -83,29 +81,29 @@ config) {
|
|
|
83
81
|
}
|
|
84
82
|
function setVikeConfigContext(vikeConfigCtx_) {
|
|
85
83
|
// If the user changes Vite's `config.root` => Vite completely reloads itself => setVikeConfigContext() is called again
|
|
86
|
-
vikeConfigCtx = vikeConfigCtx_;
|
|
84
|
+
globalObject.vikeConfigCtx = vikeConfigCtx_;
|
|
87
85
|
}
|
|
88
86
|
async function getOrResolveVikeConfig(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError) {
|
|
89
|
-
if (!vikeConfigPromise) {
|
|
87
|
+
if (!globalObject.vikeConfigPromise) {
|
|
90
88
|
resolveVikeConfigInternal_withErrorHandling(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError);
|
|
91
89
|
}
|
|
92
|
-
assert(vikeConfigPromise);
|
|
93
|
-
const vikeConfig = await vikeConfigPromise;
|
|
90
|
+
assert(globalObject.vikeConfigPromise);
|
|
91
|
+
const vikeConfig = await globalObject.vikeConfigPromise;
|
|
94
92
|
return vikeConfig;
|
|
95
93
|
}
|
|
96
94
|
async function getVikeConfigInternalOptional() {
|
|
97
|
-
if (!vikeConfigPromise)
|
|
95
|
+
if (!globalObject.vikeConfigPromise)
|
|
98
96
|
return null;
|
|
99
|
-
const vikeConfig = await vikeConfigPromise;
|
|
97
|
+
const vikeConfig = await globalObject.vikeConfigPromise;
|
|
100
98
|
return vikeConfig;
|
|
101
99
|
}
|
|
102
100
|
function isV1Design() {
|
|
103
|
-
assert(typeof isV1Design_ === 'boolean');
|
|
104
|
-
return isV1Design_;
|
|
101
|
+
assert(typeof globalObject.isV1Design_ === 'boolean');
|
|
102
|
+
return globalObject.isV1Design_;
|
|
105
103
|
}
|
|
106
104
|
async function resolveVikeConfigInternal_withErrorHandling(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError) {
|
|
107
105
|
const { promise, resolve, reject } = genPromise();
|
|
108
|
-
vikeConfigPromise = promise;
|
|
106
|
+
globalObject.vikeConfigPromise = promise;
|
|
109
107
|
const esbuildCache = {
|
|
110
108
|
transpileCache: {},
|
|
111
109
|
vikeConfigDependencies: new Set(),
|
|
@@ -122,10 +120,10 @@ async function resolveVikeConfigInternal_withErrorHandling(userRootDir, isDev, v
|
|
|
122
120
|
}
|
|
123
121
|
// There is a newer call — let the new call supersede the old one.
|
|
124
122
|
// We deliberately swallow the intermetidate state (including any potential error) — it's now outdated and has existed only for a very short period of time.
|
|
125
|
-
if (vikeConfigPromise !== promise) {
|
|
123
|
+
if (globalObject.vikeConfigPromise !== promise) {
|
|
126
124
|
// vikeConfigPromise.then(resolve).catch(reject)
|
|
127
125
|
try {
|
|
128
|
-
resolve(await vikeConfigPromise);
|
|
126
|
+
resolve(await globalObject.vikeConfigPromise);
|
|
129
127
|
}
|
|
130
128
|
catch (err) {
|
|
131
129
|
reject(err);
|
|
@@ -135,13 +133,13 @@ async function resolveVikeConfigInternal_withErrorHandling(userRootDir, isDev, v
|
|
|
135
133
|
if (!hasError) {
|
|
136
134
|
assert(ret);
|
|
137
135
|
assert(err === undefined);
|
|
138
|
-
const hadError = vikeConfigHasBuildError;
|
|
139
|
-
vikeConfigHasBuildError = false;
|
|
136
|
+
const hadError = globalObject.vikeConfigHasBuildError;
|
|
137
|
+
globalObject.vikeConfigHasBuildError = false;
|
|
140
138
|
setVikeConfigError({ errorBuild: false });
|
|
141
139
|
if (hadError) {
|
|
142
140
|
logConfigErrorRecover();
|
|
143
|
-
if (restartVite) {
|
|
144
|
-
restartVite = false;
|
|
141
|
+
if (globalObject.restartVite) {
|
|
142
|
+
globalObject.restartVite = false;
|
|
145
143
|
restartViteDevServer();
|
|
146
144
|
}
|
|
147
145
|
}
|
|
@@ -150,10 +148,10 @@ async function resolveVikeConfigInternal_withErrorHandling(userRootDir, isDev, v
|
|
|
150
148
|
else {
|
|
151
149
|
assert(ret === undefined);
|
|
152
150
|
assert(err);
|
|
153
|
-
vikeConfigHasBuildError = true;
|
|
151
|
+
globalObject.vikeConfigHasBuildError = true;
|
|
154
152
|
setVikeConfigError({ errorBuild: { err } });
|
|
155
153
|
if (!doNotRestartViteOnError)
|
|
156
|
-
restartVite = true;
|
|
154
|
+
globalObject.restartVite = true;
|
|
157
155
|
if (!isDev) {
|
|
158
156
|
reject(err);
|
|
159
157
|
}
|
|
@@ -167,8 +165,8 @@ async function resolveVikeConfigInternal(userRootDir, vikeVitePluginOptions, esb
|
|
|
167
165
|
const plusFilesAll = await getPlusFilesAll(userRootDir, esbuildCache);
|
|
168
166
|
const configDefinitionsResolved = await resolveConfigDefinitions(plusFilesAll, userRootDir, esbuildCache);
|
|
169
167
|
const { pageConfigGlobal, pageConfigs } = getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRootDir);
|
|
170
|
-
if (!isV1Design_)
|
|
171
|
-
isV1Design_ = pageConfigs.length > 0;
|
|
168
|
+
if (!globalObject.isV1Design_)
|
|
169
|
+
globalObject.isV1Design_ = pageConfigs.length > 0;
|
|
172
170
|
// Backwards compatibility for vike(options) in vite.config.js
|
|
173
171
|
temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
|
|
174
172
|
setCliAndApiOptions(pageConfigGlobal, configDefinitionsResolved);
|
|
@@ -194,7 +192,7 @@ async function resolveVikeConfigInternal(userRootDir, vikeVitePluginOptions, esb
|
|
|
194
192
|
prerenderContext,
|
|
195
193
|
_vikeConfigDependencies: esbuildCache.vikeConfigDependencies,
|
|
196
194
|
};
|
|
197
|
-
vikeConfigSync = vikeConfig;
|
|
195
|
+
globalObject.vikeConfigSync = vikeConfig;
|
|
198
196
|
return vikeConfig;
|
|
199
197
|
}
|
|
200
198
|
async function resolveConfigDefinitions(plusFilesAll, userRootDir, esbuildCache) {
|
|
@@ -1099,7 +1097,7 @@ function isGlobalLocation(locationId, plusFilesAll) {
|
|
|
1099
1097
|
}
|
|
1100
1098
|
function resolvePrerenderContext(vikeConfig) {
|
|
1101
1099
|
const { isPrerenderingEnabled, isPrerenderingEnabledForAllPages } = resolvePrerenderConfigGlobal(vikeConfig);
|
|
1102
|
-
prerenderContext ?? (prerenderContext = {
|
|
1100
|
+
globalObject.prerenderContext ?? (globalObject.prerenderContext = {
|
|
1103
1101
|
isPrerenderingEnabled: false,
|
|
1104
1102
|
isPrerenderingEnabledForAllPages: false,
|
|
1105
1103
|
// Set at runPrerender()
|
|
@@ -1107,9 +1105,9 @@ function resolvePrerenderContext(vikeConfig) {
|
|
|
1107
1105
|
// Set at runPrerender()
|
|
1108
1106
|
pageContexts: null,
|
|
1109
1107
|
});
|
|
1110
|
-
prerenderContext.isPrerenderingEnabled = isPrerenderingEnabled;
|
|
1111
|
-
prerenderContext.isPrerenderingEnabledForAllPages = isPrerenderingEnabledForAllPages;
|
|
1112
|
-
return prerenderContext;
|
|
1108
|
+
globalObject.prerenderContext.isPrerenderingEnabled = isPrerenderingEnabled;
|
|
1109
|
+
globalObject.prerenderContext.isPrerenderingEnabledForAllPages = isPrerenderingEnabledForAllPages;
|
|
1110
|
+
return globalObject.prerenderContext;
|
|
1113
1111
|
}
|
|
1114
1112
|
function restartViteDevServer() {
|
|
1115
1113
|
const viteDevServer = getViteDevServer();
|
|
@@ -1146,7 +1144,7 @@ function getVikeConfigDummy(esbuildCache) {
|
|
|
1146
1144
|
prerenderContext: prerenderContextDummy,
|
|
1147
1145
|
_vikeConfigDependencies: esbuildCache.vikeConfigDependencies,
|
|
1148
1146
|
};
|
|
1149
|
-
vikeConfigSync = vikeConfigDummy;
|
|
1150
|
-
isV1Design_ = true;
|
|
1147
|
+
globalObject.vikeConfigSync = vikeConfigDummy;
|
|
1148
|
+
globalObject.isV1Design_ = true;
|
|
1151
1149
|
return vikeConfigDummy;
|
|
1152
1150
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.237-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.237-commit-92dc549";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.237-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.237-commit-92dc549';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { assertVersion };
|
|
2
2
|
export { isVersionOrAbove };
|
|
3
3
|
import { assert, assertUsage } from './assert.js';
|
|
4
|
+
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
5
|
+
assertIsNotBrowser();
|
|
4
6
|
function assertVersion(dependencyName, versionActual, versionExpected) {
|
|
5
7
|
assert(versionActual);
|
|
6
8
|
assert(versionExpected);
|
package/dist/esm/utils/debug.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugActivated };
|
|
3
|
-
import { isBrowser } from './isBrowser.js';
|
|
4
3
|
import { isCallable } from './isCallable.js';
|
|
5
4
|
import { objectAssign } from './objectAssign.js';
|
|
6
5
|
import { assert, assertUsage } from './assert.js';
|
|
7
6
|
import { checkType } from './checkType.js';
|
|
8
|
-
import { getTerminalWidth } from './
|
|
7
|
+
import { getTerminalWidth } from './getTerminalWidth.js';
|
|
9
8
|
import pc from '@brillout/picocolors';
|
|
10
9
|
import { isArray } from './isArray.js';
|
|
11
10
|
import { isObject } from './isObject.js';
|
|
12
11
|
import { setCreateDebugger } from '../shared/route/debug.js';
|
|
13
|
-
|
|
12
|
+
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
13
|
+
assertIsNotBrowser();
|
|
14
14
|
setCreateDebugger(createDebugger); // for isomorphic code
|
|
15
15
|
const flags = [
|
|
16
16
|
'vike:crawl',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { getGlobalObject };
|
|
2
|
-
|
|
3
|
-
type
|
|
2
|
+
import type { VikeGlobalInternal } from '../types/VikeGlobalInternal.js';
|
|
3
|
+
type ModuleId = `${string}.ts`;
|
|
4
4
|
/** Share information across module instances. */
|
|
5
|
-
declare function getGlobalObject<T extends Record<string, unknown> = never>(
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
declare function getGlobalObject<T extends Record<string, unknown> = never>(moduleId: ModuleId, defaultValue: T): T;
|
|
6
|
+
declare global {
|
|
7
|
+
var _vike: VikeGlobalInternal;
|
|
8
|
+
}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
export { getGlobalObject };
|
|
2
|
-
export { assertIsSingleModuleInstance };
|
|
3
|
-
import { assert } from './assert.js';
|
|
4
2
|
/** Share information across module instances. */
|
|
5
|
-
function getGlobalObject(
|
|
6
|
-
const
|
|
7
|
-
const globalObject = (
|
|
3
|
+
function getGlobalObject(moduleId, defaultValue) {
|
|
4
|
+
const globals = getGlobals();
|
|
5
|
+
const globalObject = (globals[moduleId] ?? (globals[moduleId] = defaultValue));
|
|
8
6
|
return globalObject;
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function getGlobalObjects() {
|
|
16
|
-
const projectKey = '_vike';
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
const globalObjects = (globalThis[projectKey] = globalThis[projectKey] || {});
|
|
19
|
-
return globalObjects;
|
|
8
|
+
function getGlobals() {
|
|
9
|
+
var _a;
|
|
10
|
+
globalThis._vike ?? (globalThis._vike = {});
|
|
11
|
+
(_a = globalThis._vike).globals ?? (_a.globals = {});
|
|
12
|
+
return globalThis._vike.globals;
|
|
20
13
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { isScriptFile };
|
|
2
2
|
export { isPlainScriptFile };
|
|
3
3
|
export { isTemplateFile };
|
|
4
|
-
export { scriptFileExtensionPattern };
|
|
5
4
|
export { scriptFileExtensionList };
|
|
5
|
+
export { scriptFileExtensionPattern };
|
|
6
6
|
declare const scriptFileExtensionList: readonly ["js", "cjs", "mjs", "ts", "cts", "mts", "jsx", "cjsx", "mjsx", "tsx", "ctsx", "mtsx", "vue", "svelte", "marko", "md", "mdx"];
|
|
7
7
|
declare const scriptFileExtensionPattern: string;
|
|
8
8
|
declare function isScriptFile(filePath: string): boolean;
|