vike 0.4.237-commit-fd8294f → 0.4.237-commit-2c1db32
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/api/build.js +2 -2
- package/dist/cjs/node/api/prepareViteApiCall.js +0 -1
- package/dist/cjs/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +7 -7
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +121 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -18
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -2
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginPreview.js +1 -11
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +4 -4
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +1 -1
- package/dist/cjs/node/vite/shared/getOutDirs.js +2 -13
- package/dist/cjs/node/vite/shared/isViteServerSide.js +25 -56
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/api/build.js +2 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +0 -2
- package/dist/esm/node/api/prepareViteApiCall.js +0 -1
- package/dist/esm/node/prerender/runPrerenderEntry.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +3 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +7 -7
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.d.ts +2 -0
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +118 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +5 -19
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild.js +0 -2
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +1 -1
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +1 -1
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +2 -2
- package/dist/esm/node/vite/plugins/pluginPreview.js +3 -13
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.d.ts +1 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +4 -4
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +2 -4
- package/dist/esm/node/vite/shared/getOutDirs.js +3 -14
- package/dist/esm/node/vite/shared/isViteServerSide.d.ts +4 -4
- package/dist/esm/node/vite/shared/isViteServerSide.js +25 -56
- package/dist/esm/types/Config.d.ts +1 -3
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +0 -132
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.d.ts +0 -5
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +0 -127
|
@@ -1,56 +1,45 @@
|
|
|
1
1
|
export { isViteServerSide };
|
|
2
2
|
export { isViteClientSide };
|
|
3
|
-
export {
|
|
3
|
+
export { isViteServerSide_viteEnvOptional };
|
|
4
4
|
export { isViteServerSide_onlySsrEnv };
|
|
5
5
|
export { isViteServerSide_extraSafe };
|
|
6
6
|
import { assert } from '../../../utils/assert.js';
|
|
7
7
|
function isViteServerSide_impl(configGlobal, viteEnv) {
|
|
8
8
|
assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
9
|
-
const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
10
|
-
const isServerSide2 = !viteEnv?.config.build ? null : getBuildSsrValue(viteEnv.config.build.ssr);
|
|
11
|
-
const isServerSide3 = !configGlobal.build ? null : getBuildSsrValue(configGlobal.build.ssr);
|
|
12
|
-
const isServerSide4 = viteEnv?.name === 'ssr' ? true : viteEnv?.name === 'client' ? false : null;
|
|
13
9
|
const debug = {
|
|
14
10
|
viteEnvIsUndefined: !viteEnv,
|
|
15
11
|
viteEnvName: viteEnv?.name ?? null,
|
|
16
12
|
viteEnvConsumer: viteEnv?.config.consumer ?? null,
|
|
17
13
|
configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
|
|
18
14
|
configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
|
|
19
|
-
isServerSide1,
|
|
20
|
-
isServerSide2,
|
|
21
|
-
isServerSide3,
|
|
22
|
-
isServerSide4,
|
|
23
15
|
};
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
return isServerSide1;
|
|
30
|
-
}
|
|
31
|
-
if (isServerSide2 !== null) {
|
|
32
|
-
// assert(isServerSide2 === isServerSide4 || isServerSide4 === null, debug)
|
|
33
|
-
return isServerSide2;
|
|
34
|
-
}
|
|
35
|
-
if (isServerSide3 !== null) {
|
|
36
|
-
// assert(isServerSide3 === isServerSide4 || isServerSide4 === null, debug)
|
|
37
|
-
return isServerSide3;
|
|
16
|
+
if (!viteEnv) {
|
|
17
|
+
const isServerSide = getBuildSsrValue(configGlobal.build?.ssr);
|
|
18
|
+
assert(typeof isServerSide === 'boolean', debug);
|
|
19
|
+
return isServerSide;
|
|
38
20
|
}
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
else {
|
|
22
|
+
const isServerSide1 = !viteEnv.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
23
|
+
const isServerSide2 = getBuildSsrValue(viteEnv.config.build?.ssr);
|
|
24
|
+
const isServerSide3 = viteEnv.name === 'ssr' ? true : viteEnv.name === 'client' ? false : null;
|
|
25
|
+
const isServerSide = isServerSide1 ?? isServerSide2;
|
|
26
|
+
assert(isServerSide === isServerSide1 || isServerSide1 === null, debug);
|
|
27
|
+
assert(isServerSide === isServerSide2 || isServerSide2 === null, debug);
|
|
28
|
+
assert(isServerSide === isServerSide3 || isServerSide3 === null, debug);
|
|
29
|
+
assert(isServerSide !== null);
|
|
30
|
+
return isServerSide;
|
|
41
31
|
}
|
|
42
|
-
assert(!viteEnv);
|
|
43
|
-
return !!configGlobal.build?.ssr;
|
|
44
32
|
}
|
|
45
33
|
function getBuildSsrValue(buildSsr) {
|
|
46
34
|
if (buildSsr === undefined)
|
|
47
35
|
return null;
|
|
36
|
+
assert(typeof buildSsr === 'boolean' || typeof buildSsr === 'string');
|
|
48
37
|
return !!buildSsr;
|
|
49
38
|
}
|
|
50
39
|
function isViteServerSide(configGlobal, viteEnv) {
|
|
51
40
|
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
52
41
|
}
|
|
53
|
-
function
|
|
42
|
+
function isViteServerSide_viteEnvOptional(configGlobal, viteEnv) {
|
|
54
43
|
return isViteServerSide_impl(configGlobal, viteEnv);
|
|
55
44
|
}
|
|
56
45
|
function isViteClientSide(configGlobal, viteEnv) {
|
|
@@ -61,37 +50,17 @@ function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
|
|
|
61
50
|
return viteEnv.name ? viteEnv.name === 'ssr' : isViteServerSide(configGlobal, viteEnv);
|
|
62
51
|
}
|
|
63
52
|
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
64
|
-
function isViteServerSide_extraSafe(config,
|
|
53
|
+
function isViteServerSide_extraSafe(config, viteEnv, options) {
|
|
65
54
|
const isServerSide = isViteServerSide(config, viteEnv);
|
|
66
55
|
const debug = {
|
|
56
|
+
isServerSide,
|
|
67
57
|
configCommand: config.command,
|
|
68
|
-
configBuildSsr: config.build.ssr,
|
|
58
|
+
configBuildSsr: getBuildSsrValue(config.build.ssr),
|
|
69
59
|
optionsIsUndefined: options === undefined,
|
|
70
|
-
optionsSsr: options?.ssr,
|
|
71
|
-
isServerSide,
|
|
60
|
+
optionsSsr: options?.ssr ?? null,
|
|
72
61
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return res;
|
|
78
|
-
}
|
|
79
|
-
return isServerSide;
|
|
80
|
-
}
|
|
81
|
-
if (config.command === 'build') {
|
|
82
|
-
const res = config.build.ssr;
|
|
83
|
-
assert(typeof res === 'boolean', debug);
|
|
84
|
-
assert(res === options?.ssr || options?.ssr === undefined, debug);
|
|
85
|
-
assert(res === isServerSide, debug);
|
|
86
|
-
return res;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
const res = options?.ssr;
|
|
90
|
-
assert(typeof res === 'boolean', debug);
|
|
91
|
-
/* This assertion can fail, seems to be a Vite bug? It's very unexpected.
|
|
92
|
-
if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
|
|
93
|
-
*/
|
|
94
|
-
assert(res === isServerSide, debug);
|
|
95
|
-
return res;
|
|
96
|
-
}
|
|
62
|
+
assert(options, debug);
|
|
63
|
+
assert(typeof options.ssr === 'boolean', debug);
|
|
64
|
+
assert(options.ssr === isServerSide, debug);
|
|
65
|
+
return isServerSide;
|
|
97
66
|
}
|
|
@@ -403,9 +403,7 @@ type ConfigBuiltIn = {
|
|
|
403
403
|
includeAssetsImportedByServer?: boolean;
|
|
404
404
|
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
405
405
|
disableAutoFullBuild?: boolean | 'prerender';
|
|
406
|
-
/**
|
|
407
|
-
* @deprecated It's value is now always true.
|
|
408
|
-
*/
|
|
406
|
+
/** @deprecated It's value is now always true. */
|
|
409
407
|
vite6BuilderApp?: true;
|
|
410
408
|
/** The Base URL of your server.
|
|
411
409
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.237-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.237-commit-2c1db32";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.237-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.237-commit-2c1db32';
|
package/package.json
CHANGED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pluginAutoFullBuild = pluginAutoFullBuild;
|
|
7
|
-
exports.isPrerenderForceExit = isPrerenderForceExit;
|
|
8
|
-
const utils_js_1 = require("../../utils.js");
|
|
9
|
-
const context_js_1 = require("../../../prerender/context.js");
|
|
10
|
-
const isViteCliCall_js_1 = require("../../shared/isViteCliCall.js");
|
|
11
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
12
|
-
const logErrorHint_js_1 = require("../../../runtime/renderPage/logErrorHint.js");
|
|
13
|
-
const resolveVikeConfigInternal_js_1 = require("../../shared/resolveVikeConfigInternal.js");
|
|
14
|
-
const context_js_2 = require("../../../api/context.js");
|
|
15
|
-
const handleAssetsManifest_js_1 = require("./handleAssetsManifest.js");
|
|
16
|
-
const isViteServerSide_js_1 = require("../../shared/isViteServerSide.js");
|
|
17
|
-
const runPrerenderEntry_js_1 = require("../../../prerender/runPrerenderEntry.js");
|
|
18
|
-
const getManifestFilePathRelative_js_1 = require("../../shared/getManifestFilePathRelative.js");
|
|
19
|
-
const globalObject = (0, utils_js_1.getGlobalObject)('build/pluginAutoFullBuild.ts', {
|
|
20
|
-
forceExit: false,
|
|
21
|
-
});
|
|
22
|
-
function pluginAutoFullBuild() {
|
|
23
|
-
let config;
|
|
24
|
-
return [
|
|
25
|
-
{
|
|
26
|
-
name: 'vike:build:pluginAutoFullBuild',
|
|
27
|
-
apply: 'build',
|
|
28
|
-
enforce: 'pre',
|
|
29
|
-
async configResolved(config_) {
|
|
30
|
-
config = config_;
|
|
31
|
-
await abortViteBuildSsr();
|
|
32
|
-
},
|
|
33
|
-
writeBundle: {
|
|
34
|
-
/* We can't use this because it breaks Vite's logging. TO-DO/eventually: try again with latest Vite version.
|
|
35
|
-
sequential: true,
|
|
36
|
-
order: 'pre',
|
|
37
|
-
*/
|
|
38
|
-
async handler(options, bundle) {
|
|
39
|
-
try {
|
|
40
|
-
await (0, handleAssetsManifest_js_1.handleAssetsManifest)(config, this.environment, options, bundle);
|
|
41
|
-
await triggerFullBuild(config, this.environment, bundle);
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
// We use try-catch also because:
|
|
45
|
-
// - Vite/Rollup swallows errors thrown inside the writeBundle() hook. (It doesn't swallow errors thrown inside the first writeBundle() hook while building the client-side, but it does swallow errors thrown inside the second writeBundle() while building the server-side triggered after Vike calls Vite's `build()` API.)
|
|
46
|
-
// - Avoid Rollup prefixing the error with [vike:build:pluginAutoFullBuild], see for example https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
47
|
-
console.error(err);
|
|
48
|
-
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'vike:build:pluginAutoFullBuild:post',
|
|
56
|
-
apply: 'build',
|
|
57
|
-
enforce: 'post',
|
|
58
|
-
closeBundle: {
|
|
59
|
-
sequential: true,
|
|
60
|
-
order: 'post',
|
|
61
|
-
handler() {
|
|
62
|
-
(0, utils_js_1.onSetupBuild)();
|
|
63
|
-
(0, handleAssetsManifest_js_1.handleAssetsManifest_assertUsageCssTarget)(config, this.environment);
|
|
64
|
-
/* Let vike:build:pluginBuildApp force exit
|
|
65
|
-
runPrerender_forceExit()
|
|
66
|
-
*/
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
async function triggerFullBuild(config, viteEnv, bundle) {
|
|
73
|
-
const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
|
|
74
|
-
// Whether builder.buildApp() is being used, see plugin:build:pluginBuildApp
|
|
75
|
-
// If builder.buildApp() => trigger at end of `this.environment.name === 'ssr'`.
|
|
76
|
-
// Else => trigger at end of client-side build.
|
|
77
|
-
if (!(0, isViteServerSide_js_1.isViteServerSide_onlySsrEnv)(config, viteEnv))
|
|
78
|
-
return;
|
|
79
|
-
if (isEntirelyDisabled(vikeConfig))
|
|
80
|
-
return;
|
|
81
|
-
// Workaround for @vitejs/plugin-legacy
|
|
82
|
-
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
83
|
-
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
84
|
-
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
85
|
-
if (!bundle[(0, getManifestFilePathRelative_js_1.getManifestFilePathRelative)(config.build.manifest)])
|
|
86
|
-
return;
|
|
87
|
-
const configInline = getFullBuildInlineConfig(config);
|
|
88
|
-
/* Already triggered by vike:build:pluginBuildApp
|
|
89
|
-
await build(setSSR(configInline))
|
|
90
|
-
*/
|
|
91
|
-
if ((0, context_js_1.isPrerenderAutoRunEnabled)(vikeConfig)) {
|
|
92
|
-
const res = await (0, runPrerenderEntry_js_1.runPrerenderFromAutoRun)(configInline);
|
|
93
|
-
globalObject.forceExit = res.forceExit;
|
|
94
|
-
(0, utils_js_1.assert)((0, context_js_1.wasPrerenderRun)());
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async function abortViteBuildSsr() {
|
|
98
|
-
const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
|
|
99
|
-
if (vikeConfig.config.disableAutoFullBuild !== true && (0, isViteCliCall_js_1.isViteCliCall)() && (0, isViteCliCall_js_1.getViteConfigFromCli)()?.build.ssr) {
|
|
100
|
-
(0, utils_js_1.assertWarning)(false, `The CLI call ${picocolors_1.default.cyan('$ vite build --ssr')} is superfluous since ${picocolors_1.default.cyan('$ vite build')} also builds the server-side. If you want two separate build steps then use https://vike.dev/disableAutoFullBuild or use Vite's ${picocolors_1.default.cyan('build()')} API.`, { onlyOnce: true });
|
|
101
|
-
process.exit(0);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function isEntirelyDisabled(vikeConfig) {
|
|
105
|
-
const { disableAutoFullBuild } = vikeConfig.config;
|
|
106
|
-
if (disableAutoFullBuild === undefined || disableAutoFullBuild === 'prerender') {
|
|
107
|
-
const isUserUsingViteApi = !(0, isViteCliCall_js_1.isViteCliCall)() && !(0, context_js_2.isVikeCliOrApi)();
|
|
108
|
-
return isUserUsingViteApi;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return disableAutoFullBuild;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function isPrerenderForceExit() {
|
|
115
|
-
return globalObject.forceExit;
|
|
116
|
-
}
|
|
117
|
-
function getFullBuildInlineConfig(config) {
|
|
118
|
-
const configFromCli = !(0, isViteCliCall_js_1.isViteCliCall)() ? null : (0, isViteCliCall_js_1.getViteConfigFromCli)();
|
|
119
|
-
if (config._viteConfigFromUserEnhanced) {
|
|
120
|
-
return config._viteConfigFromUserEnhanced;
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
return {
|
|
124
|
-
...configFromCli,
|
|
125
|
-
configFile: configFromCli?.configFile || config.configFile,
|
|
126
|
-
root: config.root,
|
|
127
|
-
build: {
|
|
128
|
-
...configFromCli?.build,
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
export { pluginAutoFullBuild };
|
|
2
|
-
export { isPrerenderForceExit };
|
|
3
|
-
import { assert, assertWarning, getGlobalObject, onSetupBuild } from '../../utils.js';
|
|
4
|
-
import { isPrerenderAutoRunEnabled, wasPrerenderRun } from '../../../prerender/context.js';
|
|
5
|
-
import { isViteCliCall, getViteConfigFromCli } from '../../shared/isViteCliCall.js';
|
|
6
|
-
import pc from '@brillout/picocolors';
|
|
7
|
-
import { logErrorHint } from '../../../runtime/renderPage/logErrorHint.js';
|
|
8
|
-
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
9
|
-
import { isVikeCliOrApi } from '../../../api/context.js';
|
|
10
|
-
import { handleAssetsManifest, handleAssetsManifest_assertUsageCssTarget } from './handleAssetsManifest.js';
|
|
11
|
-
import { isViteServerSide_onlySsrEnv } from '../../shared/isViteServerSide.js';
|
|
12
|
-
import { runPrerenderFromAutoRun } from '../../../prerender/runPrerenderEntry.js';
|
|
13
|
-
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
14
|
-
const globalObject = getGlobalObject('build/pluginAutoFullBuild.ts', {
|
|
15
|
-
forceExit: false,
|
|
16
|
-
});
|
|
17
|
-
function pluginAutoFullBuild() {
|
|
18
|
-
let config;
|
|
19
|
-
return [
|
|
20
|
-
{
|
|
21
|
-
name: 'vike:build:pluginAutoFullBuild',
|
|
22
|
-
apply: 'build',
|
|
23
|
-
enforce: 'pre',
|
|
24
|
-
async configResolved(config_) {
|
|
25
|
-
config = config_;
|
|
26
|
-
await abortViteBuildSsr();
|
|
27
|
-
},
|
|
28
|
-
writeBundle: {
|
|
29
|
-
/* We can't use this because it breaks Vite's logging. TO-DO/eventually: try again with latest Vite version.
|
|
30
|
-
sequential: true,
|
|
31
|
-
order: 'pre',
|
|
32
|
-
*/
|
|
33
|
-
async handler(options, bundle) {
|
|
34
|
-
try {
|
|
35
|
-
await handleAssetsManifest(config, this.environment, options, bundle);
|
|
36
|
-
await triggerFullBuild(config, this.environment, bundle);
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
// We use try-catch also because:
|
|
40
|
-
// - Vite/Rollup swallows errors thrown inside the writeBundle() hook. (It doesn't swallow errors thrown inside the first writeBundle() hook while building the client-side, but it does swallow errors thrown inside the second writeBundle() while building the server-side triggered after Vike calls Vite's `build()` API.)
|
|
41
|
-
// - Avoid Rollup prefixing the error with [vike:build:pluginAutoFullBuild], see for example https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
42
|
-
console.error(err);
|
|
43
|
-
logErrorHint(err);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'vike:build:pluginAutoFullBuild:post',
|
|
51
|
-
apply: 'build',
|
|
52
|
-
enforce: 'post',
|
|
53
|
-
closeBundle: {
|
|
54
|
-
sequential: true,
|
|
55
|
-
order: 'post',
|
|
56
|
-
handler() {
|
|
57
|
-
onSetupBuild();
|
|
58
|
-
handleAssetsManifest_assertUsageCssTarget(config, this.environment);
|
|
59
|
-
/* Let vike:build:pluginBuildApp force exit
|
|
60
|
-
runPrerender_forceExit()
|
|
61
|
-
*/
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
}
|
|
67
|
-
async function triggerFullBuild(config, viteEnv, bundle) {
|
|
68
|
-
const vikeConfig = await getVikeConfigInternal();
|
|
69
|
-
// Whether builder.buildApp() is being used, see plugin:build:pluginBuildApp
|
|
70
|
-
// If builder.buildApp() => trigger at end of `this.environment.name === 'ssr'`.
|
|
71
|
-
// Else => trigger at end of client-side build.
|
|
72
|
-
if (!isViteServerSide_onlySsrEnv(config, viteEnv))
|
|
73
|
-
return;
|
|
74
|
-
if (isEntirelyDisabled(vikeConfig))
|
|
75
|
-
return;
|
|
76
|
-
// Workaround for @vitejs/plugin-legacy
|
|
77
|
-
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
78
|
-
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
79
|
-
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
80
|
-
if (!bundle[getManifestFilePathRelative(config.build.manifest)])
|
|
81
|
-
return;
|
|
82
|
-
const configInline = getFullBuildInlineConfig(config);
|
|
83
|
-
/* Already triggered by vike:build:pluginBuildApp
|
|
84
|
-
await build(setSSR(configInline))
|
|
85
|
-
*/
|
|
86
|
-
if (isPrerenderAutoRunEnabled(vikeConfig)) {
|
|
87
|
-
const res = await runPrerenderFromAutoRun(configInline);
|
|
88
|
-
globalObject.forceExit = res.forceExit;
|
|
89
|
-
assert(wasPrerenderRun());
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async function abortViteBuildSsr() {
|
|
93
|
-
const vikeConfig = await getVikeConfigInternal();
|
|
94
|
-
if (vikeConfig.config.disableAutoFullBuild !== true && isViteCliCall() && getViteConfigFromCli()?.build.ssr) {
|
|
95
|
-
assertWarning(false, `The CLI call ${pc.cyan('$ vite build --ssr')} is superfluous since ${pc.cyan('$ vite build')} also builds the server-side. If you want two separate build steps then use https://vike.dev/disableAutoFullBuild or use Vite's ${pc.cyan('build()')} API.`, { onlyOnce: true });
|
|
96
|
-
process.exit(0);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function isEntirelyDisabled(vikeConfig) {
|
|
100
|
-
const { disableAutoFullBuild } = vikeConfig.config;
|
|
101
|
-
if (disableAutoFullBuild === undefined || disableAutoFullBuild === 'prerender') {
|
|
102
|
-
const isUserUsingViteApi = !isViteCliCall() && !isVikeCliOrApi();
|
|
103
|
-
return isUserUsingViteApi;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return disableAutoFullBuild;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function isPrerenderForceExit() {
|
|
110
|
-
return globalObject.forceExit;
|
|
111
|
-
}
|
|
112
|
-
function getFullBuildInlineConfig(config) {
|
|
113
|
-
const configFromCli = !isViteCliCall() ? null : getViteConfigFromCli();
|
|
114
|
-
if (config._viteConfigFromUserEnhanced) {
|
|
115
|
-
return config._viteConfigFromUserEnhanced;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
return {
|
|
119
|
-
...configFromCli,
|
|
120
|
-
configFile: configFromCli?.configFile || config.configFile,
|
|
121
|
-
root: config.root,
|
|
122
|
-
build: {
|
|
123
|
-
...configFromCli?.build,
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|