vike 0.4.258 → 0.4.259

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.
@@ -11,6 +11,7 @@ import crypto from 'node:crypto';
11
11
  import { getAssetsDir } from '../../shared/getAssetsDir.js';
12
12
  import { assertModuleId, getFilePathToShowToUserModule } from '../../shared/getFilePath.js';
13
13
  import '../../assertEnvVite.js';
14
+ import { isVersionMatch } from '../../../../utils/assertVersion.js';
14
15
  function pluginDistFileNames() {
15
16
  return [
16
17
  {
@@ -41,65 +42,8 @@ function pluginDistFileNames() {
41
42
  // - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
42
43
  assertUsage(rollupOutput.assetFileNames.isTheOneSetByVike, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use it.");
43
44
  }
44
- {
45
- const manualChunksOriginal = rollupOutput.manualChunks;
46
- rollupOutput.manualChunks = function (id, ...args) {
47
- if (manualChunksOriginal) {
48
- if (isCallable(manualChunksOriginal)) {
49
- const result = manualChunksOriginal.call(this, id, ...args);
50
- if (result !== undefined)
51
- return result;
52
- }
53
- else {
54
- assertUsage(false, "The Vite's configuration build.rollupOptions.output.manualChunks must be a function. Reach out if you need to set it to another value.");
55
- }
56
- }
57
- // Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
58
- // TO-DO/eventually: let's bundle CSS again once Rolldown replaces Rollup
59
- if (id.endsWith('.css')) {
60
- const userRootDir = config.root;
61
- if (id.startsWith(userRootDir)) {
62
- assertPosixPath(id);
63
- assertModuleId(id);
64
- let name;
65
- const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
66
- if (isNodeModules) {
67
- name = isNodeModules[1];
68
- }
69
- else {
70
- const filePath = getFilePathToShowToUserModule(id, config);
71
- name = filePath;
72
- name = name.split('.').slice(0, -1).join('.'); // remove file extension
73
- name = name.split('/').filter(Boolean).join('_');
74
- }
75
- // Make fileHash the same between local development and CI
76
- const idStable = path.posix.relative(userRootDir, id);
77
- // Don't remove `?` queries because each `id` should belong to a unique bundle.
78
- const hash = getIdHash(idStable);
79
- return `${name}-${hash}`;
80
- }
81
- else {
82
- let name;
83
- const isVirtualModule = id.match(/virtual:([^:]+):/);
84
- if (isVirtualModule) {
85
- name = isVirtualModule[1];
86
- assert(name);
87
- }
88
- else if (
89
- // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
90
- id.startsWith('/__uno')) {
91
- name = 'uno';
92
- }
93
- else {
94
- name = 'style';
95
- }
96
- const hash = getIdHash(id);
97
- return `${name}-${hash}`;
98
- }
99
- }
100
- };
101
- }
102
45
  });
46
+ disableCSSBundling(config);
103
47
  },
104
48
  },
105
49
  },
@@ -243,6 +187,115 @@ function workaroundGlob(name) {
243
187
  name = name.replace(/\.page$/, '-page');
244
188
  return name;
245
189
  }
