vike 0.4.162-commit-421de1c → 0.4.163-commit-2305d5b
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/importBuild/index.js +2 -3
- 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/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +7 -4
- 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/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/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -1
|
@@ -11,6 +11,7 @@ const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
|
11
11
|
const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
13
|
const logErrorHint_js_1 = require("../../runtime/renderPage/logErrorHint.js");
|
|
14
|
+
const buildConfig_js_1 = require("./buildConfig.js");
|
|
14
15
|
let forceExit = false;
|
|
15
16
|
function autoFullBuild() {
|
|
16
17
|
let config;
|
|
@@ -64,10 +65,12 @@ async function triggerFullBuild(config, configVike, bundle) {
|
|
|
64
65
|
return; // already triggered
|
|
65
66
|
if (isDisabled(configVike))
|
|
66
67
|
return;
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
// Workaround for @vitejs/plugin-legacy
|
|
69
|
+
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
70
|
+
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
71
|
+
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
72
|
+
if (!bundle[buildConfig_js_1.manifestTempFile])
|
|
73
|
+
return;
|
|
71
74
|
const configFromCli = !(0, isViteCliCall_js_1.isViteCliCall)() ? null : (0, isViteCliCall_js_1.getViteConfigFromCli)();
|
|
72
75
|
const configInline = {
|
|
73
76
|
...configFromCli,
|
|
@@ -45,12 +45,11 @@ function getEntryCode(config, configVike) {
|
|
|
45
45
|
` import * as pageFiles from '${virtualFileImportUserCode_js_1.virtualFileIdImportUserCodeServer}';`,
|
|
46
46
|
` {`,
|
|
47
47
|
// We first set the values to a variable because of a Rollup bug, and this workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
48
|
-
` const
|
|
48
|
+
` const assetsManifest = ${ASSETS_MAP};`,
|
|
49
49
|
` const pluginManifest = ${JSON.stringify(vikeManifest, null, 2)};`,
|
|
50
50
|
' setImportBuildGetters({',
|
|
51
51
|
` pageFiles: () => pageFiles,`,
|
|
52
|
-
|
|
53
|
-
` clientManifest: () => clientManifest,`,
|
|
52
|
+
` getAssetsManifest: () => assetsManifest,`,
|
|
54
53
|
// TODO: rename pluginManifest -> vikeManifest
|
|
55
54
|
` pluginManifest: () => pluginManifest,`,
|
|
56
55
|
' });',
|
|
@@ -15,12 +15,12 @@ async function loadImportBuild(outDir) {
|
|
|
15
15
|
await (0, importServerEntry_js_1.importServerEntry)(outDir);
|
|
16
16
|
(0, utils_js_1.assert)(buildGetters.getters);
|
|
17
17
|
}
|
|
18
|
-
const [pageFiles,
|
|
18
|
+
const [pageFiles, assetsManifest, pluginManifest] = await Promise.all([
|
|
19
19
|
buildGetters.getters.pageFiles(),
|
|
20
|
-
buildGetters.getters.
|
|
20
|
+
buildGetters.getters.getAssetsManifest(),
|
|
21
21
|
buildGetters.getters.pluginManifest()
|
|
22
22
|
]);
|
|
23
|
-
const buildEntries = { pageFiles,
|
|
23
|
+
const buildEntries = { pageFiles, assetsManifest, pluginManifest };
|
|
24
24
|
return buildEntries;
|
|
25
25
|
}
|
|
26
26
|
exports.loadImportBuild = loadImportBuild;
|
|
@@ -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.getRuntimeManifest = exports.setGlobalContext_prerender = exports.setGlobalContext_viteDevServer = exports.getViteConfig = exports.getViteDevServer = exports.getGlobalContext = exports.initGlobalContext = void 0;
|
|
6
|
+
exports.getRuntimeManifest = exports.setGlobalContext_prerender = exports.setGlobalContext_viteDevServer = exports.getViteConfig = exports.getViteDevServer = exports.getGlobalContext = exports.initGlobalContext = exports.getGlobalContextAsync = exports.getGlobalContextSync = void 0;
|
|
7
7
|
const utils_js_1 = require("./utils.js");
|
|
8
8
|
const loadImportBuild_js_1 = require("./globalContext/loadImportBuild.js");
|
|
9
9
|
const getPageFiles_js_1 = require("../../shared/getPageFiles.js");
|
|
@@ -11,12 +11,52 @@ const assertPluginManifest_js_1 = require("../shared/assertPluginManifest.js");
|
|
|
11
11
|
const getConfigVike_js_1 = require("../shared/getConfigVike.js");
|
|
12
12
|
const assertRuntimeManifest_js_1 = require("../shared/assertRuntimeManifest.js");
|
|
13
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
|
-
|
|
14
|
+
let resolveGlobalContext;
|
|
15
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('globalContext.ts', {
|
|
16
|
+
globalContextPromise: new Promise((r) => (resolveGlobalContext = r))
|
|
17
|
+
});
|
|
15
18
|
function getGlobalContext() {
|
|
16
19
|
(0, utils_js_1.assert)(globalObject.globalContext);
|
|
17
20
|
return globalObject.globalContext;
|
|
18
21
|
}
|
|
19
22
|
exports.getGlobalContext = getGlobalContext;
|
|
23
|
+
/** @experimental https://vike.dev/getGlobalContext */
|
|
24
|
+
function getGlobalContextSync() {
|
|
25
|
+
(0, utils_js_1.assertUsage)(globalObject.globalContext, "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContextAsync() instead.");
|
|
26
|
+
return makePublic(globalObject.globalContext);
|
|
27
|
+
}
|
|
28
|
+
exports.getGlobalContextSync = getGlobalContextSync;
|
|
29
|
+
/** @experimental https://vike.dev/getGlobalContext */
|
|
30
|
+
async function getGlobalContextAsync() {
|
|
31
|
+
await globalObject.globalContextPromise;
|
|
32
|
+
(0, utils_js_1.assert)(globalObject.globalContext);
|
|
33
|
+
return makePublic(globalObject.globalContext);
|
|
34
|
+
}
|
|
35
|
+
exports.getGlobalContextAsync = getGlobalContextAsync;
|
|
36
|
+
function makePublic(globalContext) {
|
|
37
|
+
const globalContextPublic = {
|
|
38
|
+
assetsManifest: globalContext.assetsManifest
|
|
39
|
+
};
|
|
40
|
+
// Add internals (and prepended _ prefix to their keys)
|
|
41
|
+
{
|
|
42
|
+
const publicKeys = Object.keys(globalContextPublic);
|
|
43
|
+
(0, utils_js_1.objectKeys)(globalContext)
|
|
44
|
+
.filter((key) => !publicKeys.includes(key))
|
|
45
|
+
.forEach((key) => {
|
|
46
|
+
const keyPublic = `_${key}`;
|
|
47
|
+
Object.defineProperty(globalContextPublic, keyPublic, {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get() {
|
|
50
|
+
(0, utils_js_1.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.`, {
|
|
51
|
+
onlyOnce: true
|
|
52
|
+
});
|
|
53
|
+
return globalContext[key];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return globalContextPublic;
|
|
59
|
+
}
|
|
20
60
|
function setGlobalContext_viteDevServer(viteDevServer) {
|
|
21
61
|
if (globalObject.viteDevServer)
|
|
22
62
|
return;
|
|
@@ -55,7 +95,7 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
55
95
|
globalObject.globalContext = {
|
|
56
96
|
isProduction: false,
|
|
57
97
|
isPrerendering: false,
|
|
58
|
-
|
|
98
|
+
assetsManifest: null,
|
|
59
99
|
pluginManifest: null,
|
|
60
100
|
viteDevServer,
|
|
61
101
|
viteConfig,
|
|
@@ -70,13 +110,13 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
70
110
|
else {
|
|
71
111
|
const buildEntries = await (0, loadImportBuild_js_1.loadImportBuild)(outDir);
|
|
72
112
|
assertBuildEntries(buildEntries, isPrerendering ?? false);
|
|
73
|
-
const { pageFiles,
|
|
113
|
+
const { pageFiles, assetsManifest, pluginManifest } = buildEntries;
|
|
74
114
|
(0, getPageFiles_js_1.setPageFiles)(pageFiles);
|
|
75
|
-
assertViteManifest(
|
|
115
|
+
assertViteManifest(assetsManifest);
|
|
76
116
|
(0, assertPluginManifest_js_1.assertPluginManifest)(pluginManifest);
|
|
77
117
|
const globalContext = {
|
|
78
118
|
isProduction: true,
|
|
79
|
-
|
|
119
|
+
assetsManifest,
|
|
80
120
|
pluginManifest,
|
|
81
121
|
viteDevServer: null,
|
|
82
122
|
baseServer: pluginManifest.baseServer,
|
|
@@ -104,6 +144,7 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
104
144
|
globalObject.globalContext = globalContext;
|
|
105
145
|
}
|
|
106
146
|
}
|
|
147
|
+
resolveGlobalContext(globalObject.globalContext);
|
|
107
148
|
}
|
|
108
149
|
exports.initGlobalContext = initGlobalContext;
|
|
109
150
|
function getRuntimeManifest(configVike) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPageRenderer = exports._injectAssets = exports.version = exports.stampPipe = exports.pipeStream = exports.pipeNodeStream = exports.pipeWebStream = exports.dangerouslySkipEscape = exports.escapeInject = exports.renderPage = void 0;
|
|
3
|
+
exports.createPageRenderer = exports._injectAssets = exports.getGlobalContextAsync = exports.getGlobalContextSync = exports.version = exports.stampPipe = exports.pipeStream = exports.pipeNodeStream = exports.pipeWebStream = exports.dangerouslySkipEscape = exports.escapeInject = exports.renderPage = void 0;
|
|
4
4
|
var renderPage_js_1 = require("./renderPage.js");
|
|
5
5
|
Object.defineProperty(exports, "renderPage", { enumerable: true, get: function () { return renderPage_js_1.renderPage; } });
|
|
6
6
|
var renderHtml_js_1 = require("./html/renderHtml.js");
|
|
@@ -13,6 +13,9 @@ Object.defineProperty(exports, "pipeStream", { enumerable: true, get: function (
|
|
|
13
13
|
Object.defineProperty(exports, "stampPipe", { enumerable: true, get: function () { return stream_js_1.stampPipe; } });
|
|
14
14
|
var utils_js_1 = require("./utils.js");
|
|
15
15
|
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return utils_js_1.PROJECT_VERSION; } });
|
|
16
|
+
var globalContext_js_1 = require("./globalContext.js");
|
|
17
|
+
Object.defineProperty(exports, "getGlobalContextSync", { enumerable: true, get: function () { return globalContext_js_1.getGlobalContextSync; } });
|
|
18
|
+
Object.defineProperty(exports, "getGlobalContextAsync", { enumerable: true, get: function () { return globalContext_js_1.getGlobalContextAsync; } });
|
|
16
19
|
// TODO/v1-release: remove
|
|
17
20
|
var injectAssets__public_js_1 = require("./html/injectAssets/injectAssets__public.js");
|
|
18
21
|
Object.defineProperty(exports, "_injectAssets", { enumerable: true, get: function () { return injectAssets__public_js_1.injectAssets__public; } });
|
|
@@ -5,13 +5,13 @@ const utils_js_1 = require("../../utils.js");
|
|
|
5
5
|
const assertClientEntryId_js_1 = require("./assertClientEntryId.js");
|
|
6
6
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
7
7
|
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
8
|
-
function getManifestEntry(id,
|
|
8
|
+
function getManifestEntry(id, assetsManifest) {
|
|
9
9
|
(0, assertClientEntryId_js_1.assertClientEntryId)(id);
|
|
10
|
-
const debugInfo = getDebugInfo(id,
|
|
10
|
+
const debugInfo = getDebugInfo(id, assetsManifest);
|
|
11
11
|
// Vike client entry
|
|
12
12
|
if (id.startsWith('@@vike/')) {
|
|
13
13
|
const manifestKeyEnd = (0, utils_js_1.slice)(id, '@@vike'.length, 0);
|
|
14
|
-
const { manifestKey, manifestEntry } = findEntryWithKeyEnd(manifestKeyEnd,
|
|
14
|
+
const { manifestKey, manifestEntry } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id);
|
|
15
15
|
(0, utils_js_1.assert)(manifestEntry && manifestKey, debugInfo);
|
|
16
16
|
return { manifestEntry, manifestKey };
|
|
17
17
|
}
|
|
@@ -19,7 +19,7 @@ function getManifestEntry(id, clientManifest) {
|
|
|
19
19
|
if ((0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id)) {
|
|
20
20
|
{
|
|
21
21
|
const manifestKey = id;
|
|
22
|
-
const manifestEntry =
|
|
22
|
+
const manifestEntry = assetsManifest[manifestKey];
|
|
23
23
|
if (manifestEntry) {
|
|
24
24
|
return { manifestEntry, manifestKey };
|
|
25
25
|
}
|
|
@@ -32,20 +32,20 @@ function getManifestEntry(id, clientManifest) {
|
|
|
32
32
|
// - This workaround was implemented to support Vitest runnung /tests/*
|
|
33
33
|
// - I don't know whether end users actually need this workaround? (I'm not sure what the bug actually is.)
|
|
34
34
|
const manifestKeyEnd = id;
|
|
35
|
-
const { manifestKey, manifestEntry } = getEntryWithKeyEnd(manifestKeyEnd,
|
|
35
|
+
const { manifestKey, manifestEntry } = getEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id);
|
|
36
36
|
(0, utils_js_1.assert)(manifestEntry, debugInfo);
|
|
37
37
|
return { manifestEntry, manifestKey };
|
|
38
38
|
}
|
|
39
39
|
// User files
|
|
40
40
|
if (id.startsWith('/')) {
|
|
41
41
|
const manifestKey = id.slice(1);
|
|
42
|
-
let manifestEntry =
|
|
42
|
+
let manifestEntry = assetsManifest[manifestKey];
|
|
43
43
|
(0, utils_js_1.assert)(manifestEntry, debugInfo);
|
|
44
44
|
return { manifestEntry, manifestKey };
|
|
45
45
|
}
|
|
46
46
|
// npm package import
|
|
47
47
|
if ((0, utils_js_1.isNpmPackageImport)(id)) {
|
|
48
|
-
const found = Object.entries(
|
|
48
|
+
const found = Object.entries(assetsManifest).find(([, e]) => e.name === (0, prependEntriesDir_js_1.prependEntriesDir)(id));
|
|
49
49
|
(0, utils_js_1.assert)(found);
|
|
50
50
|
const [manifestKey, manifestEntry] = found;
|
|
51
51
|
return { manifestEntry, manifestKey };
|
|
@@ -57,7 +57,7 @@ function getManifestEntry(id, clientManifest) {
|
|
|
57
57
|
(0, utils_js_1.assert)(!manifestKeyEnd.startsWith('/'), debugInfo);
|
|
58
58
|
manifestKeyEnd = '/' + manifestKeyEnd;
|
|
59
59
|
{
|
|
60
|
-
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd,
|
|
60
|
+
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id);
|
|
61
61
|
if (manifestEntry) {
|
|
62
62
|
(0, utils_js_1.assert)(manifestKey, debugInfo);
|
|
63
63
|
return { manifestEntry, manifestKey };
|
|
@@ -71,7 +71,7 @@ function getManifestEntry(id, clientManifest) {
|
|
|
71
71
|
(0, utils_js_1.assert)(manifestKeyEnd.startsWith('/'), debugInfo);
|
|
72
72
|
}
|
|
73
73
|
{
|
|
74
|
-
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd,
|
|
74
|
+
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id);
|
|
75
75
|
if (manifestEntry) {
|
|
76
76
|
(0, utils_js_1.assert)(manifestKey, debugInfo);
|
|
77
77
|
return { manifestEntry, manifestKey };
|
|
@@ -82,11 +82,11 @@ function getManifestEntry(id, clientManifest) {
|
|
|
82
82
|
(0, utils_js_1.assert)(false, debugInfo);
|
|
83
83
|
}
|
|
84
84
|
exports.getManifestEntry = getManifestEntry;
|
|
85
|
-
function findEntryWithKeyEnd(manifestKeyEnd,
|
|
86
|
-
const debugInfo = getDebugInfo(id,
|
|
85
|
+
function findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id) {
|
|
86
|
+
const debugInfo = getDebugInfo(id, assetsManifest, manifestKeyEnd);
|
|
87
87
|
(0, utils_js_1.assert)(manifestKeyEnd.startsWith('/'), debugInfo);
|
|
88
88
|
const manifestKeys = [];
|
|
89
|
-
for (const manifestKey in
|
|
89
|
+
for (const manifestKey in assetsManifest) {
|
|
90
90
|
if (manifestKey.endsWith(manifestKeyEnd)) {
|
|
91
91
|
manifestKeys.push(manifestKey);
|
|
92
92
|
}
|
|
@@ -97,13 +97,13 @@ function findEntryWithKeyEnd(manifestKeyEnd, clientManifest, id) {
|
|
|
97
97
|
if (!manifestKey) {
|
|
98
98
|
return { manifestEntry: null, manifestKey: null };
|
|
99
99
|
}
|
|
100
|
-
const manifestEntry =
|
|
100
|
+
const manifestEntry = assetsManifest[manifestKey];
|
|
101
101
|
return { manifestEntry, manifestKey };
|
|
102
102
|
}
|
|
103
|
-
function getEntryWithKeyEnd(manifestKeyEnd,
|
|
104
|
-
const debugInfo = getDebugInfo(id,
|
|
103
|
+
function getEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id) {
|
|
104
|
+
const debugInfo = getDebugInfo(id, assetsManifest, manifestKeyEnd);
|
|
105
105
|
const manifestKeys = [];
|
|
106
|
-
for (const manifestKey in
|
|
106
|
+
for (const manifestKey in assetsManifest) {
|
|
107
107
|
if (manifestKey.endsWith(manifestKeyEnd)) {
|
|
108
108
|
manifestKeys.push(manifestKey);
|
|
109
109
|
}
|
|
@@ -113,11 +113,11 @@ function getEntryWithKeyEnd(manifestKeyEnd, clientManifest, id) {
|
|
|
113
113
|
if (!manifestKey) {
|
|
114
114
|
return { manifestEntry: null, manifestKey: null };
|
|
115
115
|
}
|
|
116
|
-
const manifestEntry =
|
|
116
|
+
const manifestEntry = assetsManifest[manifestKey];
|
|
117
117
|
return { manifestEntry, manifestKey };
|
|
118
118
|
}
|
|
119
|
-
function getDebugInfo(id,
|
|
120
|
-
const manifestKeys = Object.keys(
|
|
119
|
+
function getDebugInfo(id, assetsManifest, manifestKeyEnd) {
|
|
120
|
+
const manifestKeys = Object.keys(assetsManifest);
|
|
121
121
|
if (manifestKeyEnd === undefined) {
|
|
122
122
|
return { manifestKeys, id };
|
|
123
123
|
}
|
|
@@ -4,9 +4,9 @@ exports.retrieveAssetsProd = void 0;
|
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
5
|
const getManifestEntry_js_1 = require("./getManifestEntry.js");
|
|
6
6
|
const extractAssetsQuery_js_1 = require("../../../shared/extractAssetsQuery.js");
|
|
7
|
-
function retrieveAssetsProd(clientDependencies,
|
|
7
|
+
function retrieveAssetsProd(clientDependencies, assetsManifest, includeAssetsImportedByServer) {
|
|
8
8
|
let assetUrls = new Set();
|
|
9
|
-
(0, utils_js_1.assert)(
|
|
9
|
+
(0, utils_js_1.assert)(assetsManifest);
|
|
10
10
|
const visistedAssets = new Set();
|
|
11
11
|
clientDependencies.forEach(({ id, onlyAssets, eagerlyImported }) => {
|
|
12
12
|
if (eagerlyImported)
|
|
@@ -21,18 +21,18 @@ function retrieveAssetsProd(clientDependencies, clientManifest, includeAssetsImp
|
|
|
21
21
|
id = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(id);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
const { manifestKey } = (0, getManifestEntry_js_1.getManifestEntry)(id,
|
|
25
|
-
collectAssets(manifestKey, assetUrls, visistedAssets,
|
|
24
|
+
const { manifestKey } = (0, getManifestEntry_js_1.getManifestEntry)(id, assetsManifest);
|
|
25
|
+
collectAssets(manifestKey, assetUrls, visistedAssets, assetsManifest, onlyAssets);
|
|
26
26
|
});
|
|
27
|
-
collectSingleStyle(assetUrls,
|
|
27
|
+
collectSingleStyle(assetUrls, assetsManifest);
|
|
28
28
|
return Array.from(assetUrls);
|
|
29
29
|
}
|
|
30
30
|
exports.retrieveAssetsProd = retrieveAssetsProd;
|
|
31
|
-
function collectAssets(manifestKey, assetUrls, visistedAssets,
|
|
31
|
+
function collectAssets(manifestKey, assetUrls, visistedAssets, assetsManifest, onlyCollectStaticAssets) {
|
|
32
32
|
if (visistedAssets.has(manifestKey))
|
|
33
33
|
return;
|
|
34
34
|
visistedAssets.add(manifestKey);
|
|
35
|
-
const manifestEntry =
|
|
35
|
+
const manifestEntry = assetsManifest[manifestKey];
|
|
36
36
|
(0, utils_js_1.assert)(manifestEntry, { manifestKey });
|
|
37
37
|
const { file } = manifestEntry;
|
|
38
38
|
if (!onlyCollectStaticAssets) {
|
|
@@ -40,9 +40,9 @@ function collectAssets(manifestKey, assetUrls, visistedAssets, manifest, onlyCol
|
|
|
40
40
|
}
|
|
41
41
|
const { imports = [], assets = [], css = [] } = manifestEntry;
|
|
42
42
|
for (const manifestKey of imports) {
|
|
43
|
-
const importManifestEntry =
|
|
43
|
+
const importManifestEntry = assetsManifest[manifestKey];
|
|
44
44
|
(0, utils_js_1.assert)(importManifestEntry);
|
|
45
|
-
collectAssets(manifestKey, assetUrls, visistedAssets,
|
|
45
|
+
collectAssets(manifestKey, assetUrls, visistedAssets, assetsManifest, onlyCollectStaticAssets);
|
|
46
46
|
}
|
|
47
47
|
for (const cssAsset of css) {
|
|
48
48
|
assetUrls.add(`/${cssAsset}`);
|
|
@@ -52,9 +52,9 @@ function collectAssets(manifestKey, assetUrls, visistedAssets, manifest, onlyCol
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
// Support `config.build.cssCodeSplit: false`, see https://github.com/vikejs/vike/issues/644
|
|
55
|
-
function collectSingleStyle(assetUrls,
|
|
56
|
-
const style =
|
|
57
|
-
if (style && Object.values(
|
|
55
|
+
function collectSingleStyle(assetUrls, assetsManifest) {
|
|
56
|
+
const style = assetsManifest['style.css'];
|
|
57
|
+
if (style && Object.values(assetsManifest).filter((asset) => asset.file.endsWith('.css')).length === 1) {
|
|
58
58
|
assetUrls.add(`/${style.file}`);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -21,9 +21,9 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
21
21
|
assetUrls = await (0, retrieveAssetsDev_js_1.retrieveAssetsDev)(clientDependencies, viteDevServer);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
const {
|
|
25
|
-
clientEntriesSrc = clientEntries.map((clientEntry) => resolveClientEntriesProd(clientEntry,
|
|
26
|
-
assetUrls = (0, retrieveAssetsProd_js_1.retrieveAssetsProd)(clientDependencies,
|
|
24
|
+
const { assetsManifest } = globalContext;
|
|
25
|
+
clientEntriesSrc = clientEntries.map((clientEntry) => resolveClientEntriesProd(clientEntry, assetsManifest));
|
|
26
|
+
assetUrls = (0, retrieveAssetsProd_js_1.retrieveAssetsProd)(clientDependencies, assetsManifest, pageContext._includeAssetsImportedByServer);
|
|
27
27
|
}
|
|
28
28
|
let pageAssets = [];
|
|
29
29
|
(0, utils_js_1.unique)([...clientEntriesSrc, ...assetUrls]).forEach((src) => {
|
|
@@ -119,8 +119,8 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
119
119
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
120
120
|
return filePath;
|
|
121
121
|
}
|
|
122
|
-
function resolveClientEntriesProd(clientEntry,
|
|
123
|
-
const { manifestEntry } = (0, getManifestEntry_js_1.getManifestEntry)(clientEntry,
|
|
122
|
+
function resolveClientEntriesProd(clientEntry, assetsManifest) {
|
|
123
|
+
const { manifestEntry } = (0, getManifestEntry_js_1.getManifestEntry)(clientEntry, assetsManifest);
|
|
124
124
|
(0, utils_js_1.assert)(manifestEntry.isEntry || manifestEntry.isDynamicEntry || clientEntry.endsWith('.css'), { clientEntry });
|
|
125
125
|
let { file } = manifestEntry;
|
|
126
126
|
(0, utils_js_1.assert)(!file.startsWith('/'));
|
|
@@ -1,10 +1,6 @@
|
|
|
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.getHint = exports.isKnownError = exports.isCjsEsmError = exports.logErrorHint = void 0;
|
|
7
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
4
|
const utils_js_1 = require("../utils.js");
|
|
9
5
|
const knownErrors = [
|
|
10
6
|
{
|
|
@@ -14,6 +10,13 @@ const knownErrors = [
|
|
|
14
10
|
{
|
|
15
11
|
errMsg: 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)',
|
|
16
12
|
link: 'https://vike.dev/broken-npm-package#react-invalid-component'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
// ```
|
|
16
|
+
// Error [RollupError]: Could not resolve "../dist/client/assets.json" from "renderer/+onRenderHtml.tsx"
|
|
17
|
+
// ```
|
|
18
|
+
errMsg: 'assets.json',
|
|
19
|
+
link: 'https://vike.dev/getGlobalContext'
|
|
17
20
|
}
|
|
18
21
|
];
|
|
19
22
|
function logErrorHint(error) {
|
|
@@ -33,15 +36,7 @@ function getHint(error) {
|
|
|
33
36
|
}
|
|
34
37
|
const res = isCjsEsmError(error);
|
|
35
38
|
if (res) {
|
|
36
|
-
const
|
|
37
|
-
const hint = [
|
|
38
|
-
'Error could be a CJS/ESM issue, consider ',
|
|
39
|
-
!packageNames || packageNames.length === 0
|
|
40
|
-
? 'using'
|
|
41
|
-
: `adding ${(0, utils_js_1.joinEnglish)(packageNames.map((p) => picocolors_1.default.cyan(p)), 'or')} to`,
|
|
42
|
-
` ${picocolors_1.default.cyan('ssr.noExternal')}`,
|
|
43
|
-
', see https://vike.dev/broken-npm-package'
|
|
44
|
-
].join('');
|
|
39
|
+
const hint = 'The error seems to be a CJS/ESM issue, see https://vike.dev/broken-npm-package';
|
|
45
40
|
return hint;
|
|
46
41
|
}
|
|
47
42
|
return null;
|
|
@@ -74,6 +69,7 @@ function isCjsEsmError(error) {
|
|
|
74
69
|
packageNames.forEach((packageName) => {
|
|
75
70
|
(0, utils_js_1.assert)(!['vite', 'vike'].includes(packageName));
|
|
76
71
|
});
|
|
72
|
+
// We don't use this anymore: we could return `true` instead. Shall we remove returning a list of npm packages?
|
|
77
73
|
return packageNames;
|
|
78
74
|
}
|
|
79
75
|
exports.isCjsEsmError = isCjsEsmError;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
4
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
5
|
-
const PROJECT_VERSION = '0.4.
|
|
5
|
+
const PROJECT_VERSION = '0.4.163-commit-2305d5b';
|
|
6
6
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
7
7
|
const projectInfo = {
|
|
8
8
|
projectName: 'Vike',
|
|
@@ -6,6 +6,7 @@ import { getConfigVike } from '../../shared/getConfigVike.js';
|
|
|
6
6
|
import { isViteCliCall, getViteConfigFromCli } from '../shared/isViteCliCall.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
import { logErrorHint } from '../../runtime/renderPage/logErrorHint.js';
|
|
9
|
+
import { manifestTempFile } from './buildConfig.js';
|
|
9
10
|
let forceExit = false;
|
|
10
11
|
function autoFullBuild() {
|
|
11
12
|
let config;
|
|
@@ -58,10 +59,12 @@ async function triggerFullBuild(config, configVike, bundle) {
|
|
|
58
59
|
return; // already triggered
|
|
59
60
|
if (isDisabled(configVike))
|
|
60
61
|
return;
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
// Workaround for @vitejs/plugin-legacy
|
|
63
|
+
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
64
|
+
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
65
|
+
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
66
|
+
if (!bundle[manifestTempFile])
|
|
67
|
+
return;
|
|
65
68
|
const configFromCli = !isViteCliCall() ? null : getViteConfigFromCli();
|
|
66
69
|
const configInline = {
|
|
67
70
|
...configFromCli,
|
|
@@ -40,12 +40,11 @@ function getEntryCode(config, configVike) {
|
|
|
40
40
|
` import * as pageFiles from '${virtualFileIdImportUserCodeServer}';`,
|
|
41
41
|
` {`,
|
|
42
42
|
// We first set the values to a variable because of a Rollup bug, and this workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
43
|
-
` const
|
|
43
|
+
` const assetsManifest = ${ASSETS_MAP};`,
|
|
44
44
|
` const pluginManifest = ${JSON.stringify(vikeManifest, null, 2)};`,
|
|
45
45
|
' setImportBuildGetters({',
|
|
46
46
|
` pageFiles: () => pageFiles,`,
|
|
47
|
-
|
|
48
|
-
` clientManifest: () => clientManifest,`,
|
|
47
|
+
` getAssetsManifest: () => assetsManifest,`,
|
|
49
48
|
// TODO: rename pluginManifest -> vikeManifest
|
|
50
49
|
` pluginManifest: () => pluginManifest,`,
|
|
51
50
|
' });',
|
|
@@ -3,7 +3,7 @@ export { reloadVikeConfig };
|
|
|
3
3
|
export { vikeConfigDependencies };
|
|
4
4
|
export { isVikeConfigFile };
|
|
5
5
|
export { isV1Design };
|
|
6
|
-
export type {
|
|
6
|
+
export type { VikeConfigObject };
|
|
7
7
|
export type { InterfaceValueFile };
|
|
8
8
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime, FilePathResolved } from '../../../../../shared/page-configs/PageConfig.js';
|
|
9
9
|
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
@@ -21,13 +21,13 @@ type InterfaceValueFile = InterfaceFileCommons & {
|
|
|
21
21
|
configName: string;
|
|
22
22
|
};
|
|
23
23
|
type ConfigName = string;
|
|
24
|
-
type
|
|
24
|
+
type VikeConfigObject = {
|
|
25
25
|
pageConfigs: PageConfigBuildTime[];
|
|
26
26
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
27
27
|
globalVikeConfig: Record<string, unknown>;
|
|
28
28
|
};
|
|
29
29
|
declare const vikeConfigDependencies: Set<string>;
|
|
30
30
|
declare function reloadVikeConfig(userRootDir: string, outDirRoot: string): void;
|
|
31
|
-
declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, tolerateInvalidConfig?: boolean): Promise<
|
|
31
|
+
declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, tolerateInvalidConfig?: boolean): Promise<VikeConfigObject>;
|
|
32
32
|
declare function isV1Design(config: ResolvedConfig, isDev: boolean): Promise<boolean>;
|
|
33
33
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
@@ -2,13 +2,13 @@ export { loadImportBuild };
|
|
|
2
2
|
export { setImportBuildGetters };
|
|
3
3
|
type BuildGetters = null | {
|
|
4
4
|
pageFiles: () => Promise<Record<string, unknown>>;
|
|
5
|
-
|
|
5
|
+
getAssetsManifest: () => Promise<Record<string, unknown>>;
|
|
6
6
|
pluginManifest: () => Promise<Record<string, unknown>>;
|
|
7
7
|
};
|
|
8
8
|
declare function setImportBuildGetters(getters: BuildGetters): void;
|
|
9
9
|
declare function loadImportBuild(outDir?: string): Promise<{
|
|
10
10
|
pageFiles: Record<string, unknown>;
|
|
11
|
-
|
|
11
|
+
assetsManifest: Record<string, unknown>;
|
|
12
12
|
pluginManifest: Record<string, unknown>;
|
|
13
13
|
}>;
|
|
14
14
|
declare global {
|
|
@@ -13,11 +13,11 @@ async function loadImportBuild(outDir) {
|
|
|
13
13
|
await importServerEntry(outDir);
|
|
14
14
|
assert(buildGetters.getters);
|
|
15
15
|
}
|
|
16
|
-
const [pageFiles,
|
|
16
|
+
const [pageFiles, assetsManifest, pluginManifest] = await Promise.all([
|
|
17
17
|
buildGetters.getters.pageFiles(),
|
|
18
|
-
buildGetters.getters.
|
|
18
|
+
buildGetters.getters.getAssetsManifest(),
|
|
19
19
|
buildGetters.getters.pluginManifest()
|
|
20
20
|
]);
|
|
21
|
-
const buildEntries = { pageFiles,
|
|
21
|
+
const buildEntries = { pageFiles, assetsManifest, pluginManifest };
|
|
22
22
|
return buildEntries;
|
|
23
23
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { getGlobalContextSync };
|
|
2
|
+
export { getGlobalContextAsync };
|
|
1
3
|
export { initGlobalContext };
|
|
2
4
|
export { getGlobalContext };
|
|
3
5
|
export { getViteDevServer };
|
|
@@ -10,6 +12,9 @@ import type { ResolvedConfig, ViteDevServer } from 'vite';
|
|
|
10
12
|
import { PluginManifest } from '../shared/assertPluginManifest.js';
|
|
11
13
|
import type { ConfigVikeResolved } from '../../shared/ConfigVike.js';
|
|
12
14
|
import { type RuntimeManifest } from '../shared/assertRuntimeManifest.js';
|
|
15
|
+
type GlobalContextPublic = {
|
|
16
|
+
assetsManifest: null | ViteManifest;
|
|
17
|
+
};
|
|
13
18
|
type GlobalContext = {
|
|
14
19
|
baseServer: string;
|
|
15
20
|
baseAssets: null | string;
|
|
@@ -22,11 +27,11 @@ type GlobalContext = {
|
|
|
22
27
|
isPrerendering: false;
|
|
23
28
|
viteConfig: ResolvedConfig;
|
|
24
29
|
viteDevServer: ViteDevServer;
|
|
25
|
-
|
|
30
|
+
assetsManifest: null;
|
|
26
31
|
pluginManifest: null;
|
|
27
32
|
} | ({
|
|
28
33
|
isProduction: true;
|
|
29
|
-
|
|
34
|
+
assetsManifest: ViteManifest;
|
|
30
35
|
pluginManifest: PluginManifest;
|
|
31
36
|
viteDevServer: null;
|
|
32
37
|
} & ({
|
|
@@ -37,6 +42,10 @@ type GlobalContext = {
|
|
|
37
42
|
viteConfig: ResolvedConfig;
|
|
38
43
|
})));
|
|
39
44
|
declare function getGlobalContext(): GlobalContext;
|
|
45
|
+
/** @experimental https://vike.dev/getGlobalContext */
|
|
46
|
+
declare function getGlobalContextSync(): GlobalContextPublic;
|
|
47
|
+
/** @experimental https://vike.dev/getGlobalContext */
|
|
48
|
+
declare function getGlobalContextAsync(): Promise<GlobalContextPublic>;
|
|
40
49
|
declare function setGlobalContext_viteDevServer(viteDevServer: ViteDevServer): void;
|
|
41
50
|
declare function getViteDevServer(): ViteDevServer | null;
|
|
42
51
|
declare function setGlobalContext_prerender(viteConfig: ResolvedConfig): void;
|
|
@@ -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) {
|
|
@@ -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-2305d5b";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.163-commit-2305d5b";
|
|
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-2305d5b';
|
|
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-2305d5b",
|
|
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",
|