vike 0.4.224 → 0.4.225-commit-2b7971f
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/client/shared/getPageContextProxyForUser.js +3 -66
- package/dist/cjs/node/api/build.js +1 -1
- package/dist/cjs/node/api/context.js +4 -4
- package/dist/cjs/node/api/dev.js +1 -1
- package/dist/cjs/node/api/prepareViteApiCall.js +25 -14
- package/dist/cjs/node/api/prerender.js +1 -1
- package/dist/cjs/node/api/preview.js +1 -1
- package/dist/cjs/node/cli/context.js +5 -4
- package/dist/cjs/node/cli/entry.js +3 -3
- package/dist/cjs/node/cli/parseCli.js +43 -15
- package/dist/cjs/node/cli/utils.js +1 -1
- package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +1 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +16 -11
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +6 -4
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +14 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +10 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +139 -84
- package/dist/cjs/node/plugin/plugins/previewConfig.js +12 -7
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +10 -1
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +5 -1
- package/dist/cjs/node/plugin/shared/getEnvVarObject.js +9 -8
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/cjs/node/prerender/context.js +1 -1
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +33 -18
- package/dist/cjs/node/prerender/runPrerender.js +12 -18
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +9 -5
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +6 -3
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +67 -14
- package/dist/cjs/node/runtime/html/stream.js +7 -0
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +14 -5
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +2 -4
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +6 -1
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +3 -0
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +18 -12
- package/dist/cjs/node/runtime/renderPage.js +19 -38
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +10 -8
- package/dist/cjs/node/shared/assertV1Design.js +2 -1
- package/dist/cjs/node/shared/utils.js +0 -1
- package/dist/cjs/shared/NOT_SERIALIZABLE.js +5 -0
- package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +19 -2
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +8 -5
- package/dist/cjs/shared/page-configs/helpers.js +1 -1
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -5
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +9 -5
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +12 -5
- package/dist/cjs/utils/assertSingleInstance.js +11 -17
- package/dist/cjs/utils/debug.js +2 -1
- package/dist/cjs/utils/getRandomId.js +1 -1
- package/dist/cjs/utils/normalizeHeaders.js +1 -1
- package/dist/cjs/utils/objectAssign.js +7 -2
- package/dist/cjs/utils/parseUrl-extras.js +1 -0
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -3
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +1 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +6 -3
- package/dist/esm/client/server-routing-runtime/getPageContext.js +6 -3
- package/dist/esm/client/shared/getPageContextProxyForUser.d.ts +1 -11
- package/dist/esm/client/shared/getPageContextProxyForUser.js +4 -67
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/api/build.js +1 -1
- package/dist/esm/node/api/context.d.ts +8 -2
- package/dist/esm/node/api/context.js +4 -4
- package/dist/esm/node/api/dev.js +1 -1
- package/dist/esm/node/api/prepareViteApiCall.d.ts +2 -2
- package/dist/esm/node/api/prepareViteApiCall.js +25 -14
- package/dist/esm/node/api/prerender.js +1 -1
- package/dist/esm/node/api/preview.js +1 -1
- package/dist/esm/node/api/types.d.ts +7 -0
- package/dist/esm/node/cli/context.d.ts +4 -2
- package/dist/esm/node/cli/context.js +5 -4
- package/dist/esm/node/cli/entry.js +4 -4
- package/dist/esm/node/cli/parseCli.d.ts +3 -0
- package/dist/esm/node/cli/parseCli.js +44 -16
- package/dist/esm/node/cli/utils.d.ts +1 -1
- package/dist/esm/node/cli/utils.js +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +2 -2
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +16 -11
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +6 -4
- package/dist/esm/node/plugin/plugins/devConfig/index.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +15 -11
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +3 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +10 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +5 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +141 -85
- package/dist/esm/node/plugin/plugins/previewConfig.js +12 -7
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +11 -2
- package/dist/esm/node/plugin/shared/addSsrMiddleware.d.ts +1 -1
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +5 -1
- package/dist/esm/node/plugin/shared/getEnvVarObject.d.ts +3 -1
- package/dist/esm/node/plugin/shared/getEnvVarObject.js +9 -8
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +2 -2
- package/dist/esm/node/prerender/context.js +1 -1
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +2 -1
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +34 -19
- package/dist/esm/node/prerender/runPrerender.js +13 -19
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +1 -1
- package/dist/esm/node/runtime/globalContext.js +10 -6
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +6 -3
- package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +2 -0
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +69 -15
- package/dist/esm/node/runtime/html/stream.js +7 -0
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -3
- package/dist/esm/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.d.ts +3 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +15 -6
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +3 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -4
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +6 -1
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +3 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +32 -6
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +18 -12
- package/dist/esm/node/runtime/renderPage.js +21 -40
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +10 -8
- package/dist/esm/node/shared/assertV1Design.js +2 -1
- package/dist/esm/node/shared/utils.d.ts +0 -1
- package/dist/esm/node/shared/utils.js +0 -1
- package/dist/esm/shared/NOT_SERIALIZABLE.d.ts +1 -0
- package/dist/esm/shared/NOT_SERIALIZABLE.js +2 -0
- package/dist/esm/shared/page-configs/Config.d.ts +23 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +17 -6
- package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +5 -3
- package/dist/esm/shared/page-configs/getConfigDefinedAt.js +20 -3
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +8 -5
- package/dist/esm/shared/page-configs/helpers.js +1 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +1 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -5
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -3
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +9 -5
- package/dist/esm/shared/route/abort.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +2 -2
- package/dist/esm/shared/types.d.ts +39 -3
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.d.ts +2 -1
- package/dist/esm/utils/assert.js +12 -5
- package/dist/esm/utils/assertSingleInstance.js +11 -17
- package/dist/esm/utils/debug.js +2 -1
- package/dist/esm/utils/getRandomId.d.ts +1 -1
- package/dist/esm/utils/getRandomId.js +1 -1
- package/dist/esm/utils/normalizeHeaders.js +1 -1
- package/dist/esm/utils/objectAssign.d.ts +1 -1
- package/dist/esm/utils/objectAssign.js +7 -2
- package/dist/esm/utils/parseUrl-extras.js +1 -0
- package/package.json +6 -3
- package/dist/cjs/shared/notSerializable.js +0 -5
- package/dist/cjs/utils/projectInfo.js +0 -8
- package/dist/esm/shared/notSerializable.d.ts +0 -1
- package/dist/esm/shared/notSerializable.js +0 -2
- package/dist/esm/utils/projectInfo.d.ts +0 -4
- package/dist/esm/utils/projectInfo.js +0 -5
|
@@ -6,7 +6,7 @@ import { assert, assertPosixPath } from '../../utils.js';
|
|
|
6
6
|
import { resolveVirtualFileId, isVirtualFileId, getVirtualFileId } from '../../../shared/virtual-files.js';
|
|
7
7
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
8
8
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
9
|
-
import {
|
|
9
|
+
import { reloadVikeConfig, isV1Design, getVikeConfig, getVikeConfigOptional } from './v1-design/getVikeConfig.js';
|
|
10
10
|
import pc from '@brillout/picocolors';
|
|
11
11
|
import { logConfigInfo } from '../../shared/loggerNotProd.js';
|
|
12
12
|
import { getModuleFilePathAbsolute } from '../../shared/getFilePath.js';
|
|
@@ -29,9 +29,9 @@ function importUserCode() {
|
|
|
29
29
|
return resolveVirtualFileId(id);
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
-
handleHotUpdate(ctx) {
|
|
32
|
+
async handleHotUpdate(ctx) {
|
|
33
33
|
try {
|
|
34
|
-
return handleHotUpdate(ctx, config);
|
|
34
|
+
return await handleHotUpdate(ctx, config);
|
|
35
35
|
}
|
|
36
36
|
catch (err) {
|
|
37
37
|
// Vite swallows errors thrown by handleHotUpdate()
|
|
@@ -63,9 +63,9 @@ function handleFileAddRemove(server, config) {
|
|
|
63
63
|
server.watcher.prependListener('add', (f) => listener(f, false));
|
|
64
64
|
server.watcher.prependListener('unlink', (f) => listener(f, true));
|
|
65
65
|
return;
|
|
66
|
-
function listener(file, isRemove) {
|
|
66
|
+
async function listener(file, isRemove) {
|
|
67
67
|
file = normalizePath(file);
|
|
68
|
-
if (isPlusFile(file) || isVikeConfigDependency(file, server.moduleGraph)?.modifiesVikeVirtualFiles) {
|
|
68
|
+
if (isPlusFile(file) || (await isVikeConfigDependency(file, server.moduleGraph))?.modifiesVikeVirtualFiles) {
|
|
69
69
|
invalidateVikeVirtualFiles(server);
|
|
70
70
|
reloadConfig(file, config, isRemove ? 'removed' : 'created');
|
|
71
71
|
}
|
|
@@ -77,9 +77,9 @@ function invalidateVikeVirtualFiles(server) {
|
|
|
77
77
|
server.moduleGraph.invalidateModule(mod);
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
function handleHotUpdate(ctx, config) {
|
|
80
|
+
async function handleHotUpdate(ctx, config) {
|
|
81
81
|
const { file, server } = ctx;
|
|
82
|
-
const isVikeConfig = isVikeConfigDependency(ctx.file, ctx.server.moduleGraph);
|
|
82
|
+
const isVikeConfig = await isVikeConfigDependency(ctx.file, ctx.server.moduleGraph);
|
|
83
83
|
if (isVikeConfig) {
|
|
84
84
|
if (isVikeConfig.modifiesVikeVirtualFiles) {
|
|
85
85
|
/* Tailwind breaks this assertion, see https://github.com/vikejs/vike/discussions/1330#discussioncomment-7787238
|
|
@@ -101,12 +101,16 @@ function handleHotUpdate(ctx, config) {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
104
|
+
async function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
105
105
|
// Check config-only files, for example all pages/+config.js dependencies. (There aren't part of Vite's module graph.)
|
|
106
106
|
assertPosixPath(filePathAbsoluteFilesystem);
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
|
|
107
|
+
const vikeConfigObject = await getVikeConfigOptional();
|
|
108
|
+
if (vikeConfigObject) {
|
|
109
|
+
const { vikeConfigDependencies } = vikeConfigObject;
|
|
110
|
+
vikeConfigDependencies.forEach((f) => assertPosixPath(f));
|
|
111
|
+
if (vikeConfigDependencies.has(filePathAbsoluteFilesystem))
|
|
112
|
+
return { modifiesVikeVirtualFiles: true };
|
|
113
|
+
}
|
|
110
114
|
// Check using Vite's module graph, for example all +htmlAttributes dependencies.
|
|
111
115
|
// Alternatively, simply call updateUserFiles() on every handleHotUpdate() call.
|
|
112
116
|
const importers = getImporters(filePathAbsoluteFilesystem, moduleGraph);
|
|
@@ -44,7 +44,9 @@ type ConfigDefinition = {
|
|
|
44
44
|
*
|
|
45
45
|
* https://vike.dev/extends#inheritance
|
|
46
46
|
*/
|
|
47
|
-
global?: boolean | ((value: unknown
|
|
47
|
+
global?: boolean | ((value: unknown, moreInfo: {
|
|
48
|
+
isGlobalLocation: boolean;
|
|
49
|
+
}) => boolean);
|
|
48
50
|
type?: string | string[];
|
|
49
51
|
};
|
|
50
52
|
/**
|
|
@@ -96,7 +96,7 @@ const configDefinitionsBuiltIn = {
|
|
|
96
96
|
assert(source.valueIsLoaded);
|
|
97
97
|
if (source.value !== null) {
|
|
98
98
|
const { value } = source;
|
|
99
|
-
const definedAt = getConfigDefinedAt('Config', 'clientHooks', source.
|
|
99
|
+
const definedAt = getConfigDefinedAt('Config', 'clientHooks', source.definedAt);
|
|
100
100
|
assertUsage(typeof value === 'boolean', `${definedAt} should be a boolean`);
|
|
101
101
|
return value;
|
|
102
102
|
}
|
|
@@ -123,6 +123,14 @@ const configDefinitionsBuiltIn = {
|
|
|
123
123
|
cacheControl: {
|
|
124
124
|
env: { server: true }
|
|
125
125
|
},
|
|
126
|
+
host: {
|
|
127
|
+
env: { config: true },
|
|
128
|
+
global: true
|
|
129
|
+
},
|
|
130
|
+
port: {
|
|
131
|
+
env: { config: true },
|
|
132
|
+
global: true
|
|
133
|
+
},
|
|
126
134
|
injectScriptsAt: {
|
|
127
135
|
env: { server: true }
|
|
128
136
|
},
|
|
@@ -148,7 +156,7 @@ const configDefinitionsBuiltIn = {
|
|
|
148
156
|
},
|
|
149
157
|
prerender: {
|
|
150
158
|
env: { config: true },
|
|
151
|
-
global: (value) => typeof value === 'object',
|
|
159
|
+
global: (value, { isGlobalLocation }) => typeof value === 'object' || isGlobalLocation,
|
|
152
160
|
type: ['boolean', 'object'],
|
|
153
161
|
cumulative: true
|
|
154
162
|
},
|
|
@@ -7,8 +7,11 @@ import type { FilePathResolved } from '../../../../../../shared/page-configs/Fil
|
|
|
7
7
|
type FileExports = {
|
|
8
8
|
fileExports: Record<string, unknown>;
|
|
9
9
|
};
|
|
10
|
-
type EsbuildCache =
|
|
11
|
-
|
|
10
|
+
type EsbuildCache = {
|
|
11
|
+
transpileCache: Record<string, // filePathAbsoluteFilesystem
|
|
12
|
+
Promise<FileExports>>;
|
|
13
|
+
vikeConfigDependencies: Set<string>;
|
|
14
|
+
};
|
|
12
15
|
declare function transpileAndExecuteFile(filePath: FilePathResolved, userRootDir: string, isExtensionConfig: boolean, esbuildCache: EsbuildCache): Promise<FileExports>;
|
|
13
16
|
declare function getConfigBuildErrorFormatted(err: unknown): null | string;
|
|
14
17
|
declare function getConfigExecutionErrorIntroMsg(err: unknown): string | null;
|
|
@@ -9,7 +9,6 @@ import pc from '@brillout/picocolors';
|
|
|
9
9
|
import { import_ } from '@brillout/import';
|
|
10
10
|
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, assertWarning, isObject, toPosixPath, assertUsage, isPlainJavaScriptFile, createDebugger, assertFilePathAbsoluteFilesystem, assertIsNpmPackageImport, genPromise, isVitest } from '../../../../utils.js';
|
|
11
11
|
import { transformPointerImports } from './transformPointerImports.js';
|
|
12
|
-
import { vikeConfigDependencies } from '../getVikeConfig.js';
|
|
13
12
|
import sourceMapSupport from 'source-map-support';
|
|
14
13
|
import { getFilePathAbsoluteUserRootDir } from '../../../../shared/getFilePath.js';
|
|
15
14
|
import { createRequire } from 'module';
|
|
@@ -26,11 +25,11 @@ async function transpileAndExecuteFile(filePath, userRootDir, isExtensionConfig,
|
|
|
26
25
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
27
26
|
assert(filePathAbsoluteFilesystem);
|
|
28
27
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
29
|
-
if (esbuildCache[filePathAbsoluteFilesystem]) {
|
|
30
|
-
return await esbuildCache[filePathAbsoluteFilesystem];
|
|
28
|
+
if (esbuildCache.transpileCache[filePathAbsoluteFilesystem]) {
|
|
29
|
+
return await esbuildCache.transpileCache[filePathAbsoluteFilesystem];
|
|
31
30
|
}
|
|
32
31
|
const { promise, resolve } = genPromise();
|
|
33
|
-
esbuildCache[filePathAbsoluteFilesystem] = promise;
|
|
32
|
+
esbuildCache.transpileCache[filePathAbsoluteFilesystem] = promise;
|
|
34
33
|
assertUsage(isPlainJavaScriptFile(filePathAbsoluteFilesystem), `${filePathToShowToUserResolved} has file extension .${fileExtension} but a config file can only be a JavaScript/TypeScript file`);
|
|
35
34
|
const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
|
|
36
35
|
if (isHeader) {
|
|
@@ -43,20 +42,20 @@ async function transpileAndExecuteFile(filePath, userRootDir, isExtensionConfig,
|
|
|
43
42
|
}
|
|
44
43
|
else {
|
|
45
44
|
const transformImports = isHeader ? 'all' : true;
|
|
46
|
-
const code = await transpileFile(filePath, transformImports, userRootDir);
|
|
45
|
+
const code = await transpileFile(filePath, transformImports, userRootDir, esbuildCache);
|
|
47
46
|
fileExports = await executeTranspiledFile(filePath, code);
|
|
48
47
|
}
|
|
49
48
|
resolve({ fileExports });
|
|
50
49
|
return { fileExports };
|
|
51
50
|
}
|
|
52
|
-
async function transpileFile(filePath, transformImports, userRootDir) {
|
|
51
|
+
async function transpileFile(filePath, transformImports, userRootDir, esbuildCache) {
|
|
53
52
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
54
53
|
assert(filePathAbsoluteFilesystem);
|
|
55
54
|
assertPosixPath(filePathAbsoluteFilesystem);
|
|
56
|
-
vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
55
|
+
esbuildCache.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
57
56
|
if (debug.isActivated)
|
|
58
57
|
debug('transpile', filePathToShowToUserResolved);
|
|
59
|
-
let { code, pointerImports } = await transpileWithEsbuild(filePath, userRootDir, transformImports);
|
|
58
|
+
let { code, pointerImports } = await transpileWithEsbuild(filePath, userRootDir, transformImports, esbuildCache);
|
|
60
59
|
if (debug.isActivated)
|
|
61
60
|
debug(`code, post esbuild (${filePathToShowToUserResolved})`, code);
|
|
62
61
|
let isImportTransformed = false;
|
|
@@ -75,7 +74,7 @@ async function transpileFile(filePath, transformImports, userRootDir) {
|
|
|
75
74
|
}
|
|
76
75
|
return code;
|
|
77
76
|
}
|
|
78
|
-
async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
77
|
+
async function transpileWithEsbuild(filePath, userRootDir, transformImports, esbuildCache) {
|
|
79
78
|
const entryFilePath = filePath.filePathAbsoluteFilesystem;
|
|
80
79
|
const entryFileDir = path.posix.dirname(entryFilePath);
|
|
81
80
|
const options = {
|
|
@@ -229,7 +228,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
229
228
|
// We collect the dependency `args.path` in case the bulid fails (upon build error => error is thrown => no metafile)
|
|
230
229
|
let { path } = args;
|
|
231
230
|
path = toPosixPath(path);
|
|
232
|
-
vikeConfigDependencies.add(path);
|
|
231
|
+
esbuildCache.vikeConfigDependencies.add(path);
|
|
233
232
|
return undefined;
|
|
234
233
|
});
|
|
235
234
|
/* To exhaustively collect all dependencies upon build failure, we would also need to use onResolve().
|
|
@@ -258,7 +257,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
258
257
|
filePathRelative = toPosixPath(filePathRelative);
|
|
259
258
|
assertPosixPath(userRootDir);
|
|
260
259
|
const filePathAbsoluteFilesystem = path.posix.join(userRootDir, filePathRelative);
|
|
261
|
-
vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
260
|
+
esbuildCache.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
262
261
|
});
|
|
263
262
|
const code = result.outputFiles[0].text;
|
|
264
263
|
assert(typeof code === 'string');
|
|
@@ -330,7 +329,7 @@ function getTemporaryBuildFilePath(filePathAbsoluteFilesystem) {
|
|
|
330
329
|
const dirname = path.posix.dirname(filePathAbsoluteFilesystem);
|
|
331
330
|
const filename = path.posix.basename(filePathAbsoluteFilesystem);
|
|
332
331
|
// Syntax with semicolon `build:${/*...*/}` doesn't work on Windows: https://github.com/vikejs/vike/issues/800#issuecomment-1517329455
|
|
333
|
-
const filePathTmp = path.posix.join(dirname, `${filename}.build-${getRandomId(
|
|
332
|
+
const filePathTmp = path.posix.join(dirname, `${filename}.build-${getRandomId()}.mjs`);
|
|
334
333
|
assert(isTemporaryBuildFile(filePathTmp));
|
|
335
334
|
return filePathTmp;
|
|
336
335
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getVikeConfig };
|
|
2
|
+
export { getVikeConfigOptional };
|
|
2
3
|
export { getVikeConfig2 };
|
|
3
4
|
export { reloadVikeConfig };
|
|
4
|
-
export { vikeConfigDependencies };
|
|
5
5
|
export { isV1Design };
|
|
6
6
|
export { getConfVal };
|
|
7
7
|
export { getConfigDefinitionOptional };
|
|
@@ -17,13 +17,14 @@ type VikeConfigObject = {
|
|
|
17
17
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
18
18
|
global: PageConfigUserFriendly;
|
|
19
19
|
pages: PageConfigsUserFriendly;
|
|
20
|
+
vikeConfigDependencies: Set<string>;
|
|
20
21
|
};
|
|
21
|
-
declare const vikeConfigDependencies: Set<string>;
|
|
22
22
|
declare function reloadVikeConfig(config: ResolvedConfig): void;
|
|
23
23
|
declare function getVikeConfig(config: ResolvedConfig, { doNotRestartViteOnError }?: {
|
|
24
24
|
doNotRestartViteOnError?: true;
|
|
25
25
|
}): Promise<VikeConfigObject>;
|
|
26
26
|
declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePluginOptions: unknown): Promise<VikeConfigObject>;
|
|
27
|
+
declare function getVikeConfigOptional(): Promise<null | VikeConfigObject>;
|
|
27
28
|
declare function isV1Design(config: ResolvedConfig | UserConfig): boolean;
|
|
28
29
|
declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitions, configName: string): ConfigDefinitionInternal | null;
|
|
29
30
|
declare function getConfVal(plusFile: PlusFile, configName: string): null | {
|