190
+ // Workaround for Vite CSS duplication bug: https://github.com/vikejs/vike/issues/1815
191
+ function disableCSSBundling(config) {
192
+ if (isVite8OrAbove(config)) {
193
+ for (const output of getRolldownOutputs(config)) {
194
+ assert(output);
195
+ const { codeSplitting } = output;
196
+ // `codeSplitting: false` => single-bundle mode; respect the user's choice.
197
+ if (codeSplitting === false)
198
+ continue;
199
+ // `codeSplitting` set as an object => Rolldown ignores `manualChunks`, so inject a group into `codeSplitting.groups` instead.
200
+ if (codeSplitting && typeof codeSplitting === 'object') {
201
+ if (codeSplittingHasWorkaround.has(codeSplitting))
202
+ continue;
203
+ codeSplittingHasWorkaround.add(codeSplitting);
204
+ codeSplitting.groups ?? (codeSplitting.groups = []);
205
+ codeSplitting.groups.push({
206
+ test: /\.css$/,
207
+ name: (moduleId) => getCssChunkName(moduleId, config) ?? null,
208
+ /*
209
+ // Default priority — user-defined groups with the same priority appear earlier in the array and win the match.
210
+ // https://rolldown.rs/options/output-advanced-chunks
211
+ priority: 0
212
+ */
213
+ });
214
+ continue;
215
+ }
216
+ // `codeSplitting` unset / `true` => wrap `manualChunks` (Rolldown auto-converts it to a group).
217
+ // - Rolldown supports `manualChunks` whenever `codeSplitting` isn't an object (despite what the migration guide implies).
218
+ wrapManualChunks(output, config, 'rolldownOptions');
219
+ }
220
+ }
221
+ else {
222
+ for (const output of getRollupOutputs(config)) {
223
+ assert(output);
224
+ wrapManualChunks(output, config, 'rollupOptions');
225
+ }
226
+ }
227
+ }
228
+ const codeSplittingHasWorkaround = new WeakSet();
229
+ function wrapManualChunks(output, config, optsName) {
230
+ const manualChunksOriginal = output.manualChunks;
231
+ // Sometimes applied twice => skip if we already wrapped — same rationale as `isTheOneSetByVike` for assetFileNames above.
232
+ if (manualChunksOriginal?.isTheOneSetByVike)
233
+ return;
234
+ output.manualChunks = function (id, ...args) {
235
+ if (manualChunksOriginal) {
236
+ if (isCallable(manualChunksOriginal)) {
237
+ const result = manualChunksOriginal.call(this, id,
238
+ // @ts-ignore
239
+ ...args);
240
+ if (result !== undefined)
241
+ return result;
242
+ }
243
+ else {
244
+ assertUsage(false, `The Vite's configuration build.${optsName}.output.manualChunks must be a function. Reach out if you need to set it to another value.`);
245
+ }
246
+ }
247
+ return getCssChunkName(id, config);
248
+ };
249
+ output.manualChunks.isTheOneSetByVike = true;
250
+ }
251
+ function getCssChunkName(id, config) {
252
+ if (!id.endsWith('.css'))
253
+ return undefined;
254
+ const userRootDir = config.root;
255
+ if (id.startsWith(userRootDir)) {
256
+ assertPosixPath(id);
257
+ assertModuleId(id);
258
+ let name;
259
+ const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
260
+ if (isNodeModules) {
261
+ name = isNodeModules[1];
262
+ }
263
+ else {
264
+ const filePath = getFilePathToShowToUserModule(id, config);
265
+ name = filePath;
266
+ name = name.split('.').slice(0, -1).join('.'); // remove file extension
267
+ name = name.split('/').filter(Boolean).join('_');
268
+ }
269
+ // Make fileHash the same between local development and CI
270
+ const idStable = path.posix.relative(userRootDir, id);
271
+ // Don't remove `?` queries because each `id` should belong to a unique bundle.
272
+ const hash = getIdHash(idStable);
273
+ return `${name}-${hash}`;
274
+ }
275
+ else {
276
+ let name;
277
+ const isVirtualModule = id.match(/virtual:([^:]+):/);
278
+ if (isVirtualModule) {
279
+ name = isVirtualModule[1];
280
+ assert(name);
281
+ }
282
+ else if (
283
+ // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
284
+ id.startsWith('/__uno')) {
285
+ name = 'uno';
286
+ }
287
+ else {
288
+ name = 'style';
289
+ }
290
+ const hash = getIdHash(id);
291
+ return `${name}-${hash}`;
292
+ }
293
+ }
294
+ function isVite8OrAbove(config) {
295
+ const viteVersion = config._viteVersionResolved;
296
+ assert(viteVersion);
297
+ return isVersionMatch(viteVersion, ['8.0.0']);
298
+ }
246
299
  function getRollupOutputs(config) {
247
300
  var _a, _b;
248
301
  // @ts-expect-error is read-only
@@ -255,3 +308,18 @@ function getRollupOutputs(config) {
255
308
  }
256
309
  return output;
257
310
  }
