vike 0.4.192 → 0.4.193
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/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +22 -12
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -3
- package/dist/esm/node/plugin/plugins/importBuild/index.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/index.js +22 -12
- 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 +2 -2
|
@@ -74,7 +74,7 @@ function buildConfig() {
|
|
|
74
74
|
name: 'vike:buildConfig:writeBundle',
|
|
75
75
|
apply: 'build',
|
|
76
76
|
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
77
|
-
// -
|
|
77
|
+
// - set_ASSETS_MAP() needs to be called before dist/server/ code is executed.
|
|
78
78
|
// - 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
|
|
79
79
|
enforce: 'pre',
|
|
80
80
|
writeBundle: {
|
|
@@ -97,7 +97,7 @@ function buildConfig() {
|
|
|
97
97
|
}
|
|
98
98
|
await promises_1.default.rm(clientManifestFilePath);
|
|
99
99
|
await promises_1.default.rm(serverManifestFilePath);
|
|
100
|
-
await (0, index_js_1.
|
|
100
|
+
await (0, index_js_1.set_ASSETS_MAP)(options, bundle);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -3,7 +3,7 @@ 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.set_ASSETS_MAP = exports.importBuild = void 0;
|
|
7
7
|
const plugin_js_1 = require("@brillout/vite-plugin-server-entry/plugin.js");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -59,23 +59,33 @@ function getEntryCode(config, configVike) {
|
|
|
59
59
|
return importerCode;
|
|
60
60
|
}
|
|
61
61
|
/** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
62
|
-
async function
|
|
62
|
+
async function set_ASSETS_MAP(options, bundle) {
|
|
63
63
|
const { dir } = options;
|
|
64
64
|
(0, utils_js_1.assert)(dir);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const serverEntry = (0, plugin_js_1.findServerEntry)(bundle);
|
|
68
|
-
const serverEntryFilePath = path_1.default.join(dir, serverEntry.fileName);
|
|
65
|
+
const chunkPath = find_ASSETS_MAP(bundle);
|
|
66
|
+
const chunkFilePath = path_1.default.join(dir, chunkPath);
|
|
69
67
|
const assetsJsonFilePath = path_1.default.join(dir, '..', 'assets.json');
|
|
70
|
-
const [assetsJsonString,
|
|
68
|
+
const [assetsJsonString, chunkFileContent] = await Promise.all([
|
|
71
69
|
await promises_1.default.readFile(assetsJsonFilePath, 'utf8'),
|
|
72
|
-
await promises_1.default.readFile(
|
|
70
|
+
await promises_1.default.readFile(chunkFilePath, 'utf8')
|
|
73
71
|
]);
|
|
74
|
-
const serverEntryFileContentPatched =
|
|
75
|
-
(0, utils_js_1.assert)(serverEntryFileContentPatched !==
|
|
76
|
-
await promises_1.default.writeFile(
|
|
72
|
+
const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MAP, assetsJsonString);
|
|
73
|
+
(0, utils_js_1.assert)(serverEntryFileContentPatched !== chunkFileContent);
|
|
74
|
+
await promises_1.default.writeFile(chunkFilePath, serverEntryFileContentPatched);
|
|
75
|
+
}
|
|
76
|
+
exports.set_ASSETS_MAP = set_ASSETS_MAP;
|
|
77
|
+
function find_ASSETS_MAP(bundle) {
|
|
78
|
+
let chunkPath;
|
|
79
|
+
for (const filePath in bundle) {
|
|
80
|
+
const chunk = bundle[filePath];
|
|
81
|
+
if ('code' in chunk && chunk.code.includes(ASSETS_MAP)) {
|
|
82
|
+
(0, utils_js_1.assert)(!chunkPath);
|
|
83
|
+
chunkPath = filePath;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
(0, utils_js_1.assert)(chunkPath);
|
|
87
|
+
return chunkPath;
|
|
77
88
|
}
|
|
78
|
-
exports.set_constant_ASSETS_MAP = set_constant_ASSETS_MAP;
|
|
79
89
|
function getImportPath(config) {
|
|
80
90
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
81
91
|
const filePathAbsolute = (0, utils_js_1.toPosixPath)(
|
|
@@ -12,7 +12,7 @@ import { createRequire } from 'module';
|
|
|
12
12
|
import fs from 'fs/promises';
|
|
13
13
|
import path from 'path';
|
|
14
14
|
import { fixServerAssets, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
15
|
-
import {
|
|
15
|
+
import { set_ASSETS_MAP } from './importBuild/index.js';
|
|
16
16
|
import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
|
|
17
17
|
import { getFilePathResolved } from '../shared/getFilePath.js';
|
|
18
18
|
import { getConfigValueBuildTime } from '../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
@@ -71,7 +71,7 @@ function buildConfig() {
|
|
|
71
71
|
name: 'vike:buildConfig:writeBundle',
|
|
72
72
|
apply: 'build',
|
|
73
73
|
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
74
|
-
// -
|
|
74
|
+
// - set_ASSETS_MAP() needs to be called before dist/server/ code is executed.
|
|
75
75
|
// - 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
|
|
76
76
|
enforce: 'pre',
|
|
77
77
|
writeBundle: {
|
|
@@ -94,7 +94,7 @@ function buildConfig() {
|
|
|
94
94
|
}
|
|
95
95
|
await fs.rm(clientManifestFilePath);
|
|
96
96
|
await fs.rm(serverManifestFilePath);
|
|
97
|
-
await
|
|
97
|
+
await set_ASSETS_MAP(options, bundle);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { importBuild };
|
|
2
|
-
export {
|
|
2
|
+
export { set_ASSETS_MAP };
|
|
3
3
|
import type { Plugin, Rollup } from 'vite';
|
|
4
4
|
type Bundle = Rollup.OutputBundle;
|
|
5
5
|
type Options = Rollup.NormalizedOutputOptions;
|
|
6
6
|
declare function importBuild(): Plugin[];
|
|
7
7
|
/** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
8
|
-
declare function
|
|
8
|
+
declare function set_ASSETS_MAP(options: Options, bundle: Bundle): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { importBuild };
|
|
2
|
-
export {
|
|
3
|
-
import { serverEntryPlugin
|
|
2
|
+
export { set_ASSETS_MAP };
|
|
3
|
+
import { serverEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin.js';
|
|
4
4
|
import { assert, getOutDirs, toPosixPath } from '../../utils.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { createRequire } from 'module';
|
|
@@ -54,21 +54,31 @@ function getEntryCode(config, configVike) {
|
|
|
54
54
|
return importerCode;
|
|
55
55
|
}
|
|
56
56
|
/** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
57
|
-
async function
|
|
57
|
+
async function set_ASSETS_MAP(options, bundle) {
|
|
58
58
|
const { dir } = options;
|
|
59
59
|
assert(dir);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const serverEntry = findServerEntry(bundle);
|
|
63
|
-
const serverEntryFilePath = path.join(dir, serverEntry.fileName);
|
|
60
|
+
const chunkPath = find_ASSETS_MAP(bundle);
|
|
61
|
+
const chunkFilePath = path.join(dir, chunkPath);
|
|
64
62
|
const assetsJsonFilePath = path.join(dir, '..', 'assets.json');
|
|
65
|
-
const [assetsJsonString,
|
|
63
|
+
const [assetsJsonString, chunkFileContent] = await Promise.all([
|
|
66
64
|
await fs.readFile(assetsJsonFilePath, 'utf8'),
|
|
67
|
-
await fs.readFile(
|
|
65
|
+
await fs.readFile(chunkFilePath, 'utf8')
|
|
68
66
|
]);
|
|
69
|
-
const serverEntryFileContentPatched =
|
|
70
|
-
assert(serverEntryFileContentPatched !==
|
|
71
|
-
await fs.writeFile(
|
|
67
|
+
const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MAP, assetsJsonString);
|
|
68
|
+
assert(serverEntryFileContentPatched !== chunkFileContent);
|
|
69
|
+
await fs.writeFile(chunkFilePath, serverEntryFileContentPatched);
|
|
70
|
+
}
|
|
71
|
+
function find_ASSETS_MAP(bundle) {
|
|
72
|
+
let chunkPath;
|
|
73
|
+
for (const filePath in bundle) {
|
|
74
|
+
const chunk = bundle[filePath];
|
|
75
|
+
if ('code' in chunk && chunk.code.includes(ASSETS_MAP)) {
|
|
76
|
+
assert(!chunkPath);
|
|
77
|
+
chunkPath = filePath;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
assert(chunkPath);
|
|
81
|
+
return chunkPath;
|
|
72
82
|
}
|
|
73
83
|
function getImportPath(config) {
|
|
74
84
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.193";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.193';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.193",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@brillout/json-serializer": "^0.5.13",
|
|
18
18
|
"@brillout/picocolors": "^1.0.14",
|
|
19
19
|
"@brillout/require-shim": "^0.1.2",
|
|
20
|
-
"@brillout/vite-plugin-server-entry": "^0.4.
|
|
20
|
+
"@brillout/vite-plugin-server-entry": "^0.4.10",
|
|
21
21
|
"acorn": "^8.0.0",
|
|
22
22
|
"cac": "^6.0.0",
|
|
23
23
|
"es-module-lexer": "^1.0.0",
|