vike 0.4.220-commit-a9f46b8 → 0.4.220-commit-9a798ce
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/api/utils.js +1 -1
- package/dist/cjs/{utils → node/plugin}/getOutDirs.js +11 -11
- package/dist/cjs/node/plugin/index.js +1 -7
- package/dist/cjs/node/plugin/onLoad.js +6 -1
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +12 -13
- package/dist/cjs/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +6 -3
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +24 -21
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -3
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +10 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +158 -176
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
- package/dist/cjs/node/plugin/plugins/previewConfig.js +3 -4
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/context.js +6 -4
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +25 -0
- package/dist/cjs/node/prerender/runPrerender.js +9 -4
- package/dist/cjs/node/prerender/utils.js +2 -2
- package/dist/cjs/node/runtime/globalContext.js +42 -36
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +6 -5
- package/dist/cjs/node/runtime/renderPage.js +10 -5
- package/dist/cjs/node/runtime/utils.js +2 -2
- package/dist/cjs/node/shared/resolveBase.js +9 -0
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +2 -2
- package/dist/cjs/shared/utils.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findFile.js +3 -3
- package/dist/cjs/utils/isDev.js +2 -1
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
- package/dist/cjs/utils/requireResolve.js +3 -3
- package/dist/esm/node/api/utils.d.ts +1 -1
- package/dist/esm/node/api/utils.js +1 -1
- package/dist/esm/{utils → node/plugin}/getOutDirs.js +5 -5
- package/dist/esm/node/plugin/index.d.ts +29 -1
- package/dist/esm/node/plugin/index.js +2 -8
- package/dist/esm/node/plugin/onLoad.js +7 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +12 -13
- package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +7 -4
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +25 -22
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +4 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +4 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +10 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -95
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +159 -177
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +3 -4
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/context.d.ts +2 -2
- package/dist/esm/node/prerender/context.js +6 -4
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +5 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +23 -0
- package/dist/esm/node/prerender/runPrerender.js +9 -4
- package/dist/esm/node/prerender/utils.d.ts +2 -2
- package/dist/esm/node/prerender/utils.js +2 -2
- package/dist/esm/node/runtime/globalContext.d.ts +15 -9
- package/dist/esm/node/runtime/globalContext.js +43 -37
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +5 -5
- package/dist/esm/node/runtime/renderPage.js +10 -5
- package/dist/esm/node/runtime/utils.d.ts +2 -2
- package/dist/esm/node/runtime/utils.js +2 -2
- package/dist/esm/node/shared/resolveBase.d.ts +4 -1
- package/dist/esm/node/shared/resolveBase.js +9 -0
- package/dist/esm/shared/page-configs/Config.d.ts +76 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +25 -19
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +1 -1
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +2 -2
- package/dist/esm/shared/utils.d.ts +1 -1
- package/dist/esm/shared/utils.js +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/findFile.js +1 -1
- package/dist/esm/utils/isDev.js +2 -1
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -17
- package/dist/cjs/node/shared/assertPluginManifest.js +0 -20
- package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -16
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -15
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -12
- package/dist/esm/node/shared/assertPluginManifest.js +0 -18
- package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -10
- package/dist/esm/node/shared/assertRuntimeManifest.js +0 -14
- /package/dist/cjs/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
- /package/dist/esm/{utils → node/plugin}/getOutDirs.d.ts +0 -0
- /package/dist/esm/utils/{filesystemPathHandling.d.ts → toPosixPath.d.ts} +0 -0
- /package/dist/esm/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
|
@@ -66,6 +66,7 @@ const executeHook_js_1 = require("../../shared/hooks/executeHook.js");
|
|
|
66
66
|
const getConfigValueBuildTime_js_1 = require("../../shared/page-configs/getConfigValueBuildTime.js");
|
|
67
67
|
const prepareViteApiCall_js_1 = require("../api/prepareViteApiCall.js");
|
|
68
68
|
const context_js_1 = require("./context.js");
|
|
69
|
+
const resolvePrerenderConfig_js_1 = require("./resolvePrerenderConfig.js");
|
|
69
70
|
async function runPrerenderFromAPI(options = {}) {
|
|
70
71
|
return await runPrerender(options, 'prerender()');
|
|
71
72
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
@@ -112,7 +113,7 @@ async function runPrerender(options = {}, standaloneTrigger) {
|
|
|
112
113
|
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(viteConfig);
|
|
113
114
|
const { outDirClient } = (0, utils_js_1.getOutDirs)(viteConfig);
|
|
114
115
|
const { root } = viteConfig;
|
|
115
|
-
const prerenderConfig = vikeConfig.
|
|
116
|
+
const prerenderConfig = (0, resolvePrerenderConfig_js_1.resolvePrerenderConfig)(vikeConfig.global.config.prerender);
|
|
116
117
|
validatePrerenderConfig(prerenderConfig);
|
|
117
118
|
if (!prerenderConfig) {
|
|
118
119
|
(0, utils_js_1.assert)(standaloneTrigger);
|
|
@@ -160,9 +161,13 @@ async function collectDoNoPrerenderList(pageConfigs, doNotPrerenderList, concurr
|
|
|
160
161
|
// V1 design
|
|
161
162
|
pageConfigs.forEach((pageConfig) => {
|
|
162
163
|
const configName = 'prerender';
|
|
163
|
-
const configValue = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, configName
|
|
164
|
-
if (configValue
|
|
165
|
-
|
|
164
|
+
const configValue = (0, getConfigValueBuildTime_js_1.getConfigValueBuildTime)(pageConfig, configName);
|
|
165
|
+
if (!configValue)
|
|
166
|
+
return;
|
|
167
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(configValue, 'value', 'array'));
|
|
168
|
+
if (configValue.value[0] === false) {
|
|
169
|
+
(0, utils_js_1.assert)((0, utils_js_1.isArray)(configValue.definedAtData));
|
|
170
|
+
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(configValue.definedAtData[0]);
|
|
166
171
|
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
167
172
|
doNotPrerenderList.push({
|
|
168
173
|
pageId: pageConfig.pageId,
|
|
@@ -22,9 +22,9 @@ __exportStar(require("../../utils/projectInfo.js"), exports);
|
|
|
22
22
|
__exportStar(require("../../utils/objectAssign.js"), exports);
|
|
23
23
|
__exportStar(require("../../utils/isObjectWithKeys.js"), exports);
|
|
24
24
|
__exportStar(require("../../utils/isCallable.js"), exports);
|
|
25
|
-
__exportStar(require("
|
|
25
|
+
__exportStar(require("../plugin/getOutDirs.js"), exports);
|
|
26
26
|
__exportStar(require("../../utils/isPropertyGetter.js"), exports);
|
|
27
|
-
__exportStar(require("../../utils/
|
|
27
|
+
__exportStar(require("../../utils/toPosixPath.js"), exports);
|
|
28
28
|
__exportStar(require("../../utils/urlToFile.js"), exports);
|
|
29
29
|
__exportStar(require("../../utils/isPlainObject.js"), exports);
|
|
30
30
|
__exportStar(require("../../utils/assertSetup.js"), exports);
|
|
@@ -8,7 +8,6 @@ exports.getGlobalContextAsync = getGlobalContextAsync;
|
|
|
8
8
|
exports.getGlobalContext = getGlobalContext;
|
|
9
9
|
exports.getViteDevServer = getViteDevServer;
|
|
10
10
|
exports.getViteConfig = getViteConfig;
|
|
11
|
-
exports.getRuntimeManifest = getRuntimeManifest;
|
|
12
11
|
exports.initGlobalContext_renderPage = initGlobalContext_renderPage;
|
|
13
12
|
exports.initGlobalContext_runPrerender = initGlobalContext_runPrerender;
|
|
14
13
|
exports.initGlobalContext_getGlobalContextAsync = initGlobalContext_getGlobalContextAsync;
|
|
@@ -19,14 +18,13 @@ exports.setGlobalContext_isViteDev = setGlobalContext_isViteDev;
|
|
|
19
18
|
exports.setGlobalContext_isPrerendering = setGlobalContext_isPrerendering;
|
|
20
19
|
exports.setGlobalContext_buildEntry = setGlobalContext_buildEntry;
|
|
21
20
|
exports.clearGlobalContext = clearGlobalContext;
|
|
21
|
+
exports.assertBuildInfo = assertBuildInfo;
|
|
22
|
+
exports.getViteConfigRuntime = getViteConfigRuntime;
|
|
22
23
|
const utils_js_1 = require("./utils.js");
|
|
23
24
|
const runtime_1 = require("@brillout/vite-plugin-server-entry/runtime");
|
|
24
25
|
const virtualFileImportUserCode_js_1 = require("../shared/virtual-files/virtualFileImportUserCode.js");
|
|
25
26
|
const getPageFiles_js_1 = require("../../shared/getPageFiles/getPageFiles.js");
|
|
26
|
-
const assertPluginManifest_js_1 = require("../shared/assertPluginManifest.js");
|
|
27
|
-
const assertRuntimeManifest_js_1 = require("../shared/assertRuntimeManifest.js");
|
|
28
27
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
29
|
-
const resolveBase_js_1 = require("../shared/resolveBase.js");
|
|
30
28
|
const loadPageRoutes_js_1 = require("../../shared/route/loadPageRoutes.js");
|
|
31
29
|
const assertV1Design_js_1 = require("../shared/assertV1Design.js");
|
|
32
30
|
const debug = (0, utils_js_1.createDebugger)('vike:globalContext');
|
|
@@ -144,7 +142,7 @@ async function initGlobalContext(isProduction) {
|
|
|
144
142
|
(0, utils_js_1.assert)(viteDevServer);
|
|
145
143
|
(0, utils_js_1.assert)(!isPrerendering);
|
|
146
144
|
const { globalConfig, userFiles } = await getPageRuntimeInfo(isProduction);
|
|
147
|
-
const
|
|
145
|
+
const viteConfigRuntime = getViteConfigRuntime(viteConfig);
|
|
148
146
|
globalObject.globalContext = {
|
|
149
147
|
isProduction: false,
|
|
150
148
|
isPrerendering: false,
|
|
@@ -155,20 +153,14 @@ async function initGlobalContext(isProduction) {
|
|
|
155
153
|
global: globalConfig
|
|
156
154
|
},
|
|
157
155
|
...userFiles,
|
|
158
|
-
|
|
159
|
-
baseAssets: pluginManifest.baseAssets,
|
|
160
|
-
includeAssetsImportedByServer: pluginManifest.includeAssetsImportedByServer,
|
|
161
|
-
trailingSlash: pluginManifest.trailingSlash,
|
|
162
|
-
disableUrlNormalization: pluginManifest.disableUrlNormalization
|
|
156
|
+
viteConfigRuntime
|
|
163
157
|
};
|
|
164
158
|
}
|
|
165
159
|
else {
|
|
166
160
|
const buildEntry = await getBuildEntry(globalObject.outDirRoot, isPrerendering);
|
|
167
|
-
const { assetsManifest,
|
|
161
|
+
const { assetsManifest, buildInfo } = buildEntry;
|
|
168
162
|
(0, getPageFiles_js_1.setPageFiles)(buildEntry.pageFiles);
|
|
169
163
|
const { globalConfig, userFiles } = await getPageRuntimeInfo(isProduction);
|
|
170
|
-
assertViteManifest(assetsManifest);
|
|
171
|
-
(0, assertPluginManifest_js_1.assertPluginManifest)(pluginManifest);
|
|
172
164
|
const globalContext = {
|
|
173
165
|
isProduction: true,
|
|
174
166
|
assetsManifest,
|
|
@@ -177,12 +169,8 @@ async function initGlobalContext(isProduction) {
|
|
|
177
169
|
},
|
|
178
170
|
...userFiles,
|
|
179
171
|
viteDevServer: null,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
includeAssetsImportedByServer: pluginManifest.includeAssetsImportedByServer,
|
|
183
|
-
trailingSlash: pluginManifest.trailingSlash,
|
|
184
|
-
usesClientRouter: pluginManifest.usesClientRouter,
|
|
185
|
-
disableUrlNormalization: pluginManifest.disableUrlNormalization
|
|
172
|
+
viteConfigRuntime: buildInfo.viteConfigRuntime,
|
|
173
|
+
usesClientRouter: buildInfo.usesClientRouter
|
|
186
174
|
};
|
|
187
175
|
if (isPrerendering) {
|
|
188
176
|
(0, utils_js_1.assert)(viteConfig);
|
|
@@ -217,19 +205,6 @@ async function getPageRuntimeInfo(isProduction) {
|
|
|
217
205
|
pageConfigs.length > 0, pageFilesAll);
|
|
218
206
|
return { userFiles, globalConfig };
|
|
219
207
|
}
|
|
220
|
-
function getRuntimeManifest(vikeConfigGlobal, viteConfig) {
|
|
221
|
-
const { includeAssetsImportedByServer, trailingSlash, disableUrlNormalization } = vikeConfigGlobal;
|
|
222
|
-
const { baseServer, baseAssets } = (0, resolveBase_js_1.resolveBaseFromResolvedConfig)(vikeConfigGlobal.baseServer, vikeConfigGlobal.baseAssets, viteConfig);
|
|
223
|
-
const manifest = {
|
|
224
|
-
baseServer,
|
|
225
|
-
baseAssets,
|
|
226
|
-
includeAssetsImportedByServer,
|
|
227
|
-
trailingSlash,
|
|
228
|
-
disableUrlNormalization
|
|
229
|
-
};
|
|
230
|
-
(0, assertRuntimeManifest_js_1.assertRuntimeManifest)(manifest);
|
|
231
|
-
return manifest;
|
|
232
|
-
}
|
|
233
208
|
function assertViteManifest(manifest) {
|
|
234
209
|
(0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(manifest));
|
|
235
210
|
/* We should include these assertions but we don't as a workaround for PWA manifests: https://github.com/vikejs/vike/issues/769
|
|
@@ -262,17 +237,48 @@ async function getBuildEntry(outDir, isPrerendering) {
|
|
|
262
237
|
(0, utils_js_1.assert)(globalObject.buildEntry);
|
|
263
238
|
}
|
|
264
239
|
const { buildEntry } = globalObject;
|
|
265
|
-
(
|
|
266
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'pageFiles', 'object'));
|
|
267
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'assetsManifest', 'object'));
|
|
268
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'pluginManifest', 'object'));
|
|
240
|
+
assertBuildEntry(buildEntry);
|
|
269
241
|
return buildEntry;
|
|
270
242
|
}
|
|
271
243
|
function setGlobalContext_buildEntry(buildEntry) {
|
|
272
244
|
debug('setGlobalContext_buildEntry()');
|
|
245
|
+
assertBuildEntry(buildEntry);
|
|
273
246
|
globalObject.buildEntry = buildEntry;
|
|
274
247
|
globalObject.buildEntryPrevious = buildEntry;
|
|
275
248
|
}
|
|
249
|
+
function assertBuildEntry(buildEntry) {
|
|
250
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(buildEntry));
|
|
251
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'pageFiles', 'object'));
|
|
252
|
+
const { pageFiles } = buildEntry;
|
|
253
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'assetsManifest', 'object'));
|
|
254
|
+
const { assetsManifest } = buildEntry;
|
|
255
|
+
assertViteManifest(assetsManifest);
|
|
256
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'buildInfo', 'object'));
|
|
257
|
+
const { buildInfo } = buildEntry;
|
|
258
|
+
assertBuildInfo(buildInfo);
|
|
259
|
+
(0, utils_js_1.checkType)({ pageFiles, assetsManifest, buildInfo });
|
|
260
|
+
}
|
|
261
|
+
function assertBuildInfo(buildInfo) {
|
|
262
|
+
(0, utils_js_1.assert)((0, utils_js_1.isObject)(buildInfo));
|
|
263
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildInfo, 'versionAtBuildTime', 'string'));
|
|
264
|
+
assertVersionAtBuildTime(buildInfo.versionAtBuildTime);
|
|
265
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildInfo, 'viteConfigRuntime', 'object'));
|
|
266
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildInfo.viteConfigRuntime, '_baseViteOriginal', 'string'));
|
|
267
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildInfo, 'usesClientRouter', 'boolean'));
|
|
268
|
+
(0, utils_js_1.checkType)({ ...buildInfo, viteConfigRuntime: buildInfo.viteConfigRuntime });
|
|
269
|
+
}
|
|
270
|
+
function assertVersionAtBuildTime(versionAtBuildTime) {
|
|
271
|
+
const versionAtRuntime = utils_js_1.projectInfo.projectVersion;
|
|
272
|
+
const pretty = (version) => picocolors_1.default.bold(`vike@${version}`);
|
|
273
|
+
(0, utils_js_1.assertUsage)(versionAtBuildTime === versionAtRuntime, `Re-build your app (you're using ${pretty(versionAtRuntime)} but your app was built with ${pretty(versionAtBuildTime)})`);
|
|
274
|
+
}
|
|
275
|
+
function getViteConfigRuntime(viteConfig) {
|
|
276
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(viteConfig, '_baseViteOriginal', 'string'));
|
|
277
|
+
const viteConfigRuntime = {
|
|
278
|
+
_baseViteOriginal: viteConfig._baseViteOriginal
|
|
279
|
+
};
|
|
280
|
+
return viteConfigRuntime;
|
|
281
|
+
}
|
|
276
282
|
function initDevEntry() {
|
|
277
283
|
(0, getPageFiles_js_1.setPageFilesAsync)(getPageFilesExports);
|
|
278
284
|
}
|
|
@@ -23,6 +23,7 @@ const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePa
|
|
|
23
23
|
const executeGuardHook_js_1 = require("../../../shared/route/executeGuardHook.js");
|
|
24
24
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
25
25
|
const isServerSideError_js_1 = require("../../../shared/misc/isServerSideError.js");
|
|
26
|
+
const resolveBase_js_1 = require("../../shared/resolveBase.js");
|
|
26
27
|
async function renderPageAlreadyRouted(pageContext) {
|
|
27
28
|
// pageContext.pageId can either be the:
|
|
28
29
|
// - ID of the page matching the routing, or the
|
|
@@ -119,14 +120,16 @@ function getPageContextInitEnhanced(pageContextInit, { ssr: { urlRewrite, urlHan
|
|
|
119
120
|
} } = {}) {
|
|
120
121
|
(0, utils_js_1.assert)(pageContextInit.urlOriginal);
|
|
121
122
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
123
|
+
const { baseServer, baseAssets } = (0, resolveBase_js_1.resolveBaseRuntime)();
|
|
122
124
|
const pageContextInitEnhanced = {};
|
|
123
125
|
(0, utils_js_1.objectAssign)(pageContextInitEnhanced, pageContextInit);
|
|
124
126
|
(0, utils_js_1.objectAssign)(pageContextInitEnhanced, {
|
|
125
127
|
_objectCreatedByVike: true,
|
|
126
128
|
// The following is defined on `pageContext` because we can eventually make these non-global
|
|
127
|
-
_baseServer:
|
|
128
|
-
_baseAssets:
|
|
129
|
-
|
|
129
|
+
_baseServer: baseServer,
|
|
130
|
+
_baseAssets: baseAssets,
|
|
131
|
+
// TODO/now: add meta.default
|
|
132
|
+
_includeAssetsImportedByServer: globalContext.vikeConfig.global.config.includeAssetsImportedByServer ?? true,
|
|
130
133
|
// TODO: use GloablContext instead
|
|
131
134
|
_pageFilesAll: globalContext.pageFilesAll,
|
|
132
135
|
_pageConfigs: globalContext.pageConfigs,
|
|
@@ -3,6 +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.redirectsErrPrefix = void 0;
|
|
6
7
|
exports.resolveRedirects = resolveRedirects;
|
|
7
8
|
exports.resolveRouteStringRedirect = resolveRouteStringRedirect;
|
|
8
9
|
const assertIsNotBrowser_js_1 = require("../../../utils/assertIsNotBrowser.js");
|
|
@@ -11,8 +12,8 @@ const resolveUrlPathname_js_1 = require("../../../shared/route/resolveUrlPathnam
|
|
|
11
12
|
const resolveRouteString_js_1 = require("../../../shared/route/resolveRouteString.js");
|
|
12
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
14
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)(); // Don't bloat the client
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const redirectsErrPrefix = '[+redirects]';
|
|
16
|
+
exports.redirectsErrPrefix = redirectsErrPrefix;
|
|
16
17
|
function resolveRedirects(redirectsAll, urlPathname) {
|
|
17
18
|
const redirects = merge(redirectsAll);
|
|
18
19
|
for (const [urlSource, urlTarget] of Object.entries(redirects)) {
|
|
@@ -23,9 +24,9 @@ function resolveRedirects(redirectsAll, urlPathname) {
|
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
26
|
function resolveRouteStringRedirect(urlSource, urlTarget, urlPathname) {
|
|
26
|
-
(0, resolveRouteString_js_1.assertRouteString)(urlSource, `${
|
|
27
|
+
(0, resolveRouteString_js_1.assertRouteString)(urlSource, `${redirectsErrPrefix} Invalid`);
|
|
27
28
|
// Is allowing any protocol a safety issue? https://github.com/vikejs/vike/pull/1292#issuecomment-1828043917
|
|
28
|
-
(0, utils_js_1.assertUsageUrlRedirectTarget)(urlTarget, `${
|
|
29
|
+
(0, utils_js_1.assertUsageUrlRedirectTarget)(urlTarget, `${redirectsErrPrefix} The URL redirection target`, true);
|
|
29
30
|
assertParams(urlSource, urlTarget);
|
|
30
31
|
const match = (0, resolveRouteString_js_1.resolveRouteString)(urlSource, urlPathname);
|
|
31
32
|
if (!match)
|
|
@@ -41,7 +42,7 @@ function assertParams(urlSource, urlTarget) {
|
|
|
41
42
|
routeSegments.forEach((routeSegment) => {
|
|
42
43
|
if (routeSegment.startsWith('@') || routeSegment.startsWith('*')) {
|
|
43
44
|
const segments = urlSource.split('/');
|
|
44
|
-
(0, utils_js_1.assertUsage)(segments.includes(routeSegment), `${
|
|
45
|
+
(0, utils_js_1.assertUsage)(segments.includes(routeSegment), `${redirectsErrPrefix} The redirection source URL ${picocolors_1.default.string(urlSource)} is missing the URL parameter ${picocolors_1.default.string(routeSegment)} used by the redirection target URL ${picocolors_1.default.string(urlTarget)}`);
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
}
|
|
@@ -23,6 +23,7 @@ const error_page_js_1 = require("../../shared/error-page.js");
|
|
|
23
23
|
const handleErrorWithoutErrorPage_js_1 = require("./renderPage/handleErrorWithoutErrorPage.js");
|
|
24
24
|
const loadUserFilesServerSide_js_1 = require("./renderPage/loadUserFilesServerSide.js");
|
|
25
25
|
const resolveRedirects_js_1 = require("./renderPage/resolveRedirects.js");
|
|
26
|
+
const resolveBase_js_1 = require("../shared/resolveBase.js");
|
|
26
27
|
const globalObject = (0, utils_js_1.getGlobalObject)('runtime/renderPage.ts', {
|
|
27
28
|
httpRequestsCount: 0
|
|
28
29
|
});
|
|
@@ -342,14 +343,16 @@ function assertIsNotViteRequest(urlPathname, urlOriginal) {
|
|
|
342
343
|
(0, utils_js_1.assertUsage)(false, `${picocolors_1.default.code('renderPage(pageContextInit)')} called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which is unexpected because the URL ${picocolors_1.default.bold(urlOriginal)} should have already been handled by the development middleware: make sure the ${picocolors_1.default.cyan('createDevMiddleware()')} middleware is executed *before* the ${picocolors_1.default.cyan('renderPage()')} middleware, see ${picocolors_1.default.underline('https://vike.dev/renderPage')}`);
|
|
343
344
|
}
|
|
344
345
|
function normalizeUrl(pageContextInit, httpRequestId) {
|
|
345
|
-
const
|
|
346
|
+
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
347
|
+
const { baseServer } = (0, resolveBase_js_1.resolveBaseRuntime)();
|
|
348
|
+
const { trailingSlash, disableUrlNormalization } = globalContext.vikeConfig.global.config;
|
|
346
349
|
if (disableUrlNormalization)
|
|
347
350
|
return null;
|
|
348
351
|
const { urlOriginal } = pageContextInit;
|
|
349
352
|
const { isPageContextRequest } = (0, handlePageContextRequestUrl_js_1.handlePageContextRequestUrl)(urlOriginal);
|
|
350
353
|
if (isPageContextRequest)
|
|
351
354
|
return null;
|
|
352
|
-
const urlNormalized = (0, utils_js_1.normalizeUrlPathname)(urlOriginal, trailingSlash, baseServer);
|
|
355
|
+
const urlNormalized = (0, utils_js_1.normalizeUrlPathname)(urlOriginal, trailingSlash ?? false, baseServer);
|
|
353
356
|
if (!urlNormalized)
|
|
354
357
|
return null;
|
|
355
358
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`URL normalized from ${picocolors_1.default.cyan(urlOriginal)} to ${picocolors_1.default.cyan(urlNormalized)} (https://vike.dev/url-normalization)`, httpRequestId, 'info');
|
|
@@ -360,7 +363,8 @@ function normalizeUrl(pageContextInit, httpRequestId) {
|
|
|
360
363
|
}
|
|
361
364
|
function getPermanentRedirect(pageContextInit, httpRequestId) {
|
|
362
365
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
363
|
-
const
|
|
366
|
+
const { baseServer } = (0, resolveBase_js_1.resolveBaseRuntime)();
|
|
367
|
+
const urlWithoutBase = (0, utils_js_1.removeBaseServer)(pageContextInit.urlOriginal, baseServer);
|
|
364
368
|
let origin = null;
|
|
365
369
|
let urlTargetExternal = null;
|
|
366
370
|
let urlTarget = (0, utils_js_1.modifyUrlPathname)(urlWithoutBase, (urlPathname) => {
|
|
@@ -391,8 +395,9 @@ function getPermanentRedirect(pageContextInit, httpRequestId) {
|
|
|
391
395
|
}
|
|
392
396
|
if (normalize(urlTarget) === normalize(urlWithoutBase))
|
|
393
397
|
return null;
|
|
398
|
+
const { baseServer } = (0, resolveBase_js_1.resolveBaseRuntime)();
|
|
394
399
|
if (!originChanged)
|
|
395
|
-
urlTarget = (0, utils_js_1.prependBase)(urlTarget,
|
|
400
|
+
urlTarget = (0, utils_js_1.prependBase)(urlTarget, baseServer);
|
|
396
401
|
(0, utils_js_1.assert)(urlTarget !== pageContextInit.urlOriginal);
|
|
397
402
|
}
|
|
398
403
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`Permanent redirection defined by config.redirects (https://vike.dev/redirects)`, httpRequestId, 'info');
|
|
@@ -457,7 +462,7 @@ pageContextNominalPageInit, httpRequestId, pageContextErrorPageInit) {
|
|
|
457
462
|
return { pageContextAbort };
|
|
458
463
|
}
|
|
459
464
|
function assertBaseUrl(pageContextInit) {
|
|
460
|
-
const { baseServer } = (0,
|
|
465
|
+
const { baseServer } = (0, resolveBase_js_1.resolveBaseRuntime)();
|
|
461
466
|
const { urlOriginal } = pageContextInit;
|
|
462
467
|
const { urlWithoutPageContextRequestSuffix } = (0, handlePageContextRequestUrl_js_1.handlePageContextRequestUrl)(urlOriginal);
|
|
463
468
|
const { hasBaseServer } = (0, utils_js_1.parseUrl)(urlWithoutPageContextRequestSuffix, baseServer);
|
|
@@ -41,8 +41,8 @@ __exportStar(require("../../utils/compareString.js"), exports);
|
|
|
41
41
|
__exportStar(require("../../utils/isObjectWithKeys.js"), exports);
|
|
42
42
|
__exportStar(require("../../utils/stringifyStringArray.js"), exports);
|
|
43
43
|
__exportStar(require("../../utils/unique.js"), exports);
|
|
44
|
-
__exportStar(require("../../utils/
|
|
45
|
-
__exportStar(require("
|
|
44
|
+
__exportStar(require("../../utils/toPosixPath.js"), exports);
|
|
45
|
+
__exportStar(require("../plugin/getOutDirs.js"), exports);
|
|
46
46
|
__exportStar(require("../../utils/capitalizeFirstLetter.js"), exports);
|
|
47
47
|
__exportStar(require("../../utils/debugGlob.js"), exports);
|
|
48
48
|
__exportStar(require("../../utils/isSameErrorMessage.js"), exports);
|
|
@@ -4,14 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolveBase = resolveBase;
|
|
7
|
+
exports.resolveBaseRuntime = resolveBaseRuntime;
|
|
7
8
|
exports.resolveBaseFromResolvedConfig = resolveBaseFromResolvedConfig;
|
|
8
9
|
const utils_js_1 = require("./utils.js");
|
|
9
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
|
+
const globalContext_js_1 = require("../runtime/globalContext.js");
|
|
10
12
|
function resolveBaseFromResolvedConfig(baseServer, baseAssets, config) {
|
|
11
13
|
let baseViteOriginal = config._baseViteOriginal;
|
|
12
14
|
(0, utils_js_1.assert)(baseViteOriginal === null || typeof baseViteOriginal == 'string');
|
|
13
15
|
return resolveBase(baseViteOriginal, baseServer, baseAssets);
|
|
14
16
|
}
|
|
17
|
+
function resolveBaseRuntime() {
|
|
18
|
+
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
19
|
+
const baseViteOriginal = globalContext.viteConfigRuntime._baseViteOriginal;
|
|
20
|
+
const baseServerUnresolved = globalContext.vikeConfig.global.config.baseServer ?? null;
|
|
21
|
+
const baseAssetsUnresolved = globalContext.vikeConfig.global.config.baseAssets ?? null;
|
|
22
|
+
return resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved);
|
|
23
|
+
}
|
|
15
24
|
function resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved) {
|
|
16
25
|
if (baseViteOriginal === '/__UNSET__')
|
|
17
26
|
baseViteOriginal = null;
|
|
@@ -68,11 +68,11 @@ function getPageConfigUserFriendly(pageFiles, pageConfig) {
|
|
|
68
68
|
(0, utils_js_1.assert)(!('default' in exports));
|
|
69
69
|
(0, utils_js_1.assert)(!('default' in exportsAll));
|
|
70
70
|
const pageContextExports = {
|
|
71
|
+
config: config,
|
|
71
72
|
from,
|
|
72
73
|
source,
|
|
73
74
|
sources,
|
|
74
75
|
// TODO/eventually: deprecate/remove every prop below
|
|
75
|
-
config,
|
|
76
76
|
configEntries,
|
|
77
77
|
exports,
|
|
78
78
|
exportsAll,
|
|
@@ -156,7 +156,7 @@ function getPageConfigUserFriendlyNew(pageConfig) {
|
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
158
|
return {
|
|
159
|
-
config,
|
|
159
|
+
config: config,
|
|
160
160
|
configEntries,
|
|
161
161
|
exportsAll,
|
|
162
162
|
source,
|
package/dist/cjs/shared/utils.js
CHANGED
|
@@ -32,7 +32,7 @@ __exportStar(require("../utils/isPlainObject.js"), exports);
|
|
|
32
32
|
__exportStar(require("../utils/compareString.js"), exports);
|
|
33
33
|
__exportStar(require("../utils/isNotNullish.js"), exports);
|
|
34
34
|
__exportStar(require("../utils/stringifyStringArray.js"), exports);
|
|
35
|
-
__exportStar(require("../utils/
|
|
35
|
+
__exportStar(require("../utils/toPosixPath.js"), exports);
|
|
36
36
|
__exportStar(require("../utils/cast.js"), exports);
|
|
37
37
|
__exportStar(require("../utils/isPropertyGetter.js"), exports);
|
|
38
38
|
__exportStar(require("../utils/isPromise.js"), exports);
|
|
@@ -7,16 +7,16 @@ exports.findFile = findFile;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const isArray_js_1 = require("./isArray.js");
|
|
10
|
-
const
|
|
10
|
+
const toPosixPath_js_1 = require("./toPosixPath.js");
|
|
11
11
|
function findFile(arg, cwd) {
|
|
12
|
-
(0,
|
|
12
|
+
(0, toPosixPath_js_1.assertPosixPath)(cwd);
|
|
13
13
|
const filenames = (0, isArray_js_1.isArray)(arg) ? arg : [arg];
|
|
14
14
|
let dir = cwd;
|
|
15
15
|
while (true) {
|
|
16
16
|
for (const filename of filenames) {
|
|
17
17
|
const configFilePath = path_1.default.posix.join(dir, `./${filename}`);
|
|
18
18
|
if (fs_1.default.existsSync(configFilePath)) {
|
|
19
|
-
(0,
|
|
19
|
+
(0, toPosixPath_js_1.assertPosixPath)(configFilePath);
|
|
20
20
|
return configFilePath;
|
|
21
21
|
}
|
|
22
22
|
}
|
package/dist/cjs/utils/isDev.js
CHANGED
|
@@ -4,12 +4,13 @@ exports.isDevCheck = isDevCheck;
|
|
|
4
4
|
exports.applyDev = applyDev;
|
|
5
5
|
exports.applyPreview = applyPreview;
|
|
6
6
|
const assert_js_1 = require("./assert.js");
|
|
7
|
+
const vite_1 = require("vite");
|
|
7
8
|
function isDevCheck(configEnv) {
|
|
8
9
|
const { isPreview, command } = configEnv;
|
|
9
10
|
// Released at vite@5.1.0 which is guaranteed with `assertVersion('Vite', version, '5.1.0')`
|
|
10
11
|
// - Release: https://github.com/vitejs/vite/blob/6f7466e6211027686f40ad7e4ce6ec8477414546/packages/vite/CHANGELOG.md#510-beta4-2024-01-26:~:text=fix(preview)%3A-,set%20isPreview%20true,-(%2315695)%20(93fce55
|
|
11
12
|
// - Surprisingly, this assert() can fail: https://github.com/vikejs/vike/issues/2120
|
|
12
|
-
(0, assert_js_1.assert)(typeof isPreview === 'boolean');
|
|
13
|
+
(0, assert_js_1.assert)(typeof isPreview === 'boolean', { isPreview, version: vite_1.version });
|
|
13
14
|
return command === 'serve' && !isPreview;
|
|
14
15
|
}
|
|
15
16
|
function applyDev(_, env) {
|
|
@@ -7,7 +7,7 @@ exports.assertFilePathAbsoluteFilesystem = assertFilePathAbsoluteFilesystem;
|
|
|
7
7
|
exports.isFilePathAbsolute = isFilePathAbsolute;
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const assert_js_1 = require("./assert.js");
|
|
10
|
-
const
|
|
10
|
+
const toPosixPath_js_1 = require("./toPosixPath.js");
|
|
11
11
|
/**
|
|
12
12
|
* Asserts that `filePath` is an absolute file path starting from the filesystem root.
|
|
13
13
|
*
|
|
@@ -19,7 +19,7 @@ function assertFilePathAbsoluteFilesystem(filePath) {
|
|
|
19
19
|
// - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
|
|
20
20
|
// - But that's okay because the assertion will eventually fail for Windows users.
|
|
21
21
|
(0, assert_js_1.assert)(isFilePathAbsoluteFilesystem(filePath));
|
|
22
|
-
(0,
|
|
22
|
+
(0, toPosixPath_js_1.assertPosixPath)(filePath);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Whether `filePath` is an absolute file path starting from the filesystem root.
|
|
@@ -4,7 +4,7 @@ exports.requireResolve = requireResolve;
|
|
|
4
4
|
const assert_js_1 = require("./assert.js");
|
|
5
5
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
6
6
|
const assertSetup_js_1 = require("./assertSetup.js");
|
|
7
|
-
const
|
|
7
|
+
const toPosixPath_js_1 = require("./toPosixPath.js");
|
|
8
8
|
const isScriptFile_js_1 = require("./isScriptFile.js");
|
|
9
9
|
const module_1 = require("module");
|
|
10
10
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
@@ -15,7 +15,7 @@ const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
|
15
15
|
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
16
16
|
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
17
17
|
function requireResolve(importPath, cwd) {
|
|
18
|
-
(0,
|
|
18
|
+
(0, toPosixPath_js_1.assertPosixPath)(cwd);
|
|
19
19
|
const clean = addFileExtensionsToRequireResolve();
|
|
20
20
|
importPath = removeFileExtention(importPath);
|
|
21
21
|
let importedFile;
|
|
@@ -29,7 +29,7 @@ function requireResolve(importPath, cwd) {
|
|
|
29
29
|
clean();
|
|
30
30
|
}
|
|
31
31
|
if (importedFile) {
|
|
32
|
-
importedFile = (0,
|
|
32
|
+
importedFile = (0, toPosixPath_js_1.toPosixPath)(importedFile);
|
|
33
33
|
}
|
|
34
34
|
return importedFile;
|
|
35
35
|
}
|
|
@@ -4,5 +4,5 @@ import { onLoad } from './onLoad.js';
|
|
|
4
4
|
onLoad();
|
|
5
5
|
export * from '../../utils/assert.js';
|
|
6
6
|
export * from '../../utils/getGlobalObject.js';
|
|
7
|
-
export * from '../../utils/
|
|
7
|
+
export * from '../../utils/toPosixPath.js';
|
|
8
8
|
export * from '../../utils/isObject.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
2
|
export { resolveOutDir };
|
|
3
|
-
import { viteIsSSR } from '
|
|
4
|
-
import { assert, assertUsage } from '
|
|
5
|
-
import { pathJoin } from '
|
|
6
|
-
import { assertPosixPath, toPosixPath } from '
|
|
3
|
+
import { viteIsSSR } from '../../utils/viteIsSSR.js';
|
|
4
|
+
import { assert, assertUsage } from '../../utils/assert.js';
|
|
5
|
+
import { pathJoin } from '../../utils/path-shim.js';
|
|
6
|
+
import { assertPosixPath, toPosixPath } from '../../utils/toPosixPath.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
|
-
import { createDebugger } from '
|
|
8
|
+
import { createDebugger } from '../../utils/debug.js';
|
|
9
9
|
const debug = createDebugger('vike:outDir');
|
|
10
10
|
function getOutDirs(config) {
|
|
11
11
|
debug('getOutDirs()', new Error().stack);
|
|
@@ -2,6 +2,34 @@ export default plugin;
|
|
|
2
2
|
export { plugin };
|
|
3
3
|
export { plugin as ssr };
|
|
4
4
|
export type { VikeVitePluginOptions as UserConfig };
|
|
5
|
+
export type { VikeVitePluginOptions };
|
|
5
6
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
6
|
-
import type { VikeVitePluginOptions } from './plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
declare function plugin(vikeVitePluginOptions?: VikeVitePluginOptions): any;
|
|
8
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
9
|
+
type VikeVitePluginOptions = {
|
|
10
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
11
|
+
prerender?: boolean | {
|
|
12
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
13
|
+
noExtraDir?: boolean;
|
|
14
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
15
|
+
parallel?: boolean | number;
|
|
16
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
17
|
+
partial?: boolean;
|
|
18
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
19
|
+
disableAutoRun?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
22
|
+
disableAutoFullBuild?: boolean | 'prerender';
|
|
23
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
24
|
+
baseServer?: string;
|
|
25
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
26
|
+
baseAssets?: string;
|
|
27
|
+
/** @deprecated It's now `true` by default. You can remove this option. */
|
|
28
|
+
includeAssetsImportedByServer?: boolean;
|
|
29
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
30
|
+
redirects?: Record<string, string>;
|
|
31
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
32
|
+
trailingSlash?: boolean;
|
|
33
|
+
/** @deprecated Define Vike settings in +config.js instead of vite.config.js */
|
|
34
|
+
disableUrlNormalization?: boolean;
|
|
35
|
+
};
|
|
@@ -3,8 +3,7 @@ export { plugin };
|
|
|
3
3
|
// TODO/v1-release: remove
|
|
4
4
|
export { plugin as ssr };
|
|
5
5
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
6
|
-
import {
|
|
7
|
-
import { assertUsage, assertVersion, markSetup_vikeVitePlugin } from './utils.js';
|
|
6
|
+
import { assertUsage } from './utils.js';
|
|
8
7
|
import { buildConfig } from './plugins/buildConfig.js';
|
|
9
8
|
import { previewConfig } from './plugins/previewConfig.js';
|
|
10
9
|
import { autoFullBuild } from './plugins/autoFullBuild.js';
|
|
@@ -27,8 +26,7 @@ import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.
|
|
|
27
26
|
import { resolveClientEntriesDev } from './resolveClientEntriesDev.js';
|
|
28
27
|
import { workaroundCssModuleHmr } from './plugins/workaroundCssModuleHmr.js';
|
|
29
28
|
import { workaroundVite6HmrRegression } from './plugins/workaroundVite6HmrRegression.js';
|
|
30
|
-
|
|
31
|
-
assertViteVersion();
|
|
29
|
+
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
32
30
|
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
33
31
|
// Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
|
|
34
32
|
function plugin(vikeVitePluginOptions = {}) {
|
|
@@ -63,10 +61,6 @@ Object.defineProperty(plugin, 'apply', {
|
|
|
63
61
|
assertUsage(false, `Add ${pc.cyan('vike()')} instead of ${pc.cyan('vike')} to vite.config.js#plugins (i.e. call the function and add the return value instead of adding the function itself)`, { showStackTrace: true });
|
|
64
62
|
}
|
|
65
63
|
});
|
|
66
|
-
// package.json#peerDependencies isn't enough as users can ignore it
|
|
67
|
-
function assertViteVersion() {
|
|
68
|
-
assertVersion('Vite', version, '5.1.0');
|
|
69
|
-
}
|
|
70
64
|
// Ensures following works: `const vike = require('vike/plugin')` / `import vike from 'vike/plugin'`
|
|
71
65
|
// - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
|
|
72
66
|
try {
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export { onLoad };
|
|
2
2
|
import { assertIsNotBrowser } from '../../utils/assertIsNotBrowser.js';
|
|
3
|
-
import { assertIsNotProductionRuntime } from '../../utils/assertSetup.js';
|
|
3
|
+
import { assertIsNotProductionRuntime, markSetup_vikeVitePlugin } from '../../utils/assertSetup.js';
|
|
4
4
|
import { assertNodeVersion } from '../../utils/assertNodeVersion.js';
|
|
5
|
+
import { assertVersion } from '../../utils/assertVersion.js';
|
|
6
|
+
import { version } from 'vite';
|
|
5
7
|
function onLoad() {
|
|
8
|
+
markSetup_vikeVitePlugin();
|
|
6
9
|
assertIsNotBrowser();
|
|
7
10
|
assertNodeVersion();
|
|
8
|
-
//
|
|
11
|
+
// package.json#peerDependencies isn't enough as users can ignore it
|
|
12
|
+
assertVersion('Vite', version, '5.1.0');
|
|
13
|
+
// Ensure we don't bloat the server runtime with heavy dependencies such Vite and esbuild
|
|
9
14
|
assertIsNotProductionRuntime();
|
|
10
15
|
}
|