vike 0.4.238 → 0.4.239-commit-33e55d4
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/resolvePrerenderConfig.js +3 -2
- package/dist/cjs/node/prerender/runPrerender.js +1 -0
- package/dist/cjs/node/runtime/globalContext.js +10 -0
- package/dist/cjs/node/runtime/index.js +3 -3
- package/dist/cjs/node/runtime/page-files/setup.js +3 -1
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +2 -9
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/csp.js +47 -0
- package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +1 -1
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/cjs/node/runtime/renderPage/headersResponse.js +48 -0
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +8 -6
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +5 -3
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
- package/dist/cjs/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
- package/dist/cjs/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/stream.js +1 -1
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +17 -38
- package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
- package/dist/cjs/node/runtime/renderPage.js +1 -1
- package/dist/cjs/node/vite/onLoad.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +32 -28
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +17 -9
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
- package/dist/cjs/node/vite/plugins/pluginCommon.js +7 -21
- package/dist/cjs/node/vite/plugins/pluginDev.js +51 -47
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +62 -57
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +107 -93
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +27 -13
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +107 -84
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +40 -21
- package/dist/cjs/node/vite/plugins/pluginPreview.js +30 -24
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +59 -33
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +54 -36
- package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +20 -22
- package/dist/cjs/shared/createGlobalContextShared.js +4 -22
- package/dist/cjs/shared/createPageContextShared.js +2 -2
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +62 -43
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +16 -1
- package/dist/cjs/utils/assertNodeVersion.js +3 -1
- package/dist/cjs/utils/assertVersion.js +26 -5
- package/dist/cjs/utils/joinEnglish.js +2 -1
- package/dist/cjs/utils/virtualFileId.js +15 -11
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +40 -17
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +99 -85
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +39 -11
- package/dist/esm/client/runtime-client-routing/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.js +2 -2
- package/dist/esm/client/runtime-client-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +44 -29
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +40 -17
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +39 -11
- package/dist/esm/client/runtime-server-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +39 -11
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.d.ts +1 -1
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +2 -3
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +2 -2
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +4 -3
- package/dist/esm/node/prerender/runPrerender.d.ts +61 -16
- package/dist/esm/node/prerender/runPrerender.js +2 -1
- package/dist/esm/node/runtime/globalContext.d.ts +167 -42
- package/dist/esm/node/runtime/globalContext.js +11 -1
- package/dist/esm/node/runtime/index.d.ts +3 -3
- package/dist/esm/node/runtime/index.js +3 -3
- package/dist/esm/node/runtime/page-files/setup.js +3 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -9
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +56 -12
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/csp.d.ts +12 -0
- package/dist/esm/node/runtime/renderPage/csp.js +45 -0
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -1
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/esm/node/runtime/renderPage/headersResponse.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/headersResponse.js +46 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
- package/dist/esm/node/runtime/renderPage/html/injectAssets/inferHtmlTags.d.ts +10 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +7 -5
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage/html/injectAssets/mergeScriptTags.d.ts +3 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +6 -4
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
- package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.d.ts +6 -5
- package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
- package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/stream.js +1 -1
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +66 -17
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +18 -39
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +122 -32
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
- package/dist/esm/node/runtime/renderPage.d.ts +56 -12
- package/dist/esm/node/runtime/renderPage.js +1 -1
- package/dist/esm/node/vite/onLoad.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBaseUrls.js +32 -28
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +18 -10
- package/dist/esm/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
- package/dist/esm/node/vite/plugins/pluginCommon.js +8 -22
- package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +62 -57
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +107 -91
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +27 -13
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +107 -84
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +41 -22
- package/dist/esm/node/vite/plugins/pluginPreview.js +30 -24
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +11 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +58 -33
- package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +56 -38
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +4 -8
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +22 -24
- package/dist/esm/shared/createGlobalContextShared.d.ts +75 -19
- package/dist/esm/shared/createGlobalContextShared.js +5 -23
- package/dist/esm/shared/createPageContextShared.d.ts +2 -7
- package/dist/esm/shared/createPageContextShared.js +2 -2
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/hooks/execHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +91 -31
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +62 -43
- package/dist/esm/types/Config/ConfigResolved.d.ts +8 -0
- package/dist/esm/types/Config.d.ts +14 -6
- package/dist/esm/types/PageContext.d.ts +8 -25
- package/dist/esm/types/VikeNamespace.d.ts +0 -27
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +16 -1
- package/dist/esm/utils/assertNodeVersion.js +3 -1
- package/dist/esm/utils/assertVersion.d.ts +4 -3
- package/dist/esm/utils/assertVersion.js +23 -5
- package/dist/esm/utils/joinEnglish.js +2 -1
- package/dist/esm/utils/virtualFileId.d.ts +4 -0
- package/dist/esm/utils/virtualFileId.js +14 -11
- package/package.json +5 -5
- package/dist/cjs/types/Config/helpers.js +0 -2
- package/dist/esm/node/runtime/html/injectAssets/inferHtmlTags.d.ts +0 -9
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +0 -2
- package/dist/esm/types/Config/PageContextConfig.d.ts +0 -15
- package/dist/esm/types/Config/helpers.d.ts +0 -10
- package/dist/esm/types/Config/helpers.js +0 -1
- /package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
- /package/dist/cjs/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/stream.d.ts +0 -0
- /package/dist/esm/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
|
@@ -18,7 +18,7 @@ const isNewError_js_1 = require("./renderPage/isNewError.js");
|
|
|
18
18
|
const assertArguments_js_1 = require("./renderPage/assertArguments.js");
|
|
19
19
|
const index_js_2 = require("./renderPage/log404/index.js");
|
|
20
20
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
21
|
-
const serializeContext_js_1 = require("./html/serializeContext.js");
|
|
21
|
+
const serializeContext_js_1 = require("./renderPage/html/serializeContext.js");
|
|
22
22
|
const error_page_js_1 = require("../../shared/error-page.js");
|
|
23
23
|
const handleErrorWithoutErrorPage_js_1 = require("./renderPage/handleErrorWithoutErrorPage.js");
|
|
24
24
|
const loadPageConfigsLazyServerSide_js_1 = require("./renderPage/loadPageConfigsLazyServerSide.js");
|
|
@@ -15,7 +15,7 @@ function onLoad() {
|
|
|
15
15
|
// TO-DO/eventually: let's also use this.meta.viteVersion
|
|
16
16
|
// - https://github.com/vitejs/vite/pull/20088
|
|
17
17
|
// - https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#700-2025-06-24
|
|
18
|
-
(0, assertVersion_js_1.assertVersion)('Vite', vite_1.version, '6.
|
|
18
|
+
(0, assertVersion_js_1.assertVersion)('Vite', vite_1.version, ['6.3.0']);
|
|
19
19
|
// Ensure we don't bloat the server runtime with heavy dependencies such Vite and esbuild
|
|
20
20
|
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
21
21
|
}
|
|
@@ -9,35 +9,39 @@ function pluginBaseUrls() {
|
|
|
9
9
|
return {
|
|
10
10
|
name: 'vike:pluginBaseUrls',
|
|
11
11
|
enforce: 'post',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
config: {
|
|
13
|
+
async handler(config) {
|
|
14
|
+
const isDev = config._isDev;
|
|
15
|
+
(0, utils_js_1.assert)(typeof isDev === 'boolean');
|
|
16
|
+
const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
|
|
17
|
+
const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
|
|
18
|
+
basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, vikeConfig.config.baseServer ?? null, vikeConfig.config.baseAssets ?? null);
|
|
19
|
+
// We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
|
|
20
|
+
process.env.BASE_SERVER = basesResolved.baseServer;
|
|
21
|
+
process.env.BASE_ASSETS = basesResolved.baseAssets;
|
|
22
|
+
return {
|
|
23
|
+
envPrefix: [
|
|
24
|
+
'VITE_', // Vite doesn't seem to merge in its default, see https://github.com/vikejs/vike/issues/554
|
|
25
|
+
'BASE_SERVER',
|
|
26
|
+
'BASE_ASSETS',
|
|
27
|
+
],
|
|
28
|
+
base: basesResolved.baseAssets, // Make Vite inject baseAssets to imports e.g. `import logoUrl from './logo.svg.js'`
|
|
29
|
+
_baseViteOriginal: baseViteOriginal,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
30
32
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
configResolved: {
|
|
34
|
+
async handler(config) {
|
|
35
|
+
const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
|
|
36
|
+
const basesResolved2 = resolveBaseFromResolvedConfig(vikeConfig.config.baseServer ?? null, vikeConfig.config.baseAssets ?? null, config);
|
|
37
|
+
(0, utils_js_1.assert)(basesResolved2.baseServer === basesResolved.baseServer);
|
|
38
|
+
(0, utils_js_1.assert)(basesResolved2.baseAssets === basesResolved.baseAssets);
|
|
39
|
+
/* In dev, Vite seems buggy around setting vite.config.js#base to an absolute URL (e.g. http://localhost:8080/cdn/)
|
|
40
|
+
* - In dev, Vite removes the URL origin. (I.e. it resolves the user config `vite.config.js#base: 'http://localhost:8080/cdn/'` to resolved config `config.base === '/cdn/'`.)
|
|
41
|
+
* - Instead of having an internal Vike assertion fail, we let the user discover Vite's buggy behavior.
|
|
42
|
+
assert(config.base === baseAssets)
|
|
43
|
+
*/
|
|
44
|
+
},
|
|
41
45
|
},
|
|
42
46
|
};
|
|
43
47
|
}
|
|
@@ -24,7 +24,7 @@ const getManifestFilePathRelative_js_1 = require("../../shared/getManifestFilePa
|
|
|
24
24
|
const globalObject = (0, utils_js_1.getGlobalObject)('build/handleAssetsManifest.ts', {
|
|
25
25
|
assetsJsonFilePath: undefined,
|
|
26
26
|
});
|
|
27
|
-
//
|
|
27
|
+
// yes => use workaround config.build.ssrEmitAssets
|
|
28
28
|
// false => use workaround extractAssets plugin
|
|
29
29
|
function handleAssetsManifest_isFixEnabled() {
|
|
30
30
|
// Allow user to toggle between the two workarounds? E.g. based on https://vike.dev/includeAssetsImportedByServer.
|
|
@@ -51,35 +51,39 @@ function pluginBuildApp() {
|
|
|
51
51
|
{
|
|
52
52
|
name: 'vike:build:pluginBuildApp',
|
|
53
53
|
apply: 'build',
|
|
54
|
-
config
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
config: {
|
|
55
|
+
handler(config) {
|
|
56
|
+
return {
|
|
57
|
+
environments: {
|
|
58
|
+
ssr: {
|
|
59
|
+
consumer: 'server',
|
|
60
|
+
build: {
|
|
61
|
+
outDir: (0, getOutDirs_js_1.resolveOutDir)(config, true),
|
|
62
|
+
ssr: true,
|
|
63
|
+
},
|
|
62
64
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
client: {
|
|
66
|
+
consumer: 'client',
|
|
67
|
+
build: {
|
|
68
|
+
outDir: (0, getOutDirs_js_1.resolveOutDir)(config, false),
|
|
69
|
+
copyPublicDir: true,
|
|
70
|
+
ssr: false,
|
|
71
|
+
},
|
|
70
72
|
},
|
|
71
73
|
},
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
+
};
|
|
75
|
+
},
|
|
74
76
|
},
|
|
75
77
|
},
|
|
76
78
|
{
|
|
77
79
|
name: 'vike:build:pluginBuildApp:autoFullBuild:pre',
|
|
78
80
|
apply: 'build',
|
|
79
81
|
enforce: 'pre',
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
configResolved: {
|
|
83
|
+
async handler(config_) {
|
|
84
|
+
config = config_;
|
|
85
|
+
await abortViteBuildSsr();
|
|
86
|
+
},
|
|
83
87
|
},
|
|
84
88
|
// TO-DO/eventually: stop using this writeBundle() hack and, instead, use the buildApp() implementation above.
|
|
85
89
|
// - Could it cause issues if a tool uses the writeBundle() hack together with getVikeConfig() ?
|
|
@@ -17,88 +17,90 @@ function pluginDistFileNames() {
|
|
|
17
17
|
name: 'vike:build:pluginDistFileNames',
|
|
18
18
|
apply: 'build',
|
|
19
19
|
enforce: 'post',
|
|
20
|
-
configResolved
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
else {
|
|
53
|
-
(0, utils_js_1.assertUsage)(false, "The Vite's configuration build.rollupOptions.output.manualChunks must be a function. Reach out if you need to set it to another value.");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
|
|
57
|
-
// TO-DO/eventually: let's bundle CSS again once Rolldown replaces Rollup
|
|
58
|
-
if (id.endsWith('.css')) {
|
|
59
|
-
const userRootDir = config.root;
|
|
60
|
-
if (id.startsWith(userRootDir)) {
|
|
61
|
-
(0, utils_js_1.assertPosixPath)(id);
|
|
62
|
-
(0, getFilePath_js_1.assertModuleId)(id);
|
|
63
|
-
let name;
|
|
64
|
-
const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
|
|
65
|
-
if (isNodeModules) {
|
|
66
|
-
name = isNodeModules[1];
|
|
20
|
+
configResolved: {
|
|
21
|
+
handler(config) {
|
|
22
|
+
const rollupOutputs = getRollupOutputs(config);
|
|
23
|
+
// We need to support multiple outputs: @vite/plugin-legacy adds an output, see https://github.com/vikejs/vike/issues/477#issuecomment-1406434802
|
|
24
|
+
rollupOutputs.forEach((rollupOutput) => {
|
|
25
|
+
if (!('entryFileNames' in rollupOutput)) {
|
|
26
|
+
rollupOutput.entryFileNames = (chunkInfo) => getEntryFileName(chunkInfo, config, true);
|
|
27
|
+
}
|
|
28
|
+
if (!('chunkFileNames' in rollupOutput)) {
|
|
29
|
+
rollupOutput.chunkFileNames = (chunkInfo) => getChunkFileName(chunkInfo, config);
|
|
30
|
+
}
|
|
31
|
+
if (!('assetFileNames' in rollupOutput)) {
|
|
32
|
+
rollupOutput.assetFileNames = (chunkInfo) => getAssetFileName(chunkInfo, config);
|
|
33
|
+
rollupOutput.assetFileNames.isTheOneSetByVike = true;
|
|
34
|
+
(0, utils_js_1.assert)(rollupOutput.assetFileNames.isTheOneSetByVike);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// If a user needs this:
|
|
38
|
+
// - assertUsage() that the naming provided by the user ends with `.[hash][extname]`
|
|
39
|
+
// - It's needed for getHash() of handleAssetsManifest()
|
|
40
|
+
// - Asset URLs should always contain a hash: it's paramount for caching assets.
|
|
41
|
+
// - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
|
|
42
|
+
(0, utils_js_1.assertUsage)(rollupOutput.assetFileNames.isTheOneSetByVike, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use it.");
|
|
43
|
+
}
|
|
44
|
+
{
|
|
45
|
+
const manualChunksOriginal = rollupOutput.manualChunks;
|
|
46
|
+
rollupOutput.manualChunks = function (id, ...args) {
|
|
47
|
+
if (manualChunksOriginal) {
|
|
48
|
+
if ((0, utils_js_1.isCallable)(manualChunksOriginal)) {
|
|
49
|
+
const result = manualChunksOriginal.call(this, id, ...args);
|
|
50
|
+
if (result !== undefined)
|
|
51
|
+
return result;
|
|
67
52
|
}
|
|
68
53
|
else {
|
|
69
|
-
|
|
70
|
-
name = filePath;
|
|
71
|
-
name = name.split('.').slice(0, -1).join('.'); // remove file extension
|
|
72
|
-
name = name.split('/').filter(Boolean).join('_');
|
|
54
|
+
(0, utils_js_1.assertUsage)(false, "The Vite's configuration build.rollupOptions.output.manualChunks must be a function. Reach out if you need to set it to another value.");
|
|
73
55
|
}
|
|
74
|
-
// Make fileHash the same between local development and CI
|
|
75
|
-
const idStable = node_path_1.default.posix.relative(userRootDir, id);
|
|
76
|
-
// Don't remove `?` queries because each `id` should belong to a unique bundle.
|
|
77
|
-
const hash = getIdHash(idStable);
|
|
78
|
-
return `${name}-${hash}`;
|
|
79
56
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
(0, utils_js_1.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
// Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
|
|
58
|
+
// TO-DO/eventually: let's bundle CSS again once Rolldown replaces Rollup
|
|
59
|
+
if (id.endsWith('.css')) {
|
|
60
|
+
const userRootDir = config.root;
|
|
61
|
+
if (id.startsWith(userRootDir)) {
|
|
62
|
+
(0, utils_js_1.assertPosixPath)(id);
|
|
63
|
+
(0, getFilePath_js_1.assertModuleId)(id);
|
|
64
|
+
let name;
|
|
65
|
+
const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
|
|
66
|
+
if (isNodeModules) {
|
|
67
|
+
name = isNodeModules[1];
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const filePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
|
|
71
|
+
name = filePath;
|
|
72
|
+
name = name.split('.').slice(0, -1).join('.'); // remove file extension
|
|
73
|
+
name = name.split('/').filter(Boolean).join('_');
|
|
74
|
+
}
|
|
75
|
+
// Make fileHash the same between local development and CI
|
|
76
|
+
const idStable = node_path_1.default.posix.relative(userRootDir, id);
|
|
77
|
+
// Don't remove `?` queries because each `id` should belong to a unique bundle.
|
|
78
|
+
const hash = getIdHash(idStable);
|
|
79
|
+
return `${name}-${hash}`;
|
|
91
80
|
}
|
|
92
81
|
else {
|
|
93
|
-
name
|
|
82
|
+
let name;
|
|
83
|
+
const isVirtualModule = id.match(/virtual:([^:]+):/);
|
|
84
|
+
if (isVirtualModule) {
|
|
85
|
+
name = isVirtualModule[1];
|
|
86
|
+
(0, utils_js_1.assert)(name);
|
|
87
|
+
}
|
|
88
|
+
else if (
|
|
89
|
+
// https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
|
|
90
|
+
id.startsWith('/__uno')) {
|
|
91
|
+
name = 'uno';
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
name = 'style';
|
|
95
|
+
}
|
|
96
|
+
const hash = getIdHash(id);
|
|
97
|
+
return `${name}-${hash}`;
|
|
94
98
|
}
|
|
95
|
-
const hash = getIdHash(id);
|
|
96
|
-
return `${name}-${hash}`;
|
|
97
99
|
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
},
|
|
102
104
|
},
|
|
103
105
|
};
|
|
104
106
|
}
|
|
@@ -8,21 +8,25 @@ function pluginDistPackageJsonFile() {
|
|
|
8
8
|
return {
|
|
9
9
|
name: 'vike:build:pluginDistPackageJsonFile',
|
|
10
10
|
apply: 'build',
|
|
11
|
-
configResolved
|
|
12
|
-
|
|
11
|
+
configResolved: {
|
|
12
|
+
handler(config_) {
|
|
13
|
+
config = config_;
|
|
14
|
+
},
|
|
13
15
|
},
|
|
14
|
-
generateBundle
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
generateBundle: {
|
|
17
|
+
handler(options, bundle) {
|
|
18
|
+
if (!(0, isViteServerSide_js_1.isViteServerSide)(config, this.environment))
|
|
19
|
+
return;
|
|
20
|
+
const isEsm = (0, rollupIsEsm_js_1.rollupIsEsm)(options);
|
|
21
|
+
const fileName = 'package.json';
|
|
22
|
+
if (bundle[fileName])
|
|
23
|
+
return; // E.g. already generated by Telefunc / vike
|
|
24
|
+
this.emitFile({
|
|
25
|
+
fileName,
|
|
26
|
+
type: 'asset',
|
|
27
|
+
source: getPackageJsonContent(isEsm),
|
|
28
|
+
});
|
|
29
|
+
},
|
|
26
30
|
},
|
|
27
31
|
};
|
|
28
32
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.pluginModuleBanner = pluginModuleBanner;
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
5
|
const getMagicString_js_1 = require("../../shared/getMagicString.js");
|
|
6
|
-
const isViteServerSide_js_1 = require("../../shared/isViteServerSide.js");
|
|
7
6
|
// Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
|
|
8
7
|
// 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).
|
|
9
8
|
function pluginModuleBanner() {
|
|
@@ -12,17 +11,26 @@ function pluginModuleBanner() {
|
|
|
12
11
|
name: 'vike:build:pluginModuleBanner',
|
|
13
12
|
enforce: 'post',
|
|
14
13
|
apply: 'build',
|
|
15
|
-
|
|
16
|
-
config =
|
|
14
|
+
applyToEnvironment(environment) {
|
|
15
|
+
const { config } = environment;
|
|
16
|
+
const { consumer } = config;
|
|
17
|
+
const { minify } = config.build;
|
|
18
|
+
(0, utils_js_1.assert)(minify === false || minify, { minify, consumer });
|
|
19
|
+
return !minify;
|
|
20
|
+
},
|
|
21
|
+
configResolved: {
|
|
22
|
+
handler(config_) {
|
|
23
|
+
config = config_;
|
|
24
|
+
},
|
|
17
25
|
},
|
|
18
26
|
transform: {
|
|
19
27
|
order: 'post',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
28
|
+
/* Using a Rolldown hook filter doesn't make sense here — we use applyToEnvironment() to conditionally apply this plugin.
|
|
29
|
+
filter: {},
|
|
30
|
+
*/
|
|
31
|
+
handler(code, id) {
|
|
32
|
+
const { minify } = this.environment.config.build;
|
|
33
|
+
(0, utils_js_1.assert)(minify === false, { minify });
|
|
26
34
|
if (id.startsWith('\0'))
|
|
27
35
|
id = id;
|
|
28
36
|
id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
|
|
@@ -22,8 +22,10 @@ function pluginProdBuildEntry() {
|
|
|
22
22
|
name: 'vike:build:pluginProdBuildEntry',
|
|
23
23
|
apply: 'build',
|
|
24
24
|
enforce: 'post',
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
configResolved: {
|
|
26
|
+
async handler(config_) {
|
|
27
|
+
config = config_;
|
|
28
|
+
},
|
|
27
29
|
},
|
|
28
30
|
},
|
|
29
31
|
...(0, plugin_1.serverProductionEntryPlugin)({
|
|
@@ -7,24 +7,26 @@ function pluginSuppressRollupWarning() {
|
|
|
7
7
|
name: 'vike:build:pluginSuppressRollupWarning',
|
|
8
8
|
apply: 'build',
|
|
9
9
|
enforce: 'post',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
onWarnOriginal
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
configResolved: {
|
|
11
|
+
async handler(config) {
|
|
12
|
+
const onWarnOriginal = config.build.rollupOptions.onwarn;
|
|
13
|
+
config.build.rollupOptions.onwarn = function (warning, warn) {
|
|
14
|
+
// Suppress
|
|
15
|
+
if (suppressUnusedImport(warning))
|
|
16
|
+
return;
|
|
17
|
+
if (suppressEmptyBundle(warning))
|
|
18
|
+
return;
|
|
19
|
+
if (suppressUseClientDirective(warning))
|
|
20
|
+
return;
|
|
21
|
+
// Pass through
|
|
22
|
+
if (onWarnOriginal) {
|
|
23
|
+
onWarnOriginal.apply(this, arguments);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
warn(warning);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
},
|
|
28
30
|
},
|
|
29
31
|
};
|
|
30
32
|
}
|
|
@@ -8,7 +8,6 @@ const utils_js_1 = require("../utils.js");
|
|
|
8
8
|
const pluginBuildConfig_js_1 = require("./pluginBuild/pluginBuildConfig.js");
|
|
9
9
|
const require_shim_1 = require("@brillout/require-shim");
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
12
11
|
const assertResolveAlias_js_1 = require("./pluginCommon/assertResolveAlias.js");
|
|
13
12
|
const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
|
|
14
13
|
const context_js_1 = require("../../api/context.js");
|
|
@@ -47,10 +46,12 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
47
46
|
},
|
|
48
47
|
{
|
|
49
48
|
name: pluginName,
|
|
50
|
-
configResolved
|
|
51
|
-
(
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
configResolved: {
|
|
50
|
+
handler(config) {
|
|
51
|
+
(0, prepareViteApiCall_js_1.assertViteRoot)(config._rootResolvedEarly, config);
|
|
52
|
+
assertSingleInstance(config);
|
|
53
|
+
(0, require_shim_1.installRequireShim_setUserRootDir)(config.root);
|
|
54
|
+
},
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
{
|
|
@@ -69,7 +70,6 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
69
70
|
workaroundCI(config);
|
|
70
71
|
(0, pluginBuildConfig_js_1.assertRollupInput)(config);
|
|
71
72
|
(0, assertResolveAlias_js_1.assertResolveAlias)(config);
|
|
72
|
-
assertEsm(config.root);
|
|
73
73
|
assertVikeCliOrApi(config);
|
|
74
74
|
temp_supportOldInterface(config);
|
|
75
75
|
await emitServerEntryOnlyIfNeeded(config);
|
|
@@ -112,7 +112,7 @@ function setDefault(setting, value, configFromUser, configFromVike) {
|
|
|
112
112
|
/*
|
|
113
113
|
import { version } from 'vite'
|
|
114
114
|
function overrideViteDefaultSsrExternal(config: ResolvedConfig) {
|
|
115
|
-
if (!
|
|
115
|
+
if (!isVersionMatch(version, ['5.0.12'])) return
|
|
116
116
|
// @ts-ignore Not released yet: https://github.com/vitejs/vite/pull/10939/files#diff-5a3d42620df2c6b17e25f440ffdb67683dee7ef57317674d19f41d5f30502310L5
|
|
117
117
|
config.ssr.external ??= true
|
|
118
118
|
}
|
|
@@ -125,20 +125,6 @@ function workaroundCI(config) {
|
|
|
125
125
|
(_b = config.preview).host ?? (_b.host = true);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
function assertEsm(userViteRoot) {
|
|
129
|
-
const found = (0, utils_js_1.findPackageJson)(userViteRoot);
|
|
130
|
-
if (!found)
|
|
131
|
-
return;
|
|
132
|
-
const { packageJson, packageJsonPath } = found;
|
|
133
|
-
let dir = node_path_1.default.posix.dirname(packageJsonPath);
|
|
134
|
-
if (dir !== '/') {
|
|
135
|
-
(0, utils_js_1.assert)(!dir.endsWith('/'));
|
|
136
|
-
dir = dir + '/';
|
|
137
|
-
}
|
|
138
|
-
(0, utils_js_1.assert)(dir.endsWith('/'));
|
|
139
|
-
dir = picocolors_1.default.dim(dir);
|
|
140
|
-
(0, utils_js_1.assertWarning)(packageJson.type === 'module', `We recommend setting ${dir}package.json#type to "module", see https://vike.dev/CJS`, { onlyOnce: true });
|
|
141
|
-
}
|
|
142
128
|
function assertSingleInstance(config) {
|
|
143
129
|
const numberOfInstances = config.plugins.filter((o) => o.name === pluginName).length;
|
|
144
130
|
(0, utils_js_1.assertUsage)(numberOfInstances === 1, `Vike's Vite plugin (${picocolors_1.default.cyan("import vike from 'vike/plugin'")}) is being added ${numberOfInstances} times to the list of Vite plugins. Make sure to add it only once instead.`);
|