vike 0.4.223-commit-586dbfb → 0.4.223-commit-f1089b4
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 +82 -24
- package/dist/cjs/node/plugin/plugins/{autoFullBuild.js → build/pluginAutoFullBuild.js} +20 -25
- package/dist/cjs/node/plugin/plugins/{buildApp.js → build/pluginBuildApp.js} +13 -13
- package/dist/cjs/node/plugin/plugins/{buildConfig.js → build/pluginBuildConfig.js} +22 -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 +21 -0
- package/dist/cjs/node/plugin/plugins/commonConfig.js +3 -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/getVikeConfig.js +4 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/shared/getOutDirs.js +5 -4
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/cjs/node/plugin/shared/viteIsSSR.js +9 -2
- package/dist/cjs/node/prerender/runPrerender.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findPackageJson.js +1 -1
- package/dist/cjs/utils/requireResolve.js +8 -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/build/pluginAssetsManifest/fixServerAssets.d.ts +27 -0
- package/dist/esm/node/plugin/plugins/{buildConfig → build/pluginAssetsManifest}/fixServerAssets.js +84 -24
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{autoFullBuild.js → build/pluginAutoFullBuild.js} +19 -24
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{buildApp.js → build/pluginBuildApp.js} +13 -13
- 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} +22 -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 +19 -0
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -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/getVikeConfig.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +4 -2
- 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/getOutDirs.d.ts +2 -2
- package/dist/esm/node/plugin/shared/getOutDirs.js +5 -4
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +4 -2
- package/dist/esm/node/plugin/shared/viteIsSSR.js +9 -2
- package/dist/esm/node/prerender/runPrerender.js +1 -0
- 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 +8 -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/buildConfig/fixServerAssets.d.ts +0 -20
- 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
|
@@ -3,22 +3,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.handleAssetsManifest = handleAssetsManifest;
|
|
7
|
+
exports.fixServerAssets_getBuildConfig = fixServerAssets_getBuildConfig;
|
|
7
8
|
exports.fixServerAssets_isEnabled = fixServerAssets_isEnabled;
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
9
|
+
exports.fixServerAssets_assertUsageCssCodeSplit = fixServerAssets_assertUsageCssCodeSplit;
|
|
10
|
+
exports.fixServerAssets_assertUsageCssTarget = fixServerAssets_assertUsageCssTarget;
|
|
11
|
+
exports.writeManifestFile = writeManifestFile;
|
|
10
12
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
11
13
|
const fs_1 = __importDefault(require("fs"));
|
|
12
14
|
const path_1 = __importDefault(require("path"));
|
|
13
15
|
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("
|
|
16
|
+
const utils_js_1 = require("../../../utils.js");
|
|
17
|
+
const virtualFilePageConfigValuesAll_js_1 = require("../../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
18
|
+
const pluginBuildConfig_js_1 = require("../pluginBuildConfig.js");
|
|
19
|
+
const getAssetsDir_js_1 = require("../../../shared/getAssetsDir.js");
|
|
18
20
|
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("
|
|
21
|
+
const getVikeConfig_js_1 = require("../../importUserCode/v1-design/getVikeConfig.js");
|
|
22
|
+
const getOutDirs_js_1 = require("../../../shared/getOutDirs.js");
|
|
23
|
+
const viteIsSSR_js_1 = require("../../../shared/viteIsSSR.js");
|
|
24
|
+
const commonConfig_js_1 = require("../../commonConfig.js");
|
|
25
|
+
const pluginBuildEntry_js_1 = require("../pluginBuildEntry.js");
|
|
26
|
+
(0, utils_js_1.assertIsSingleModuleInstance)('build/handleAssetsManifest.ts');
|
|
27
|
+
let assetsJsonFilePath;
|
|
28
|
+
// TODO/now move isV1Design() inside fixServerAssets_isEnabled()
|
|
22
29
|
/**
|
|
23
30
|
* true => use workaround config.build.ssrEmitAssets
|
|
24
31
|
* false => use workaround extractAssets plugin
|
|
@@ -33,20 +40,12 @@ function fixServerAssets_isEnabled() {
|
|
|
33
40
|
/** https://github.com/vikejs/vike/issues/1339 */
|
|
34
41
|
async function fixServerAssets(config) {
|
|
35
42
|
const outDirs = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
36
|
-
const clientManifest = await
|
|
37
|
-
const serverManifest = await
|
|
43
|
+
const clientManifest = await readManifestFile(outDirs.outDirClient);
|
|
44
|
+
const serverManifest = await readManifestFile(outDirs.outDirServer);
|
|
38
45
|
const { clientManifestMod, serverManifestMod, filesToMove, filesToRemove } = addServerAssets(clientManifest, serverManifest);
|
|
39
46
|
await copyAssets(filesToMove, filesToRemove, config);
|
|
40
47
|
return { clientManifestMod, serverManifestMod };
|
|
41
48
|
}
|
|
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
49
|
async function copyAssets(filesToMove, filesToRemove, config) {
|
|
51
50
|
const { outDirClient, outDirServer } = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
52
51
|
const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
|
|
@@ -219,20 +218,23 @@ function collectResources(entryRoot, manifest) {
|
|
|
219
218
|
// </head>
|
|
220
219
|
// ```
|
|
221
220
|
function getHash(src) {
|
|
222
|
-
// src is guarenteed to end with `.[hash][extname]`, see
|
|
221
|
+
// src is guarenteed to end with `.[hash][extname]`, see pluginDistFileNames.ts
|
|
223
222
|
const hash = src.split('.').at(-2);
|
|
224
223
|
(0, utils_js_1.assert)(hash);
|
|
225
224
|
return hash;
|
|
226
225
|
}
|
|
227
226
|
// https://github.com/vikejs/vike/issues/1993
|
|
228
|
-
function
|
|
227
|
+
function fixServerAssets_assertUsageCssCodeSplit(config) {
|
|
228
|
+
const isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (0, getVikeConfig_js_1.isV1Design)(config);
|
|
229
|
+
if (!isServerAssetsFixEnabled)
|
|
230
|
+
return;
|
|
229
231
|
(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
232
|
}
|
|
231
233
|
const targets = [];
|
|
232
|
-
|
|
234
|
+
function fixServerAssets_assertUsageCssTarget(config) {
|
|
233
235
|
if (!fixServerAssets_isEnabled())
|
|
234
236
|
return;
|
|
235
|
-
if (!(
|
|
237
|
+
if (!(0, getVikeConfig_js_1.isV1Design)(config))
|
|
236
238
|
return;
|
|
237
239
|
const isServerSide = (0, viteIsSSR_js_1.viteIsSSR)(config);
|
|
238
240
|
(0, utils_js_1.assert)(typeof isServerSide === 'boolean');
|
|
@@ -279,3 +281,59 @@ function removeEmptyDirectories(dirPath) {
|
|
|
279
281
|
fs_1.default.rmdirSync(dirPath);
|
|
280
282
|
}
|
|
281
283
|
}
|
|
284
|
+
async function readManifestFile(outDir) {
|
|
285
|
+
const manifestFilePath = path_1.default.posix.join(outDir, pluginBuildConfig_js_1.manifestTempFile);
|
|
286
|
+
const manifestFileContent = await promises_1.default.readFile(manifestFilePath, 'utf-8');
|
|
287
|
+
(0, utils_js_1.assert)(manifestFileContent);
|
|
288
|
+
const manifest = JSON.parse(manifestFileContent);
|
|
289
|
+
(0, utils_js_1.assert)(manifest);
|
|
290
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(manifest));
|
|
291
|
+
return manifest;
|
|
292
|
+
}
|
|
293
|
+
async function writeManifestFile(manifest, manifestFilePath) {
|
|
294
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(manifest));
|
|
295
|
+
const manifestFileContent = JSON.stringify(manifest, null, 2);
|
|
296
|
+
await promises_1.default.writeFile(manifestFilePath, manifestFileContent, 'utf-8');
|
|
297
|
+
}
|
|
298
|
+
function fixServerAssets_getBuildConfig(config) {
|
|
299
|
+
const vike = (0, commonConfig_js_1.getVikeConfigPublic)(config);
|
|
300
|
+
const isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (0, getVikeConfig_js_1.isV1Design)(config);
|
|
301
|
+
return {
|
|
302
|
+
// https://github.com/vikejs/vike/issues/1339
|
|
303
|
+
ssrEmitAssets: isServerAssetsFixEnabled ? true : undefined,
|
|
304
|
+
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
305
|
+
cssMinify: isServerAssetsFixEnabled ? 'esbuild' : undefined,
|
|
306
|
+
manifest: pluginBuildConfig_js_1.manifestTempFile,
|
|
307
|
+
copyPublicDir: vike.config.viteEnvironmentAPI
|
|
308
|
+
? // Already set by vike:build:pluginBuildApp
|
|
309
|
+
undefined
|
|
310
|
+
: !(0, viteIsSSR_js_1.viteIsSSR)(config)
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
314
|
+
if ((0, viteIsSSR_js_1.viteIsSSR)(config, viteEnv)) {
|
|
315
|
+
(0, utils_js_1.assert)(!assetsJsonFilePath);
|
|
316
|
+
const outDirs = (0, getOutDirs_js_1.getOutDirs)(config, viteEnv);
|
|
317
|
+
assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
318
|
+
await writeAssetsManifestFile(outDirs, assetsJsonFilePath, config);
|
|
319
|
+
}
|
|
320
|
+
if ((0, viteIsSSR_js_1.viteIsServerBuildEnvAny)(config, viteEnv)) {
|
|
321
|
+
(0, utils_js_1.assert)(assetsJsonFilePath);
|
|
322
|
+
// Replace __VITE_ASSETS_MANIFEST__ in all server-side bundles
|
|
323
|
+
await (0, pluginBuildEntry_js_1.set_macro_ASSETS_MANIFEST)(options, bundle, assetsJsonFilePath);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
async function writeAssetsManifestFile(outDirs, assetsJsonFilePath, config) {
|
|
327
|
+
const isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (0, getVikeConfig_js_1.isV1Design)(config);
|
|
328
|
+
const clientManifestFilePath = path_1.default.posix.join(outDirs.outDirClient, pluginBuildConfig_js_1.manifestTempFile);
|
|
329
|
+
const serverManifestFilePath = path_1.default.posix.join(outDirs.outDirServer, pluginBuildConfig_js_1.manifestTempFile);
|
|
330
|
+
if (!isServerAssetsFixEnabled) {
|
|
331
|
+
await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
const { clientManifestMod } = await fixServerAssets(config);
|
|
335
|
+
await writeManifestFile(clientManifestMod, assetsJsonFilePath);
|
|
336
|
+
}
|
|
337
|
+
await promises_1.default.rm(clientManifestFilePath);
|
|
338
|
+
await promises_1.default.rm(serverManifestFilePath);
|
|
339
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
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");
|
|
18
|
+
const fixServerAssets_js_1 = require("./pluginAssetsManifest/fixServerAssets.js");
|
|
19
19
|
let forceExit = false;
|
|
20
|
-
function
|
|
20
|
+
function pluginAutoFullBuild() {
|
|
21
21
|
let config;
|
|
22
22
|
let vikeConfig;
|
|
23
23
|
return [
|
|
24
24
|
{
|
|
25
|
-
name: 'vike:
|
|
25
|
+
name: 'vike:build:pluginAutoFullBuild',
|
|
26
26
|
apply: 'build',
|
|
27
27
|
enforce: 'pre',
|
|
28
28
|
async configResolved(config_) {
|
|
@@ -31,24 +31,18 @@ function autoFullBuild() {
|
|
|
31
31
|
abortViteBuildSsr(vikeConfig);
|
|
32
32
|
},
|
|
33
33
|
writeBundle: {
|
|
34
|
-
/* We can't use this because it breaks Vite's logging. TODO: try again with latest Vite version.
|
|
34
|
+
/* We can't use this because it breaks Vite's logging. TODO/eventually: try again with latest Vite version.
|
|
35
35
|
sequential: true,
|
|
36
36
|
order: 'pre',
|
|
37
37
|
*/
|
|
38
|
-
async handler(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
// Avoid Rollup prefixing the error with [vike:autoFullBuild], for example see https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
44
|
-
console.error(err);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
38
|
+
async handler(options, bundle) {
|
|
39
|
+
await (0, fixServerAssets_js_1.handleAssetsManifest)(config, this.environment, options, bundle);
|
|
40
|
+
await triggerFullBuild(config, vikeConfig, bundle);
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
43
|
},
|
|
50
44
|
{
|
|
51
|
-
name: 'vike:
|
|
45
|
+
name: 'vike:build:pluginAutoFullBuild:forceExit',
|
|
52
46
|
apply: 'build',
|
|
53
47
|
enforce: 'post',
|
|
54
48
|
closeBundle: {
|
|
@@ -73,13 +67,14 @@ async function triggerFullBuild(config, vikeConfig, bundle) {
|
|
|
73
67
|
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
74
68
|
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
75
69
|
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
76
|
-
if (!bundle[
|
|
70
|
+
if (!bundle[pluginBuildConfig_js_1.manifestTempFile])
|
|
77
71
|
return;
|
|
78
72
|
const configInline = (0, getFullBuildInlineConfig_js_1.getFullBuildInlineConfig)(config);
|
|
79
73
|
try {
|
|
80
74
|
await (0, vite_1.build)(setSSR(configInline));
|
|
81
75
|
}
|
|
82
76
|
catch (err) {
|
|
77
|
+
// Avoid Rollup prefixing the error with [vike:build:pluginAutoFullBuild], see for example https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
83
78
|
console.error(err);
|
|
84
79
|
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
85
80
|
process.exit(1);
|
|
@@ -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
|
|
14
|
-
// In that case, we
|
|
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
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,54 @@
|
|
|
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
|
-
const
|
|
22
|
-
|
|
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
|
+
const fixServerAssets_js_1 = require("./pluginAssetsManifest/fixServerAssets.js");
|
|
19
|
+
// @ts-ignore `file://${__filename}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
27
20
|
const importMetaUrl = `file://${__filename}`;
|
|
28
21
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
29
22
|
const manifestTempFile = '_temp_manifest.json';
|
|
30
23
|
exports.manifestTempFile = manifestTempFile;
|
|
31
|
-
function
|
|
32
|
-
let isServerAssetsFixEnabled;
|
|
33
|
-
let outDirs;
|
|
24
|
+
function pluginBuildConfig() {
|
|
34
25
|
let config;
|
|
35
26
|
return [
|
|
36
27
|
{
|
|
37
|
-
name: 'vike:
|
|
28
|
+
name: 'vike:build:pluginBuildConfig',
|
|
38
29
|
apply: 'build',
|
|
39
30
|
enforce: 'post',
|
|
40
31
|
configResolved: {
|
|
41
32
|
order: 'post',
|
|
42
33
|
async handler(config_) {
|
|
43
|
-
config = config_;
|
|
44
34
|
(0, utils_js_1.onSetupBuild)();
|
|
35
|
+
config = config_;
|
|
45
36
|
assertRollupInput(config);
|
|
46
37
|
const entries = await getEntries(config);
|
|
47
38
|
(0, utils_js_1.assert)(Object.keys(entries).length > 0);
|
|
48
39
|
config.build.rollupOptions.input = (0, utils_js_1.injectRollupInputs)(entries, config);
|
|
49
40
|
addLogHook();
|
|
50
|
-
|
|
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
|
-
}
|
|
41
|
+
(0, fixServerAssets_js_1.fixServerAssets_assertUsageCssCodeSplit)(config);
|
|
61
42
|
}
|
|
62
43
|
},
|
|
63
44
|
config: {
|
|
64
45
|
order: 'post',
|
|
65
46
|
handler(config) {
|
|
66
47
|
(0, utils_js_1.onSetupBuild)();
|
|
67
|
-
const vike = (0, commonConfig_js_1.getVikeConfigPublic)(config);
|
|
68
48
|
return {
|
|
69
49
|
build: {
|
|
70
50
|
outDir: (0, getOutDirs_js_1.resolveOutDir)(config),
|
|
71
|
-
|
|
72
|
-
copyPublicDir: vike.config.viteEnvironmentAPI
|
|
73
|
-
? // Already set by buildApp() plugin
|
|
74
|
-
undefined
|
|
75
|
-
: !(0, viteIsSSR_js_1.viteIsSSR)(config)
|
|
51
|
+
...(0, fixServerAssets_js_1.fixServerAssets_getBuildConfig)(config)
|
|
76
52
|
}
|
|
77
53
|
};
|
|
78
54
|
}
|
|
@@ -80,44 +56,9 @@ function buildConfig() {
|
|
|
80
56
|
buildStart() {
|
|
81
57
|
(0, utils_js_1.onSetupBuild)();
|
|
82
58
|
},
|
|
83
|
-
|
|
59
|
+
closeBundle() {
|
|
84
60
|
(0, utils_js_1.onSetupBuild)();
|
|
85
|
-
|
|
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
|
-
}
|
|
61
|
+
(0, fixServerAssets_js_1.fixServerAssets_assertUsageCssTarget)(config);
|
|
121
62
|
}
|
|
122
63
|
}
|
|
123
64
|
];
|
|
@@ -133,7 +74,6 @@ async function getEntries(config) {
|
|
|
133
74
|
if ((0, viteIsSSR_js_1.viteIsSSR)(config)) {
|
|
134
75
|
const pageEntries = getPageEntries(pageConfigs);
|
|
135
76
|
const entries = {
|
|
136
|
-
// buildEntry: resolve('dist/esm/node/buildEntry.js'), // TODO/next-major-release: remove
|
|
137
77
|
...pageFileEntries,
|
|
138
78
|
// Ensure Rollup generates a bundle per page: https://github.com/vikejs/vike/issues/349#issuecomment-1166247275
|
|
139
79
|
...pageEntries
|
|
@@ -263,8 +203,8 @@ function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
|
263
203
|
}
|
|
264
204
|
function resolve(filePath) {
|
|
265
205
|
(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(
|
|
206
|
+
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/build/
|
|
207
|
+
return require_.resolve(`../../../../../../${filePath}`);
|
|
268
208
|
}
|
|
269
209
|
function addLogHook() {
|
|
270
210
|
const tty = process.stdout.isTTY && !process.env.CI; // Equals https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts#L27
|
|
@@ -3,26 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
6
|
+
exports.pluginBuildEntry = pluginBuildEntry;
|
|
7
|
+
exports.set_macro_ASSETS_MANIFEST = set_macro_ASSETS_MANIFEST;
|
|
8
8
|
const plugin_1 = require("@brillout/vite-plugin-server-entry/plugin");
|
|
9
9
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
10
10
|
const utils_js_1 = require("../../utils.js");
|
|
11
11
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const module_1 = require("module");
|
|
14
|
-
// @ts-ignore
|
|
14
|
+
// @ts-ignore `file://${__filename}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
15
15
|
const importMetaUrl = `file://${__filename}`;
|
|
16
16
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
17
17
|
const extractExportNamesPlugin_js_1 = require("../extractExportNamesPlugin.js");
|
|
18
18
|
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
19
19
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
20
20
|
const ASSETS_MANIFEST = '__VITE_ASSETS_MANIFEST__';
|
|
21
|
-
function
|
|
21
|
+
function pluginBuildEntry() {
|
|
22
22
|
let config;
|
|
23
23
|
return [
|
|
24
24
|
{
|
|
25
|
-
name: 'vike:
|
|
25
|
+
name: 'vike:build:pluginBuildEntry',
|
|
26
|
+
apply: 'build',
|
|
26
27
|
enforce: 'post',
|
|
27
28
|
async configResolved(config_) {
|
|
28
29
|
config = config_;
|
|
@@ -64,12 +65,11 @@ function getServerProductionEntryCode(config) {
|
|
|
64
65
|
return importerCode;
|
|
65
66
|
}
|
|
66
67
|
/** Set the value of the ASSETS_MANIFEST constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
67
|
-
async function
|
|
68
|
+
async function set_macro_ASSETS_MANIFEST(options, bundle, assetsJsonFilePath) {
|
|
68
69
|
const { dir } = options;
|
|
69
70
|
(0, utils_js_1.assert)(dir);
|
|
70
71
|
const chunkPath = find_ASSETS_MANIFEST(bundle);
|
|
71
72
|
const chunkFilePath = path_1.default.join(dir, chunkPath);
|
|
72
|
-
const assetsJsonFilePath = path_1.default.join(dir, '..', 'assets.json');
|
|
73
73
|
const [assetsJsonString, chunkFileContent] = await Promise.all([
|
|
74
74
|
await promises_1.default.readFile(assetsJsonFilePath, 'utf8'),
|
|
75
75
|
await promises_1.default.readFile(chunkFilePath, 'utf8')
|
|
@@ -93,7 +93,7 @@ function find_ASSETS_MANIFEST(bundle) {
|
|
|
93
93
|
function getImportPath(config) {
|
|
94
94
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
95
95
|
const filePathAbsolute = (0, utils_js_1.toPosixPath)(
|
|
96
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/
|
|
96
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/pluginBuildEntry/index.js
|
|
97
97
|
require_.resolve(`../../../../../../dist/esm/__internal/index.js`));
|
|
98
98
|
if (
|
|
99
99
|
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|