vike 0.4.162 → 0.4.163-commit-407cb5c
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/autoFullBuild.js +7 -4
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +9 -5
- package/dist/cjs/node/plugin/plugins/buildConfig.js +24 -18
- package/dist/cjs/node/plugin/plugins/commonConfig.js +8 -2
- package/dist/cjs/node/plugin/plugins/distFileNames.js +4 -9
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +2 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +6 -1
- package/dist/cjs/node/plugin/shared/getAssetsDir.js +11 -0
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +3 -3
- package/dist/cjs/node/runtime/globalContext.js +47 -6
- package/dist/cjs/node/runtime/index-common.js +4 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +19 -19
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +12 -12
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +5 -5
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +9 -13
- package/dist/cjs/node/runtime/renderPage.js +3 -0
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +4 -11
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +20 -14
- package/dist/esm/client/shared/getPageContextProxyForUser.js +19 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +7 -4
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +10 -6
- package/dist/esm/node/plugin/plugins/buildConfig.js +24 -18
- package/dist/esm/node/plugin/plugins/commonConfig.js +9 -3
- package/dist/esm/node/plugin/plugins/distFileNames.js +1 -6
- package/dist/esm/node/plugin/plugins/importBuild/index.js +2 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +6 -1
- package/dist/esm/node/plugin/shared/getAssetsDir.d.ts +3 -0
- package/dist/esm/node/plugin/shared/getAssetsDir.js +8 -0
- package/dist/esm/node/runtime/globalContext/loadImportBuild.d.ts +2 -2
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +3 -3
- package/dist/esm/node/runtime/globalContext.d.ts +11 -2
- package/dist/esm/node/runtime/globalContext.js +49 -6
- package/dist/esm/node/runtime/index-common.d.ts +1 -0
- package/dist/esm/node/runtime/index-common.js +1 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +19 -19
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +12 -12
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +5 -5
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +10 -11
- package/dist/esm/node/runtime/renderPage.js +3 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +1 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +5 -9
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// Public use
|
|
2
|
+
export { getGlobalContextSync };
|
|
3
|
+
export { getGlobalContextAsync };
|
|
4
|
+
// Internal use
|
|
1
5
|
export { initGlobalContext };
|
|
2
6
|
export { getGlobalContext };
|
|
3
7
|
export { getViteDevServer };
|
|
@@ -5,18 +9,56 @@ export { getViteConfig };
|
|
|
5
9
|
export { setGlobalContext_viteDevServer };
|
|
6
10
|
export { setGlobalContext_prerender };
|
|
7
11
|
export { getRuntimeManifest };
|
|
8
|
-
import { assert, assertUsage, getGlobalObject, getNodeEnv, getNodeEnvDesc, isNodeEnvDev, isPlainObject, objectAssign } from './utils.js';
|
|
12
|
+
import { assert, assertUsage, assertWarning, getGlobalObject, getNodeEnv, getNodeEnvDesc, isNodeEnvDev, isPlainObject, objectAssign, objectKeys } from './utils.js';
|
|
9
13
|
import { loadImportBuild } from './globalContext/loadImportBuild.js';
|
|
10
14
|
import { setPageFiles } from '../../shared/getPageFiles.js';
|
|
11
15
|
import { assertPluginManifest } from '../shared/assertPluginManifest.js';
|
|
12
16
|
import { getConfigVike } from '../shared/getConfigVike.js';
|
|
13
17
|
import { assertRuntimeManifest } from '../shared/assertRuntimeManifest.js';
|
|
14
18
|
import pc from '@brillout/picocolors';
|
|
15
|
-
|
|
19
|
+
let resolveGlobalContext;
|
|
20
|
+
const globalObject = getGlobalObject('globalContext.ts', {
|
|
21
|
+
globalContextPromise: new Promise((r) => (resolveGlobalContext = r))
|
|
22
|
+
});
|
|
16
23
|
function getGlobalContext() {
|
|
17
24
|
assert(globalObject.globalContext);
|
|
18
25
|
return globalObject.globalContext;
|
|
19
26
|
}
|
|
27
|
+
/** @experimental https://vike.dev/getGlobalContext */
|
|
28
|
+
function getGlobalContextSync() {
|
|
29
|
+
assertUsage(globalObject.globalContext, "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContextAsync() instead.");
|
|
30
|
+
return makePublic(globalObject.globalContext);
|
|
31
|
+
}
|
|
32
|
+
/** @experimental https://vike.dev/getGlobalContext */
|
|
33
|
+
async function getGlobalContextAsync() {
|
|
34
|
+
await globalObject.globalContextPromise;
|
|
35
|
+
assert(globalObject.globalContext);
|
|
36
|
+
return makePublic(globalObject.globalContext);
|
|
37
|
+
}
|
|
38
|
+
function makePublic(globalContext) {
|
|
39
|
+
const globalContextPublic = {
|
|
40
|
+
assetsManifest: globalContext.assetsManifest
|
|
41
|
+
};
|
|
42
|
+
// Add internals (and prepended _ prefix to their keys)
|
|
43
|
+
{
|
|
44
|
+
const publicKeys = Object.keys(globalContextPublic);
|
|
45
|
+
objectKeys(globalContext)
|
|
46
|
+
.filter((key) => !publicKeys.includes(key))
|
|
47
|
+
.forEach((key) => {
|
|
48
|
+
const keyPublic = `_${key}`;
|
|
49
|
+
Object.defineProperty(globalContextPublic, keyPublic, {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get() {
|
|
52
|
+
assertWarning(false, `Using internal globalContext.${keyPublic} which is discouraged: it may break in any minor version update. Instead, reach out on GitHub and elaborate your use case.`, {
|
|
53
|
+
onlyOnce: true
|
|
54
|
+
});
|
|
55
|
+
return globalContext[key];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return globalContextPublic;
|
|
61
|
+
}
|
|
20
62
|
function setGlobalContext_viteDevServer(viteDevServer) {
|
|
21
63
|
if (globalObject.viteDevServer)
|
|
22
64
|
return;
|
|
@@ -51,7 +93,7 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
51
93
|
globalObject.globalContext = {
|
|
52
94
|
isProduction: false,
|
|
53
95
|
isPrerendering: false,
|
|
54
|
-
|
|
96
|
+
assetsManifest: null,
|
|
55
97
|
pluginManifest: null,
|
|
56
98
|
viteDevServer,
|
|
57
99
|
viteConfig,
|
|
@@ -66,13 +108,13 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
66
108
|
else {
|
|
67
109
|
const buildEntries = await loadImportBuild(outDir);
|
|
68
110
|
assertBuildEntries(buildEntries, isPrerendering ?? false);
|
|
69
|
-
const { pageFiles,
|
|
111
|
+
const { pageFiles, assetsManifest, pluginManifest } = buildEntries;
|
|
70
112
|
setPageFiles(pageFiles);
|
|
71
|
-
assertViteManifest(
|
|
113
|
+
assertViteManifest(assetsManifest);
|
|
72
114
|
assertPluginManifest(pluginManifest);
|
|
73
115
|
const globalContext = {
|
|
74
116
|
isProduction: true,
|
|
75
|
-
|
|
117
|
+
assetsManifest,
|
|
76
118
|
pluginManifest,
|
|
77
119
|
viteDevServer: null,
|
|
78
120
|
baseServer: pluginManifest.baseServer,
|
|
@@ -100,6 +142,7 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
100
142
|
globalObject.globalContext = globalContext;
|
|
101
143
|
}
|
|
102
144
|
}
|
|
145
|
+
resolveGlobalContext(globalObject.globalContext);
|
|
103
146
|
}
|
|
104
147
|
function getRuntimeManifest(configVike) {
|
|
105
148
|
const { includeAssetsImportedByServer, baseServer, baseAssets, redirects, trailingSlash, disableUrlNormalization } = configVike;
|
|
@@ -2,6 +2,7 @@ export { renderPage } from './renderPage.js';
|
|
|
2
2
|
export { escapeInject, dangerouslySkipEscape } from './html/renderHtml.js';
|
|
3
3
|
export { pipeWebStream, pipeNodeStream, pipeStream, stampPipe } from './html/stream.js';
|
|
4
4
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
5
|
+
export { getGlobalContextSync, getGlobalContextAsync } from './globalContext.js';
|
|
5
6
|
export { injectAssets__public as _injectAssets } from './html/injectAssets/injectAssets__public.js';
|
|
6
7
|
export { createPageRenderer } from '../createPageRenderer.js';
|
|
7
8
|
declare global {
|
|
@@ -2,6 +2,7 @@ export { renderPage } from './renderPage.js';
|
|
|
2
2
|
export { escapeInject, dangerouslySkipEscape } from './html/renderHtml.js';
|
|
3
3
|
export { pipeWebStream, pipeNodeStream, pipeStream, stampPipe } from './html/stream.js';
|
|
4
4
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
5
|
+
export { getGlobalContextSync, getGlobalContextAsync } from './globalContext.js';
|
|
5
6
|
// TODO/v1-release: remove
|
|
6
7
|
export { injectAssets__public as _injectAssets } from './html/injectAssets/injectAssets__public.js';
|
|
7
8
|
// TODO/v1-release: remove
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getManifestEntry };
|
|
2
2
|
import type { ViteManifest, ViteManifestEntry } from '../../../shared/ViteManifest.js';
|
|
3
|
-
declare function getManifestEntry(id: string,
|
|
3
|
+
declare function getManifestEntry(id: string, assetsManifest: ViteManifest): {
|
|
4
4
|
manifestKey: string;
|
|
5
5
|
manifestEntry: ViteManifestEntry;
|
|
6
6
|
};
|
|
@@ -3,13 +3,13 @@ import { assert, slice, isNpmPackageImport } from '../../utils.js';
|
|
|
3
3
|
import { assertClientEntryId } from './assertClientEntryId.js';
|
|
4
4
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
6
|
-
function getManifestEntry(id,
|
|
6
|
+
function getManifestEntry(id, assetsManifest) {
|
|
7
7
|
assertClientEntryId(id);
|
|
8
|
-
const debugInfo = getDebugInfo(id,
|
|
8
|
+
const debugInfo = getDebugInfo(id, assetsManifest);
|
|
9
9
|
// Vike client entry
|
|
10
10
|
if (id.startsWith('@@vike/')) {
|
|
11
11
|
const manifestKeyEnd = slice(id, '@@vike'.length, 0);
|
|
12
|
-
const { manifestKey, manifestEntry } = findEntryWithKeyEnd(manifestKeyEnd,
|
|
12
|
+
const { manifestKey, manifestEntry } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id);
|
|
13
13
|
assert(manifestEntry && manifestKey, debugInfo);
|
|
14
14
|
return { manifestEntry, manifestKey };
|
|
15
15
|
}
|
|
@@ -17,7 +17,7 @@ function getManifestEntry(id, clientManifest) {
|
|
|
17
17
|
if (isVirtualFileIdPageConfigValuesAll(id)) {
|
|
18
18
|
{
|
|
19
19
|
const manifestKey = id;
|
|
20
|
-
const manifestEntry =
|
|
20
|
+
const manifestEntry = assetsManifest[manifestKey];
|
|
21
21
|
if (manifestEntry) {
|
|
22
22
|
return { manifestEntry, manifestKey };
|
|
23
23
|
}
|
|
@@ -30,20 +30,20 @@ function getManifestEntry(id, clientManifest) {
|
|
|
30
30
|
// - This workaround was implemented to support Vitest runnung /tests/*
|
|
31
31
|
// - I don't know whether end users actually need this workaround? (I'm not sure what the bug actually is.)
|
|
32
32
|
const manifestKeyEnd = id;
|
|
33
|
-
const { manifestKey, manifestEntry } = getEntryWithKeyEnd(manifestKeyEnd,
|
|
33
|
+
const { manifestKey, manifestEntry } = getEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id);
|
|
34
34
|
assert(manifestEntry, debugInfo);
|
|
35
35
|
return { manifestEntry, manifestKey };
|
|
36
36
|
}
|
|
37
37
|
// User files
|
|
38
38
|
if (id.startsWith('/')) {
|
|
39
39
|
const manifestKey = id.slice(1);
|
|
40
|
-
let manifestEntry =
|
|
40
|
+
let manifestEntry = assetsManifest[manifestKey];
|
|
41
41
|
assert(manifestEntry, debugInfo);
|
|
42
42
|
return { manifestEntry, manifestKey };
|
|
43
43
|
}
|
|
44
44
|
// npm package import
|
|
45
45
|
if (isNpmPackageImport(id)) {
|
|
46
|
-
const found = Object.entries(
|
|
46
|
+
const found = Object.entries(assetsManifest).find(([, e]) => e.name === prependEntriesDir(id));
|
|
47
47
|
assert(found);
|
|
48
48
|
const [manifestKey, manifestEntry] = found;
|
|
49
49
|
return { manifestEntry, manifestKey };
|
|
@@ -55,7 +55,7 @@ function getManifestEntry(id, clientManifest) {
|
|
|
55
55
|
assert(!manifestKeyEnd.startsWith('/'), debugInfo);
|
|
56
56
|
manifestKeyEnd = '/' + manifestKeyEnd;
|
|
57
57
|
{
|
|
58
|
-
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd,
|
|
58
|
+
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id);
|
|
59
59
|
if (manifestEntry) {
|
|
60
60
|
assert(manifestKey, debugInfo);
|
|
61
61
|
return { manifestEntry, manifestKey };
|
|
@@ -69,7 +69,7 @@ function getManifestEntry(id, clientManifest) {
|
|
|
69
69
|
assert(manifestKeyEnd.startsWith('/'), debugInfo);
|
|
70
70
|
}
|
|
71
71
|
{
|
|
72
|
-
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd,
|
|
72
|
+
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id);
|
|
73
73
|
if (manifestEntry) {
|
|
74
74
|
assert(manifestKey, debugInfo);
|
|
75
75
|
return { manifestEntry, manifestKey };
|
|
@@ -79,11 +79,11 @@ function getManifestEntry(id, clientManifest) {
|
|
|
79
79
|
}
|
|
80
80
|
assert(false, debugInfo);
|
|
81
81
|
}
|
|
82
|
-
function findEntryWithKeyEnd(manifestKeyEnd,
|
|
83
|
-
const debugInfo = getDebugInfo(id,
|
|
82
|
+
function findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id) {
|
|
83
|
+
const debugInfo = getDebugInfo(id, assetsManifest, manifestKeyEnd);
|
|
84
84
|
assert(manifestKeyEnd.startsWith('/'), debugInfo);
|
|
85
85
|
const manifestKeys = [];
|
|
86
|
-
for (const manifestKey in
|
|
86
|
+
for (const manifestKey in assetsManifest) {
|
|
87
87
|
if (manifestKey.endsWith(manifestKeyEnd)) {
|
|
88
88
|
manifestKeys.push(manifestKey);
|
|
89
89
|
}
|
|
@@ -94,13 +94,13 @@ function findEntryWithKeyEnd(manifestKeyEnd, clientManifest, id) {
|
|
|
94
94
|
if (!manifestKey) {
|
|
95
95
|
return { manifestEntry: null, manifestKey: null };
|
|
96
96
|
}
|
|
97
|
-
const manifestEntry =
|
|
97
|
+
const manifestEntry = assetsManifest[manifestKey];
|
|
98
98
|
return { manifestEntry, manifestKey };
|
|
99
99
|
}
|
|
100
|
-
function getEntryWithKeyEnd(manifestKeyEnd,
|
|
101
|
-
const debugInfo = getDebugInfo(id,
|
|
100
|
+
function getEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id) {
|
|
101
|
+
const debugInfo = getDebugInfo(id, assetsManifest, manifestKeyEnd);
|
|
102
102
|
const manifestKeys = [];
|
|
103
|
-
for (const manifestKey in
|
|
103
|
+
for (const manifestKey in assetsManifest) {
|
|
104
104
|
if (manifestKey.endsWith(manifestKeyEnd)) {
|
|
105
105
|
manifestKeys.push(manifestKey);
|
|
106
106
|
}
|
|
@@ -110,11 +110,11 @@ function getEntryWithKeyEnd(manifestKeyEnd, clientManifest, id) {
|
|
|
110
110
|
if (!manifestKey) {
|
|
111
111
|
return { manifestEntry: null, manifestKey: null };
|
|
112
112
|
}
|
|
113
|
-
const manifestEntry =
|
|
113
|
+
const manifestEntry = assetsManifest[manifestKey];
|
|
114
114
|
return { manifestEntry, manifestKey };
|
|
115
115
|
}
|
|
116
|
-
function getDebugInfo(id,
|
|
117
|
-
const manifestKeys = Object.keys(
|
|
116
|
+
function getDebugInfo(id, assetsManifest, manifestKeyEnd) {
|
|
117
|
+
const manifestKeys = Object.keys(assetsManifest);
|
|
118
118
|
if (manifestKeyEnd === undefined) {
|
|
119
119
|
return { manifestKeys, id };
|
|
120
120
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { retrieveAssetsProd };
|
|
2
2
|
import type { ViteManifest } from '../../../shared/ViteManifest.js';
|
|
3
3
|
import type { ClientDependency } from '../../../../shared/getPageFiles/analyzePageClientSide/ClientDependency.js';
|
|
4
|
-
declare function retrieveAssetsProd(clientDependencies: ClientDependency[],
|
|
4
|
+
declare function retrieveAssetsProd(clientDependencies: ClientDependency[], assetsManifest: ViteManifest, includeAssetsImportedByServer: boolean): string[];
|
|
@@ -2,9 +2,9 @@ export { retrieveAssetsProd };
|
|
|
2
2
|
import { assert, isNpmPackageImport } from '../../utils.js';
|
|
3
3
|
import { getManifestEntry } from './getManifestEntry.js';
|
|
4
4
|
import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
5
|
-
function retrieveAssetsProd(clientDependencies,
|
|
5
|
+
function retrieveAssetsProd(clientDependencies, assetsManifest, includeAssetsImportedByServer) {
|
|
6
6
|
let assetUrls = new Set();
|
|
7
|
-
assert(
|
|
7
|
+
assert(assetsManifest);
|
|
8
8
|
const visistedAssets = new Set();
|
|
9
9
|
clientDependencies.forEach(({ id, onlyAssets, eagerlyImported }) => {
|
|
10
10
|
if (eagerlyImported)
|
|
@@ -19,17 +19,17 @@ function retrieveAssetsProd(clientDependencies, clientManifest, includeAssetsImp
|
|
|
19
19
|
id = extractAssetsAddQuery(id);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
const { manifestKey } = getManifestEntry(id,
|
|
23
|
-
collectAssets(manifestKey, assetUrls, visistedAssets,
|
|
22
|
+
const { manifestKey } = getManifestEntry(id, assetsManifest);
|
|
23
|
+
collectAssets(manifestKey, assetUrls, visistedAssets, assetsManifest, onlyAssets);
|
|
24
24
|
});
|
|
25
|
-
collectSingleStyle(assetUrls,
|
|
25
|
+
collectSingleStyle(assetUrls, assetsManifest);
|
|
26
26
|
return Array.from(assetUrls);
|
|
27
27
|
}
|
|
28
|
-
function collectAssets(manifestKey, assetUrls, visistedAssets,
|
|
28
|
+
function collectAssets(manifestKey, assetUrls, visistedAssets, assetsManifest, onlyCollectStaticAssets) {
|
|
29
29
|
if (visistedAssets.has(manifestKey))
|
|
30
30
|
return;
|
|
31
31
|
visistedAssets.add(manifestKey);
|
|
32
|
-
const manifestEntry =
|
|
32
|
+
const manifestEntry = assetsManifest[manifestKey];
|
|
33
33
|
assert(manifestEntry, { manifestKey });
|
|
34
34
|
const { file } = manifestEntry;
|
|
35
35
|
if (!onlyCollectStaticAssets) {
|
|
@@ -37,9 +37,9 @@ function collectAssets(manifestKey, assetUrls, visistedAssets, manifest, onlyCol
|
|
|
37
37
|
}
|
|
38
38
|
const { imports = [], assets = [], css = [] } = manifestEntry;
|
|
39
39
|
for (const manifestKey of imports) {
|
|
40
|
-
const importManifestEntry =
|
|
40
|
+
const importManifestEntry = assetsManifest[manifestKey];
|
|
41
41
|
assert(importManifestEntry);
|
|
42
|
-
collectAssets(manifestKey, assetUrls, visistedAssets,
|
|
42
|
+
collectAssets(manifestKey, assetUrls, visistedAssets, assetsManifest, onlyCollectStaticAssets);
|
|
43
43
|
}
|
|
44
44
|
for (const cssAsset of css) {
|
|
45
45
|
assetUrls.add(`/${cssAsset}`);
|
|
@@ -49,9 +49,9 @@ function collectAssets(manifestKey, assetUrls, visistedAssets, manifest, onlyCol
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
// Support `config.build.cssCodeSplit: false`, see https://github.com/vikejs/vike/issues/644
|
|
52
|
-
function collectSingleStyle(assetUrls,
|
|
53
|
-
const style =
|
|
54
|
-
if (style && Object.values(
|
|
52
|
+
function collectSingleStyle(assetUrls, assetsManifest) {
|
|
53
|
+
const style = assetsManifest['style.css'];
|
|
54
|
+
if (style && Object.values(assetsManifest).filter((asset) => asset.file.endsWith('.css')).length === 1) {
|
|
55
55
|
assetUrls.add(`/${style.file}`);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -19,9 +19,9 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
19
19
|
assetUrls = await retrieveAssetsDev(clientDependencies, viteDevServer);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
const {
|
|
23
|
-
clientEntriesSrc = clientEntries.map((clientEntry) => resolveClientEntriesProd(clientEntry,
|
|
24
|
-
assetUrls = retrieveAssetsProd(clientDependencies,
|
|
22
|
+
const { assetsManifest } = globalContext;
|
|
23
|
+
clientEntriesSrc = clientEntries.map((clientEntry) => resolveClientEntriesProd(clientEntry, assetsManifest));
|
|
24
|
+
assetUrls = retrieveAssetsProd(clientDependencies, assetsManifest, pageContext._includeAssetsImportedByServer);
|
|
25
25
|
}
|
|
26
26
|
let pageAssets = [];
|
|
27
27
|
unique([...clientEntriesSrc, ...assetUrls]).forEach((src) => {
|
|
@@ -116,8 +116,8 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
116
116
|
assertPosixPath(filePath);
|
|
117
117
|
return filePath;
|
|
118
118
|
}
|
|
119
|
-
function resolveClientEntriesProd(clientEntry,
|
|
120
|
-
const { manifestEntry } = getManifestEntry(clientEntry,
|
|
119
|
+
function resolveClientEntriesProd(clientEntry, assetsManifest) {
|
|
120
|
+
const { manifestEntry } = getManifestEntry(clientEntry, assetsManifest);
|
|
121
121
|
assert(manifestEntry.isEntry || manifestEntry.isDynamicEntry || clientEntry.endsWith('.css'), { clientEntry });
|
|
122
122
|
let { file } = manifestEntry;
|
|
123
123
|
assert(!file.startsWith('/'));
|
|
@@ -3,8 +3,7 @@ export { logErrorHint };
|
|
|
3
3
|
export { isCjsEsmError };
|
|
4
4
|
export { isKnownError };
|
|
5
5
|
export { getHint };
|
|
6
|
-
import
|
|
7
|
-
import { assert, formatHintLog, isNotNullish, isObject, unique, joinEnglish } from '../utils.js';
|
|
6
|
+
import { assert, formatHintLog, isNotNullish, isObject, unique } from '../utils.js';
|
|
8
7
|
const knownErrors = [
|
|
9
8
|
{
|
|
10
9
|
errMsg: 'jsxDEV is not a function',
|
|
@@ -13,6 +12,13 @@ const knownErrors = [
|
|
|
13
12
|
{
|
|
14
13
|
errMsg: 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)',
|
|
15
14
|
link: 'https://vike.dev/broken-npm-package#react-invalid-component'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
// ```
|
|
18
|
+
// Error [RollupError]: Could not resolve "../dist/client/assets.json" from "renderer/+onRenderHtml.tsx"
|
|
19
|
+
// ```
|
|
20
|
+
errMsg: 'assets.json',
|
|
21
|
+
link: 'https://vike.dev/getGlobalContext'
|
|
16
22
|
}
|
|
17
23
|
];
|
|
18
24
|
function logErrorHint(error) {
|
|
@@ -31,15 +37,7 @@ function getHint(error) {
|
|
|
31
37
|
}
|
|
32
38
|
const res = isCjsEsmError(error);
|
|
33
39
|
if (res) {
|
|
34
|
-
const
|
|
35
|
-
const hint = [
|
|
36
|
-
'Error could be a CJS/ESM issue, consider ',
|
|
37
|
-
!packageNames || packageNames.length === 0
|
|
38
|
-
? 'using'
|
|
39
|
-
: `adding ${joinEnglish(packageNames.map((p) => pc.cyan(p)), 'or')} to`,
|
|
40
|
-
` ${pc.cyan('ssr.noExternal')}`,
|
|
41
|
-
', see https://vike.dev/broken-npm-package'
|
|
42
|
-
].join('');
|
|
40
|
+
const hint = 'The error seems to be a CJS/ESM issue, see https://vike.dev/broken-npm-package';
|
|
43
41
|
return hint;
|
|
44
42
|
}
|
|
45
43
|
return null;
|
|
@@ -70,6 +68,7 @@ function isCjsEsmError(error) {
|
|
|
70
68
|
packageNames.forEach((packageName) => {
|
|
71
69
|
assert(!['vite', 'vike'].includes(packageName));
|
|
72
70
|
});
|
|
71
|
+
// We don't use this anymore: we could return `true` instead. Shall we remove returning a list of npm packages?
|
|
73
72
|
return packageNames;
|
|
74
73
|
}
|
|
75
74
|
function normalizeRes(res) {
|
|
@@ -321,6 +321,9 @@ function normalizeUrl(pageContextInit, httpRequestId) {
|
|
|
321
321
|
if (disableUrlNormalization)
|
|
322
322
|
return null;
|
|
323
323
|
const { urlOriginal } = pageContextInit;
|
|
324
|
+
const { isPageContextRequest } = handlePageContextRequestUrl(urlOriginal);
|
|
325
|
+
if (isPageContextRequest)
|
|
326
|
+
return null;
|
|
324
327
|
const urlNormalized = normalizeUrlPathname(urlOriginal, trailingSlash, baseServer);
|
|
325
328
|
if (!urlNormalized)
|
|
326
329
|
return null;
|
|
@@ -75,6 +75,7 @@ type ConfigValueSource = {
|
|
|
75
75
|
valueIsImportedAtRuntime: boolean;
|
|
76
76
|
/** Whether the config value is a file path, for example config.client */
|
|
77
77
|
valueIsFilePath?: true;
|
|
78
|
+
valueIsDefinedByValueFile: boolean;
|
|
78
79
|
};
|
|
79
80
|
type DefinedAtFileFullInfo = DefinedAtFile & FilePath & {
|
|
80
81
|
fileExportName?: string;
|
|
@@ -6,8 +6,7 @@ export { serializeConfigValueImported };
|
|
|
6
6
|
// Both parsePageConfigs() parseConfigValuesImported() and are loaded on the client-side and server-side
|
|
7
7
|
import { assertIsNotProductionRuntime } from '../../../utils/assertIsNotProductionRuntime.js';
|
|
8
8
|
assertIsNotProductionRuntime();
|
|
9
|
-
import
|
|
10
|
-
import { assert, assertPosixPath } from '../../utils.js';
|
|
9
|
+
import { assert } from '../../utils.js';
|
|
11
10
|
import { generateEagerImport } from '../../../node/plugin/plugins/importUserCode/generateEagerImport.js';
|
|
12
11
|
function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
13
12
|
let whitespace = ' ';
|
|
@@ -23,13 +22,10 @@ function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
|
23
22
|
function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
|
|
24
23
|
assert(!configValueSource.valueIsFilePath);
|
|
25
24
|
assert(whitespace.replaceAll(' ', '').length === 0);
|
|
26
|
-
const { valueIsImportedAtRuntime, definedAt } = configValueSource;
|
|
25
|
+
const { valueIsImportedAtRuntime, valueIsDefinedByValueFile, definedAt } = configValueSource;
|
|
27
26
|
assert(valueIsImportedAtRuntime);
|
|
28
27
|
const { filePathAbsoluteVite, fileExportName } = definedAt;
|
|
29
|
-
|
|
30
|
-
const fileName = path.posix.basename(filePathAbsoluteVite);
|
|
31
|
-
const isValueFile = fileName.startsWith('+');
|
|
32
|
-
if (isValueFile)
|
|
28
|
+
if (valueIsDefinedByValueFile)
|
|
33
29
|
assert(fileExportName === undefined);
|
|
34
30
|
const { importName, importStatement } = generateEagerImport(filePathAbsoluteVite, varCounterContainer.varCounter++, fileExportName);
|
|
35
31
|
importStatements.push(importStatement);
|
|
@@ -37,8 +33,8 @@ function serializeConfigValueImported(configValueSource, configName, whitespace,
|
|
|
37
33
|
lines.push(` {`);
|
|
38
34
|
lines.push(` configName: '${configName}',`);
|
|
39
35
|
lines.push(` importPath: '${filePathAbsoluteVite}',`);
|
|
40
|
-
lines.push(` isValueFile: ${JSON.stringify(
|
|
41
|
-
if (
|
|
36
|
+
lines.push(` isValueFile: ${JSON.stringify(valueIsDefinedByValueFile)},`);
|
|
37
|
+
if (valueIsDefinedByValueFile) {
|
|
42
38
|
lines.push(` exportValues: ${importName},`);
|
|
43
39
|
}
|
|
44
40
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.163-commit-407cb5c";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.163-commit-407cb5c";
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
3
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
4
|
-
const PROJECT_VERSION = '0.4.
|
|
4
|
+
const PROJECT_VERSION = '0.4.163-commit-407cb5c';
|
|
5
5
|
const projectInfo = {
|
|
6
6
|
projectName: 'Vike',
|
|
7
7
|
projectVersion: PROJECT_VERSION
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.163-commit-407cb5c",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -169,6 +169,7 @@
|
|
|
169
169
|
"vike": "./node/cli/bin-entry.js"
|
|
170
170
|
},
|
|
171
171
|
"devDependencies": {
|
|
172
|
+
"@biomejs/biome": "^1.5.3",
|
|
172
173
|
"@brillout/import": "^0.2.3",
|
|
173
174
|
"@brillout/json-serializer": "^0.5.8",
|
|
174
175
|
"@brillout/picocolors": "^1.0.10",
|