vike 0.4.228-commit-13824ea → 0.4.228-commit-1553dee
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/handleAssetsManifest.js +9 -4
- package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +8 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +1 -0
- package/dist/cjs/node/runtime/globalContext.js +5 -7
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +2 -2
- package/dist/esm/node/plugin/plugins/build/handleAssetsManifest.js +9 -4
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +8 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +1 -0
- package/dist/esm/node/runtime/globalContext.js +5 -7
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
|
@@ -301,16 +301,21 @@ function handleAssetsManifest_getBuildConfig(config) {
|
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
303
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
304
|
-
|
|
304
|
+
const isSsREnv = (0, isViteServerBuild_js_1.isViteServerBuild_onlySsrEnv)(config, viteEnv);
|
|
305
|
+
if (isSsREnv) {
|
|
305
306
|
(0, utils_js_1.assert)(!assetsJsonFilePath);
|
|
306
307
|
const outDirs = (0, getOutDirs_js_1.getOutDirs)(config, viteEnv);
|
|
307
308
|
assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
308
309
|
await writeAssetsManifestFile(outDirs, assetsJsonFilePath, config);
|
|
309
310
|
}
|
|
310
311
|
if ((0, isViteServerBuild_js_1.isViteServerBuild)(config, viteEnv)) {
|
|
311
|
-
|
|
312
|
-
//
|
|
313
|
-
|
|
312
|
+
// Replace __VITE_ASSETS_MANIFEST__ in server builds
|
|
313
|
+
// - Always replace it in dist/server/
|
|
314
|
+
// - Also in some other server builds such as dist/vercel/ from vike-vercel
|
|
315
|
+
// - Don't replace it in dist/rsc/ from vike-react-rsc since __VITE_ASSETS_MANIFEST__ doesn't exist there
|
|
316
|
+
const noop = await (0, pluginBuildEntry_js_1.set_macro_ASSETS_MANIFEST)(options, bundle, assetsJsonFilePath);
|
|
317
|
+
if (isSsREnv)
|
|
318
|
+
(0, utils_js_1.assert)(!noop); // dist/server should always contain __VITE_ASSETS_MANIFEST__
|
|
314
319
|
}
|
|
315
320
|
}
|
|
316
321
|
async function writeAssetsManifestFile(outDirs, assetsJsonFilePath, config) {
|
|
@@ -68,6 +68,12 @@ async function set_macro_ASSETS_MANIFEST(options, bundle, assetsJsonFilePath) {
|
|
|
68
68
|
const { dir } = options;
|
|
69
69
|
(0, utils_js_1.assert)(dir);
|
|
70
70
|
const chunkPath = find_ASSETS_MANIFEST(bundle);
|
|
71
|
+
// Some server builds don't contain __VITE_ASSETS_MANIFEST__ such as dist/rsc/ from vike-react-rsc
|
|
72
|
+
if (!chunkPath) {
|
|
73
|
+
const noop = true; // no operation
|
|
74
|
+
return noop;
|
|
75
|
+
}
|
|
76
|
+
(0, utils_js_1.assert)(assetsJsonFilePath);
|
|
71
77
|
const chunkFilePath = path_1.default.join(dir, chunkPath);
|
|
72
78
|
const [assetsJsonString, chunkFileContent] = await Promise.all([
|
|
73
79
|
await promises_1.default.readFile(assetsJsonFilePath, 'utf8'),
|
|
@@ -76,6 +82,8 @@ async function set_macro_ASSETS_MANIFEST(options, bundle, assetsJsonFilePath) {
|
|
|
76
82
|
const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MANIFEST, assetsJsonString);
|
|
77
83
|
(0, utils_js_1.assert)(serverEntryFileContentPatched !== chunkFileContent);
|
|
78
84
|
await promises_1.default.writeFile(chunkFilePath, serverEntryFileContentPatched);
|
|
85
|
+
const noop = false;
|
|
86
|
+
return noop;
|
|
79
87
|
}
|
|
80
88
|
function find_ASSETS_MANIFEST(bundle) {
|
|
81
89
|
let chunkPath;
|
|
@@ -86,7 +94,6 @@ function find_ASSETS_MANIFEST(bundle) {
|
|
|
86
94
|
chunkPath = filePath;
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
|
-
(0, utils_js_1.assert)(chunkPath);
|
|
90
97
|
return chunkPath;
|
|
91
98
|
}
|
|
92
99
|
function getImportPath(config) {
|
|
@@ -904,6 +904,7 @@ function assertKnownConfig(configName, configNamesKnownRelevant, configDefinitio
|
|
|
904
904
|
const errMsg = isPlusFile
|
|
905
905
|
? `${sourceName} sets an unknown config ${configNameColored}`
|
|
906
906
|
: `${sourceName} sets an unknown Vike config, see ${picocolors_1.default.underline('https://vike.dev/cli')} for the list of CLI options`;
|
|
907
|
+
(0, utils_js_1.assert)(errMsg.includes(configName));
|
|
907
908
|
// Missing vike-{react,vue,solid} installation
|
|
908
909
|
{
|
|
909
910
|
const ui = ['vike-react', 'vike-vue', 'vike-solid'];
|
|
@@ -345,14 +345,12 @@ async function loadBuildEntry(outDir) {
|
|
|
345
345
|
globalObject.buildEntry = globalObject.buildEntryPrevious;
|
|
346
346
|
}
|
|
347
347
|
(0, utils_js_1.assert)(globalObject.buildEntry);
|
|
348
|
+
// If using `inject` then dist/server/index.js imports dist/server/entry.js and loadBuildEntry() isn't needed.
|
|
349
|
+
// If dist/server/entry.js isn't imported then this means the user is running the original server entry `$ ts-node server/index.ts`.
|
|
348
350
|
(0, utils_js_1.assertWarning)(
|
|
349
|
-
// vike-server => `
|
|
350
|
-
// vike-node => `
|
|
351
|
-
globalObject.buildInfo?.viteConfigRuntime.vitePluginServerEntry.inject !== true,
|
|
352
|
-
/* TO-DO/eventually:
|
|
353
|
-
!!globalObject.buildInfo?.viteConfigRuntime.vitePluginServerEntry.inject,
|
|
354
|
-
*/
|
|
355
|
-
`Run the built server entry (e.g. ${picocolors_1.default.cyan('$ node dist/server/index.mjs')}) instead of the original server entry (e.g. ${picocolors_1.default.cyan('$ ts-node server/index.ts')})`, { onlyOnce: true });
|
|
351
|
+
// vike-server => `inject === true`
|
|
352
|
+
// vike-node => `inject === [ 'index' ]` => we don't show the warning to vike-node users (I don't remember why).
|
|
353
|
+
globalObject.buildInfo?.viteConfigRuntime.vitePluginServerEntry.inject !== true || globalObject.isPrerendering, `Run the built server entry (e.g. ${picocolors_1.default.cyan('$ node dist/server/index.mjs')}) instead of the original server entry (e.g. ${picocolors_1.default.cyan('$ ts-node server/index.ts')})`, { onlyOnce: true });
|
|
356
354
|
}
|
|
357
355
|
const { buildEntry } = globalObject;
|
|
358
356
|
assertBuildEntry(buildEntry);
|
|
@@ -3,9 +3,9 @@ import { isSameAsCurrentUrl, skipLink } from './skipLink.js';
|
|
|
3
3
|
import { renderPageClientSide } from './renderPageClientSide.js';
|
|
4
4
|
import { scrollToHashOrTop } from './setScrollPosition.js';
|
|
5
5
|
function initOnLinkClick() {
|
|
6
|
-
document.addEventListener('click',
|
|
6
|
+
document.addEventListener('click', onLinkClick);
|
|
7
7
|
}
|
|
8
|
-
async function
|
|
8
|
+
async function onLinkClick(ev) {
|
|
9
9
|
if (!isNormalLeftClick(ev))
|
|
10
10
|
return;
|
|
11
11
|
const linkTag = findLinkTag(ev.target);
|
|
@@ -296,16 +296,21 @@ function handleAssetsManifest_getBuildConfig(config) {
|
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
298
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
299
|
-
|
|
299
|
+
const isSsREnv = isViteServerBuild_onlySsrEnv(config, viteEnv);
|
|
300
|
+
if (isSsREnv) {
|
|
300
301
|
assert(!assetsJsonFilePath);
|
|
301
302
|
const outDirs = getOutDirs(config, viteEnv);
|
|
302
303
|
assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
303
304
|
await writeAssetsManifestFile(outDirs, assetsJsonFilePath, config);
|
|
304
305
|
}
|
|
305
306
|
if (isViteServerBuild(config, viteEnv)) {
|
|
306
|
-
|
|
307
|
-
//
|
|
308
|
-
|
|
307
|
+
// Replace __VITE_ASSETS_MANIFEST__ in server builds
|
|
308
|
+
// - Always replace it in dist/server/
|
|
309
|
+
// - Also in some other server builds such as dist/vercel/ from vike-vercel
|
|
310
|
+
// - Don't replace it in dist/rsc/ from vike-react-rsc since __VITE_ASSETS_MANIFEST__ doesn't exist there
|
|
311
|
+
const noop = await set_macro_ASSETS_MANIFEST(options, bundle, assetsJsonFilePath);
|
|
312
|
+
if (isSsREnv)
|
|
313
|
+
assert(!noop); // dist/server should always contain __VITE_ASSETS_MANIFEST__
|
|
309
314
|
}
|
|
310
315
|
}
|
|
311
316
|
async function writeAssetsManifestFile(outDirs, assetsJsonFilePath, config) {
|
|
@@ -4,4 +4,4 @@ import type { Plugin, Rollup } from 'vite';
|
|
|
4
4
|
type Bundle = Rollup.OutputBundle;
|
|
5
5
|
type Options = Rollup.NormalizedOutputOptions;
|
|
6
6
|
declare function pluginBuildEntry(): Plugin[];
|
|
7
|
-
declare function set_macro_ASSETS_MANIFEST(options: Options, bundle: Bundle, assetsJsonFilePath: string): Promise<
|
|
7
|
+
declare function set_macro_ASSETS_MANIFEST(options: Options, bundle: Bundle, assetsJsonFilePath: string | undefined): Promise<boolean>;
|
|
@@ -63,6 +63,12 @@ async function set_macro_ASSETS_MANIFEST(options, bundle, assetsJsonFilePath) {
|
|
|
63
63
|
const { dir } = options;
|
|
64
64
|
assert(dir);
|
|
65
65
|
const chunkPath = find_ASSETS_MANIFEST(bundle);
|
|
66
|
+
// Some server builds don't contain __VITE_ASSETS_MANIFEST__ such as dist/rsc/ from vike-react-rsc
|
|
67
|
+
if (!chunkPath) {
|
|
68
|
+
const noop = true; // no operation
|
|
69
|
+
return noop;
|
|
70
|
+
}
|
|
71
|
+
assert(assetsJsonFilePath);
|
|
66
72
|
const chunkFilePath = path.join(dir, chunkPath);
|
|
67
73
|
const [assetsJsonString, chunkFileContent] = await Promise.all([
|
|
68
74
|
await fs.readFile(assetsJsonFilePath, 'utf8'),
|
|
@@ -71,6 +77,8 @@ async function set_macro_ASSETS_MANIFEST(options, bundle, assetsJsonFilePath) {
|
|
|
71
77
|
const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MANIFEST, assetsJsonString);
|
|
72
78
|
assert(serverEntryFileContentPatched !== chunkFileContent);
|
|
73
79
|
await fs.writeFile(chunkFilePath, serverEntryFileContentPatched);
|
|
80
|
+
const noop = false;
|
|
81
|
+
return noop;
|
|
74
82
|
}
|
|
75
83
|
function find_ASSETS_MANIFEST(bundle) {
|
|
76
84
|
let chunkPath;
|
|
@@ -81,7 +89,6 @@ function find_ASSETS_MANIFEST(bundle) {
|
|
|
81
89
|
chunkPath = filePath;
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
|
-
assert(chunkPath);
|
|
85
92
|
return chunkPath;
|
|
86
93
|
}
|
|
87
94
|
function getImportPath(config) {
|
|
@@ -899,6 +899,7 @@ function assertKnownConfig(configName, configNamesKnownRelevant, configDefinitio
|
|
|
899
899
|
const errMsg = isPlusFile
|
|
900
900
|
? `${sourceName} sets an unknown config ${configNameColored}`
|
|
901
901
|
: `${sourceName} sets an unknown Vike config, see ${pc.underline('https://vike.dev/cli')} for the list of CLI options`;
|
|
902
|
+
assert(errMsg.includes(configName));
|
|
902
903
|
// Missing vike-{react,vue,solid} installation
|
|
903
904
|
{
|
|
904
905
|
const ui = ['vike-react', 'vike-vue', 'vike-solid'];
|
|
@@ -342,14 +342,12 @@ async function loadBuildEntry(outDir) {
|
|
|
342
342
|
globalObject.buildEntry = globalObject.buildEntryPrevious;
|
|
343
343
|
}
|
|
344
344
|
assert(globalObject.buildEntry);
|
|
345
|
+
// If using `inject` then dist/server/index.js imports dist/server/entry.js and loadBuildEntry() isn't needed.
|
|
346
|
+
// If dist/server/entry.js isn't imported then this means the user is running the original server entry `$ ts-node server/index.ts`.
|
|
345
347
|
assertWarning(
|
|
346
|
-
// vike-server => `
|
|
347
|
-
// vike-node => `
|
|
348
|
-
globalObject.buildInfo?.viteConfigRuntime.vitePluginServerEntry.inject !== true,
|
|
349
|
-
/* TO-DO/eventually:
|
|
350
|
-
!!globalObject.buildInfo?.viteConfigRuntime.vitePluginServerEntry.inject,
|
|
351
|
-
*/
|
|
352
|
-
`Run the built server entry (e.g. ${pc.cyan('$ node dist/server/index.mjs')}) instead of the original server entry (e.g. ${pc.cyan('$ ts-node server/index.ts')})`, { onlyOnce: true });
|
|
348
|
+
// vike-server => `inject === true`
|
|
349
|
+
// vike-node => `inject === [ 'index' ]` => we don't show the warning to vike-node users (I don't remember why).
|
|
350
|
+
globalObject.buildInfo?.viteConfigRuntime.vitePluginServerEntry.inject !== true || globalObject.isPrerendering, `Run the built server entry (e.g. ${pc.cyan('$ node dist/server/index.mjs')}) instead of the original server entry (e.g. ${pc.cyan('$ ts-node server/index.ts')})`, { onlyOnce: true });
|
|
353
351
|
}
|
|
354
352
|
const { buildEntry } = globalObject;
|
|
355
353
|
assertBuildEntry(buildEntry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.228-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.228-commit-1553dee";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.228-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.228-commit-1553dee';
|