vike 0.4.258-commit-e168602 → 0.4.258-commit-24a5c2b

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.
@@ -42,63 +42,8 @@ function pluginDistFileNames() {
42
42
  // - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
43
43
  assertUsage(rollupOutput.assetFileNames.isTheOneSetByVike, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use it.");
44
44
  }
45
- if (disableCSSBundling(config)) {
46
- const manualChunksOriginal = rollupOutput.manualChunks;
47
- rollupOutput.manualChunks = function (id, ...args) {
48
- if (manualChunksOriginal) {
49
- if (isCallable(manualChunksOriginal)) {
50
- const result = manualChunksOriginal.call(this, id, ...args);
51
- if (result !== undefined)
52
- return result;
53
- }
54
- else {
55
- 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.");
56
- }
57
- }
58
- if (id.endsWith('.css')) {
59
- const userRootDir = config.root;
60
- if (id.startsWith(userRootDir)) {
61
- assertPosixPath(id);
62
- assertModuleId(id);
63
- let name;
64
- const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
65
- if (isNodeModules) {
66
- name = isNodeModules[1];
67
- }
68
- else {
69
- const filePath = getFilePathToShowToUserModule(id, config);
70
- name = filePath;
71
- name = name.split('.').slice(0, -1).join('.'); // remove file extension
72
- name = name.split('/').filter(Boolean).join('_');
73
- }
74
- // Make fileHash the same between local development and CI
75
- const idStable = path.posix.relative(userRootDir, id);
76
- // Don't remove `?` queries because each `id` should belong to a unique bundle.
77
- const hash = getIdHash(idStable);
78
- return `${name}-${hash}`;
79
- }
80
- else {
81
- let name;
82
- const isVirtualModule = id.match(/virtual:([^:]+):/);
83
- if (isVirtualModule) {
84
- name = isVirtualModule[1];
85
- assert(name);
86
- }
87
- else if (
88
- // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
89
- id.startsWith('/__uno')) {
90
- name = 'uno';
91
- }
92
- else {
93
- name = 'style';
94
- }
95
- const hash = getIdHash(id);
96
- return `${name}-${hash}`;
97
- }
98
- }
99
- };
100
- }
101
45
  });
46
+ disableCSSBundling(config);
102
47
  },
103
48
  },
104
49
  },
@@ -242,6 +187,115 @@ function workaroundGlob(name) {
242
187
  name = name.replace(/\.page$/, '-page');
243
188
  return name;
244
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
+ }
245
299
  function getRollupOutputs(config) {
246
300
  var _a, _b;
247
301
  // @ts-expect-error is read-only
@@ -254,22 +308,18 @@ function getRollupOutputs(config) {
254
308
  }
255
309
  return output;
256
310
  }
257
- function disableCSSBundling(config) {
258
- // Vite 7 => disable CSS bundling, see: https://github.com/vikejs/vike/issues/1815
259
- if (!isVite8OrAbove(config))
260
- return true;
261
- // Vite 8 doesn't support `manualChunks` when `codeSplitting` is used.
262
- // - It does, however, support `manualChunks` if `codeSplitting` isn't used (despite what the following migration guide says)
263
- // - https://vite.dev/guide/migration#removed-object-form-build-rollupoptions-output-manualchunks-and-deprecate-function-form-one
311
+ function getRolldownOutputs(config) {
312
+ var _a, _b;
313
+ // @ts-expect-error is read-only
314
+ config.build ?? (config.build = {});
264
315
  // @ts-ignore
265
- if (!config.build?.rolldownOptions?.output?.codeSplitting)
266
- return true;
267
- // TO-DO/eventually: we should probably show a warning, because Vite 8 still builds the client and server separately (potentially leading to the CSS duplication bug):
268
- // https://github.com/vitejs/ecosystem/issues/6
269
- return false;
270
- }
271
- function isVite8OrAbove(config) {
272
- const viteVersion = config._viteVersionResolved;
273
- assert(viteVersion);
274
- return isVersionMatch(viteVersion, ['8.0.0']);
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;
275
325
  }
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.258-commit-e168602";
1
+ export declare const PROJECT_VERSION: "0.4.258-commit-24a5c2b";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.258-commit-e168602';
2
+ export const PROJECT_VERSION = '0.4.258-commit-24a5c2b';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.258-commit-e168602",
3
+ "version": "0.4.258-commit-24a5c2b",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -129,7 +129,7 @@
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",
@@ -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
  },