vike 0.4.239-commit-050a4a3 → 0.4.239-commit-59f1017
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/prerender/runPrerender.js +1 -0
- package/dist/cjs/node/runtime/globalContext.js +9 -0
- package/dist/cjs/node/vite/onLoad.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +20 -5
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +15 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +13 -7
- package/dist/cjs/node/vite/plugins/pluginBuild.js +1 -0
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +4 -5
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +9 -5
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +11 -5
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +43 -30
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +19 -7
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +23 -5
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +12 -7
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/virtualFileId.js +15 -11
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +3 -3
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +14 -1
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +1 -1
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +4 -2
- package/dist/esm/node/prerender/runPrerender.js +2 -1
- package/dist/esm/node/runtime/globalContext.d.ts +13 -2
- package/dist/esm/node/runtime/globalContext.js +10 -1
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +4 -2
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +4 -2
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +8 -4
- package/dist/esm/node/runtime/renderPage.d.ts +4 -2
- package/dist/esm/node/vite/onLoad.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +4 -0
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +21 -6
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +16 -4
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +14 -8
- package/dist/esm/node/vite/plugins/pluginBuild.js +1 -0
- package/dist/esm/node/vite/plugins/pluginCommon.js +1 -1
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +4 -5
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +9 -3
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +11 -5
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +43 -30
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +20 -8
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +11 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +22 -5
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +13 -8
- package/dist/esm/shared/createGlobalContextShared.d.ts +3 -3
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/virtualFileId.d.ts +4 -0
- package/dist/esm/utils/virtualFileId.js +14 -11
- package/package.json +5 -5
|
@@ -7,7 +7,7 @@ export type { PageContextBegin };
|
|
|
7
7
|
import { type PageContextFromRewrite } from '../../shared/route/abort.js';
|
|
8
8
|
import { type ScrollTarget } from './setScrollPosition.js';
|
|
9
9
|
import type { PageContextConfig } from '../../shared/getPageFiles.js';
|
|
10
|
-
import type { PageContextClient } from '../../types/PageContext.js';
|
|
10
|
+
import type { PageContextClient, PageContextInternalClient } from '../../types/PageContext.js';
|
|
11
11
|
import type { VikeGlobalInternal } from '../../types/VikeGlobalInternal.js';
|
|
12
12
|
declare const firstRenderStartPromise: Promise<void>;
|
|
13
13
|
type PageContextRouted = {
|
|
@@ -92,7 +92,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
92
92
|
} & {
|
|
93
93
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
94
94
|
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
95
|
-
}
|
|
95
|
+
};
|
|
96
96
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
97
97
|
_urlHandler: null;
|
|
98
98
|
_urlRewrite: null | string;
|
|
@@ -107,7 +107,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
107
107
|
isHydration: boolean;
|
|
108
108
|
previousPageContext: ({
|
|
109
109
|
pageId: string;
|
|
110
|
-
} & PageContextConfig & PageContextRouted & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum &
|
|
110
|
+
} & PageContextConfig & PageContextRouted & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & PageContextInternalClient & Omit<Partial<PageContextConfig & {
|
|
111
111
|
isPageContext: true;
|
|
112
112
|
Page: import("../../types/Config.js").Config["Page"];
|
|
113
113
|
routeParams: Record<string, string>;
|
|
@@ -16,7 +16,7 @@ import { route } from '../../shared/route/index.js';
|
|
|
16
16
|
import { isClientSideRoutable } from './isClientSideRoutable.js';
|
|
17
17
|
import { setScrollPosition } from './setScrollPosition.js';
|
|
18
18
|
import { scrollRestoration_initialRenderIsDone } from './scrollRestoration.js';
|
|
19
|
-
import { getErrorPageId } from '../../shared/error-page.js';
|
|
19
|
+
import { getErrorPageId, isErrorPage } from '../../shared/error-page.js';
|
|
20
20
|
import { setPageContextCurrent } from './getPageContextCurrent.js';
|
|
21
21
|
import { getRouteStringParameterList } from '../../shared/route/resolveRouteString.js';
|
|
22
22
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
@@ -644,3 +644,16 @@ function handleErrorFetchingStaticAssets(err, pageContext, isFirstRender) {
|
|
|
644
644
|
redirectHard(pageContext.urlOriginal);
|
|
645
645
|
return true;
|
|
646
646
|
}
|
|
647
|
+
// [HMR] If error page is shown => re-render whole page
|
|
648
|
+
if (import.meta.env.DEV && import.meta.hot)
|
|
649
|
+
import.meta.hot.on('vite:beforeUpdate', () => {
|
|
650
|
+
const pageContext = globalObject.renderedPageContext;
|
|
651
|
+
if (pageContext?.pageId && isErrorPage(pageContext.pageId, pageContext._globalContext._pageConfigs)) {
|
|
652
|
+
renderPageClientSide({
|
|
653
|
+
scrollTarget: { preserveScroll: false },
|
|
654
|
+
urlOriginal: getCurrentUrl(),
|
|
655
|
+
overwriteLastHistoryEntry: true,
|
|
656
|
+
isBackwardNavigation: false,
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
});
|
|
@@ -54,7 +54,7 @@ declare function createPageContextClientSide(): Promise<{
|
|
|
54
54
|
_allPageIds: string[];
|
|
55
55
|
} & {
|
|
56
56
|
isClientSide: true;
|
|
57
|
-
} & object
|
|
57
|
+
} & object;
|
|
58
58
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
59
59
|
isBackwardNavigation: null;
|
|
60
60
|
_hasPageContextFromServer: true;
|
|
@@ -58,7 +58,7 @@ declare function createGetGlobalContextClient<GlobalContextAddendum extends obje
|
|
|
58
58
|
* We recommend using `import.meta.env.SSR` instead, see https://vike.dev/globalContext
|
|
59
59
|
*/
|
|
60
60
|
isClientSide: true;
|
|
61
|
-
} & Awaited<GlobalContextAddendum
|
|
61
|
+
} & Awaited<GlobalContextAddendum>>;
|
|
62
62
|
type NeverExported = never;
|
|
63
63
|
declare function getGlobalContext(): Promise<NeverExported>;
|
|
64
64
|
declare function getGlobalContextSync(): NeverExported;
|
|
@@ -74,7 +74,7 @@ declare function createPageContextPrerendering(urlOriginal: string, prerenderCon
|
|
|
74
74
|
url?: string;
|
|
75
75
|
headers?: Record<string, string>;
|
|
76
76
|
} & {
|
|
77
|
-
_globalContext: {
|
|
77
|
+
_globalContext: ({
|
|
78
78
|
_globalConfigPublic: {
|
|
79
79
|
pages: {
|
|
80
80
|
[k: string]: {
|
|
@@ -162,7 +162,9 @@ declare function createPageContextPrerendering(urlOriginal: string, prerenderCon
|
|
|
162
162
|
inject: boolean | undefined;
|
|
163
163
|
};
|
|
164
164
|
};
|
|
165
|
-
})
|
|
165
|
+
})) & {
|
|
166
|
+
prerenderContext: PrerenderContextPublic | undefined;
|
|
167
|
+
};
|
|
166
168
|
_pageFilesAll: PageFile[];
|
|
167
169
|
_baseServer: string;
|
|
168
170
|
_baseAssets: string;
|
|
@@ -9,7 +9,7 @@ import { prerenderPage } from '../runtime/renderPage/renderPageAfterRoute.js';
|
|
|
9
9
|
import { createPageContextServerSide } from '../runtime/renderPage/createPageContextServerSide.js';
|
|
10
10
|
import pc from '@brillout/picocolors';
|
|
11
11
|
import { cpus } from 'node:os';
|
|
12
|
-
import { getGlobalContextServerInternal, initGlobalContext_runPrerender, setGlobalContext_isPrerendering, } from '../runtime/globalContext.js';
|
|
12
|
+
import { getGlobalContextServerInternal, initGlobalContext_runPrerender, setGlobalContext_isPrerendering, setGlobalContext_prerenderContext, } from '../runtime/globalContext.js';
|
|
13
13
|
import { resolveConfig as resolveViteConfig } from 'vite';
|
|
14
14
|
import { getPageFilesServerSide } from '../../shared/getPageFiles.js';
|
|
15
15
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
@@ -108,6 +108,7 @@ async function runPrerender(options = {}, trigger) {
|
|
|
108
108
|
await warnMissingPages(prerenderContext._prerenderedPageContexts, globalContext, doNotPrerenderList, partial);
|
|
109
109
|
const prerenderContextPublic = preparePrerenderContextForPublicUsage(prerenderContext);
|
|
110
110
|
objectAssign(vikeConfig.prerenderContext, prerenderContextPublic, true);
|
|
111
|
+
setGlobalContext_prerenderContext(prerenderContextPublic);
|
|
111
112
|
if (prerenderConfigGlobal.isPrerenderingEnabledForAllPages && !prerenderConfigGlobal.keepDistServer) {
|
|
112
113
|
fs.rmSync(outDirServer, { recursive: true });
|
|
113
114
|
}
|
|
@@ -10,6 +10,7 @@ export { initGlobalContext_getPagesAndRoutes };
|
|
|
10
10
|
export { setGlobalContext_viteDevServer };
|
|
11
11
|
export { setGlobalContext_viteConfig };
|
|
12
12
|
export { setGlobalContext_isPrerendering };
|
|
13
|
+
export { setGlobalContext_prerenderContext };
|
|
13
14
|
export { setGlobalContext_isProductionAccordingToVite };
|
|
14
15
|
export { setGlobalContext_prodBuildEntry };
|
|
15
16
|
export { clearGlobalContext };
|
|
@@ -26,6 +27,7 @@ import { type PageRoutes } from '../../shared/route/loadPageRoutes.js';
|
|
|
26
27
|
import type { ViteConfigRuntime } from '../vite/shared/getViteConfigRuntime.js';
|
|
27
28
|
import type { GlobalContext } from '../../types/PageContext.js';
|
|
28
29
|
import type { Hook } from '../../shared/hooks/getHook.js';
|
|
30
|
+
import type { PrerenderContext } from '../../types/index.js';
|
|
29
31
|
declare const vikeConfigErrorRecoverMsg: "Vike config loaded";
|
|
30
32
|
type GlobalContextServer = Pick<GlobalContextServerInternal, 'assetsManifest' | 'config' | 'viteConfig' | 'viteConfigRuntime' | 'pages' | 'baseServer' | 'baseAssets' | 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextServer;
|
|
31
33
|
type GlobalContextServerInternal = Awaited<ReturnType<typeof createGlobalContext>>;
|
|
@@ -98,6 +100,8 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
98
100
|
inject: boolean | undefined;
|
|
99
101
|
};
|
|
100
102
|
};
|
|
103
|
+
} & {
|
|
104
|
+
prerenderContext: PrerenderContext | undefined;
|
|
101
105
|
}) | (Record<string, unknown> & {
|
|
102
106
|
_globalConfigPublic: {
|
|
103
107
|
pages: {
|
|
@@ -167,6 +171,8 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
167
171
|
inject: boolean | undefined;
|
|
168
172
|
};
|
|
169
173
|
};
|
|
174
|
+
} & {
|
|
175
|
+
prerenderContext: PrerenderContext | undefined;
|
|
170
176
|
}) | (Record<string, unknown> & {
|
|
171
177
|
_globalConfigPublic: {
|
|
172
178
|
pages: {
|
|
@@ -236,6 +242,8 @@ declare function getGlobalContextServerInternal(): Promise<{
|
|
|
236
242
|
inject: boolean | undefined;
|
|
237
243
|
};
|
|
238
244
|
};
|
|
245
|
+
} & {
|
|
246
|
+
prerenderContext: PrerenderContext | undefined;
|
|
239
247
|
});
|
|
240
248
|
}>;
|
|
241
249
|
/**
|
|
@@ -259,6 +267,7 @@ declare function getGlobalContextSync(): GlobalContext;
|
|
|
259
267
|
declare function setGlobalContext_viteDevServer(viteDevServer: ViteDevServer): Promise<void>;
|
|
260
268
|
declare function setGlobalContext_viteConfig(viteConfig: ResolvedConfig, viteConfigRuntime: ViteConfigRuntime): void;
|
|
261
269
|
declare function setGlobalContext_isPrerendering(): void;
|
|
270
|
+
declare function setGlobalContext_prerenderContext(prerenderContextPublic: PrerenderContext): void;
|
|
262
271
|
declare function setGlobalContext_isProductionAccordingToVite(isProductionAccordingToVite: boolean): void;
|
|
263
272
|
declare function getViteDevServer(): ViteDevServer | null;
|
|
264
273
|
declare function getViteConfig(): ResolvedConfig | null;
|
|
@@ -275,7 +284,7 @@ declare function assertBuildInfo(buildInfo: unknown): asserts buildInfo is Build
|
|
|
275
284
|
declare function updateUserFiles(): Promise<{
|
|
276
285
|
success: boolean;
|
|
277
286
|
}>;
|
|
278
|
-
declare function createGlobalContext(virtualFileExportsGlobalEntry: unknown): Promise<{
|
|
287
|
+
declare function createGlobalContext(virtualFileExportsGlobalEntry: unknown): Promise<({
|
|
279
288
|
_globalConfigPublic: {
|
|
280
289
|
pages: {
|
|
281
290
|
[k: string]: {
|
|
@@ -363,6 +372,8 @@ declare function createGlobalContext(virtualFileExportsGlobalEntry: unknown): Pr
|
|
|
363
372
|
inject: boolean | undefined;
|
|
364
373
|
};
|
|
365
374
|
};
|
|
366
|
-
})
|
|
375
|
+
})) & {
|
|
376
|
+
prerenderContext: PrerenderContext | undefined;
|
|
377
|
+
}>;
|
|
367
378
|
declare function clearGlobalContext(): void;
|
|
368
379
|
declare function isRunnable(viteDevServer: ViteDevServer): boolean;
|
|
@@ -12,6 +12,7 @@ export { initGlobalContext_getPagesAndRoutes };
|
|
|
12
12
|
export { setGlobalContext_viteDevServer };
|
|
13
13
|
export { setGlobalContext_viteConfig };
|
|
14
14
|
export { setGlobalContext_isPrerendering };
|
|
15
|
+
export { setGlobalContext_prerenderContext };
|
|
15
16
|
export { setGlobalContext_isProductionAccordingToVite };
|
|
16
17
|
export { setGlobalContext_prodBuildEntry }; // production entry
|
|
17
18
|
export { clearGlobalContext };
|
|
@@ -27,7 +28,7 @@ export { vikeConfigErrorRecoverMsg };
|
|
|
27
28
|
// - Without vike-server it's manually loaded here using importServerProductionEntry() which uses @brillout/vite-plugin-server-entry's autoImporter or crawler
|
|
28
29
|
// - In development: globalObject.viteDevServer which is Vite's development server
|
|
29
30
|
// - globalObject.viteDevServer is used by updateUserFiles() which then sets virtualFileExportsGlobalEntry
|
|
30
|
-
import { assert, onSetupRuntime, assertUsage, assertWarning, isPlainObject, objectReplace, isObject, hasProp, getGlobalObject, genPromise, createDebugger, checkType, PROJECT_VERSION, getViteRPC, isRunnableDevEnvironment, assertIsNotBrowser, isNonRunnableDev, } from './utils.js';
|
|
31
|
+
import { assert, onSetupRuntime, assertUsage, assertWarning, isPlainObject, objectReplace, isObject, hasProp, getGlobalObject, genPromise, createDebugger, checkType, PROJECT_VERSION, getViteRPC, isRunnableDevEnvironment, assertIsNotBrowser, isNonRunnableDev, objectAssign, } from './utils.js';
|
|
31
32
|
import { importServerProductionEntry } from '@brillout/vite-plugin-server-entry/runtime';
|
|
32
33
|
import { virtualFileIdGlobalEntryServer } from '../shared/virtualFileId.js';
|
|
33
34
|
import pc from '@brillout/picocolors';
|
|
@@ -150,6 +151,13 @@ function assertIsNotInitializedYet() {
|
|
|
150
151
|
function setGlobalContext_isPrerendering() {
|
|
151
152
|
globalObject.isPrerendering = true;
|
|
152
153
|
}
|
|
154
|
+
function setGlobalContext_prerenderContext(prerenderContextPublic) {
|
|
155
|
+
globalObject.prerenderContextPublic = prerenderContextPublic;
|
|
156
|
+
// Ugly redundancy, which we can remove after globalContext is a proxy
|
|
157
|
+
const { globalContext } = globalObjectTyped;
|
|
158
|
+
if (globalContext)
|
|
159
|
+
globalContext.prerenderContext = prerenderContextPublic;
|
|
160
|
+
}
|
|
153
161
|
function setGlobalContext_isProductionAccordingToVite(isProductionAccordingToVite) {
|
|
154
162
|
globalObject.isProductionAccordingToVite = isProductionAccordingToVite;
|
|
155
163
|
}
|
|
@@ -401,6 +409,7 @@ async function createGlobalContext(virtualFileExportsGlobalEntry) {
|
|
|
401
409
|
globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
|
|
402
410
|
assertGlobalContextIsDefined();
|
|
403
411
|
onSetupRuntime();
|
|
412
|
+
objectAssign(globalContext, { prerenderContext: globalObject.prerenderContextPublic });
|
|
404
413
|
// Never actually used, only used for TypeScript `ReturnType<typeof createGlobalContext>`
|
|
405
414
|
return globalContext;
|
|
406
415
|
}
|
|
@@ -23,7 +23,7 @@ declare function createPageContextServerSide(pageContextInit: PageContextInit, g
|
|
|
23
23
|
url?: string;
|
|
24
24
|
headers?: Record<string, string>;
|
|
25
25
|
} & {
|
|
26
|
-
_globalContext: {
|
|
26
|
+
_globalContext: ({
|
|
27
27
|
_globalConfigPublic: {
|
|
28
28
|
pages: {
|
|
29
29
|
[k: string]: {
|
|
@@ -111,7 +111,9 @@ declare function createPageContextServerSide(pageContextInit: PageContextInit, g
|
|
|
111
111
|
inject: boolean | undefined;
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
|
-
})
|
|
114
|
+
})) & {
|
|
115
|
+
prerenderContext: import("../../prerender/runPrerender.js").PrerenderContextPublic | undefined;
|
|
116
|
+
};
|
|
115
117
|
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
116
118
|
_baseServer: string;
|
|
117
119
|
_baseAssets: string;
|
|
@@ -24,7 +24,7 @@ declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPage
|
|
|
24
24
|
url?: string;
|
|
25
25
|
headers?: Record<string, string>;
|
|
26
26
|
} & {
|
|
27
|
-
_globalContext: {
|
|
27
|
+
_globalContext: ({
|
|
28
28
|
_globalConfigPublic: {
|
|
29
29
|
pages: {
|
|
30
30
|
[k: string]: {
|
|
@@ -112,7 +112,9 @@ declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPage
|
|
|
112
112
|
inject: boolean | undefined;
|
|
113
113
|
};
|
|
114
114
|
};
|
|
115
|
-
})
|
|
115
|
+
})) & {
|
|
116
|
+
prerenderContext: import("../../prerender/runPrerender.js").PrerenderContextPublic | undefined;
|
|
117
|
+
};
|
|
116
118
|
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
117
119
|
_baseServer: string;
|
|
118
120
|
_baseAssets: string;
|
|
@@ -39,7 +39,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
39
39
|
url?: string;
|
|
40
40
|
headers?: Record<string, string>;
|
|
41
41
|
} & {
|
|
42
|
-
_globalContext: {
|
|
42
|
+
_globalContext: ({
|
|
43
43
|
_globalConfigPublic: {
|
|
44
44
|
pages: {
|
|
45
45
|
[k: string]: {
|
|
@@ -127,7 +127,9 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
127
127
|
inject: boolean | undefined;
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
|
-
})
|
|
130
|
+
})) & {
|
|
131
|
+
prerenderContext: import("../../prerender/runPrerender.js").PrerenderContextPublic | undefined;
|
|
132
|
+
};
|
|
131
133
|
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
132
134
|
_baseServer: string;
|
|
133
135
|
_baseAssets: string;
|
|
@@ -201,7 +203,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
201
203
|
url?: string;
|
|
202
204
|
headers?: Record<string, string>;
|
|
203
205
|
} & {
|
|
204
|
-
_globalContext: {
|
|
206
|
+
_globalContext: ({
|
|
205
207
|
_globalConfigPublic: {
|
|
206
208
|
pages: {
|
|
207
209
|
[k: string]: {
|
|
@@ -289,7 +291,9 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
289
291
|
inject: boolean | undefined;
|
|
290
292
|
};
|
|
291
293
|
};
|
|
292
|
-
})
|
|
294
|
+
})) & {
|
|
295
|
+
prerenderContext: import("../../prerender/runPrerender.js").PrerenderContextPublic | undefined;
|
|
296
|
+
};
|
|
293
297
|
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
294
298
|
_baseServer: string;
|
|
295
299
|
_baseAssets: string;
|
|
@@ -31,7 +31,7 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
31
31
|
/** @deprecated Set `pageContextInit.urlOriginal` instead */ url?: string;
|
|
32
32
|
/** @deprecated Set pageContextInit.headersOriginal instead */ headers?: Record<string, string>;
|
|
33
33
|
} & {
|
|
34
|
-
_globalContext: {
|
|
34
|
+
_globalContext: ({
|
|
35
35
|
_globalConfigPublic: {
|
|
36
36
|
pages: {
|
|
37
37
|
[k: string]: {
|
|
@@ -119,7 +119,9 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
119
119
|
inject: boolean | undefined;
|
|
120
120
|
};
|
|
121
121
|
};
|
|
122
|
-
})
|
|
122
|
+
})) & {
|
|
123
|
+
prerenderContext: import("../prerender/runPrerender.js").PrerenderContextPublic | undefined;
|
|
124
|
+
};
|
|
123
125
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
124
126
|
_baseServer: string;
|
|
125
127
|
_baseAssets: string;
|
|
@@ -13,7 +13,7 @@ function onLoad() {
|
|
|
13
13
|
// TO-DO/eventually: let's also use this.meta.viteVersion
|
|
14
14
|
// - https://github.com/vitejs/vite/pull/20088
|
|
15
15
|
// - https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#700-2025-06-24
|
|
16
|
-
assertVersion('Vite', version, ['6.
|
|
16
|
+
assertVersion('Vite', version, ['6.3.0']);
|
|
17
17
|
// Ensure we don't bloat the server runtime with heavy dependencies such Vite and esbuild
|
|
18
18
|
assertIsNotProductionRuntime();
|
|
19
19
|
}
|
|
@@ -3,10 +3,14 @@ export { handleAssetsManifest_getBuildConfig };
|
|
|
3
3
|
export { handleAssetsManifest_isFixEnabled };
|
|
4
4
|
export { handleAssetsManifest_assertUsageCssCodeSplit };
|
|
5
5
|
export { handleAssetsManifest_assertUsageCssTarget };
|
|
6
|
+
export { handleAssetsManifest_workaroundCssTarget_part1 };
|
|
7
|
+
export { handleAssetsManifest_workaroundCssTarget_part2 };
|
|
6
8
|
import type { Environment, ResolvedConfig, Rollup } from 'vite';
|
|
7
9
|
type Bundle = Rollup.OutputBundle;
|
|
8
10
|
declare function handleAssetsManifest_isFixEnabled(): boolean;
|
|
9
11
|
declare function handleAssetsManifest_assertUsageCssCodeSplit(config: ResolvedConfig): void;
|
|
12
|
+
declare function handleAssetsManifest_workaroundCssTarget_part1(config: ResolvedConfig): void;
|
|
13
|
+
declare function handleAssetsManifest_workaroundCssTarget_part2(): void;
|
|
10
14
|
declare function handleAssetsManifest_assertUsageCssTarget(config: ResolvedConfig, env: Environment): void;
|
|
11
15
|
declare function handleAssetsManifest_getBuildConfig(): Promise<{
|
|
12
16
|
readonly ssrEmitAssets: true | undefined;
|
|
@@ -3,6 +3,8 @@ export { handleAssetsManifest_getBuildConfig };
|
|
|
3
3
|
export { handleAssetsManifest_isFixEnabled };
|
|
4
4
|
export { handleAssetsManifest_assertUsageCssCodeSplit };
|
|
5
5
|
export { handleAssetsManifest_assertUsageCssTarget };
|
|
6
|
+
export { handleAssetsManifest_workaroundCssTarget_part1 };
|
|
7
|
+
export { handleAssetsManifest_workaroundCssTarget_part2 };
|
|
6
8
|
import fs from 'node:fs/promises';
|
|
7
9
|
import fs_sync from 'node:fs';
|
|
8
10
|
import path from 'node:path';
|
|
@@ -13,11 +15,14 @@ import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
|
13
15
|
import pc from '@brillout/picocolors';
|
|
14
16
|
import { isV1Design } from '../../shared/resolveVikeConfigInternal.js';
|
|
15
17
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
16
|
-
import { isViteServerSide_onlySsrEnv, isViteServerSide } from '../../shared/isViteServerSide.js';
|
|
18
|
+
import { isViteServerSide_onlySsrEnv, isViteServerSide, isViteServerSide_viteEnvOptional, } from '../../shared/isViteServerSide.js';
|
|
17
19
|
import { set_macro_ASSETS_MANIFEST } from './pluginProdBuildEntry.js';
|
|
18
20
|
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
19
|
-
const globalObject = getGlobalObject('
|
|
21
|
+
const globalObject = getGlobalObject('handleAssetsManifest.ts', {
|
|
20
22
|
assetsJsonFilePath: undefined,
|
|
23
|
+
cssTarget: '__VIKE__UNSET',
|
|
24
|
+
targetsAll: [],
|
|
25
|
+
configsAll: [],
|
|
21
26
|
});
|
|
22
27
|
// yes => use workaround config.build.ssrEmitAssets
|
|
23
28
|
// false => use workaround extractAssets plugin
|
|
@@ -216,16 +221,26 @@ function handleAssetsManifest_assertUsageCssCodeSplit(config) {
|
|
|
216
221
|
return;
|
|
217
222
|
assertWarning(config.build.cssCodeSplit, `${pc.cyan('build.cssCodeSplit')} shouldn't be set to ${pc.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
218
223
|
}
|
|
219
|
-
|
|
224
|
+
function handleAssetsManifest_workaroundCssTarget_part1(config) {
|
|
225
|
+
globalObject.configsAll.push(config);
|
|
226
|
+
if (!isViteServerSide_viteEnvOptional(config, undefined)) {
|
|
227
|
+
globalObject.cssTarget = config.build.cssTarget;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function handleAssetsManifest_workaroundCssTarget_part2() {
|
|
231
|
+
assert(globalObject.cssTarget !== '__VIKE__UNSET');
|
|
232
|
+
globalObject.configsAll.forEach((c) => (c.build.cssTarget = globalObject.cssTarget));
|
|
233
|
+
}
|
|
220
234
|
function handleAssetsManifest_assertUsageCssTarget(config, env) {
|
|
221
235
|
if (!handleAssetsManifest_isFixEnabled())
|
|
222
236
|
return;
|
|
223
237
|
const isServerSide = isViteServerSide(config, env);
|
|
224
238
|
assert(typeof isServerSide === 'boolean');
|
|
225
239
|
assert(config.build.target !== undefined);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const
|
|
240
|
+
const { targetsAll } = globalObject;
|
|
241
|
+
targetsAll.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
242
|
+
const targetsServer = targetsAll.filter((t) => t.isServerSide);
|
|
243
|
+
const targetsClient = targetsAll.filter((t) => !t.isServerSide);
|
|
229
244
|
targetsClient.forEach((targetClient) => {
|
|
230
245
|
const targetCssResolvedClient = resolveCssTarget(targetClient);
|
|
231
246
|
targetsServer.forEach((targetServer) => {
|
|
@@ -10,20 +10,32 @@ 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
12
|
import { isViteServerSide_viteEnvOptional } from '../../shared/isViteServerSide.js';
|
|
13
|
-
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, } from './handleAssetsManifest.js';
|
|
13
|
+
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, handleAssetsManifest_workaroundCssTarget_part1, handleAssetsManifest_workaroundCssTarget_part2, } from './handleAssetsManifest.js';
|
|
14
14
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
15
15
|
function pluginBuildConfig() {
|
|
16
16
|
let config;
|
|
17
17
|
return [
|
|
18
18
|
{
|
|
19
|
-
name: 'vike:build:pluginBuildConfig',
|
|
19
|
+
name: 'vike:build:pluginBuildConfig:post1',
|
|
20
20
|
apply: 'build',
|
|
21
21
|
enforce: 'post',
|
|
22
22
|
configResolved: {
|
|
23
23
|
order: 'post',
|
|
24
|
-
|
|
25
|
-
onSetupBuild();
|
|
24
|
+
handler(config_) {
|
|
26
25
|
config = config_;
|
|
26
|
+
handleAssetsManifest_workaroundCssTarget_part1(config);
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'vike:build:pluginBuildConfig:post2',
|
|
32
|
+
apply: 'build',
|
|
33
|
+
enforce: 'post',
|
|
34
|
+
configResolved: {
|
|
35
|
+
order: 'post',
|
|
36
|
+
async handler() {
|
|
37
|
+
handleAssetsManifest_workaroundCssTarget_part2();
|
|
38
|
+
onSetupBuild();
|
|
27
39
|
assertRollupInput(config);
|
|
28
40
|
const entries = await getEntries(config);
|
|
29
41
|
assert(Object.keys(entries).length > 0);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { pluginModuleBanner };
|
|
2
|
-
import { removeVirtualFileIdPrefix } from '../../utils.js';
|
|
2
|
+
import { assert, removeVirtualFileIdPrefix } from '../../utils.js';
|
|
3
3
|
import { getMagicString } from '../../shared/getMagicString.js';
|
|
4
|
-
import { isViteServerSide_extraSafe } from '../../shared/isViteServerSide.js';
|
|
5
4
|
// Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
|
|
6
5
|
// 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
6
|
function pluginModuleBanner() {
|
|
@@ -10,6 +9,13 @@ function pluginModuleBanner() {
|
|
|
10
9
|
name: 'vike:build:pluginModuleBanner',
|
|
11
10
|
enforce: 'post',
|
|
12
11
|
apply: 'build',
|
|
12
|
+
applyToEnvironment(environment) {
|
|
13
|
+
const { config } = environment;
|
|
14
|
+
const { consumer } = config;
|
|
15
|
+
const { minify } = config.build;
|
|
16
|
+
assert(minify === false || minify, { minify, consumer });
|
|
17
|
+
return !minify;
|
|
18
|
+
},
|
|
13
19
|
configResolved: {
|
|
14
20
|
handler(config_) {
|
|
15
21
|
config = config_;
|
|
@@ -17,12 +23,12 @@ function pluginModuleBanner() {
|
|
|
17
23
|
},
|
|
18
24
|
transform: {
|
|
19
25
|
order: 'post',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
+
/* Using a Rolldown hook filter doesn't make sense here — we use applyToEnvironment() to conditionally apply this plugin.
|
|
27
|
+
filter: {},
|
|
28
|
+
*/
|
|
29
|
+
handler(code, id) {
|
|
30
|
+
const { minify } = this.environment.config.build;
|
|
31
|
+
assert(minify === false, { minify });
|
|
26
32
|
if (id.startsWith('\0'))
|
|
27
33
|
id = id;
|
|
28
34
|
id = removeVirtualFileIdPrefix(id);
|
|
@@ -6,6 +6,7 @@ import { pluginDistFileNames } from './pluginBuild/pluginDistFileNames.js';
|
|
|
6
6
|
import { pluginProdBuildEntry } from './pluginBuild/pluginProdBuildEntry.js';
|
|
7
7
|
import { pluginBuildConfig } from './pluginBuild/pluginBuildConfig.js';
|
|
8
8
|
import { pluginModuleBanner } from './pluginBuild/pluginModuleBanner.js';
|
|
9
|
+
// TODO/now refactor
|
|
9
10
|
function pluginBuild() {
|
|
10
11
|
return [
|
|
11
12
|
...pluginBuildConfig(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { pluginCommon };
|
|
2
|
-
import { assert, assertUsage, assertWarning, hasProp, isDevCheck, isDocker, isObject, isVitest
|
|
2
|
+
import { assert, assertUsage, assertWarning, hasProp, isDevCheck, isDocker, isObject, isVitest } from '../utils.js';
|
|
3
3
|
import { assertRollupInput } from './pluginBuild/pluginBuildConfig.js';
|
|
4
4
|
import { installRequireShim_setUserRootDir } from '@brillout/require-shim';
|
|
5
5
|
import pc from '@brillout/picocolors';
|
|
@@ -5,6 +5,7 @@ import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
|
5
5
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
6
6
|
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
7
7
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
8
|
+
import { filterRolldown, filterFunction } from './pluginReplaceConstants.js';
|
|
8
9
|
// TO-DO/eventually:
|
|
9
10
|
// - Make import.meta.env work inside +config.js
|
|
10
11
|
// - For it to work, we'll probably need the user to define the settings (e.g. `envDir`) for loadEnv() inside vike.config.js instead of vite.config.js
|
|
@@ -28,16 +29,14 @@ function pluginEnvVars() {
|
|
|
28
29
|
},
|
|
29
30
|
},
|
|
30
31
|
transform: {
|
|
32
|
+
filter: filterRolldown,
|
|
31
33
|
handler(code, id, options) {
|
|
32
34
|
id = normalizeId(id);
|
|
33
35
|
assertPosixPath(id);
|
|
34
|
-
if (id.includes('/node_modules/'))
|
|
35
|
-
return;
|
|
36
36
|
assertPosixPath(config.root);
|
|
37
37
|
if (!id.startsWith(config.root))
|
|
38
|
-
return;
|
|
39
|
-
|
|
40
|
-
return;
|
|
38
|
+
return; // skip linked dependencies
|
|
39
|
+
assert(filterFunction(id, code));
|
|
41
40
|
const isBuild = config.command === 'build';
|
|
42
41
|
const isClientSide = !isViteServerSide_extraSafe(config, this.environment, options);
|
|
43
42
|
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// TO-DO/next-major-release: remove
|
|
1
2
|
// Remove this workaround if the other workaround config.build.ssrEmitAssets turns out to be reliable.
|
|
2
3
|
// - Remove this file then revert this commit: https://github.com/vikejs/vike/commit/805a18974f13420a78fcc30fdd676696e405c3ca
|
|
3
4
|
// Workaround to make client-side bundles include the CSS imports living in server-side-only code.
|
|
@@ -22,6 +23,12 @@ const rawRE = /(\?|&)raw(?:&|$)/;
|
|
|
22
23
|
const urlRE = /(\?|&)url(?:&|$)/;
|
|
23
24
|
const EMPTY_MODULE_ID = 'virtual:vike:empty-module';
|
|
24
25
|
const debug = createDebugger('vike:pluginExtractAssets');
|
|
26
|
+
const filterRolldown = {
|
|
27
|
+
id: {
|
|
28
|
+
include: extractAssetsRE,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const filterFunction = (id) => extractAssetsRE.test(id);
|
|
25
32
|
function pluginExtractAssets() {
|
|
26
33
|
let config;
|
|
27
34
|
let vikeConfig;
|
|
@@ -34,11 +41,10 @@ function pluginExtractAssets() {
|
|
|
34
41
|
apply: 'build',
|
|
35
42
|
enforce: 'post',
|
|
36
43
|
transform: {
|
|
44
|
+
filter: filterRolldown,
|
|
37
45
|
async handler(src, id, options) {
|
|
38
46
|
id = normalizeId(id);
|
|
39
|
-
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
47
|
+
assert(filterFunction(id));
|
|
42
48
|
if (isFixEnabled) {
|
|
43
49
|
// I'm guessing isFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
|
|
44
50
|
assertV1Design(vikeConfig._pageConfigs, true);
|
|
@@ -8,6 +8,12 @@ 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', {});
|
|
11
|
+
const filterRolldown = {
|
|
12
|
+
id: {
|
|
13
|
+
include: extractExportNamesRE,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const filterFunction = (id) => extractExportNamesRE.test(id);
|
|
11
17
|
function pluginExtractExportNames() {
|
|
12
18
|
let isDev = false;
|
|
13
19
|
let config;
|
|
@@ -15,14 +21,14 @@ function pluginExtractExportNames() {
|
|
|
15
21
|
name: 'vike:pluginExtractExportNames',
|
|
16
22
|
enforce: 'post',
|
|
17
23
|
transform: {
|
|
24
|
+
filter: filterRolldown,
|
|
18
25
|
async handler(src, id, options) {
|
|
19
26
|
id = normalizeId(id);
|
|
20
27
|
const isClientSide = !isViteServerSide_extraSafe(config, this.environment, options);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
28
|
+
assert(filterFunction(id));
|
|
29
|
+
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
30
|
+
debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
|
|
31
|
+
return code;
|
|
26
32
|
},
|
|
27
33
|
},
|
|
28
34
|
configureServer: {
|