vike 0.4.237-commit-85e89b1 → 0.4.237-commit-e549c30
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 -2
- 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/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} +18 -16
- package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +6 -4
- 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 -2
- 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/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} +18 -17
- package/dist/esm/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +7 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +6 -5
- 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 +1 -1
- 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
|
@@ -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-e549c30";
|
|
@@ -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-e549c30';
|
|
@@ -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;
|
|
@@ -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
|
// We can't use a RegExp:
|
|
7
7
|
// - Needs to work with Micromatch: https://github.com/micromatch/micromatch because:
|
|
8
8
|
// - Vite's `import.meta.glob()` uses Micromatch
|
package/dist/esm/utils/path.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { pathJoin };
|
|
2
2
|
export { pathIsRelative };
|
|
3
|
+
export { pathIsAbsolute };
|
|
3
4
|
export { toPosixPath };
|
|
4
5
|
export { assertPosixPath };
|
|
5
6
|
/**********************/
|
|
6
7
|
/****** SHIMS *********/
|
|
7
8
|
/**********************/
|
|
8
9
|
declare function pathJoin(path1: string, path2: string): string;
|
|
10
|
+
declare function pathIsAbsolute(filePath: string): boolean;
|
|
9
11
|
/**********************/
|
|
10
12
|
/****** UTILS *********/
|
|
11
13
|
/**********************/
|
package/dist/esm/utils/path.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { pathJoin };
|
|
2
2
|
export { pathIsRelative };
|
|
3
|
+
export { pathIsAbsolute };
|
|
3
4
|
export { toPosixPath };
|
|
4
5
|
export { assertPosixPath };
|
|
5
6
|
// Utilities for handling file paths.
|
|
@@ -20,12 +21,11 @@ function pathJoin(path1, path2) {
|
|
|
20
21
|
joined = '/' + joined;
|
|
21
22
|
return joined;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]
|
|
25
|
-
function pathIsAbsolute(filePath
|
|
26
|
-
|
|
24
|
+
// https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
|
|
25
|
+
const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
26
|
+
function pathIsAbsolute(filePath) {
|
|
27
|
+
return IS_ABSOLUTE_RE.test(filePath);
|
|
27
28
|
}
|
|
28
|
-
//*/
|
|
29
29
|
/**********************/
|
|
30
30
|
/****** UTILS *********/
|
|
31
31
|
/**********************/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { requireResolveOptional };
|
|
2
2
|
export { requireResolveOptionalDir };
|
|
3
3
|
export { requireResolveNpmPackage };
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { requireResolveDistFile };
|
|
5
|
+
export { getPackageNodeModulesDirectory };
|
|
6
6
|
declare function requireResolveOptional({ importPath, importerFilePath, userRootDir, }: {
|
|
7
7
|
importPath: string;
|
|
8
8
|
importerFilePath: string;
|
|
@@ -17,5 +17,5 @@ declare function requireResolveNpmPackage({ importPathNpmPackage, userRootDir, }
|
|
|
17
17
|
importPathNpmPackage: string;
|
|
18
18
|
userRootDir: string;
|
|
19
19
|
}): string;
|
|
20
|
-
declare function
|
|
21
|
-
declare function
|
|
20
|
+
declare function requireResolveDistFile(distFile: `dist/esm/${string}.js`): string;
|
|
21
|
+
declare function getPackageNodeModulesDirectory(): string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { requireResolveOptional };
|
|
2
2
|
export { requireResolveOptionalDir };
|
|
3
3
|
export { requireResolveNpmPackage };
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { requireResolveDistFile };
|
|
5
|
+
export { getPackageNodeModulesDirectory };
|
|
6
6
|
import { assert } from './assert.js';
|
|
7
7
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
8
8
|
import { assertIsNotProductionRuntime } from './assertSetup.js';
|
|
@@ -104,11 +104,11 @@ function requireResolveNpmPackage({ importPathNpmPackage, userRootDir, }) {
|
|
|
104
104
|
throw res.err;
|
|
105
105
|
return res.importPathResolvedFilePath;
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
const
|
|
109
|
-
assertPosixPath(
|
|
110
|
-
assertPosixPath(
|
|
111
|
-
const importPathResolvedFilePath = makeNodeFriendly(path.posix.join(
|
|
107
|
+
function requireResolveDistFile(distFile) {
|
|
108
|
+
const packageNodeModulesDirectory = getPackageNodeModulesDirectory();
|
|
109
|
+
assertPosixPath(packageNodeModulesDirectory);
|
|
110
|
+
assertPosixPath(distFile);
|
|
111
|
+
const importPathResolvedFilePath = makeNodeFriendly(path.posix.join(packageNodeModulesDirectory, distFile));
|
|
112
112
|
// Double check
|
|
113
113
|
{
|
|
114
114
|
const res = requireResolve_(importPathResolvedFilePath,
|
|
@@ -166,11 +166,12 @@ function addFileExtensionsToRequireResolve(require_) {
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
// [RELATIVE_PATH_FROM_DIST] Current file:
|
|
171
|
-
assert(importMetaUrl.includes('/dist/esm/') || importMetaUrl.includes('/dist/cjs/'));
|
|
172
|
-
const
|
|
173
|
-
|
|
169
|
+
function getPackageNodeModulesDirectory() {
|
|
170
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/${packageName}/dist/esm/utils/requireResolve.js
|
|
171
|
+
assert(importMetaUrl.includes('/dist/esm/utils/') || importMetaUrl.includes('/dist/cjs/utils/'));
|
|
172
|
+
const packageNodeModulesDirectory = path.posix.join(removeFilePrefix(path.dirname(importMetaUrl)), '../../../');
|
|
173
|
+
// Return `node_modules/${packageName}/`
|
|
174
|
+
return packageNodeModulesDirectory;
|
|
174
175
|
}
|
|
175
176
|
function getFakeImporterFile(dirPath) {
|
|
176
177
|
assertPosixPath(dirPath);
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export { isViteServerBuild };
|
|
2
|
-
export { isViteClientBuild };
|
|
3
|
-
export { isViteServerBuild_withoutEnv };
|
|
4
|
-
export { isViteServerBuild_onlySsrEnv };
|
|
5
|
-
export { isViteServerBuild_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 isViteServerBuild_withoutEnv(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv): boolean;
|
|
13
|
-
declare function isViteServerBuild(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
|
|
14
|
-
declare function isViteClientBuild(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
15
|
-
declare function isViteServerBuild_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
16
|
-
declare function isViteServerBuild_extraSafe(config: ResolvedConfig, options: {
|
|
17
|
-
ssr?: boolean;
|
|
18
|
-
} | undefined, viteEnv: ViteEnv): boolean;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|