vike 0.4.223-commit-586dbfb → 0.4.223-commit-62ca594
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 +3 -36
- package/dist/cjs/node/plugin/index.js +3 -17
- package/dist/cjs/node/plugin/plugins/{buildConfig → build/pluginAssetsManifest}/fixServerAssets.js +29 -22
- package/dist/cjs/node/plugin/plugins/build/pluginAssetsManifest.js +115 -0
- package/dist/cjs/node/plugin/plugins/{autoFullBuild.js → build/pluginAutoFullBuild.js} +15 -16
- package/dist/cjs/node/plugin/plugins/{buildApp.js → build/pluginBuildApp.js} +12 -12
- package/dist/cjs/node/plugin/plugins/{buildConfig.js → build/pluginBuildConfig.js} +18 -82
- package/dist/cjs/node/plugin/plugins/{buildEntry/index.js → build/pluginBuildEntry.js} +8 -8
- package/dist/cjs/node/plugin/plugins/{distFileNames.js → build/pluginDistFileNames.js} +6 -6
- package/dist/cjs/node/plugin/plugins/{packageJsonFile.js → build/pluginDistPackageJsonFile.js} +5 -5
- package/dist/cjs/node/plugin/plugins/{suppressRollupWarning.js → build/pluginSuppressRollupWarning.js} +3 -3
- package/dist/cjs/node/plugin/plugins/build.js +23 -0
- package/dist/cjs/node/plugin/plugins/commonConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findPackageJson.js +1 -1
- package/dist/cjs/utils/requireResolve.js +1 -1
- package/dist/esm/node/api/build.js +3 -3
- package/dist/esm/node/plugin/index.js +3 -17
- package/dist/esm/node/plugin/plugins/{buildConfig → build/pluginAssetsManifest}/fixServerAssets.d.ts +7 -5
- package/dist/esm/node/plugin/plugins/{buildConfig → build/pluginAssetsManifest}/fixServerAssets.js +29 -22
- package/dist/esm/node/plugin/plugins/build/pluginAssetsManifest.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/build/pluginAssetsManifest.js +110 -0
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{autoFullBuild.js → build/pluginAutoFullBuild.js} +14 -15
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{buildApp.js → build/pluginBuildApp.js} +12 -12
- package/dist/esm/node/plugin/plugins/{buildConfig.d.ts → build/pluginBuildConfig.d.ts} +3 -3
- package/dist/esm/node/plugin/plugins/{buildConfig.js → build/pluginBuildConfig.js} +18 -79
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +8 -0
- package/dist/esm/node/plugin/plugins/{buildEntry/index.js → build/pluginBuildEntry.js} +8 -8
- package/dist/esm/node/plugin/plugins/build/pluginDistFileNames.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{distFileNames.js → build/pluginDistFileNames.js} +6 -6
- package/dist/esm/node/plugin/plugins/build/pluginDistPackageJsonFile.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{packageJsonFile.js → build/pluginDistPackageJsonFile.js} +6 -5
- package/dist/esm/node/plugin/plugins/build/pluginSuppressRollupWarning.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{suppressRollupWarning.js → build/pluginSuppressRollupWarning.js} +3 -3
- package/dist/esm/node/plugin/plugins/build.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/build.js +21 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -1
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js +1 -3
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/findPackageJson.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +4 -13
- package/dist/cjs/node/plugin/plugins/removeRequireHookPlugin.js +0 -17
- package/dist/esm/node/plugin/plugins/autoFullBuild.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/buildApp.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +0 -8
- package/dist/esm/node/plugin/plugins/distFileNames.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/packageJsonFile.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/removeRequireHookPlugin.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/removeRequireHookPlugin.js +0 -15
- package/dist/esm/node/plugin/plugins/suppressRollupWarning.d.ts +0 -3
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -50,13 +17,13 @@ const utils_js_1 = require("./utils.js");
|
|
|
50
17
|
*/
|
|
51
18
|
async function build(options = {}) {
|
|
52
19
|
const { viteConfigEnhanced, vikeConfig } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options.viteConfig, 'build');
|
|
53
|
-
// Pass it to
|
|
20
|
+
// Pass it to pluginAutoFullBuild()
|
|
54
21
|
if (viteConfigEnhanced)
|
|
55
22
|
viteConfigEnhanced._viteConfigEnhanced = viteConfigEnhanced;
|
|
56
23
|
if (vikeConfig.global.config.viteEnvironmentAPI) {
|
|
57
24
|
(0, utils_js_1.assertVersion)('Vite', vite_1.version, '6.0.0');
|
|
58
|
-
const
|
|
59
|
-
|
|
25
|
+
const builder = await (0, vite_1.createBuilder)(viteConfigEnhanced);
|
|
26
|
+
// See Vite plugin vike:build:pluginBuildApp
|
|
60
27
|
await builder.buildApp();
|
|
61
28
|
}
|
|
62
29
|
else {
|
|
@@ -12,19 +12,13 @@ Object.defineProperty(exports, "getVikeConfig", { enumerable: true, get: functio
|
|
|
12
12
|
var utils_js_1 = require("./utils.js");
|
|
13
13
|
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return utils_js_1.PROJECT_VERSION; } });
|
|
14
14
|
const utils_js_2 = require("./utils.js");
|
|
15
|
-
const
|
|
15
|
+
const build_js_1 = require("./plugins/build.js");
|
|
16
16
|
const previewConfig_js_1 = require("./plugins/previewConfig.js");
|
|
17
|
-
const autoFullBuild_js_1 = require("./plugins/autoFullBuild.js");
|
|
18
17
|
const index_js_1 = require("./plugins/devConfig/index.js");
|
|
19
|
-
const packageJsonFile_js_1 = require("./plugins/packageJsonFile.js");
|
|
20
|
-
const removeRequireHookPlugin_js_1 = require("./plugins/removeRequireHookPlugin.js");
|
|
21
18
|
const index_js_2 = require("./plugins/importUserCode/index.js");
|
|
22
|
-
const distFileNames_js_1 = require("./plugins/distFileNames.js");
|
|
23
19
|
const extractAssetsPlugin_js_1 = require("./plugins/extractAssetsPlugin.js");
|
|
24
20
|
const extractExportNamesPlugin_js_1 = require("./plugins/extractExportNamesPlugin.js");
|
|
25
|
-
const suppressRollupWarning_js_1 = require("./plugins/suppressRollupWarning.js");
|
|
26
21
|
const setGlobalContext_js_1 = require("./plugins/setGlobalContext.js");
|
|
27
|
-
const index_js_3 = require("./plugins/buildEntry/index.js");
|
|
28
22
|
const commonConfig_js_2 = require("./plugins/commonConfig.js");
|
|
29
23
|
const baseUrls_js_1 = require("./plugins/baseUrls.js");
|
|
30
24
|
const envVars_js_1 = require("./plugins/envVars.js");
|
|
@@ -34,7 +28,6 @@ const getPageAssets_js_1 = require("../runtime/renderPage/getPageAssets.js");
|
|
|
34
28
|
const resolveClientEntriesDev_js_1 = require("./shared/resolveClientEntriesDev.js");
|
|
35
29
|
const workaroundCssModuleHmr_js_1 = require("./plugins/workaroundCssModuleHmr.js");
|
|
36
30
|
const workaroundVite6HmrRegression_js_1 = require("./plugins/workaroundVite6HmrRegression.js");
|
|
37
|
-
const buildApp_js_1 = require("./plugins/buildApp.js");
|
|
38
31
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
39
32
|
(0, getPageAssets_js_1.setResolveClientEntriesDev)(resolveClientEntriesDev_js_1.resolveClientEntriesDev);
|
|
40
33
|
// Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
|
|
@@ -43,18 +36,11 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
43
36
|
...(0, commonConfig_js_2.commonConfig)(vikeVitePluginOptions),
|
|
44
37
|
(0, index_js_2.importUserCode)(),
|
|
45
38
|
...(0, index_js_1.devConfig)(),
|
|
46
|
-
...(0,
|
|
47
|
-
...(0, buildApp_js_1.buildApp)(),
|
|
39
|
+
...(0, build_js_1.build)(),
|
|
48
40
|
(0, previewConfig_js_1.previewConfig)(),
|
|
49
|
-
...(0, autoFullBuild_js_1.autoFullBuild)(),
|
|
50
|
-
(0, packageJsonFile_js_1.packageJsonFile)(),
|
|
51
|
-
(0, removeRequireHookPlugin_js_1.removeRequireHookPlugin)(),
|
|
52
|
-
(0, distFileNames_js_1.distFileNames)(),
|
|
53
41
|
...(0, extractAssetsPlugin_js_1.extractAssetsPlugin)(),
|
|
54
42
|
(0, extractExportNamesPlugin_js_1.extractExportNamesPlugin)(),
|
|
55
|
-
(0, suppressRollupWarning_js_1.suppressRollupWarning)(),
|
|
56
43
|
...(0, setGlobalContext_js_1.setGlobalContext)(),
|
|
57
|
-
...(0, index_js_3.buildEntry)(),
|
|
58
44
|
(0, baseUrls_js_1.baseUrls)(),
|
|
59
45
|
(0, envVars_js_1.envVarsPlugin)(),
|
|
60
46
|
(0, fileEnv_js_1.fileEnv)(),
|
|
@@ -71,7 +57,7 @@ Object.defineProperty(plugin, 'apply', {
|
|
|
71
57
|
(0, utils_js_2.assertUsage)(false, `Add ${picocolors_1.default.cyan('vike()')} instead of ${picocolors_1.default.cyan('vike')} to vite.config.js#plugins (i.e. call the function and add the return value instead of adding the function itself)`, { showStackTrace: true });
|
|
72
58
|
}
|
|
73
59
|
});
|
|
74
|
-
//
|
|
60
|
+
// CJS default export `const vike = require('vike/plugin')`
|
|
75
61
|
// - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
|
|
76
62
|
try {
|
|
77
63
|
module.exports = Object.assign(exports.default, exports);
|
package/dist/cjs/node/plugin/plugins/{buildConfig → build/pluginAssetsManifest}/fixServerAssets.js
RENAMED
|
@@ -5,20 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fixServerAssets = fixServerAssets;
|
|
7
7
|
exports.fixServerAssets_isEnabled = fixServerAssets_isEnabled;
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
8
|
+
exports.fixServerAssets_assertUsageCssCodeSplit = fixServerAssets_assertUsageCssCodeSplit;
|
|
9
|
+
exports.fixServerAssets_assertUsageCssTarget = fixServerAssets_assertUsageCssTarget;
|
|
10
|
+
exports.writeManifestFile = writeManifestFile;
|
|
10
11
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
11
12
|
const fs_1 = __importDefault(require("fs"));
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
13
14
|
const fs_2 = require("fs");
|
|
14
|
-
const utils_js_1 = require("
|
|
15
|
-
const virtualFilePageConfigValuesAll_js_1 = require("
|
|
16
|
-
const
|
|
17
|
-
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");
|
|
18
19
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
19
|
-
const getVikeConfig_js_1 = require("
|
|
20
|
-
const getOutDirs_js_1 = require("
|
|
21
|
-
const viteIsSSR_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 viteIsSSR_js_1 = require("../../../shared/viteIsSSR.js");
|
|
22
23
|
/**
|
|
23
24
|
* true => use workaround config.build.ssrEmitAssets
|
|
24
25
|
* false => use workaround extractAssets plugin
|
|
@@ -33,20 +34,12 @@ function fixServerAssets_isEnabled() {
|
|
|
33
34
|
/** https://github.com/vikejs/vike/issues/1339 */
|
|
34
35
|
async function fixServerAssets(config) {
|
|
35
36
|
const outDirs = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
36
|
-
const clientManifest = await
|
|
37
|
-
const serverManifest = await
|
|
37
|
+
const clientManifest = await readManifestFile(outDirs.outDirClient);
|
|
38
|
+
const serverManifest = await readManifestFile(outDirs.outDirServer);
|
|
38
39
|
const { clientManifestMod, serverManifestMod, filesToMove, filesToRemove } = addServerAssets(clientManifest, serverManifest);
|
|
39
40
|
await copyAssets(filesToMove, filesToRemove, config);
|
|
40
41
|
return { clientManifestMod, serverManifestMod };
|
|
41
42
|
}
|
|
42
|
-
async function loadManifest(outDir) {
|
|
43
|
-
const manifestFilePath = path_1.default.posix.join(outDir, buildConfig_js_1.manifestTempFile);
|
|
44
|
-
const manifestFileContent = await promises_1.default.readFile(manifestFilePath, 'utf-8');
|
|
45
|
-
(0, utils_js_1.assert)(manifestFileContent);
|
|
46
|
-
const manifest = JSON.parse(manifestFileContent);
|
|
47
|
-
(0, utils_js_1.assert)(manifest);
|
|
48
|
-
return manifest;
|
|
49
|
-
}
|
|
50
43
|
async function copyAssets(filesToMove, filesToRemove, config) {
|
|
51
44
|
const { outDirClient, outDirServer } = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
52
45
|
const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
|
|
@@ -219,17 +212,17 @@ function collectResources(entryRoot, manifest) {
|
|
|
219
212
|
// </head>
|
|
220
213
|
// ```
|
|
221
214
|
function getHash(src) {
|
|
222
|
-
// src is guarenteed to end with `.[hash][extname]`, see
|
|
215
|
+
// src is guarenteed to end with `.[hash][extname]`, see pluginDistFileNames.ts
|
|
223
216
|
const hash = src.split('.').at(-2);
|
|
224
217
|
(0, utils_js_1.assert)(hash);
|
|
225
218
|
return hash;
|
|
226
219
|
}
|
|
227
220
|
// https://github.com/vikejs/vike/issues/1993
|
|
228
|
-
function
|
|
221
|
+
function fixServerAssets_assertUsageCssCodeSplit(config) {
|
|
229
222
|
(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 });
|
|
230
223
|
}
|
|
231
224
|
const targets = [];
|
|
232
|
-
async function
|
|
225
|
+
async function fixServerAssets_assertUsageCssTarget(config) {
|
|
233
226
|
if (!fixServerAssets_isEnabled())
|
|
234
227
|
return;
|
|
235
228
|
if (!(await (0, getVikeConfig_js_1.isV1Design)(config)))
|
|
@@ -279,3 +272,17 @@ function removeEmptyDirectories(dirPath) {
|
|
|
279
272
|
fs_1.default.rmdirSync(dirPath);
|
|
280
273
|
}
|
|
281
274
|
}
|
|
275
|
+
async function readManifestFile(outDir) {
|
|
276
|
+
const manifestFilePath = path_1.default.posix.join(outDir, pluginBuildConfig_js_1.manifestTempFile);
|
|
277
|
+
const manifestFileContent = await promises_1.default.readFile(manifestFilePath, 'utf-8');
|
|
278
|
+
(0, utils_js_1.assert)(manifestFileContent);
|
|
279
|
+
const manifest = JSON.parse(manifestFileContent);
|
|
280
|
+
(0, utils_js_1.assert)(manifest);
|
|
281
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(manifest));
|
|
282
|
+
return manifest;
|
|
283
|
+
}
|
|
284
|
+
async function writeManifestFile(manifest, manifestFilePath) {
|
|
285
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(manifest));
|
|
286
|
+
const manifestFileContent = JSON.stringify(manifest, null, 2);
|
|
287
|
+
await promises_1.default.writeFile(manifestFilePath, manifestFileContent, 'utf-8');
|
|
288
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
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.pluginAssetsManifest = pluginAssetsManifest;
|
|
7
|
+
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const fixServerAssets_js_1 = require("../build/pluginAssetsManifest/fixServerAssets.js");
|
|
11
|
+
const pluginBuildEntry_js_1 = require("./pluginBuildEntry.js");
|
|
12
|
+
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
13
|
+
const viteIsSSR_js_1 = require("../../shared/viteIsSSR.js");
|
|
14
|
+
const commonConfig_js_1 = require("../commonConfig.js");
|
|
15
|
+
const manifestTempFile = '_temp_manifest.json';
|
|
16
|
+
function pluginAssetsManifest() {
|
|
17
|
+
let isServerAssetsFixEnabled;
|
|
18
|
+
let config;
|
|
19
|
+
let assetsJsonFilePath;
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
name: 'vike:build:pluginAssetsManifest:post',
|
|
23
|
+
apply: 'build',
|
|
24
|
+
enforce: 'post',
|
|
25
|
+
configResolved: {
|
|
26
|
+
order: 'post',
|
|
27
|
+
async handler(config_) {
|
|
28
|
+
config = config_;
|
|
29
|
+
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config));
|
|
30
|
+
if (isServerAssetsFixEnabled) {
|
|
31
|
+
// https://github.com/vikejs/vike/issues/1339
|
|
32
|
+
config.build.ssrEmitAssets = true;
|
|
33
|
+
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
34
|
+
config.build.cssMinify = 'esbuild';
|
|
35
|
+
(0, fixServerAssets_js_1.fixServerAssets_assertUsageCssCodeSplit)(config);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
config: {
|
|
40
|
+
order: 'post',
|
|
41
|
+
handler(config) {
|
|
42
|
+
const vike = (0, commonConfig_js_1.getVikeConfigPublic)(config);
|
|
43
|
+
return {
|
|
44
|
+
build: {
|
|
45
|
+
manifest: manifestTempFile,
|
|
46
|
+
copyPublicDir: vike.config.viteEnvironmentAPI
|
|
47
|
+
? // Already set by vike:build:pluginBuildApp
|
|
48
|
+
undefined
|
|
49
|
+
: !(0, viteIsSSR_js_1.viteIsSSR)(config)
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
async closeBundle() {
|
|
55
|
+
await (0, fixServerAssets_js_1.fixServerAssets_assertUsageCssTarget)(config);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'vike:build:pluginAssetsManifest:pre',
|
|
60
|
+
apply: 'build',
|
|
61
|
+
// Compatiblity with Environment API. It replaces `vike:build:pluginAssetsManifest:pre` when compatible
|
|
62
|
+
// See https://vite.dev/guide/api-environment-plugins.html#per-environment-plugins
|
|
63
|
+
applyToEnvironment() {
|
|
64
|
+
return {
|
|
65
|
+
name: 'vike:build:pluginAssetsManifest:pre:env-api-compat',
|
|
66
|
+
apply: 'build',
|
|
67
|
+
enforce: 'pre',
|
|
68
|
+
writeBundle: {
|
|
69
|
+
order: 'pre',
|
|
70
|
+
sequential: true,
|
|
71
|
+
async handler(options, bundle) {
|
|
72
|
+
if (this.environment.name === 'ssr') {
|
|
73
|
+
await writeAssetsManifestFile((0, getOutDirs_js_1.getOutDirs)(this.environment.config));
|
|
74
|
+
}
|
|
75
|
+
if ((0, viteIsSSR_js_1.viteIsSSR)(this.environment.config)) {
|
|
76
|
+
// Replace __VITE_ASSETS_MANIFEST__ in all server-side bundles
|
|
77
|
+
await (0, pluginBuildEntry_js_1.set_macro_ASSETS_MANIFEST)(options, bundle, assetsJsonFilePath);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
// Ensures that we can reuse `assetsJsonFilePath`
|
|
84
|
+
sharedDuringBuild: true,
|
|
85
|
+
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
86
|
+
// - set_macro_ASSETS_MANIFEST() needs to be called before dist/server/ code is executed.
|
|
87
|
+
// - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
|
|
88
|
+
enforce: 'pre',
|
|
89
|
+
writeBundle: {
|
|
90
|
+
order: 'pre',
|
|
91
|
+
sequential: true,
|
|
92
|
+
async handler(options, bundle) {
|
|
93
|
+
if ((0, viteIsSSR_js_1.viteIsSSR)(config)) {
|
|
94
|
+
await writeAssetsManifestFile((0, getOutDirs_js_1.getOutDirs)(config));
|
|
95
|
+
await (0, pluginBuildEntry_js_1.set_macro_ASSETS_MANIFEST)(options, bundle, assetsJsonFilePath);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
async function writeAssetsManifestFile(outDirs) {
|
|
102
|
+
assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
103
|
+
const clientManifestFilePath = path_1.default.posix.join(outDirs.outDirClient, manifestTempFile);
|
|
104
|
+
const serverManifestFilePath = path_1.default.posix.join(outDirs.outDirServer, manifestTempFile);
|
|
105
|
+
if (!isServerAssetsFixEnabled) {
|
|
106
|
+
await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const { clientManifestMod } = await (0, fixServerAssets_js_1.fixServerAssets)(config);
|
|
110
|
+
await (0, fixServerAssets_js_1.writeManifestFile)(clientManifestMod, assetsJsonFilePath);
|
|
111
|
+
}
|
|
112
|
+
await promises_1.default.rm(clientManifestFilePath);
|
|
113
|
+
await promises_1.default.rm(serverManifestFilePath);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// TODO/v1-release: remove this file
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
8
|
-
const getFullBuildInlineConfig_js_1 = require("
|
|
6
|
+
exports.pluginAutoFullBuild = pluginAutoFullBuild;
|
|
7
|
+
const getFullBuildInlineConfig_js_1 = require("../../shared/getFullBuildInlineConfig.js");
|
|
9
8
|
const vite_1 = require("vite");
|
|
10
|
-
const utils_js_1 = require("
|
|
11
|
-
const runPrerender_js_1 = require("
|
|
12
|
-
const context_js_1 = require("
|
|
13
|
-
const isViteCliCall_js_1 = require("
|
|
9
|
+
const utils_js_1 = require("../../utils.js");
|
|
10
|
+
const runPrerender_js_1 = require("../../../prerender/runPrerender.js");
|
|
11
|
+
const context_js_1 = require("../../../prerender/context.js");
|
|
12
|
+
const isViteCliCall_js_1 = require("../../shared/isViteCliCall.js");
|
|
14
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
|
-
const logErrorHint_js_1 = require("
|
|
16
|
-
const
|
|
17
|
-
const getVikeConfig_js_1 = require("
|
|
18
|
-
const context_js_2 = require("
|
|
14
|
+
const logErrorHint_js_1 = require("../../../runtime/renderPage/logErrorHint.js");
|
|
15
|
+
const pluginBuildConfig_js_1 = require("./pluginBuildConfig.js");
|
|
16
|
+
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
17
|
+
const context_js_2 = require("../../../api/context.js");
|
|
19
18
|
let forceExit = false;
|
|
20
|
-
function
|
|
19
|
+
function pluginAutoFullBuild() {
|
|
21
20
|
let config;
|
|
22
21
|
let vikeConfig;
|
|
23
22
|
return [
|
|
24
23
|
{
|
|
25
|
-
name: 'vike:
|
|
24
|
+
name: 'vike:build:pluginAutoFullBuild',
|
|
26
25
|
apply: 'build',
|
|
27
26
|
enforce: 'pre',
|
|
28
27
|
async configResolved(config_) {
|
|
@@ -40,7 +39,7 @@ function autoFullBuild() {
|
|
|
40
39
|
await triggerFullBuild(config, vikeConfig, bundle);
|
|
41
40
|
}
|
|
42
41
|
catch (err) {
|
|
43
|
-
// Avoid Rollup prefixing the error with [vike:
|
|
42
|
+
// Avoid Rollup prefixing the error with [vike:build:pluginAutoFullBuild], for example see https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
44
43
|
console.error(err);
|
|
45
44
|
process.exit(1);
|
|
46
45
|
}
|
|
@@ -48,7 +47,7 @@ function autoFullBuild() {
|
|
|
48
47
|
}
|
|
49
48
|
},
|
|
50
49
|
{
|
|
51
|
-
name: 'vike:
|
|
50
|
+
name: 'vike:build:pluginAutoFullBuild:forceExit',
|
|
52
51
|
apply: 'build',
|
|
53
52
|
enforce: 'post',
|
|
54
53
|
closeBundle: {
|
|
@@ -73,7 +72,7 @@ async function triggerFullBuild(config, vikeConfig, bundle) {
|
|
|
73
72
|
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
74
73
|
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
75
74
|
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
76
|
-
if (!bundle[
|
|
75
|
+
if (!bundle[pluginBuildConfig_js_1.manifestTempFile])
|
|
77
76
|
return;
|
|
78
77
|
const configInline = (0, getFullBuildInlineConfig_js_1.getFullBuildInlineConfig)(config);
|
|
79
78
|
try {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const runPrerender_js_1 = require("
|
|
5
|
-
const context_js_1 = require("
|
|
6
|
-
const getOutDirs_js_1 = require("
|
|
7
|
-
const utils_js_1 = require("
|
|
8
|
-
const getVikeConfig_js_1 = require("
|
|
9
|
-
const getFullBuildInlineConfig_js_1 = require("
|
|
10
|
-
const commonConfig_js_1 = require("
|
|
11
|
-
function
|
|
3
|
+
exports.pluginBuildApp = pluginBuildApp;
|
|
4
|
+
const runPrerender_js_1 = require("../../../prerender/runPrerender.js");
|
|
5
|
+
const context_js_1 = require("../../../prerender/context.js");
|
|
6
|
+
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
7
|
+
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
|
+
const commonConfig_js_1 = require("../commonConfig.js");
|
|
11
|
+
function pluginBuildApp() {
|
|
12
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
|
|
13
|
+
// `builder.buildApp()` can be overriden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
14
14
|
// In that case, we should'nt `forceExit`.
|
|
15
15
|
let forceExit = false;
|
|
16
16
|
return [
|
|
17
17
|
{
|
|
18
|
-
name: 'vike:
|
|
18
|
+
name: 'vike:build:pluginBuildApp',
|
|
19
19
|
apply: 'build',
|
|
20
20
|
config(config) {
|
|
21
21
|
const vike = (0, commonConfig_js_1.getVikeConfigPublic)(config);
|
|
@@ -54,7 +54,7 @@ function buildApp() {
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
|
-
name: 'vike:
|
|
57
|
+
name: 'vike:build:pluginBuildApp:prerender',
|
|
58
58
|
apply: 'build',
|
|
59
59
|
enforce: 'pre',
|
|
60
60
|
applyToEnvironment(env) {
|
|
@@ -1,78 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.manifestTempFile = void 0;
|
|
7
|
-
exports.
|
|
4
|
+
exports.pluginBuildConfig = pluginBuildConfig;
|
|
8
5
|
exports.assertRollupInput = assertRollupInput;
|
|
9
6
|
exports.analyzeClientEntries = analyzeClientEntries;
|
|
10
|
-
const utils_js_1 = require("
|
|
11
|
-
const getVikeConfig_js_1 = require("
|
|
12
|
-
const findPageFiles_js_1 = require("
|
|
13
|
-
const virtualFilePageConfigValuesAll_js_1 = require("
|
|
14
|
-
const extractAssetsQuery_js_1 = require("
|
|
7
|
+
const utils_js_1 = require("../../utils.js");
|
|
8
|
+
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
9
|
+
const findPageFiles_js_1 = require("../../shared/findPageFiles.js");
|
|
10
|
+
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
11
|
+
const extractAssetsQuery_js_1 = require("../../../shared/extractAssetsQuery.js");
|
|
15
12
|
const module_1 = require("module");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const getConfigValueBuildTime_js_1 = require("../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
23
|
-
const getOutDirs_js_1 = require("../shared/getOutDirs.js");
|
|
24
|
-
const viteIsSSR_js_1 = require("../shared/viteIsSSR.js");
|
|
25
|
-
const commonConfig_js_1 = require("./commonConfig.js");
|
|
26
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
13
|
+
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
14
|
+
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
15
|
+
const getConfigValueBuildTime_js_1 = require("../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
16
|
+
const viteIsSSR_js_1 = require("../../shared/viteIsSSR.js");
|
|
17
|
+
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
18
|
+
// @ts-ignore `file://${__filename}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
27
19
|
const importMetaUrl = `file://${__filename}`;
|
|
28
20
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
29
21
|
const manifestTempFile = '_temp_manifest.json';
|
|
30
22
|
exports.manifestTempFile = manifestTempFile;
|
|
31
|
-
function
|
|
32
|
-
let isServerAssetsFixEnabled;
|
|
33
|
-
let outDirs;
|
|
23
|
+
function pluginBuildConfig() {
|
|
34
24
|
let config;
|
|
35
25
|
return [
|
|
36
26
|
{
|
|
37
|
-
name: 'vike:
|
|
27
|
+
name: 'vike:build:pluginBuildConfig',
|
|
38
28
|
apply: 'build',
|
|
39
29
|
enforce: 'post',
|
|
40
30
|
configResolved: {
|
|
41
31
|
order: 'post',
|
|
42
32
|
async handler(config_) {
|
|
43
|
-
config = config_;
|
|
44
33
|
(0, utils_js_1.onSetupBuild)();
|
|
34
|
+
config = config_;
|
|
45
35
|
assertRollupInput(config);
|
|
46
36
|
const entries = await getEntries(config);
|
|
47
37
|
(0, utils_js_1.assert)(Object.keys(entries).length > 0);
|
|
48
38
|
config.build.rollupOptions.input = (0, utils_js_1.injectRollupInputs)(entries, config);
|
|
49
39
|
addLogHook();
|
|
50
|
-
outDirs = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
51
|
-
{
|
|
52
|
-
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config));
|
|
53
|
-
if (isServerAssetsFixEnabled) {
|
|
54
|
-
// https://github.com/vikejs/vike/issues/1339
|
|
55
|
-
config.build.ssrEmitAssets = true;
|
|
56
|
-
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
57
|
-
config.build.cssMinify = 'esbuild';
|
|
58
|
-
(0, fixServerAssets_js_1.fixServerAssets_assertCssCodeSplit)(config);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
40
|
}
|
|
62
41
|
},
|
|
63
42
|
config: {
|
|
64
43
|
order: 'post',
|
|
65
44
|
handler(config) {
|
|
66
45
|
(0, utils_js_1.onSetupBuild)();
|
|
67
|
-
const vike = (0, commonConfig_js_1.getVikeConfigPublic)(config);
|
|
68
46
|
return {
|
|
69
47
|
build: {
|
|
70
|
-
outDir: (0, getOutDirs_js_1.resolveOutDir)(config)
|
|
71
|
-
manifest: manifestTempFile,
|
|
72
|
-
copyPublicDir: vike.config.viteEnvironmentAPI
|
|
73
|
-
? // Already set by buildApp() plugin
|
|
74
|
-
undefined
|
|
75
|
-
: !(0, viteIsSSR_js_1.viteIsSSR)(config)
|
|
48
|
+
outDir: (0, getOutDirs_js_1.resolveOutDir)(config)
|
|
76
49
|
}
|
|
77
50
|
};
|
|
78
51
|
}
|
|
@@ -82,42 +55,6 @@ function buildConfig() {
|
|
|
82
55
|
},
|
|
83
56
|
async closeBundle() {
|
|
84
57
|
(0, utils_js_1.onSetupBuild)();
|
|
85
|
-
await (0, fixServerAssets_js_1.fixServerAssets_assertCssTarget)(config);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'vike:buildConfig:pre',
|
|
90
|
-
apply: 'build',
|
|
91
|
-
applyToEnvironment(env) {
|
|
92
|
-
return env.name === 'ssr';
|
|
93
|
-
},
|
|
94
|
-
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
95
|
-
// - set_ASSETS_MANIFEST() needs to be called before dist/server/ code is executed.
|
|
96
|
-
// - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
|
|
97
|
-
enforce: 'pre',
|
|
98
|
-
writeBundle: {
|
|
99
|
-
order: 'pre',
|
|
100
|
-
sequential: true,
|
|
101
|
-
async handler(options, bundle) {
|
|
102
|
-
if ((0, viteIsSSR_js_1.viteIsSSR)(config)) {
|
|
103
|
-
// Ideally we'd move dist/_temp_manifest.json to dist/server/client-assets.json instead of dist/assets.json
|
|
104
|
-
// - But we can't because there is no guarentee whether dist/server/ is generated before or after dist/client/ (generating dist/server/ after dist/client/ erases dist/server/client-assets.json)
|
|
105
|
-
// - We'll able to do so once we replace `$ vite build` with `$ vike build`
|
|
106
|
-
const assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
107
|
-
const clientManifestFilePath = path_1.default.posix.join(outDirs.outDirClient, manifestTempFile);
|
|
108
|
-
const serverManifestFilePath = path_1.default.posix.join(outDirs.outDirServer, manifestTempFile);
|
|
109
|
-
if (!isServerAssetsFixEnabled) {
|
|
110
|
-
await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
const { clientManifestMod } = await (0, fixServerAssets_js_1.fixServerAssets)(config);
|
|
114
|
-
await promises_1.default.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
|
|
115
|
-
}
|
|
116
|
-
await promises_1.default.rm(clientManifestFilePath);
|
|
117
|
-
await promises_1.default.rm(serverManifestFilePath);
|
|
118
|
-
await (0, index_js_1.set_ASSETS_MANIFEST)(options, bundle);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
58
|
}
|
|
122
59
|
}
|
|
123
60
|
];
|
|
@@ -133,7 +70,6 @@ async function getEntries(config) {
|
|
|
133
70
|
if ((0, viteIsSSR_js_1.viteIsSSR)(config)) {
|
|
134
71
|
const pageEntries = getPageEntries(pageConfigs);
|
|
135
72
|
const entries = {
|
|
136
|
-
// buildEntry: resolve('dist/esm/node/buildEntry.js'), // TODO/next-major-release: remove
|
|
137
73
|
...pageFileEntries,
|
|
138
74
|
// Ensure Rollup generates a bundle per page: https://github.com/vikejs/vike/issues/349#issuecomment-1166247275
|
|
139
75
|
...pageEntries
|
|
@@ -263,8 +199,8 @@ function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
|
263
199
|
}
|
|
264
200
|
function resolve(filePath) {
|
|
265
201
|
(0, utils_js_1.assert)(filePath.startsWith('dist/'));
|
|
266
|
-
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/
|
|
267
|
-
return require_.resolve(
|
|
202
|
+
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/build/
|
|
203
|
+
return require_.resolve(`../../../../../../${filePath}`);
|
|
268
204
|
}
|
|
269
205
|
function addLogHook() {
|
|
270
206
|
const tty = process.stdout.isTTY && !process.env.CI; // Equals https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts#L27
|