vike 0.4.253-commit-a8f23e5 → 0.4.253-commit-6539e7f

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.
@@ -4,15 +4,15 @@ import { VikeConfigInternal } from '../vite/shared/resolveVikeConfigInternal.js'
4
4
  import type { PageConfigBuildTime } from '../../types/PageConfig.js';
5
5
  declare function resolvePrerenderConfigGlobal(vikeConfig: Pick<VikeConfigInternal, 'config' | '_pageConfigs' | '_from'>): Promise<{
6
6
  partial: boolean;
7
- redirects: boolean | null;
8
7
  noExtraDir: boolean | null;
9
- keepDistServer: boolean;
10
8
  parallel: number | boolean;
11
9
  disableAutoRun: boolean;
12
10
  } & {
13
11
  defaultLocalValue: boolean;
14
- isPrerenderingEnabledForAllPages: boolean;
15
12
  isPrerenderingEnabled: boolean;
13
+ isPrerenderingEnabledForAllPages: boolean;
14
+ redirects: boolean;
15
+ keepDistServer: boolean;
16
16
  }>;
17
17
  declare function resolvePrerenderConfigLocal(pageConfig: PageConfigBuildTime): Promise<{
18
18
  value: boolean;
@@ -16,9 +16,7 @@ async function resolvePrerenderConfigGlobal(vikeConfig) {
16
16
  const prerenderSettings = prerenderConfigsResolved.filter(isObject2);
17
17
  const prerenderConfigGlobal = {
18
18
  partial: pickFirst(prerenderSettings.map((c) => c.partial)) ?? false,
19
- redirects: pickFirst(prerenderSettings.map((c) => c.redirects)) ?? null,
20
19
  noExtraDir: pickFirst(prerenderSettings.map((c) => c.noExtraDir)) ?? null,
21
- keepDistServer: pickFirst(prerenderSettings.map((c) => c.keepDistServer)) ?? false,
22
20
  parallel: pickFirst(prerenderSettings.map((c) => c.parallel)) ?? true,
23
21
  disableAutoRun: pickFirst(prerenderSettings.map((c) => c.disableAutoRun)) ?? false,
24
22
  };
@@ -40,10 +38,16 @@ async function resolvePrerenderConfigGlobal(vikeConfig) {
40
38
  const pageConfigs = vikeConfig._pageConfigs;
41
39
  const prerenderConfigLocalList = await Promise.all(pageConfigs.map(resolvePrerenderConfigLocal));
42
40
  const isEnable = (prerenderConfigLocal) => prerenderConfigLocal?.value ?? defaultLocalValue;
41
+ const isPrerenderingEnabled = pageConfigs.length > 0 && prerenderConfigLocalList.some(isEnable);
42
+ const isPrerenderingEnabledForAllPages = pageConfigs.length > 0 && prerenderConfigLocalList.every(isEnable);
43
43
  objectAssign(prerenderConfigGlobal, {
44
44
  defaultLocalValue,
45
- isPrerenderingEnabledForAllPages: pageConfigs.length > 0 && prerenderConfigLocalList.every(isEnable),
46
- isPrerenderingEnabled: pageConfigs.length > 0 && prerenderConfigLocalList.some(isEnable),
45
+ isPrerenderingEnabled,
46
+ isPrerenderingEnabledForAllPages,
47
+ redirects: pickFirst(prerenderSettings.map((c) => c.redirects)) ?? isPrerenderingEnabledForAllPages,
48
+ keepDistServer: !isPrerenderingEnabledForAllPages
49
+ ? true
50
+ : (pickFirst(prerenderSettings.map((c) => c.keepDistServer)) ?? false),
47
51
  });
48
52
  // TO-DO/next-major-release: remove
49
53
  if (vikeConfig._pageConfigs.length === 0 && defaultLocalValue)
@@ -113,8 +113,7 @@ async function runPrerender(options = {}, trigger) {
113
113
  };
114
114
  await prerenderPages(prerenderContext, concurrencyLimit, onComplete);
115
115
  warnContradictoryNoPrerenderList(prerenderContext._prerenderedPageContexts, doNotPrerenderList);
116
- const { redirects, isPrerenderingEnabledForAllPages } = prerenderConfigGlobal;
117
- if (redirects !== null ? redirects : isPrerenderingEnabledForAllPages) {
116
+ if (prerenderConfigGlobal.redirects) {
118
117
  const showWarningUponDynamicRedirects = !prerenderConfigGlobal.partial;
119
118
  await prerenderRedirects(globalContext, onComplete, showWarningUponDynamicRedirects);
120
119
  }
@@ -125,7 +124,7 @@ async function runPrerender(options = {}, trigger) {
125
124
  const prerenderContextPublic = getPrerenderContextPublic(prerenderContext);
126
125
  objectAssign(vikeConfig.prerenderContext, prerenderContextPublic, true);
127
126
  setGlobalContext_prerenderContext(prerenderContextPublic);
128
- if (prerenderConfigGlobal.isPrerenderingEnabledForAllPages && !prerenderConfigGlobal.keepDistServer) {
127
+ if (!prerenderConfigGlobal.keepDistServer) {
129
128
  fs.rmSync(outDirServer, { recursive: true });
130
129
  }
131
130
  return { viteConfig };
@@ -43,11 +43,13 @@ setGetClientEntrySrcDev(getClientEntrySrcDev);
43
43
  assertIsNotProductionRuntime();
44
44
  // Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
45
45
  function plugin(vikeVitePluginOptions = {}) {
46
+ // TO-DO/next-major-release: remove
47
+ const pluginAddendum = { _vikeVitePluginOptions: vikeVitePluginOptions };
46
48
  const promise = (async () => {
47
49
  if (skip())
48
50
  return [];
49
51
  const vikeConfig = await getVikeConfigInternalEarly();
50
- const plugins = [
52
+ const plugin = [
51
53
  ...pluginCommon(vikeVitePluginOptions),
52
54
  ...pluginVirtualFiles(),
53
55
  ...pluginDev(),
@@ -67,9 +69,10 @@ function plugin(vikeVitePluginOptions = {}) {
67
69
  ...pluginNonRunnabeDev(),
68
70
  ...(await pluginViteConfigVikeExtensions(vikeConfig)),
69
71
  ];
70
- return plugins;
72
+ Object.assign(plugin, pluginAddendum);
73
+ return plugin;
71
74
  })();
72
- Object.assign(promise, { _vikeVitePluginOptions: vikeVitePluginOptions });
75
+ Object.assign(promise, pluginAddendum);
73
76
  return promise;
74
77
  }
75
78
  function pluginBuild() {
@@ -1,5 +1,5 @@
1
1
  export { generateVirtualFileGlobalEntryWithOldDesign };
2
- import { assert, assertWarning } from '../../../../utils/assert.js';
2
+ import { assert } from '../../../../utils/assert.js';
3
3
  import { isVersionMatch } from '../../../../utils/assertVersion.js';
4
4
  import { debugGlob } from '../../../../utils/debugGlob.js';
5
5
  import { scriptFileExtensionPattern } from '../../../../utils/isScriptFile.js';
@@ -9,7 +9,7 @@ import { version as viteVersion } from 'vite';
9
9
  import { fileTypes } from '../../../../shared-server-client/getPageFiles/fileTypes.js';
10
10
  import path from 'node:path';
11
11
  import { generateVirtualFileGlobalEntry } from './generateVirtualFileGlobalEntry.js';
12
- import { getVikeConfigInternal, isV1Design as isV1Design_ } from '../../shared/resolveVikeConfigInternal.js';
12
+ import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
13
13
  import { getOutDirs } from '../../shared/getOutDirs.js';
14
14
  import { isViteServerSide_extraSafe } from '../../shared/isViteServerSide.js';
15
15
  import { resolveIncludeAssetsImportedByServer } from '../../../../server/runtime/renderPageServer/getPageAssets/retrievePageAssetsProd.js';
@@ -78,8 +78,6 @@ export const neverLoaded = {};
78
78
  ${await generateVirtualFileGlobalEntry(isForClientSide, isDev, id, isClientRouting)}
79
79
 
80
80
  `;
81
- // We still use import.meta.glob() when using th V1 design in order to not break the V1 design deprecation warning
82
- const isV1Design = isV1Design_();
83
81
  const vikeConfig = await getVikeConfigInternal();
84
82
  // Old design => no + files => only to enable pre-rendering is setting `vike({prerender})` in vite.config.js
85
83
  const isPrerendering = !!vikeConfig.config.prerender;
@@ -94,19 +92,19 @@ ${await generateVirtualFileGlobalEntry(isForClientSide, isDev, id, isClientRouti
94
92
  isBuild,
95
93
  });
96
94
  if (includeImport) {
97
- fileContent += getGlobs(globRoots, isBuild, fileType, null, isV1Design);
95
+ fileContent += getGlobs(globRoots, isBuild, fileType, null);
98
96
  }
99
97
  if (includeExportNames) {
100
- fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames', isV1Design);
98
+ fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames');
101
99
  }
102
100
  });
103
101
  const includeAssetsImportedByServer = resolveIncludeAssetsImportedByServer(vikeConfig.config);
104
102
  if (includeAssetsImportedByServer && isForClientSide) {
105
- fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets', isV1Design);
103
+ fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets');
106
104
  }
107
105
  return fileContent;
108
106
  }
109
- function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
107
+ function getGlobs(globRoots, isBuild, fileType, query) {
110
108
  const isEager = isBuild && (query === 'extractExportNames' || fileType === '.page.route');
111
109
  let pageFilesVar;
112
110
  if (query === 'extractExportNames') {
@@ -149,19 +147,11 @@ function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
149
147
  const globOptions = { eager: isEager };
150
148
  if (query) {
151
149
  const isNewViteInterface = isVersionMatch(viteVersion, ['5.1.0']);
152
- if (isNewViteInterface &&
153
- // When used for the old design, the new syntax breaks Vike's CI (surprinsigly so). I couldn't reproduce locally (I didn't dig much).
154
- isV1Design) {
150
+ if (isNewViteInterface) {
155
151
  globOptions.query = `?${query}`;
156
152
  }
157
153
  else {
158
154
  globOptions.as = query;
159
- const msg = [
160
- "Update to the new V1 design to get rid of Vite's warning:",
161
- 'The glob option "as" has been deprecated in favour of "query".',
162
- 'See https://vike.dev/migration/v1-design for how to migrate.',
163
- ].join(' ');
164
- assertWarning(!isNewViteInterface, msg, { onlyOnce: true });
165
155
  }
166
156
  }
167
157
  const globPaths = globExcludePath ? `[${globIncludePath}, ${globExcludePath}]` : `[${globIncludePath}]`;
@@ -31,7 +31,7 @@ function addSsrMiddleware(middlewares, config, isPreview, isPrerenderingEnabled)
31
31
  pageContext = await renderPageServer(pageContextInit);
32
32
  }
33
33
  catch (err) {
34
- // Throwing an error in a connect middleware shut downs the server
34
+ // Throwing an error in a connect middleware shuts down the server
35
35
  console.error(err);
36
36
  // - next(err) automatically uses buildErrorMessage() (pretty formatting of Rollup errors)
37
37
  // - But it only works for users using Vite's standalone dev server (it doesn't work for users using Vite's dev middleware)
@@ -78,6 +78,10 @@ async function stringToStreamReadableNode(str) {
78
78
  const { Readable } = await loadStreamNodeModule();
79
79
  return Readable.from(str);
80
80
  }
81
+ async function streamReadableWebToStreamReadableNode(stream) {
82
+ const { Readable } = await loadStreamNodeModule();
83
+ return Readable.fromWeb(stream);
84
+ }
81
85
  function stringToStreamReadableWeb(str) {
82
86
  // ReadableStream.from() spec discussion: https://github.com/whatwg/streams/issues/1018
83
87
  assertReadableStreamConstructor();
@@ -214,7 +218,11 @@ function pipeToStreamWritableNode(htmlRender, writable) {
214
218
  streamPipeNode(writable);
215
219
  return true;
216
220
  }
217
- if (isStreamReadableWeb(htmlRender) || isStreamPipeWeb(htmlRender)) {
221
+ if (isStreamReadableWeb(htmlRender)) {
222
+ streamReadableWebToStreamReadableNode(htmlRender).then((s) => s.pipe(writable));
223
+ return true;
224
+ }
225
+ if (isStreamPipeWeb(htmlRender)) {
218
226
  return false;
219
227
  }
220
228
  checkType(htmlRender);
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.253-commit-a8f23e5";
1
+ export declare const PROJECT_VERSION: "0.4.253-commit-6539e7f";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.253-commit-a8f23e5';
2
+ export const PROJECT_VERSION = '0.4.253-commit-6539e7f';
@@ -52,7 +52,7 @@ const extTemplates = [
52
52
  'mdx'
53
53
  ];
54
54
  const scriptFileExtensionList = [...extJsOrTs, ...extJsxOrTsx, ...extTemplates];
55
- const scriptFileExtensionPattern = '(' + scriptFileExtensionList.join('|') + ')';
55
+ const scriptFileExtensionPattern = '{' + scriptFileExtensionList.join(',') + '}';
56
56
  function isScriptFile(filePath) {
57
57
  return scriptFileExtensionList.some((ext) => filePath.endsWith('.' + ext));
58
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.253-commit-a8f23e5",
3
+ "version": "0.4.253-commit-6539e7f",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -121,9 +121,9 @@
121
121
  "@babel/core": "^7.28.5",
122
122
  "@babel/types": "^7.28.5",
123
123
  "@brillout/import": "^0.2.6",
124
- "@brillout/json-serializer": "^0.5.21",
124
+ "@brillout/json-serializer": "^0.5.22",
125
125
  "@brillout/picocolors": "^1.0.30",
126
- "@brillout/vite-plugin-server-entry": "^0.7.17",
126
+ "@brillout/vite-plugin-server-entry": "0.7.18",
127
127
  "cac": "^6.0.0",
128
128
  "es-module-lexer": "^1.0.0",
129
129
  "esbuild": ">=0.19.0",