vike 0.4.205 → 0.4.207
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/__internal/index.js +13 -2
- package/dist/cjs/node/plugin/index.js +6 -7
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +41 -0
- package/dist/cjs/node/plugin/plugins/buildConfig.js +5 -0
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +5 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/node/shared/utils.js +0 -1
- package/dist/cjs/node/shared/virtual-files/virtualFileImportUserCode.js +2 -1
- package/dist/cjs/node/shared/virtual-files/virtualFilePageConfigValuesAll.js +2 -1
- package/dist/cjs/{utils → node/shared}/virtual-files.js +10 -5
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +18 -27
- package/dist/cjs/utils/isEqualStringList.js +13 -0
- package/dist/cjs/utils/path-shim.js +5 -0
- package/dist/esm/__internal/index.d.ts +2 -7
- package/dist/esm/__internal/index.js +14 -3
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +1 -0
- package/dist/esm/node/plugin/index.js +6 -7
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +6 -0
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +42 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +6 -1
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -1
- package/dist/esm/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/node/shared/utils.d.ts +0 -1
- package/dist/esm/node/shared/utils.js +0 -1
- package/dist/esm/node/shared/virtual-files/virtualFileImportUserCode.js +2 -1
- package/dist/esm/node/shared/virtual-files/virtualFilePageConfigValuesAll.js +2 -1
- package/dist/esm/{utils → node/shared}/virtual-files.js +4 -2
- package/dist/esm/shared/page-configs/Config.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +18 -27
- package/dist/esm/utils/isEqualStringList.d.ts +3 -0
- package/dist/esm/utils/isEqualStringList.js +11 -0
- package/dist/esm/utils/path-shim.js +5 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +2 -2
- /package/dist/esm/{utils → node/shared}/virtual-files.d.ts +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.route = route;
|
|
4
4
|
exports.getPagesAndRoutes = getPagesAndRoutes;
|
|
5
|
-
exports.
|
|
5
|
+
exports.getMiddlewares = getMiddlewares;
|
|
6
6
|
const index_js_1 = require("../shared/route/index.js");
|
|
7
7
|
const getPageFiles_js_1 = require("../shared/getPageFiles.js");
|
|
8
8
|
const globalContext_js_1 = require("../node/runtime/globalContext.js");
|
|
@@ -27,7 +27,18 @@ async function getPagesAndRoutes() {
|
|
|
27
27
|
allPageIds
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
// TODO:
|
|
30
|
+
// TODO/eventually:
|
|
31
|
+
// - Remove the need for `isProduction` after Vike's CLI is implemented
|
|
32
|
+
// - Remove it in favor of https://vike.dev/getGlobalContext
|
|
33
|
+
async function getMiddlewares() {
|
|
34
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
35
|
+
const { pageConfigs } = await getPageFilesAllSafe(isProduction);
|
|
36
|
+
const middlewares = pageConfigs[0].configValues.middleware.value.flat(Infinity);
|
|
37
|
+
return middlewares;
|
|
38
|
+
}
|
|
39
|
+
// TODO/eventually:
|
|
40
|
+
// - Make it cleaner once the internal refactoring about global configs is done.
|
|
41
|
+
// - Remove it in favor of https://vike.dev/getGlobalContext
|
|
31
42
|
// Demo usage: https://github.com/vikejs/vike/pull/1823
|
|
32
43
|
async function getPageFilesAllSafe(isProduction) {
|
|
33
44
|
await (0, globalContext_js_1.initGlobalContext_getGlobalContextAsync)(isProduction);
|
|
@@ -62,13 +62,6 @@ function plugin(vikeConfig) {
|
|
|
62
62
|
];
|
|
63
63
|
return plugins;
|
|
64
64
|
}
|
|
65
|
-
// Enable `const vike = require('vike/plugin')`.
|
|
66
|
-
// - This lives at the end of the file to ensure it happens after all assignments to `exports`.
|
|
67
|
-
// - This is only used for the CJS build; we wrap it in a try-catch for the ESM build.
|
|
68
|
-
try {
|
|
69
|
-
module.exports = Object.assign(exports.default, exports);
|
|
70
|
-
}
|
|
71
|
-
catch { }
|
|
72
65
|
// Error upon wrong usage
|
|
73
66
|
Object.defineProperty(plugin, 'apply', {
|
|
74
67
|
enumerable: true,
|
|
@@ -80,3 +73,9 @@ Object.defineProperty(plugin, 'apply', {
|
|
|
80
73
|
function assertViteVersion() {
|
|
81
74
|
(0, utils_js_2.assertVersion)('Vite', vite_1.version, '5.1.0');
|
|
82
75
|
}
|
|
76
|
+
// Ensures following works: `const vike = require('vike/plugin')` / `import vike from 'vike/plugin'`
|
|
77
|
+
// - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
|
|
78
|
+
try {
|
|
79
|
+
module.exports = Object.assign(exports.default, exports);
|
|
80
|
+
}
|
|
81
|
+
catch { }
|
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fixServerAssets = fixServerAssets;
|
|
7
7
|
exports.fixServerAssets_isEnabled = fixServerAssets_isEnabled;
|
|
8
|
+
exports.fixServerAssets_assertCssCodeSplit = fixServerAssets_assertCssCodeSplit;
|
|
9
|
+
exports.fixServerAssets_assertCssTarget = fixServerAssets_assertCssTarget;
|
|
10
|
+
exports.fixServerAssets_assertCssTarget_populate = fixServerAssets_assertCssTarget_populate;
|
|
8
11
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
12
|
const path_1 = __importDefault(require("path"));
|
|
10
13
|
const fs_1 = require("fs");
|
|
@@ -12,6 +15,8 @@ const utils_js_1 = require("../../utils.js");
|
|
|
12
15
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
13
16
|
const buildConfig_js_1 = require("../buildConfig.js");
|
|
14
17
|
const getAssetsDir_js_1 = require("../../shared/getAssetsDir.js");
|
|
18
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
19
|
+
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
15
20
|
/**
|
|
16
21
|
* true => use workaround config.build.ssrEmitAssets
|
|
17
22
|
* false => use workaround extractAssets plugin
|
|
@@ -153,3 +158,39 @@ function getHash(src) {
|
|
|
153
158
|
(0, utils_js_1.assert)(hash);
|
|
154
159
|
return hash;
|
|
155
160
|
}
|
|
161
|
+
// https://github.com/vikejs/vike/issues/1993
|
|
162
|
+
function fixServerAssets_assertCssCodeSplit(config) {
|
|
163
|
+
(0, utils_js_1.assertWarning)(config.build.cssCodeSplit, `${picocolors_1.default.cyan('build.cssCodeSplit')} shouldn't be set to ${picocolors_1.default.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
164
|
+
}
|
|
165
|
+
const targets = [];
|
|
166
|
+
function fixServerAssets_assertCssTarget_populate(config) {
|
|
167
|
+
const isServerSide = (0, utils_js_1.viteIsSSR)(config);
|
|
168
|
+
(0, utils_js_1.assert)(typeof isServerSide === 'boolean');
|
|
169
|
+
(0, utils_js_1.assert)(config.build.target !== undefined);
|
|
170
|
+
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
171
|
+
}
|
|
172
|
+
async function fixServerAssets_assertCssTarget(config) {
|
|
173
|
+
if (!fixServerAssets_isEnabled())
|
|
174
|
+
return;
|
|
175
|
+
if (!(await (0, getVikeConfig_js_1.isV1Design)(config, false)))
|
|
176
|
+
return;
|
|
177
|
+
const targetsServer = targets.filter((t) => t.isServerSide);
|
|
178
|
+
const targetsClient = targets.filter((t) => !t.isServerSide);
|
|
179
|
+
targetsClient.forEach((targetClient) => {
|
|
180
|
+
const targetCssResolvedClient = resolveCssTarget(targetClient);
|
|
181
|
+
targetsServer.forEach((targetServer) => {
|
|
182
|
+
const targetCssResolvedServer = resolveCssTarget(targetServer);
|
|
183
|
+
(0, utils_js_1.assertWarning)((0, utils_js_1.isEqualStringList)(targetCssResolvedClient, targetCssResolvedServer), [
|
|
184
|
+
'The CSS browser target should be the same for both client-side and server-side (https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979) but we got:',
|
|
185
|
+
`Client-side: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedClient))}`,
|
|
186
|
+
`Server-side: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedServer))}`
|
|
187
|
+
].join('\n'), {
|
|
188
|
+
showStackTrace: true,
|
|
189
|
+
onlyOnce: 'different-css-target'
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function resolveCssTarget(target) {
|
|
195
|
+
return target.css ?? target.global;
|
|
196
|
+
}
|
|
@@ -54,6 +54,8 @@ function buildConfig() {
|
|
|
54
54
|
config.build.ssrEmitAssets = true;
|
|
55
55
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
56
56
|
config.build.cssMinify = 'esbuild';
|
|
57
|
+
(0, fixServerAssets_js_1.fixServerAssets_assertCssTarget_populate)(config);
|
|
58
|
+
(0, fixServerAssets_js_1.fixServerAssets_assertCssCodeSplit)(config);
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
}
|
|
@@ -71,6 +73,9 @@ function buildConfig() {
|
|
|
71
73
|
},
|
|
72
74
|
buildStart() {
|
|
73
75
|
(0, utils_js_1.assertNodeEnv_build)();
|
|
76
|
+
},
|
|
77
|
+
async closeBundle() {
|
|
78
|
+
await (0, fixServerAssets_js_1.fixServerAssets_assertCssTarget)(config);
|
|
74
79
|
}
|
|
75
80
|
},
|
|
76
81
|
{
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.extractAssetsRE = void 0;
|
|
9
9
|
exports.extractAssetsPlugin = extractAssetsPlugin;
|
|
10
10
|
const utils_js_1 = require("../utils.js");
|
|
11
|
+
const virtual_files_js_1 = require("../../shared/virtual-files.js");
|
|
11
12
|
const extractAssetsQuery_js_1 = require("../../shared/extractAssetsQuery.js");
|
|
12
13
|
const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
13
14
|
const isAsset_js_1 = require("../shared/isAsset.js");
|
|
@@ -122,9 +123,9 @@ function extractAssetsPlugin() {
|
|
|
122
123
|
name: 'vike:extractAssets-3',
|
|
123
124
|
apply: 'build',
|
|
124
125
|
load(id) {
|
|
125
|
-
if (!(0,
|
|
126
|
+
if (!(0, virtual_files_js_1.isVirtualFileId)(id))
|
|
126
127
|
return undefined;
|
|
127
|
-
id = (0,
|
|
128
|
+
id = (0, virtual_files_js_1.getVirtualFileId)(id);
|
|
128
129
|
if (id === EMPTY_MODULE_ID) {
|
|
129
130
|
return '// Erased by vike:extractAssets';
|
|
130
131
|
}
|
|
@@ -152,7 +153,7 @@ function extractAssetsPlugin() {
|
|
|
152
153
|
}
|
|
153
154
|
function emptyModule(file, importer) {
|
|
154
155
|
debugOperation('NUKED', file, importer);
|
|
155
|
-
return (0,
|
|
156
|
+
return (0, virtual_files_js_1.resolveVirtualFileId)(EMPTY_MODULE_ID);
|
|
156
157
|
}
|
|
157
158
|
function appendExtractAssetsQuery(file, importer) {
|
|
158
159
|
debugOperation('TRANSFORMED', file, importer);
|
|
@@ -9,6 +9,7 @@ const getConfigVike_js_1 = require("../../../shared/getConfigVike.js");
|
|
|
9
9
|
const getVirtualFilePageConfigValuesAll_js_1 = require("./v1-design/getVirtualFilePageConfigValuesAll.js");
|
|
10
10
|
const getVirtualFileImportUserCode_js_1 = require("./getVirtualFileImportUserCode.js");
|
|
11
11
|
const utils_js_1 = require("../../utils.js");
|
|
12
|
+
const virtual_files_js_1 = require("../../../shared/virtual-files.js");
|
|
12
13
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
13
14
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
14
15
|
const getVikeConfig_js_1 = require("./v1-design/getVikeConfig.js");
|
|
@@ -36,8 +37,8 @@ function importUserCode() {
|
|
|
36
37
|
}
|
|
37
38
|
},
|
|
38
39
|
resolveId(id) {
|
|
39
|
-
if ((0,
|
|
40
|
-
return (0,
|
|
40
|
+
if ((0, virtual_files_js_1.isVirtualFileId)(id)) {
|
|
41
|
+
return (0, virtual_files_js_1.resolveVirtualFileId)(id);
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
handleHotUpdate(ctx) {
|
|
@@ -51,9 +52,9 @@ function importUserCode() {
|
|
|
51
52
|
}
|
|
52
53
|
},
|
|
53
54
|
async load(id, options) {
|
|
54
|
-
if (!(0,
|
|
55
|
+
if (!(0, virtual_files_js_1.isVirtualFileId)(id))
|
|
55
56
|
return undefined;
|
|
56
|
-
id = (0,
|
|
57
|
+
id = (0, virtual_files_js_1.getVirtualFileId)(id);
|
|
57
58
|
(0, utils_js_1.assert)(typeof isDev === 'boolean');
|
|
58
59
|
if ((0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id)) {
|
|
59
60
|
const code = await (0, getVirtualFilePageConfigValuesAll_js_1.getVirtualFilePageConfigValuesAll)(id, isDev, config);
|
|
@@ -131,7 +131,9 @@ const configDefinitionsBuiltIn = {
|
|
|
131
131
|
},
|
|
132
132
|
keepScrollPosition: {
|
|
133
133
|
env: { client: true }
|
|
134
|
-
}
|
|
134
|
+
},
|
|
135
|
+
// TODO/eventually: define it as a global config.
|
|
136
|
+
middleware: { env: { server: true }, cumulative: true, eager: true }
|
|
135
137
|
};
|
|
136
138
|
exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
|
|
137
139
|
const configDefinitionsBuiltInGlobal = {
|
|
@@ -168,7 +168,7 @@ function assertLogger(thing, logType) {
|
|
|
168
168
|
assert(res)
|
|
169
169
|
*/
|
|
170
170
|
if (!res)
|
|
171
|
-
throw new Error('Internal error, reach out to a maintainer');
|
|
171
|
+
throw new Error('Internal Vike error, reach out to a maintainer');
|
|
172
172
|
const { assertMsg, showVikeVersion } = res;
|
|
173
173
|
(0, log_js_1.logWithVikeTag)(assertMsg, logType, category, showVikeVersion);
|
|
174
174
|
}
|
|
@@ -43,3 +43,4 @@ __exportStar(require("../../utils/assertVersion.js"), exports);
|
|
|
43
43
|
__exportStar(require("../../utils/isFilePathAbsoluteFilesystem.js"), exports);
|
|
44
44
|
__exportStar(require("../../utils/isArray.js"), exports);
|
|
45
45
|
__exportStar(require("../../utils/PROJECT_VERSION.js"), exports);
|
|
46
|
+
__exportStar(require("../../utils/isEqualStringList.js"), exports);
|
|
@@ -59,7 +59,6 @@ __exportStar(require("../../utils/objectEntries.js"), exports);
|
|
|
59
59
|
__exportStar(require("../../utils/objectFromEntries.js"), exports);
|
|
60
60
|
__exportStar(require("../../utils/getFileExtension.js"), exports);
|
|
61
61
|
__exportStar(require("../../utils/assertIsNotProductionRuntime.js"), exports);
|
|
62
|
-
__exportStar(require("../../utils/virtual-files.js"), exports);
|
|
63
62
|
__exportStar(require("../../utils/path-shim.js"), exports);
|
|
64
63
|
__exportStar(require("../../utils/assertNodeEnv.js"), exports);
|
|
65
64
|
__exportStar(require("../../utils/isHtml.js"), exports);
|
|
@@ -28,7 +28,6 @@ __exportStar(require("../../utils/hasProp.js"), exports);
|
|
|
28
28
|
__exportStar(require("../../utils/parseUrl.js"), exports);
|
|
29
29
|
__exportStar(require("../../utils/parseUrl-extras.js"), exports);
|
|
30
30
|
__exportStar(require("../../utils/isObject.js"), exports);
|
|
31
|
-
__exportStar(require("../../utils/virtual-files.js"), exports);
|
|
32
31
|
__exportStar(require("../../utils/assertIsNotBrowser.js"), exports);
|
|
33
32
|
__exportStar(require("../../utils/isNotNullish.js"), exports);
|
|
34
33
|
__exportStar(require("../../utils/unique.js"), exports);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.virtualFileIdImportUserCodeClientCR = exports.virtualFileIdImportUserCodeClientSR = exports.virtualFileIdImportUserCodeServer = void 0;
|
|
4
4
|
exports.isVirtualFileIdImportUserCode = isVirtualFileIdImportUserCode;
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
|
+
const virtual_files_js_1 = require("../virtual-files.js");
|
|
6
7
|
const idBase = 'virtual:vike:importUserCode';
|
|
7
8
|
const virtualFileIdImportUserCodeServer = `${idBase}:server`;
|
|
8
9
|
exports.virtualFileIdImportUserCodeServer = virtualFileIdImportUserCodeServer;
|
|
@@ -11,7 +12,7 @@ exports.virtualFileIdImportUserCodeClientSR = virtualFileIdImportUserCodeClientS
|
|
|
11
12
|
const virtualFileIdImportUserCodeClientCR = `${idBase}:client:client-routing`;
|
|
12
13
|
exports.virtualFileIdImportUserCodeClientCR = virtualFileIdImportUserCodeClientCR;
|
|
13
14
|
function isVirtualFileIdImportUserCode(id) {
|
|
14
|
-
id = (0,
|
|
15
|
+
id = (0, virtual_files_js_1.getVirtualFileId)(id);
|
|
15
16
|
if (!id.startsWith(idBase))
|
|
16
17
|
return false;
|
|
17
18
|
(0, utils_js_1.assert)(
|
|
@@ -4,6 +4,7 @@ exports.isVirtualFileIdPageConfigValuesAll = isVirtualFileIdPageConfigValuesAll;
|
|
|
4
4
|
exports.getVirtualFileIdPageConfigValuesAll = getVirtualFileIdPageConfigValuesAll;
|
|
5
5
|
const extractAssetsQuery_js_1 = require("../extractAssetsQuery.js");
|
|
6
6
|
const utils_js_1 = require("../utils.js");
|
|
7
|
+
const virtual_files_js_1 = require("../virtual-files.js");
|
|
7
8
|
const idBase = 'virtual:vike:pageConfigValuesAll:';
|
|
8
9
|
const idBaseClient = `${idBase}client:`;
|
|
9
10
|
const idBaseServer = `${idBase}server:`;
|
|
@@ -12,7 +13,7 @@ function getVirtualFileIdPageConfigValuesAll(pageId, isForClientSide) {
|
|
|
12
13
|
return id;
|
|
13
14
|
}
|
|
14
15
|
function isVirtualFileIdPageConfigValuesAll(id) {
|
|
15
|
-
id = (0,
|
|
16
|
+
id = (0, virtual_files_js_1.getVirtualFileId)(id);
|
|
16
17
|
if (!id.includes(idBase))
|
|
17
18
|
return false;
|
|
18
19
|
(0, utils_js_1.assert)(id.startsWith(idBase));
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isVirtualFileId = isVirtualFileId;
|
|
4
7
|
exports.getVirtualFileId = getVirtualFileId;
|
|
5
8
|
exports.resolveVirtualFileId = resolveVirtualFileId;
|
|
6
|
-
const
|
|
9
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
|
+
const utils_js_1 = require("./utils.js");
|
|
7
11
|
const idBase = 'virtual:vike:';
|
|
8
12
|
// https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
|
|
9
13
|
const tag = '\0';
|
|
@@ -12,21 +16,22 @@ function isVirtualFileId(id) {
|
|
|
12
16
|
return true;
|
|
13
17
|
if (id.startsWith(tag + idBase))
|
|
14
18
|
return true;
|
|
15
|
-
|
|
19
|
+
// https://github.com/vikejs/vike/issues/1985
|
|
20
|
+
(0, utils_js_1.assertUsage)(!id.includes(idBase), `Encountered a module ID ${picocolors_1.default.cyan(id)} that is unexpected. Are you using a tool that modifies the ID of modules? For example, the baseUrl setting in tsconfig.json cannot be used.`);
|
|
16
21
|
return false;
|
|
17
22
|
}
|
|
18
23
|
function getVirtualFileId(id) {
|
|
19
24
|
if (id.startsWith(tag)) {
|
|
20
25
|
id = id.slice(tag.length);
|
|
21
26
|
}
|
|
22
|
-
(0,
|
|
27
|
+
(0, utils_js_1.assert)(!id.startsWith(tag));
|
|
23
28
|
return id;
|
|
24
29
|
}
|
|
25
30
|
function resolveVirtualFileId(id) {
|
|
26
|
-
(0,
|
|
31
|
+
(0, utils_js_1.assert)(isVirtualFileId(id));
|
|
27
32
|
if (!id.startsWith(tag)) {
|
|
28
33
|
id = tag + id;
|
|
29
34
|
}
|
|
30
|
-
(0,
|
|
35
|
+
(0, utils_js_1.assert)(id.startsWith(tag));
|
|
31
36
|
return id;
|
|
32
37
|
}
|
package/dist/cjs/utils/assert.js
CHANGED
|
@@ -150,7 +150,7 @@ function addPrefixProjctName(msg, showProjectVersion = false) {
|
|
|
150
150
|
}
|
|
151
151
|
function getAssertErrMsg(thing) {
|
|
152
152
|
let errMsg;
|
|
153
|
-
let errStack
|
|
153
|
+
let errStack;
|
|
154
154
|
if (typeof thing === 'string') {
|
|
155
155
|
errMsg = thing;
|
|
156
156
|
}
|
|
@@ -161,33 +161,24 @@ function getAssertErrMsg(thing) {
|
|
|
161
161
|
else {
|
|
162
162
|
return null;
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
164
|
+
for (const tag of [projectTagWithVersion, projectTag]) {
|
|
165
|
+
const showVikeVersion = tag === projectTagWithVersion;
|
|
166
|
+
const errStackPrefix = `Error: ${tag}`;
|
|
167
|
+
if (errStack?.startsWith(errStackPrefix)) {
|
|
168
|
+
if (globalObject.showStackTraceList.has(thing)) {
|
|
169
|
+
const assertMsg = errStack.slice(errStackPrefix.length);
|
|
170
|
+
return { assertMsg, showVikeVersion };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (errStack?.includes(tag)) {
|
|
174
|
+
throw new Error('Internal Vike error');
|
|
175
|
+
}
|
|
176
|
+
if (errMsg?.startsWith(tag)) {
|
|
177
|
+
const assertMsg = errMsg.slice(tag.length);
|
|
178
|
+
return { assertMsg, showVikeVersion };
|
|
179
|
+
}
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
return { assertMsg, showVikeVersion };
|
|
183
|
-
}
|
|
184
|
-
function removeErrMsg(stack) {
|
|
185
|
-
if (typeof stack !== 'string')
|
|
186
|
-
return String(stack);
|
|
187
|
-
const [firstLine, ...stackLines] = stack.split('\n');
|
|
188
|
-
if (!firstLine.startsWith('Error: '))
|
|
189
|
-
return stack;
|
|
190
|
-
return stackLines.join('\n');
|
|
181
|
+
return null;
|
|
191
182
|
}
|
|
192
183
|
function overwriteAssertProductionLogger(logger) {
|
|
193
184
|
globalObject.logger = logger;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEqualStringList = isEqualStringList;
|
|
4
|
+
function isEqualStringList(a, b) {
|
|
5
|
+
if (a === b)
|
|
6
|
+
return true;
|
|
7
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
8
|
+
const sortedA = [...a].sort();
|
|
9
|
+
const sortedB = [...b].sort();
|
|
10
|
+
return sortedA.length === sortedB.length && sortedA.every((val, i) => val === sortedB[i]);
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
@@ -12,3 +12,8 @@ function pathJoin(path1, path2) {
|
|
|
12
12
|
joined = '/' + joined;
|
|
13
13
|
return joined;
|
|
14
14
|
}
|
|
15
|
+
/* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
|
|
16
|
+
function isAbsolute(filePath: string) {
|
|
17
|
+
// ...
|
|
18
|
+
}
|
|
19
|
+
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { route, getPagesAndRoutes };
|
|
2
2
|
export type { PageRoutes, PageFile, PageConfigRuntime as PageConfig };
|
|
3
|
-
export {
|
|
3
|
+
export { getMiddlewares };
|
|
4
4
|
import { route as routeInternal, type PageRoutes } from '../shared/route/index.js';
|
|
5
5
|
import { type PageFile } from '../shared/getPageFiles.js';
|
|
6
6
|
import { PageConfigRuntime } from '../shared/page-configs/PageConfig.js';
|
|
@@ -16,12 +16,7 @@ declare function getPagesAndRoutes(): Promise<{
|
|
|
16
16
|
pageConfigs: PageConfigRuntime[];
|
|
17
17
|
allPageIds: string[];
|
|
18
18
|
}>;
|
|
19
|
-
declare function
|
|
20
|
-
pageFilesAll: PageFile[];
|
|
21
|
-
allPageIds: string[];
|
|
22
|
-
pageConfigs: PageConfigRuntime[];
|
|
23
|
-
pageConfigGlobal: import("../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
24
|
-
}>;
|
|
19
|
+
declare function getMiddlewares(): Promise<unknown[]>;
|
|
25
20
|
declare function route(pageContext: Parameters<typeof routeInternal>[0]): Promise<{
|
|
26
21
|
pageContextAddendum: import("../shared/route/index.js").PageContextFromRoute;
|
|
27
22
|
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Internals needed by vite-plugin-vercel
|
|
2
2
|
export { route, getPagesAndRoutes };
|
|
3
|
-
// Internals needed by
|
|
4
|
-
export {
|
|
3
|
+
// Internals needed by experimental implementation of vike-telefunc
|
|
4
|
+
export { getMiddlewares };
|
|
5
5
|
import { route as routeInternal } from '../shared/route/index.js';
|
|
6
6
|
import { getPageFilesAll } from '../shared/getPageFiles.js';
|
|
7
7
|
import { getGlobalContext, initGlobalContext_getGlobalContextAsync } from '../node/runtime/globalContext.js';
|
|
@@ -26,7 +26,18 @@ async function getPagesAndRoutes() {
|
|
|
26
26
|
allPageIds
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
// TODO:
|
|
29
|
+
// TODO/eventually:
|
|
30
|
+
// - Remove the need for `isProduction` after Vike's CLI is implemented
|
|
31
|
+
// - Remove it in favor of https://vike.dev/getGlobalContext
|
|
32
|
+
async function getMiddlewares() {
|
|
33
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
34
|
+
const { pageConfigs } = await getPageFilesAllSafe(isProduction);
|
|
35
|
+
const middlewares = pageConfigs[0].configValues.middleware.value.flat(Infinity);
|
|
36
|
+
return middlewares;
|
|
37
|
+
}
|
|
38
|
+
// TODO/eventually:
|
|
39
|
+
// - Make it cleaner once the internal refactoring about global configs is done.
|
|
40
|
+
// - Remove it in favor of https://vike.dev/getGlobalContext
|
|
30
41
|
// Demo usage: https://github.com/vikejs/vike/pull/1823
|
|
31
42
|
async function getPageFilesAllSafe(isProduction) {
|
|
32
43
|
await initGlobalContext_getGlobalContextAsync(isProduction);
|
|
@@ -218,6 +218,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
218
218
|
isBackwardNavigation,
|
|
219
219
|
isClientSideNavigation,
|
|
220
220
|
isHydration: isFirstRender && !isForErrorPage,
|
|
221
|
+
// Make it public as `pageContext.previous`? Maybe after https://github.com/vikejs/vike/issues/1268
|
|
221
222
|
_previousPageContext: previousPageContext,
|
|
222
223
|
...pageContextInitClient
|
|
223
224
|
});
|
|
@@ -56,13 +56,6 @@ function plugin(vikeConfig) {
|
|
|
56
56
|
];
|
|
57
57
|
return plugins;
|
|
58
58
|
}
|
|
59
|
-
// Enable `const vike = require('vike/plugin')`.
|
|
60
|
-
// - This lives at the end of the file to ensure it happens after all assignments to `exports`.
|
|
61
|
-
// - This is only used for the CJS build; we wrap it in a try-catch for the ESM build.
|
|
62
|
-
try {
|
|
63
|
-
module.exports = Object.assign(exports.default, exports);
|
|
64
|
-
}
|
|
65
|
-
catch { }
|
|
66
59
|
// Error upon wrong usage
|
|
67
60
|
Object.defineProperty(plugin, 'apply', {
|
|
68
61
|
enumerable: true,
|
|
@@ -74,3 +67,9 @@ Object.defineProperty(plugin, 'apply', {
|
|
|
74
67
|
function assertViteVersion() {
|
|
75
68
|
assertVersion('Vite', version, '5.1.0');
|
|
76
69
|
}
|
|
70
|
+
// Ensures following works: `const vike = require('vike/plugin')` / `import vike from 'vike/plugin'`
|
|
71
|
+
// - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
|
|
72
|
+
try {
|
|
73
|
+
module.exports = Object.assign(exports.default, exports);
|
|
74
|
+
}
|
|
75
|
+
catch { }
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { fixServerAssets };
|
|
2
2
|
export { fixServerAssets_isEnabled };
|
|
3
|
+
export { fixServerAssets_assertCssCodeSplit };
|
|
4
|
+
export { fixServerAssets_assertCssTarget };
|
|
5
|
+
export { fixServerAssets_assertCssTarget_populate };
|
|
3
6
|
import { ViteManifest } from '../../../shared/ViteManifest.js';
|
|
4
7
|
import { ResolvedConfig } from 'vite';
|
|
5
8
|
/**
|
|
@@ -11,3 +14,6 @@ import { ResolvedConfig } from 'vite';
|
|
|
11
14
|
declare function fixServerAssets_isEnabled(): boolean;
|
|
12
15
|
/** https://github.com/vikejs/vike/issues/1339 */
|
|
13
16
|
declare function fixServerAssets(config: ResolvedConfig): Promise<ViteManifest>;
|
|
17
|
+
declare function fixServerAssets_assertCssCodeSplit(config: ResolvedConfig): void;
|
|
18
|
+
declare function fixServerAssets_assertCssTarget_populate(config: ResolvedConfig): void;
|
|
19
|
+
declare function fixServerAssets_assertCssTarget(config: ResolvedConfig): Promise<void>;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
export { fixServerAssets };
|
|
2
2
|
export { fixServerAssets_isEnabled };
|
|
3
|
+
export { fixServerAssets_assertCssCodeSplit };
|
|
4
|
+
export { fixServerAssets_assertCssTarget };
|
|
5
|
+
export { fixServerAssets_assertCssTarget_populate };
|
|
3
6
|
import fs from 'fs/promises';
|
|
4
7
|
import path from 'path';
|
|
5
8
|
import { existsSync } from 'fs';
|
|
6
|
-
import { assert, getOutDirs, pLimit, unique } from '../../utils.js';
|
|
9
|
+
import { assert, assertWarning, getOutDirs, isEqualStringList, pLimit, unique, viteIsSSR } from '../../utils.js';
|
|
7
10
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
8
11
|
import { manifestTempFile } from '../buildConfig.js';
|
|
9
12
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
13
|
+
import pc from '@brillout/picocolors';
|
|
14
|
+
import { isV1Design } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
10
15
|
/**
|
|
11
16
|
* true => use workaround config.build.ssrEmitAssets
|
|
12
17
|
* false => use workaround extractAssets plugin
|
|
@@ -148,3 +153,39 @@ function getHash(src) {
|
|
|
148
153
|
assert(hash);
|
|
149
154
|
return hash;
|
|
150
155
|
}
|
|
156
|
+
// https://github.com/vikejs/vike/issues/1993
|
|
157
|
+
function fixServerAssets_assertCssCodeSplit(config) {
|
|
158
|
+
assertWarning(config.build.cssCodeSplit, `${pc.cyan('build.cssCodeSplit')} shouldn't be set to ${pc.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
159
|
+
}
|
|
160
|
+
const targets = [];
|
|
161
|
+
function fixServerAssets_assertCssTarget_populate(config) {
|
|
162
|
+
const isServerSide = viteIsSSR(config);
|
|
163
|
+
assert(typeof isServerSide === 'boolean');
|
|
164
|
+
assert(config.build.target !== undefined);
|
|
165
|
+
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
166
|
+
}
|
|
167
|
+
async function fixServerAssets_assertCssTarget(config) {
|
|
168
|
+
if (!fixServerAssets_isEnabled())
|
|
169
|
+
return;
|
|
170
|
+
if (!(await isV1Design(config, false)))
|
|
171
|
+
return;
|
|
172
|
+
const targetsServer = targets.filter((t) => t.isServerSide);
|
|
173
|
+
const targetsClient = targets.filter((t) => !t.isServerSide);
|
|
174
|
+
targetsClient.forEach((targetClient) => {
|
|
175
|
+
const targetCssResolvedClient = resolveCssTarget(targetClient);
|
|
176
|
+
targetsServer.forEach((targetServer) => {
|
|
177
|
+
const targetCssResolvedServer = resolveCssTarget(targetServer);
|
|
178
|
+
assertWarning(isEqualStringList(targetCssResolvedClient, targetCssResolvedServer), [
|
|
179
|
+
'The CSS browser target should be the same for both client-side and server-side (https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979) but we got:',
|
|
180
|
+
`Client-side: ${pc.cyan(JSON.stringify(targetCssResolvedClient))}`,
|
|
181
|
+
`Server-side: ${pc.cyan(JSON.stringify(targetCssResolvedServer))}`
|
|
182
|
+
].join('\n'), {
|
|
183
|
+
showStackTrace: true,
|
|
184
|
+
onlyOnce: 'different-css-target'
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function resolveCssTarget(target) {
|
|
190
|
+
return target.css ?? target.global;
|
|
191
|
+
}
|
|
@@ -11,7 +11,7 @@ import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
|
11
11
|
import { createRequire } from 'module';
|
|
12
12
|
import fs from 'fs/promises';
|
|
13
13
|
import path from 'path';
|
|
14
|
-
import { fixServerAssets, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
14
|
+
import { fixServerAssets, fixServerAssets_assertCssCodeSplit, fixServerAssets_assertCssTarget, fixServerAssets_assertCssTarget_populate, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
15
15
|
import { set_ASSETS_MAP } from './importBuild/index.js';
|
|
16
16
|
import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
|
|
17
17
|
import { getFilePathResolved } from '../shared/getFilePath.js';
|
|
@@ -48,6 +48,8 @@ function buildConfig() {
|
|
|
48
48
|
config.build.ssrEmitAssets = true;
|
|
49
49
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
50
50
|
config.build.cssMinify = 'esbuild';
|
|
51
|
+
fixServerAssets_assertCssTarget_populate(config);
|
|
52
|
+
fixServerAssets_assertCssCodeSplit(config);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}
|
|
@@ -65,6 +67,9 @@ function buildConfig() {
|
|
|
65
67
|
},
|
|
66
68
|
buildStart() {
|
|
67
69
|
assertNodeEnv_build();
|
|
70
|
+
},
|
|
71
|
+
async closeBundle() {
|
|
72
|
+
await fixServerAssets_assertCssTarget(config);
|
|
68
73
|
}
|
|
69
74
|
},
|
|
70
75
|
{
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// - This appraoch supports import path aliases `vite.config.js#resolve.alias` https://vitejs.dev/config/#resolve-alias
|
|
7
7
|
export { extractAssetsPlugin };
|
|
8
8
|
export { extractAssetsRE };
|
|
9
|
-
import { viteIsSSR_options, assert, assertPosixPath, styleFileRE, createDebugger, isScriptFile,
|
|
9
|
+
import { viteIsSSR_options, assert, assertPosixPath, styleFileRE, createDebugger, isScriptFile, assertUsage } from '../utils.js';
|
|
10
|
+
import { resolveVirtualFileId, isVirtualFileId, getVirtualFileId } from '../../shared/virtual-files.js';
|
|
10
11
|
import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
11
12
|
import { getConfigVike } from '../../shared/getConfigVike.js';
|
|
12
13
|
import { isAsset } from '../shared/isAsset.js';
|
|
@@ -3,7 +3,8 @@ import { normalizePath } from 'vite';
|
|
|
3
3
|
import { getConfigVike } from '../../../shared/getConfigVike.js';
|
|
4
4
|
import { getVirtualFilePageConfigValuesAll } from './v1-design/getVirtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { getVirtualFileImportUserCode } from './getVirtualFileImportUserCode.js';
|
|
6
|
-
import { assert, assertPosixPath, getOutDirs,
|
|
6
|
+
import { assert, assertPosixPath, getOutDirs, isDev3 } from '../../utils.js';
|
|
7
|
+
import { resolveVirtualFileId, isVirtualFileId, getVirtualFileId } from '../../../shared/virtual-files.js';
|
|
7
8
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
8
9
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
9
10
|
import { vikeConfigDependencies, reloadVikeConfig, isVikeConfigFile, isV1Design } from './v1-design/getVikeConfig.js';
|
|
@@ -130,7 +130,9 @@ const configDefinitionsBuiltIn = {
|
|
|
130
130
|
},
|
|
131
131
|
keepScrollPosition: {
|
|
132
132
|
env: { client: true }
|
|
133
|
-
}
|
|
133
|
+
},
|
|
134
|
+
// TODO/eventually: define it as a global config.
|
|
135
|
+
middleware: { env: { server: true }, cumulative: true, eager: true }
|
|
134
136
|
};
|
|
135
137
|
const configDefinitionsBuiltInGlobal = {
|
|
136
138
|
onPrerenderStart: {
|
|
@@ -163,7 +163,7 @@ function assertLogger(thing, logType) {
|
|
|
163
163
|
assert(res)
|
|
164
164
|
*/
|
|
165
165
|
if (!res)
|
|
166
|
-
throw new Error('Internal error, reach out to a maintainer');
|
|
166
|
+
throw new Error('Internal Vike error, reach out to a maintainer');
|
|
167
167
|
const { assertMsg, showVikeVersion } = res;
|
|
168
168
|
logWithVikeTag(assertMsg, logType, category, showVikeVersion);
|
|
169
169
|
}
|
|
@@ -40,7 +40,6 @@ export * from '../../utils/objectEntries.js';
|
|
|
40
40
|
export * from '../../utils/objectFromEntries.js';
|
|
41
41
|
export * from '../../utils/getFileExtension.js';
|
|
42
42
|
export * from '../../utils/assertIsNotProductionRuntime.js';
|
|
43
|
-
export * from '../../utils/virtual-files.js';
|
|
44
43
|
export * from '../../utils/path-shim.js';
|
|
45
44
|
export * from '../../utils/assertNodeEnv.js';
|
|
46
45
|
export * from '../../utils/isHtml.js';
|
|
@@ -43,7 +43,6 @@ export * from '../../utils/objectEntries.js';
|
|
|
43
43
|
export * from '../../utils/objectFromEntries.js';
|
|
44
44
|
export * from '../../utils/getFileExtension.js';
|
|
45
45
|
export * from '../../utils/assertIsNotProductionRuntime.js';
|
|
46
|
-
export * from '../../utils/virtual-files.js';
|
|
47
46
|
export * from '../../utils/path-shim.js';
|
|
48
47
|
export * from '../../utils/assertNodeEnv.js';
|
|
49
48
|
export * from '../../utils/isHtml.js';
|
|
@@ -10,7 +10,6 @@ export * from '../../utils/hasProp.js';
|
|
|
10
10
|
export * from '../../utils/parseUrl.js';
|
|
11
11
|
export * from '../../utils/parseUrl-extras.js';
|
|
12
12
|
export * from '../../utils/isObject.js';
|
|
13
|
-
export * from '../../utils/virtual-files.js';
|
|
14
13
|
export * from '../../utils/assertIsNotBrowser.js';
|
|
15
14
|
export * from '../../utils/isNotNullish.js';
|
|
16
15
|
export * from '../../utils/unique.js';
|
|
@@ -12,7 +12,6 @@ export * from '../../utils/hasProp.js';
|
|
|
12
12
|
export * from '../../utils/parseUrl.js';
|
|
13
13
|
export * from '../../utils/parseUrl-extras.js';
|
|
14
14
|
export * from '../../utils/isObject.js';
|
|
15
|
-
export * from '../../utils/virtual-files.js';
|
|
16
15
|
export * from '../../utils/assertIsNotBrowser.js';
|
|
17
16
|
export * from '../../utils/isNotNullish.js';
|
|
18
17
|
export * from '../../utils/unique.js';
|
|
@@ -2,7 +2,8 @@ export { virtualFileIdImportUserCodeServer };
|
|
|
2
2
|
export { virtualFileIdImportUserCodeClientSR };
|
|
3
3
|
export { virtualFileIdImportUserCodeClientCR };
|
|
4
4
|
export { isVirtualFileIdImportUserCode };
|
|
5
|
-
import { assert
|
|
5
|
+
import { assert } from '../utils.js';
|
|
6
|
+
import { getVirtualFileId } from '../virtual-files.js';
|
|
6
7
|
const idBase = 'virtual:vike:importUserCode';
|
|
7
8
|
const virtualFileIdImportUserCodeServer = `${idBase}:server`;
|
|
8
9
|
const virtualFileIdImportUserCodeClientSR = `${idBase}:client:server-routing`;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { isVirtualFileIdPageConfigValuesAll };
|
|
2
2
|
export { getVirtualFileIdPageConfigValuesAll };
|
|
3
3
|
import { extractAssetsRemoveQuery } from '../extractAssetsQuery.js';
|
|
4
|
-
import { assert
|
|
4
|
+
import { assert } from '../utils.js';
|
|
5
|
+
import { getVirtualFileId } from '../virtual-files.js';
|
|
5
6
|
const idBase = 'virtual:vike:pageConfigValuesAll:';
|
|
6
7
|
const idBaseClient = `${idBase}client:`;
|
|
7
8
|
const idBaseServer = `${idBase}server:`;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { isVirtualFileId };
|
|
2
2
|
export { getVirtualFileId };
|
|
3
3
|
export { resolveVirtualFileId };
|
|
4
|
-
import
|
|
4
|
+
import pc from '@brillout/picocolors';
|
|
5
|
+
import { assert, assertUsage } from './utils.js';
|
|
5
6
|
const idBase = 'virtual:vike:';
|
|
6
7
|
// https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
|
|
7
8
|
const tag = '\0';
|
|
@@ -10,7 +11,8 @@ function isVirtualFileId(id) {
|
|
|
10
11
|
return true;
|
|
11
12
|
if (id.startsWith(tag + idBase))
|
|
12
13
|
return true;
|
|
13
|
-
|
|
14
|
+
// https://github.com/vikejs/vike/issues/1985
|
|
15
|
+
assertUsage(!id.includes(idBase), `Encountered a module ID ${pc.cyan(id)} that is unexpected. Are you using a tool that modifies the ID of modules? For example, the baseUrl setting in tsconfig.json cannot be used.`);
|
|
14
16
|
return false;
|
|
15
17
|
}
|
|
16
18
|
function getVirtualFileId(id) {
|
|
@@ -43,7 +43,7 @@ type HookName = HookNamePage | HookNameGlobal | HookNameOldDesign;
|
|
|
43
43
|
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data';
|
|
44
44
|
type HookNameGlobal = 'onBeforePrerender' | 'onBeforeRoute' | 'onPrerenderStart';
|
|
45
45
|
type HookNameOldDesign = 'render' | 'prerender';
|
|
46
|
-
type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks';
|
|
46
|
+
type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware';
|
|
47
47
|
type Config = ConfigBuiltIn & Vike.Config & (VikePackages.ConfigVikeReact | VikePackages.ConfigVikeVue | VikePackages.ConfigVikeSolid | VikePackages.ConfigVikeSvelte | VikePackages.ConfigVikeAngular);
|
|
48
48
|
/** Hook for fetching data.
|
|
49
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.207";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.207';
|
package/dist/esm/utils/assert.js
CHANGED
|
@@ -145,7 +145,7 @@ function addPrefixProjctName(msg, showProjectVersion = false) {
|
|
|
145
145
|
}
|
|
146
146
|
function getAssertErrMsg(thing) {
|
|
147
147
|
let errMsg;
|
|
148
|
-
let errStack
|
|
148
|
+
let errStack;
|
|
149
149
|
if (typeof thing === 'string') {
|
|
150
150
|
errMsg = thing;
|
|
151
151
|
}
|
|
@@ -156,33 +156,24 @@ function getAssertErrMsg(thing) {
|
|
|
156
156
|
else {
|
|
157
157
|
return null;
|
|
158
158
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
159
|
+
for (const tag of [projectTagWithVersion, projectTag]) {
|
|
160
|
+
const showVikeVersion = tag === projectTagWithVersion;
|
|
161
|
+
const errStackPrefix = `Error: ${tag}`;
|
|
162
|
+
if (errStack?.startsWith(errStackPrefix)) {
|
|
163
|
+
if (globalObject.showStackTraceList.has(thing)) {
|
|
164
|
+
const assertMsg = errStack.slice(errStackPrefix.length);
|
|
165
|
+
return { assertMsg, showVikeVersion };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else if (errStack?.includes(tag)) {
|
|
169
|
+
throw new Error('Internal Vike error');
|
|
170
|
+
}
|
|
171
|
+
if (errMsg?.startsWith(tag)) {
|
|
172
|
+
const assertMsg = errMsg.slice(tag.length);
|
|
173
|
+
return { assertMsg, showVikeVersion };
|
|
174
|
+
}
|
|
175
175
|
}
|
|
176
|
-
|
|
177
|
-
return { assertMsg, showVikeVersion };
|
|
178
|
-
}
|
|
179
|
-
function removeErrMsg(stack) {
|
|
180
|
-
if (typeof stack !== 'string')
|
|
181
|
-
return String(stack);
|
|
182
|
-
const [firstLine, ...stackLines] = stack.split('\n');
|
|
183
|
-
if (!firstLine.startsWith('Error: '))
|
|
184
|
-
return stack;
|
|
185
|
-
return stackLines.join('\n');
|
|
176
|
+
return null;
|
|
186
177
|
}
|
|
187
178
|
function overwriteAssertProductionLogger(logger) {
|
|
188
179
|
globalObject.logger = logger;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { isEqualStringList };
|
|
2
|
+
function isEqualStringList(a, b) {
|
|
3
|
+
if (a === b)
|
|
4
|
+
return true;
|
|
5
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
6
|
+
const sortedA = [...a].sort();
|
|
7
|
+
const sortedB = [...b].sort();
|
|
8
|
+
return sortedA.length === sortedB.length && sortedA.every((val, i) => val === sortedB[i]);
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
@@ -10,3 +10,8 @@ function pathJoin(path1, path2) {
|
|
|
10
10
|
joined = '/' + joined;
|
|
11
11
|
return joined;
|
|
12
12
|
}
|
|
13
|
+
/* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
|
|
14
|
+
function isAbsolute(filePath: string) {
|
|
15
|
+
// ...
|
|
16
|
+
}
|
|
17
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.207",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
"@types/resolve": "^1.20.6",
|
|
232
232
|
"@types/semver": "^7.5.8",
|
|
233
233
|
"@types/source-map-support": "^0.5.10",
|
|
234
|
-
"react-streaming": "^0.3.
|
|
234
|
+
"react-streaming": "^0.3.44",
|
|
235
235
|
"rimraf": "^5.0.5",
|
|
236
236
|
"typescript": "^5.6.2",
|
|
237
237
|
"vite": "^5.4.0"
|
|
File without changes
|