vike 0.4.223-commit-f1089b4 → 0.4.223-commit-6adb186
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/plugin/plugins/build/{pluginAssetsManifest/fixServerAssets.js → handleAssetsManifest.js} +32 -42
- package/dist/cjs/node/plugin/plugins/build/pluginAutoFullBuild.js +55 -24
- package/dist/cjs/node/plugin/plugins/build/pluginBuildApp.js +4 -31
- package/dist/cjs/node/plugin/plugins/build/pluginBuildConfig.js +6 -10
- package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +1 -1
- package/dist/cjs/node/plugin/plugins/build/pluginDistFileNames.js +1 -1
- package/dist/cjs/node/plugin/plugins/build/pluginDistPackageJsonFile.js +2 -2
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +9 -9
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +4 -4
- package/dist/cjs/node/plugin/shared/getOutDirs.js +3 -3
- package/dist/cjs/node/plugin/shared/{viteIsSSR.js → isViteServerBuild.js} +20 -11
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/plugin/plugins/build/handleAssetsManifest.d.ts +18 -0
- package/dist/esm/node/plugin/plugins/build/{pluginAssetsManifest/fixServerAssets.js → handleAssetsManifest.js} +32 -44
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.d.ts +2 -0
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.js +54 -23
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.js +5 -32
- package/dist/esm/node/plugin/plugins/build/pluginBuildConfig.js +6 -10
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginDistFileNames.js +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginDistPackageJsonFile.js +2 -2
- package/dist/esm/node/plugin/plugins/envVars.js +2 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +10 -10
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +4 -4
- package/dist/esm/node/plugin/shared/getOutDirs.js +3 -3
- package/dist/esm/node/plugin/shared/isViteServerBuild.d.ts +15 -0
- package/dist/esm/node/plugin/shared/{viteIsSSR.js → isViteServerBuild.js} +20 -11
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/shared/getFullBuildInlineConfig.js +0 -20
- package/dist/esm/node/plugin/plugins/build/pluginAssetsManifest/fixServerAssets.d.ts +0 -27
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.d.ts +0 -2
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.js +0 -17
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +0 -13
|
@@ -4,38 +4,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.handleAssetsManifest = handleAssetsManifest;
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.writeManifestFile = writeManifestFile;
|
|
7
|
+
exports.handleAssetsManifest_getBuildConfig = handleAssetsManifest_getBuildConfig;
|
|
8
|
+
exports.handleAssetsManifest_isFixEnabled = handleAssetsManifest_isFixEnabled;
|
|
9
|
+
exports.handleAssetsManifest_assertUsageCssCodeSplit = handleAssetsManifest_assertUsageCssCodeSplit;
|
|
10
|
+
exports.handleAssetsManifest_assertUsageCssTarget = handleAssetsManifest_assertUsageCssTarget;
|
|
12
11
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
13
12
|
const fs_1 = __importDefault(require("fs"));
|
|
14
13
|
const path_1 = __importDefault(require("path"));
|
|
15
14
|
const fs_2 = require("fs");
|
|
16
|
-
const utils_js_1 = require("
|
|
17
|
-
const virtualFilePageConfigValuesAll_js_1 = require("
|
|
18
|
-
const pluginBuildConfig_js_1 = require("
|
|
19
|
-
const getAssetsDir_js_1 = require("
|
|
15
|
+
const utils_js_1 = require("../../utils.js");
|
|
16
|
+
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
17
|
+
const pluginBuildConfig_js_1 = require("./pluginBuildConfig.js");
|
|
18
|
+
const getAssetsDir_js_1 = require("../../shared/getAssetsDir.js");
|
|
20
19
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
21
|
-
const getVikeConfig_js_1 = require("
|
|
22
|
-
const getOutDirs_js_1 = require("
|
|
23
|
-
const
|
|
24
|
-
const commonConfig_js_1 = require("
|
|
25
|
-
const pluginBuildEntry_js_1 = require("
|
|
20
|
+
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
21
|
+
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
22
|
+
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
23
|
+
const commonConfig_js_1 = require("../commonConfig.js");
|
|
24
|
+
const pluginBuildEntry_js_1 = require("./pluginBuildEntry.js");
|
|
26
25
|
(0, utils_js_1.assertIsSingleModuleInstance)('build/handleAssetsManifest.ts');
|
|
27
26
|
let assetsJsonFilePath;
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* Only used by V1 design.
|
|
34
|
-
*/
|
|
35
|
-
function fixServerAssets_isEnabled() {
|
|
36
|
-
// We currently apply the workaround iff V1 design.
|
|
37
|
-
// Shall we allow the user to toggle between the two workarounds? E.g. based on https://vike.dev/includeAssetsImportedByServer.
|
|
38
|
-
return true;
|
|
27
|
+
// true => use workaround config.build.ssrEmitAssets
|
|
28
|
+
// false => use workaround extractAssets plugin
|
|
29
|
+
function handleAssetsManifest_isFixEnabled(config) {
|
|
30
|
+
// Allow user to toggle between the two workarounds? E.g. based on https://vike.dev/includeAssetsImportedByServer.
|
|
31
|
+
return (0, getVikeConfig_js_1.isV1Design)(config);
|
|
39
32
|
}
|
|
40
33
|
/** https://github.com/vikejs/vike/issues/1339 */
|
|
41
34
|
async function fixServerAssets(config) {
|
|
@@ -224,19 +217,16 @@ function getHash(src) {
|
|
|
224
217
|
return hash;
|
|
225
218
|
}
|
|
226
219
|
// https://github.com/vikejs/vike/issues/1993
|
|
227
|
-
function
|
|
228
|
-
|
|
229
|
-
if (!isServerAssetsFixEnabled)
|
|
220
|
+
function handleAssetsManifest_assertUsageCssCodeSplit(config) {
|
|
221
|
+
if (!handleAssetsManifest_isFixEnabled(config))
|
|
230
222
|
return;
|
|
231
223
|
(0, utils_js_1.assertWarning)(config.build.cssCodeSplit, `${picocolors_1.default.cyan('build.cssCodeSplit')} shouldn't be set to ${picocolors_1.default.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
232
224
|
}
|
|
233
225
|
const targets = [];
|
|
234
|
-
function
|
|
235
|
-
if (!
|
|
236
|
-
return;
|
|
237
|
-
if (!(0, getVikeConfig_js_1.isV1Design)(config))
|
|
226
|
+
function handleAssetsManifest_assertUsageCssTarget(config) {
|
|
227
|
+
if (!handleAssetsManifest_isFixEnabled(config))
|
|
238
228
|
return;
|
|
239
|
-
const isServerSide = (0,
|
|
229
|
+
const isServerSide = (0, isViteServerBuild_js_1.isViteServerBuild)(config);
|
|
240
230
|
(0, utils_js_1.assert)(typeof isServerSide === 'boolean');
|
|
241
231
|
(0, utils_js_1.assert)(config.build.target !== undefined);
|
|
242
232
|
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
@@ -295,39 +285,39 @@ async function writeManifestFile(manifest, manifestFilePath) {
|
|
|
295
285
|
const manifestFileContent = JSON.stringify(manifest, null, 2);
|
|
296
286
|
await promises_1.default.writeFile(manifestFilePath, manifestFileContent, 'utf-8');
|
|
297
287
|
}
|
|
298
|
-
function
|
|
288
|
+
function handleAssetsManifest_getBuildConfig(config) {
|
|
299
289
|
const vike = (0, commonConfig_js_1.getVikeConfigPublic)(config);
|
|
300
|
-
const
|
|
290
|
+
const isFixEnabled = handleAssetsManifest_isFixEnabled(config);
|
|
301
291
|
return {
|
|
302
292
|
// https://github.com/vikejs/vike/issues/1339
|
|
303
|
-
ssrEmitAssets:
|
|
293
|
+
ssrEmitAssets: isFixEnabled ? true : undefined,
|
|
304
294
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
305
|
-
cssMinify:
|
|
295
|
+
cssMinify: isFixEnabled ? 'esbuild' : undefined,
|
|
306
296
|
manifest: pluginBuildConfig_js_1.manifestTempFile,
|
|
307
297
|
copyPublicDir: vike.config.viteEnvironmentAPI
|
|
308
298
|
? // Already set by vike:build:pluginBuildApp
|
|
309
299
|
undefined
|
|
310
|
-
: !(0,
|
|
300
|
+
: !(0, isViteServerBuild_js_1.isViteServerBuild)(config)
|
|
311
301
|
};
|
|
312
302
|
}
|
|
313
303
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
314
|
-
if ((0,
|
|
304
|
+
if ((0, isViteServerBuild_js_1.isViteServerBuild_onlySsrEnv)(config, viteEnv)) {
|
|
315
305
|
(0, utils_js_1.assert)(!assetsJsonFilePath);
|
|
316
306
|
const outDirs = (0, getOutDirs_js_1.getOutDirs)(config, viteEnv);
|
|
317
307
|
assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
318
308
|
await writeAssetsManifestFile(outDirs, assetsJsonFilePath, config);
|
|
319
309
|
}
|
|
320
|
-
if ((0,
|
|
310
|
+
if ((0, isViteServerBuild_js_1.isViteServerBuild)(config, viteEnv)) {
|
|
321
311
|
(0, utils_js_1.assert)(assetsJsonFilePath);
|
|
322
312
|
// Replace __VITE_ASSETS_MANIFEST__ in all server-side bundles
|
|
323
313
|
await (0, pluginBuildEntry_js_1.set_macro_ASSETS_MANIFEST)(options, bundle, assetsJsonFilePath);
|
|
324
314
|
}
|
|
325
315
|
}
|
|
326
316
|
async function writeAssetsManifestFile(outDirs, assetsJsonFilePath, config) {
|
|
327
|
-
const
|
|
317
|
+
const isFixEnabled = handleAssetsManifest_isFixEnabled(config);
|
|
328
318
|
const clientManifestFilePath = path_1.default.posix.join(outDirs.outDirClient, pluginBuildConfig_js_1.manifestTempFile);
|
|
329
319
|
const serverManifestFilePath = path_1.default.posix.join(outDirs.outDirServer, pluginBuildConfig_js_1.manifestTempFile);
|
|
330
|
-
if (!
|
|
320
|
+
if (!isFixEnabled) {
|
|
331
321
|
await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
|
|
332
322
|
}
|
|
333
323
|
else {
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.pluginAutoFullBuild = pluginAutoFullBuild;
|
|
7
|
-
|
|
7
|
+
exports.isPrerenderForceExit = isPrerenderForceExit;
|
|
8
8
|
const vite_1 = require("vite");
|
|
9
9
|
const utils_js_1 = require("../../utils.js");
|
|
10
10
|
const runPrerender_js_1 = require("../../../prerender/runPrerender.js");
|
|
@@ -15,7 +15,9 @@ const logErrorHint_js_1 = require("../../../runtime/renderPage/logErrorHint.js")
|
|
|
15
15
|
const pluginBuildConfig_js_1 = require("./pluginBuildConfig.js");
|
|
16
16
|
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
17
17
|
const context_js_2 = require("../../../api/context.js");
|
|
18
|
-
const
|
|
18
|
+
const handleAssetsManifest_js_1 = require("./handleAssetsManifest.js");
|
|
19
|
+
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
20
|
+
(0, utils_js_1.assertIsSingleModuleInstance)('build/pluginAutoFullBuild.ts');
|
|
19
21
|
let forceExit = false;
|
|
20
22
|
function pluginAutoFullBuild() {
|
|
21
23
|
let config;
|
|
@@ -36,8 +38,8 @@ function pluginAutoFullBuild() {
|
|
|
36
38
|
order: 'pre',
|
|
37
39
|
*/
|
|
38
40
|
async handler(options, bundle) {
|
|
39
|
-
await (0,
|
|
40
|
-
await triggerFullBuild(config, vikeConfig, bundle);
|
|
41
|
+
await (0, handleAssetsManifest_js_1.handleAssetsManifest)(config, this.environment, options, bundle);
|
|
42
|
+
await triggerFullBuild(config, vikeConfig, this.environment, bundle);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
},
|
|
@@ -49,7 +51,11 @@ function pluginAutoFullBuild() {
|
|
|
49
51
|
sequential: true,
|
|
50
52
|
order: 'post',
|
|
51
53
|
handler() {
|
|
52
|
-
|
|
54
|
+
(0, utils_js_1.onSetupBuild)();
|
|
55
|
+
(0, handleAssetsManifest_js_1.handleAssetsManifest_assertUsageCssTarget)(config);
|
|
56
|
+
if (forceExit &&
|
|
57
|
+
// Let vike:build:pluginBuildApp force exit
|
|
58
|
+
!vikeConfig.global.config.viteEnvironmentAPI) {
|
|
53
59
|
(0, runPrerender_js_1.runPrerender_forceExit)();
|
|
54
60
|
(0, utils_js_1.assert)(false);
|
|
55
61
|
}
|
|
@@ -58,10 +64,14 @@ function pluginAutoFullBuild() {
|
|
|
58
64
|
}
|
|
59
65
|
];
|
|
60
66
|
}
|
|
61
|
-
async function triggerFullBuild(config, vikeConfig, bundle) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
async function triggerFullBuild(config, vikeConfig, viteEnv, bundle) {
|
|
68
|
+
// Whether builder.buildApp() is being used, see plugin:build:pluginBuildApp
|
|
69
|
+
const isBuilderApp = vikeConfig.global.config.viteEnvironmentAPI;
|
|
70
|
+
// If builder.buildApp() => trigger at end of `this.environment.name === 'ssr'`.
|
|
71
|
+
// Else => trigger at end of client-side build.
|
|
72
|
+
if (isBuilderApp ? !(0, isViteServerBuild_js_1.isViteServerBuild_onlySsrEnv)(config, viteEnv) : !(0, isViteServerBuild_js_1.isViteClientBuild)(config, viteEnv))
|
|
73
|
+
return;
|
|
74
|
+
if (isEntirelyDisabled(vikeConfig))
|
|
65
75
|
return;
|
|
66
76
|
// Workaround for @vitejs/plugin-legacy
|
|
67
77
|
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
@@ -69,15 +79,20 @@ async function triggerFullBuild(config, vikeConfig, bundle) {
|
|
|
69
79
|
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
70
80
|
if (!bundle[pluginBuildConfig_js_1.manifestTempFile])
|
|
71
81
|
return;
|
|
72
|
-
const configInline =
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
const configInline = getFullBuildInlineConfig(config);
|
|
83
|
+
if (!isBuilderApp) {
|
|
84
|
+
try {
|
|
85
|
+
await (0, vite_1.build)(setSSR(configInline));
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
// Avoid Rollup prefixing the error with [vike:build:pluginAutoFullBuild], see for example https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
89
|
+
console.error(err);
|
|
90
|
+
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
75
93
|
}
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
console.error(err);
|
|
79
|
-
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
80
|
-
process.exit(1);
|
|
94
|
+
else {
|
|
95
|
+
// The server bulid is already called by builder.buildApp()
|
|
81
96
|
}
|
|
82
97
|
if ((0, context_js_1.isPrerenderAutoRunEnabled)(vikeConfig)) {
|
|
83
98
|
const res = await (0, runPrerender_js_1.runPrerenderFromAutoRun)(configInline, config);
|
|
@@ -99,16 +114,32 @@ function abortViteBuildSsr(vikeConfig) {
|
|
|
99
114
|
process.exit(0);
|
|
100
115
|
}
|
|
101
116
|
}
|
|
102
|
-
function
|
|
103
|
-
const { disableAutoFullBuild
|
|
104
|
-
if (viteEnvironmentAPI) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
117
|
+
function isEntirelyDisabled(vikeConfig) {
|
|
118
|
+
const { disableAutoFullBuild } = vikeConfig.global.config;
|
|
107
119
|
if (disableAutoFullBuild === undefined || disableAutoFullBuild === 'prerender') {
|
|
108
|
-
const
|
|
109
|
-
return
|
|
120
|
+
const isUserUsingViteApi = !(0, isViteCliCall_js_1.isViteCliCall)() && !(0, context_js_2.isVikeCliOrApi)();
|
|
121
|
+
return isUserUsingViteApi;
|
|
110
122
|
}
|
|
111
123
|
else {
|
|
112
124
|
return disableAutoFullBuild;
|
|
113
125
|
}
|
|
114
126
|
}
|
|
127
|
+
function isPrerenderForceExit() {
|
|
128
|
+
return forceExit;
|
|
129
|
+
}
|
|
130
|
+
function getFullBuildInlineConfig(config) {
|
|
131
|
+
const configFromCli = !(0, isViteCliCall_js_1.isViteCliCall)() ? null : (0, isViteCliCall_js_1.getViteConfigFromCli)();
|
|
132
|
+
if (config._viteConfigEnhanced) {
|
|
133
|
+
return config._viteConfigEnhanced;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
return {
|
|
137
|
+
...configFromCli,
|
|
138
|
+
configFile: configFromCli?.configFile || config.configFile,
|
|
139
|
+
root: config.root,
|
|
140
|
+
build: {
|
|
141
|
+
...configFromCli?.build
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pluginBuildApp = pluginBuildApp;
|
|
4
4
|
const runPrerender_js_1 = require("../../../prerender/runPrerender.js");
|
|
5
|
-
const context_js_1 = require("../../../prerender/context.js");
|
|
6
5
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
7
6
|
const utils_js_1 = require("../../utils.js");
|
|
8
|
-
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
9
|
-
const getFullBuildInlineConfig_js_1 = require("../../shared/getFullBuildInlineConfig.js");
|
|
10
7
|
const commonConfig_js_1 = require("../commonConfig.js");
|
|
8
|
+
const pluginAutoFullBuild_js_1 = require("./pluginAutoFullBuild.js");
|
|
11
9
|
function pluginBuildApp() {
|
|
12
|
-
let config;
|
|
13
|
-
// `builder.buildApp()` can be overriden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
14
|
-
// In that case, we shouldn't `forceExit`.
|
|
15
|
-
let forceExit = false;
|
|
16
10
|
return [
|
|
17
11
|
{
|
|
18
12
|
name: 'vike:build:pluginBuildApp',
|
|
@@ -23,12 +17,13 @@ function pluginBuildApp() {
|
|
|
23
17
|
return;
|
|
24
18
|
return {
|
|
25
19
|
builder: {
|
|
26
|
-
|
|
20
|
+
// Can be overriden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
21
|
+
async buildApp(builder) {
|
|
27
22
|
(0, utils_js_1.assert)(builder.environments.client);
|
|
28
23
|
(0, utils_js_1.assert)(builder.environments.ssr);
|
|
29
24
|
await builder.build(builder.environments.client);
|
|
30
25
|
await builder.build(builder.environments.ssr);
|
|
31
|
-
if (
|
|
26
|
+
if ((0, pluginAutoFullBuild_js_1.isPrerenderForceExit)()) {
|
|
32
27
|
(0, runPrerender_js_1.runPrerender_forceExit)();
|
|
33
28
|
(0, utils_js_1.assert)(false);
|
|
34
29
|
}
|
|
@@ -52,28 +47,6 @@ function pluginBuildApp() {
|
|
|
52
47
|
}
|
|
53
48
|
};
|
|
54
49
|
}
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'vike:build:pluginBuildApp:prerender',
|
|
58
|
-
apply: 'build',
|
|
59
|
-
enforce: 'pre',
|
|
60
|
-
applyToEnvironment(env) {
|
|
61
|
-
return env.name === 'ssr';
|
|
62
|
-
},
|
|
63
|
-
configResolved(_config) {
|
|
64
|
-
config = _config;
|
|
65
|
-
},
|
|
66
|
-
async writeBundle() {
|
|
67
|
-
const vike = (0, commonConfig_js_1.getVikeConfigPublic)(config);
|
|
68
|
-
if (!vike.config.viteEnvironmentAPI)
|
|
69
|
-
return;
|
|
70
|
-
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
|
|
71
|
-
if (!(0, context_js_1.isPrerenderAutoRunEnabled)(vikeConfig))
|
|
72
|
-
return;
|
|
73
|
-
const configInline = (0, getFullBuildInlineConfig_js_1.getFullBuildInlineConfig)(config);
|
|
74
|
-
const res = await (0, runPrerender_js_1.runPrerenderFromAutoRun)(configInline, config);
|
|
75
|
-
forceExit = res.forceExit;
|
|
76
|
-
}
|
|
77
50
|
}
|
|
78
51
|
];
|
|
79
52
|
}
|
|
@@ -13,9 +13,9 @@ const module_1 = require("module");
|
|
|
13
13
|
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
14
14
|
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
15
15
|
const getConfigValueBuildTime_js_1 = require("../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
16
|
-
const
|
|
16
|
+
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
17
17
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
18
|
-
const
|
|
18
|
+
const handleAssetsManifest_js_1 = require("./handleAssetsManifest.js");
|
|
19
19
|
// @ts-ignore `file://${__filename}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
20
20
|
const importMetaUrl = `file://${__filename}`;
|
|
21
21
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
@@ -38,7 +38,7 @@ function pluginBuildConfig() {
|
|
|
38
38
|
(0, utils_js_1.assert)(Object.keys(entries).length > 0);
|
|
39
39
|
config.build.rollupOptions.input = (0, utils_js_1.injectRollupInputs)(entries, config);
|
|
40
40
|
addLogHook();
|
|
41
|
-
(0,
|
|
41
|
+
(0, handleAssetsManifest_js_1.handleAssetsManifest_assertUsageCssCodeSplit)(config);
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
config: {
|
|
@@ -48,17 +48,13 @@ function pluginBuildConfig() {
|
|
|
48
48
|
return {
|
|
49
49
|
build: {
|
|
50
50
|
outDir: (0, getOutDirs_js_1.resolveOutDir)(config),
|
|
51
|
-
...(0,
|
|
51
|
+
...(0, handleAssetsManifest_js_1.handleAssetsManifest_getBuildConfig)(config)
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
buildStart() {
|
|
57
57
|
(0, utils_js_1.onSetupBuild)();
|
|
58
|
-
},
|
|
59
|
-
closeBundle() {
|
|
60
|
-
(0, utils_js_1.onSetupBuild)();
|
|
61
|
-
(0, fixServerAssets_js_1.fixServerAssets_assertUsageCssTarget)(config);
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
];
|
|
@@ -71,7 +67,7 @@ async function getEntries(config) {
|
|
|
71
67
|
// TODO/now: add meta.default
|
|
72
68
|
vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
73
69
|
(0, utils_js_1.assertUsage)(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
74
|
-
if ((0,
|
|
70
|
+
if ((0, isViteServerBuild_js_1.isViteServerBuild)(config)) {
|
|
75
71
|
const pageEntries = getPageEntries(pageConfigs);
|
|
76
72
|
const entries = {
|
|
77
73
|
...pageFileEntries,
|
|
@@ -144,7 +140,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
144
140
|
// Ensure Rollup creates entries for each page file, see https://github.com/vikejs/vike/issues/350
|
|
145
141
|
// (Otherwise the page files may be missing in the client manifest.json)
|
|
146
142
|
async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
147
|
-
const isForClientSide = !(0,
|
|
143
|
+
const isForClientSide = !(0, isViteServerBuild_js_1.isViteServerBuild)(config);
|
|
148
144
|
const fileTypes = isForClientSide ? ['.page', '.page.client'] : ['.page', '.page.server'];
|
|
149
145
|
if (isForClientSide && includeAssetsImportedByServer) {
|
|
150
146
|
fileTypes.push('.page.server');
|
|
@@ -64,7 +64,7 @@ function getServerProductionEntryCode(config) {
|
|
|
64
64
|
].join('\n');
|
|
65
65
|
return importerCode;
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
// Set the value of the ASSETS_MANIFEST constant inside dist/server/entry.js (or dist/server/index.js)
|
|
68
68
|
async function set_macro_ASSETS_MANIFEST(options, bundle, assetsJsonFilePath) {
|
|
69
69
|
const { dir } = options;
|
|
70
70
|
(0, utils_js_1.assert)(dir);
|
|
@@ -33,7 +33,7 @@ function pluginDistFileNames() {
|
|
|
33
33
|
else {
|
|
34
34
|
// If a user needs this:
|
|
35
35
|
// - assertUsage() that the naming provided by the user ends with `.[hash][extname]`
|
|
36
|
-
// - It's needed for getHash() of
|
|
36
|
+
// - It's needed for getHash() of handleAssetsManifest()
|
|
37
37
|
// - Asset URLs should always contain a hash: it's paramount for caching assets.
|
|
38
38
|
// - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
|
|
39
39
|
(0, utils_js_1.assertUsage)(false, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use.");
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.pluginDistPackageJsonFile = pluginDistPackageJsonFile;
|
|
12
12
|
const rollupIsEsm_js_1 = require("../../shared/rollupIsEsm.js");
|
|
13
|
-
const
|
|
13
|
+
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
14
14
|
function pluginDistPackageJsonFile() {
|
|
15
15
|
let config;
|
|
16
16
|
return {
|
|
@@ -20,7 +20,7 @@ function pluginDistPackageJsonFile() {
|
|
|
20
20
|
config = config_;
|
|
21
21
|
},
|
|
22
22
|
generateBundle(options, bundle) {
|
|
23
|
-
if (!(0,
|
|
23
|
+
if (!(0, isViteServerBuild_js_1.isViteServerBuild)(config))
|
|
24
24
|
return;
|
|
25
25
|
const isEsm = (0, rollupIsEsm_js_1.rollupIsEsm)(options);
|
|
26
26
|
const fileName = 'package.json';
|
|
@@ -6,7 +6,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
6
6
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
7
7
|
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
8
8
|
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
9
|
-
const
|
|
9
|
+
const isViteServerBuild_js_1 = require("../shared/isViteServerBuild.js");
|
|
10
10
|
// TODO/enventually: (after we implemented vike.config.js)
|
|
11
11
|
// - Make import.meta.env work inside +config.js
|
|
12
12
|
// - 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
|
|
@@ -39,7 +39,7 @@ function envVarsPlugin() {
|
|
|
39
39
|
if (!code.includes('import.meta.env.'))
|
|
40
40
|
return;
|
|
41
41
|
const isBuild = config.command === 'build';
|
|
42
|
-
const isClientSide = !(0,
|
|
42
|
+
const isClientSide = !(0, isViteServerBuild_js_1.isViteServerBuild_safe)(config, options);
|
|
43
43
|
Object.entries(envsAll)
|
|
44
44
|
.filter(([key]) => {
|
|
45
45
|
// Already handled by Vite
|
|
@@ -14,11 +14,11 @@ const isAsset_js_1 = require("../shared/isAsset.js");
|
|
|
14
14
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
15
15
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
16
16
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
17
|
-
const
|
|
17
|
+
const handleAssetsManifest_js_1 = require("./build/handleAssetsManifest.js");
|
|
18
18
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
19
19
|
const assertV1Design_js_1 = require("../../shared/assertV1Design.js");
|
|
20
20
|
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
21
|
-
const
|
|
21
|
+
const isViteServerBuild_js_1 = require("../shared/isViteServerBuild.js");
|
|
22
22
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
23
23
|
exports.extractAssetsRE = extractAssetsRE;
|
|
24
24
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
@@ -28,7 +28,7 @@ const debug = (0, utils_js_1.createDebugger)('vike:extractAssets');
|
|
|
28
28
|
function extractAssetsPlugin() {
|
|
29
29
|
let config;
|
|
30
30
|
let vikeConfig;
|
|
31
|
-
let
|
|
31
|
+
let isFixEnabled;
|
|
32
32
|
return [
|
|
33
33
|
// This plugin removes all JavaScript from server-side only code, so that only CSS imports remains. (And also satic files imports e.g. `import logoURL from './logo.svg.js'`).
|
|
34
34
|
{
|
|
@@ -41,14 +41,14 @@ function extractAssetsPlugin() {
|
|
|
41
41
|
if (!extractAssetsRE.test(id)) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
45
|
-
// I'm guessing
|
|
44
|
+
if (isFixEnabled) {
|
|
45
|
+
// I'm guessing isFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
|
|
46
46
|
(0, assertV1Design_js_1.assertV1Design)(vikeConfig.pageConfigs, true);
|
|
47
47
|
(0, utils_js_1.assert)(false);
|
|
48
48
|
}
|
|
49
49
|
// TODO/now: add meta.default
|
|
50
50
|
(0, utils_js_1.assert)(vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
51
|
-
(0, utils_js_1.assert)(!(0,
|
|
51
|
+
(0, utils_js_1.assert)(!(0, isViteServerBuild_js_1.isViteServerBuild_safe)(config, options));
|
|
52
52
|
const importStatements = await (0, parseEsModule_js_1.getImportStatements)(src);
|
|
53
53
|
const moduleNames = getImportedModules(importStatements);
|
|
54
54
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
@@ -65,7 +65,7 @@ function extractAssetsPlugin() {
|
|
|
65
65
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
66
66
|
enforce: 'pre',
|
|
67
67
|
async resolveId(source, importer, options) {
|
|
68
|
-
if ((0,
|
|
68
|
+
if ((0, isViteServerBuild_js_1.isViteServerBuild_safe)(config, options)) {
|
|
69
69
|
// When building for the server, there should never be a `?extractAssets` query
|
|
70
70
|
(0, utils_js_1.assert)(!extractAssetsRE.test(source));
|
|
71
71
|
(0, utils_js_1.assert)(importer === undefined || !extractAssetsRE.test(importer));
|
|
@@ -142,8 +142,8 @@ function extractAssetsPlugin() {
|
|
|
142
142
|
async configResolved(config_) {
|
|
143
143
|
config = config_;
|
|
144
144
|
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
|
|
145
|
-
|
|
146
|
-
if (!
|
|
145
|
+
isFixEnabled = (0, handleAssetsManifest_js_1.handleAssetsManifest_isFixEnabled)(config);
|
|
146
|
+
if (!isFixEnabled) {
|
|
147
147
|
// https://github.com/vikejs/vike/issues/1060
|
|
148
148
|
(0, utils_js_1.assertUsage)(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
|
|
149
149
|
}
|
|
@@ -7,7 +7,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
7
7
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
8
8
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
9
9
|
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
10
|
-
const
|
|
10
|
+
const isViteServerBuild_js_1 = require("../shared/isViteServerBuild.js");
|
|
11
11
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
12
12
|
exports.extractExportNamesRE = extractExportNamesRE;
|
|
13
13
|
const debug = (0, utils_js_1.createDebugger)('vike:extractExportNames');
|
|
@@ -19,7 +19,7 @@ function extractExportNamesPlugin() {
|
|
|
19
19
|
enforce: 'post',
|
|
20
20
|
async transform(src, id, options) {
|
|
21
21
|
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
22
|
-
const isClientSide = !(0,
|
|
22
|
+
const isClientSide = !(0, isViteServerBuild_js_1.isViteServerBuild_options)(options);
|
|
23
23
|
if (extractExportNamesRE.test(id)) {
|
|
24
24
|
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
25
25
|
debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
|
|
@@ -12,12 +12,12 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
12
|
const getVirtualFilePageConfigs_js_1 = require("./v1-design/virtual-files/getVirtualFilePageConfigs.js");
|
|
13
13
|
const getVikeConfig_js_1 = require("./v1-design/getVikeConfig.js");
|
|
14
14
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
15
|
-
const
|
|
15
|
+
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
16
16
|
async function getVirtualFileImportUserCode(id, options, vikeConfig, config, isDev) {
|
|
17
17
|
const idParsed = (0, virtualFileImportUserCode_js_1.isVirtualFileIdImportUserCode)(id);
|
|
18
18
|
(0, utils_js_1.assert)(idParsed);
|
|
19
19
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
20
|
-
(0, utils_js_1.assert)(isForClientSide === !(0,
|
|
20
|
+
(0, utils_js_1.assert)(isForClientSide === !(0, isViteServerBuild_js_1.isViteServerBuild_options)(options));
|
|
21
21
|
const code = await getCode(config, vikeConfig, isForClientSide, isClientRouting, isDev, id);
|
|
22
22
|
return code;
|
|
23
23
|
}
|
|
@@ -74,7 +74,7 @@ ${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClien
|
|
|
74
74
|
|
|
75
75
|
`;
|
|
76
76
|
// We still use import.meta.glob() when using th V1 design in order to not break the V1 design deprecation warning
|
|
77
|
-
const isV1Design =
|
|
77
|
+
const isV1Design = (0, getVikeConfig_js_1.isV1Design)(config);
|
|
78
78
|
// Old design => no + files => only to enable pre-rendering is setting `vike({prerender})` in vite.config.js
|
|
79
79
|
const isPrerendering = !!vikeConfig.global.config.prerender;
|
|
80
80
|
fileTypes_js_1.fileTypes
|
|
@@ -26,11 +26,8 @@ function importUserCode() {
|
|
|
26
26
|
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config_);
|
|
27
27
|
config = config_;
|
|
28
28
|
// TODO/v1-release: remove
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!isV1)
|
|
32
|
-
config.experimental.importGlobRestoreExtension = true;
|
|
33
|
-
}
|
|
29
|
+
if (!(0, getVikeConfig_js_1.isV1Design)(config))
|
|
30
|
+
config.experimental.importGlobRestoreExtension = true;
|
|
34
31
|
},
|
|
35
32
|
resolveId(id) {
|
|
36
33
|
if ((0, virtual_files_js_1.isVirtualFileId)(id)) {
|
|
@@ -73,6 +73,7 @@ async function handleReloadSideEffects() {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
// TODO/soon: predominantly use getVikeConfigPublic() instead of getVikeConfig() then maybe refector?
|
|
76
77
|
async function getVikeConfig(config, { doNotRestartViteOnError } = {}) {
|
|
77
78
|
const userRootDir = config.root;
|
|
78
79
|
const vikeVitePluginOptions = config._vikeVitePluginOptions;
|
|
@@ -91,7 +92,6 @@ async function getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doN
|
|
|
91
92
|
}
|
|
92
93
|
return await vikeConfigPromise;
|
|
93
94
|
}
|
|
94
|
-
// TODO/now update all isV1Design() usage
|
|
95
95
|
function isV1Design(config) {
|
|
96
96
|
const vikeConfig = config._vikeConfigObject;
|
|
97
97
|
(0, utils_js_1.assert)(vikeConfig);
|
|
@@ -8,7 +8,7 @@ const extractAssetsQuery_js_1 = require("../../../../../shared/extractAssetsQuer
|
|
|
8
8
|
const debug_js_1 = require("./debug.js");
|
|
9
9
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
10
10
|
const serializeConfigValues_js_1 = require("../../../../../../shared/page-configs/serialize/serializeConfigValues.js");
|
|
11
|
-
const
|
|
11
|
+
const handleAssetsManifest_js_1 = require("../../../build/handleAssetsManifest.js");
|
|
12
12
|
const getConfigValueBuildTime_js_1 = require("../../../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
13
13
|
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
14
14
|
const result = (0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id);
|
|
@@ -26,11 +26,11 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
26
26
|
(0, utils_js_1.assert)(pageConfig, { id, pageId });
|
|
27
27
|
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId,
|
|
28
28
|
// TODO/now: add meta.default
|
|
29
|
-
vikeConfig.global.config.includeAssetsImportedByServer ?? true, isDev);
|
|
29
|
+
vikeConfig.global.config.includeAssetsImportedByServer ?? true, config, isDev);
|
|
30
30
|
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
31
31
|
return code;
|
|
32
32
|
}
|
|
33
|
-
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
33
|
+
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, config, isDev) {
|
|
34
34
|
const lines = [];
|
|
35
35
|
const importStatements = [];
|
|
36
36
|
const filesEnv = new Map();
|
|
@@ -38,7 +38,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
38
38
|
lines.push('export const configValuesSerialized = {');
|
|
39
39
|
lines.push(...(0, serializeConfigValues_js_1.serializeConfigValues)(pageConfig, importStatements, filesEnv, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isDev }), '', false));
|
|
40
40
|
lines.push('};');
|
|
41
|
-
if (!(0,
|
|
41
|
+
if (!(0, handleAssetsManifest_js_1.handleAssetsManifest_isFixEnabled)(config) && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
42
42
|
importStatements.push(`import '${(0, extractAssetsQuery_js_1.extractAssetsAddQuery)((0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, false))}'`);
|
|
43
43
|
}
|
|
44
44
|
const code = [...importStatements, ...lines].join('\n');
|