311
+ function getRolldownOutputs(config) {
312
+ var _a, _b;
313
+ // @ts-expect-error is read-only
314
+ config.build ?? (config.build = {});
315
+ // @ts-ignore
316
+ (_a = config.build).rolldownOptions ?? (_a.rolldownOptions = {});
317
+ // @ts-ignore
318
+ (_b = config.build.rolldownOptions).output ?? (_b.output = {});
319
+ // @ts-ignore
320
+ const { output } = config.build.rolldownOptions;
321
+ if (!isArray(output)) {
322
+ return [output];
323
+ }
324
+ return output;
325
+ }
@@ -29,6 +29,7 @@ import { getBetterError } from '../../../utils/getBetterError.js';
29
29
  import { getRequestId_withAsyncHook } from '../../../server/runtime/asyncHook.js';
30
30
  import { getRequestTag } from '../../../server/runtime/renderPageServer.js';
31
31
  import '../assertEnvVite.js';
32
+ import { isDeno } from '../../../utils/isDeno.js';
32
33
  assertIsNotProductionRuntime();
33
34
  setLogRuntimeDev(logErrorServerDev, logRuntimeInfoDev);
34
35
  setAssertOnBeforeErr((err) => {
@@ -138,7 +139,9 @@ function logDev(msg, logType, tagSource, tagTool, doNotAddTags) {
138
139
  }
139
140
  function getTagSource(requestId = null) {
140
141
  const requestIdFromStore = getRequestId_withAsyncHook();
141
- if (requestIdFromStore !== null) {
142
+ if (requestIdFromStore !== null &&
143
+ // Workaround for Deno bug: https://github.com/vikejs/vike/issues/3240
144
+ !isDeno()) {
142
145
  if (requestId === null) {
143
146
  requestId = requestIdFromStore;
144
147
  }
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.258";
1
+ export declare const PROJECT_VERSION: "0.4.259";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.258';
2
+ export const PROJECT_VERSION = '0.4.259';
@@ -0,0 +1 @@
1
+ export declare function isDeno(): boolean;
@@ -0,0 +1,3 @@
1
+ export function isDeno() {
2
+ return typeof Deno !== 'undefined' && typeof Deno.version === 'object' && typeof Deno.version.deno === 'string';
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.258",
3
+ "version": "0.4.259",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -129,11 +129,11 @@
129
129
  "@babel/core": "^7.28.5",
130
130
  "@babel/types": "^7.28.5",
131
131
  "@brillout/import": "^0.2.6",
132
- "@brillout/json-serializer": "^0.5.22",
132
+ "@brillout/json-serializer": "^0.5.23",
133
133
  "@brillout/picocolors": "^1.0.30",
134
134
  "@brillout/vite-plugin-server-entry": "0.7.18",
135
135
  "@universal-deploy/store": "^0.2.1",
136
- "@universal-deploy/vite": "^0.1.7",
136
+ "@universal-deploy/vite": "^0.1.9",
137
137
  "@universal-middleware/core": "^0.4.17",
138
138
  "@universal-middleware/node": "^0.1.0",
139
139
  "cac": "^6.0.0",
@@ -262,7 +262,7 @@
262
262
  "./fetch.js"
263
263
  ],
264
264
  "devDependencies": {
265
- "@brillout/release-me": "^0.4.13",
265
+ "@brillout/release-me": "^0.4.15",
266
266
  "@types/babel__core": "^7.20.5",
267
267
  "@types/estree": "^1.0.5",
268
268
  "@types/node": "^20.10.5",
@@ -271,6 +271,7 @@
271
271
  "@types/source-map-support": "^0.5.10",
272
272
  "react-streaming": "^0.4.17",
273
273
  "rimraf": "^6.1.3",
274
+ "rolldown": "1.0.0-rc.17",
274
275
  "typescript": "^5.9.3",
275
276
  "vite": "^7.2.6"
276
277
  },