@@ -257,13 +257,17 @@ export function generateManifestFromBundles(
257
257
} ,
258
258
} ;
259
259
260
+ const buildPath = path . resolve ( opts . rootDir , opts . outDir , 'build' ) ;
260
261
// We need to find our QRL exports
261
262
const qrlNames = new Set ( [ ...hooks . map ( ( h ) => h . name ) ] ) ;
262
- for ( const [ fileName , outputBundle ] of Object . entries ( outputBundles ) ) {
263
+ for ( const outputBundle of Object . values ( outputBundles ) ) {
263
264
if ( outputBundle . type !== 'chunk' ) {
264
265
continue ;
265
266
}
266
- const bundleFileName = path . basename ( fileName ) ;
267
+ const bundleFileName = path . relative (
268
+ buildPath ,
269
+ path . resolve ( opts . outDir , outputBundle . fileName )
270
+ ) ;
267
271
268
272
const buildDirName = path . dirname ( outputBundle . fileName ) ;
269
273
const bundle : QwikBundle = {
@@ -282,21 +286,23 @@ export function generateManifestFromBundles(
282
286
283
287
const bundleImports = outputBundle . imports
284
288
. filter ( ( i ) => path . dirname ( i ) === buildDirName )
285
- . map ( ( i ) => path . relative ( buildDirName , i ) ) ;
289
+ . map ( ( i ) => path . relative ( buildDirName , outputBundles [ i ] . fileName ) ) ;
286
290
if ( bundleImports . length > 0 ) {
287
291
bundle . imports = bundleImports ;
288
292
}
289
293
290
294
const bundleDynamicImports = outputBundle . dynamicImports
291
295
. filter ( ( i ) => path . dirname ( i ) === buildDirName )
292
- . map ( ( i ) => path . relative ( buildDirName , i ) ) ;
296
+ . map ( ( i ) => path . relative ( buildDirName , outputBundles [ i ] . fileName ) ) ;
293
297
if ( bundleDynamicImports . length > 0 ) {
294
298
bundle . dynamicImports = bundleDynamicImports ;
295
299
}
296
300
297
301
// Rollup doesn't provide the moduleIds in the outputBundle but Vite does
298
302
const ids = outputBundle . moduleIds || Object . keys ( outputBundle . modules ) ;
299
- const modulePaths = ids . filter ( ( m ) => ! m . startsWith ( `\u0000` ) ) ;
303
+ const modulePaths = ids
304
+ . filter ( ( m ) => ! m . startsWith ( `\u0000` ) )
305
+ . map ( ( m ) => path . relative ( opts . rootDir , m ) ) ;
300
306
if ( modulePaths . length > 0 ) {
301
307
bundle . origins = modulePaths ;
302
308
}
@@ -324,6 +330,30 @@ export function generateManifestFromBundles(
324
330
loc : hook . loc ,
325
331
} ;
326
332
}
333
+ // To inspect the bundles, uncomment the following lines
334
+ // and temporarily add the writeFileSync import from fs
335
+ // writeFileSync(
336
+ // 'output-bundles.json',
337
+ // JSON.stringify(
338
+ // Object.entries(outputBundles).map(([n, b]) => [
339
+ // n,
340
+ // {
341
+ // ...b,
342
+ // code: '<removed>',
343
+ // map: '<removed>',
344
+ // source: '<removed>',
345
+ // modules:
346
+ // 'modules' in b
347
+ // ? Object.fromEntries(
348
+ // Object.entries(b.modules).map(([k, v]) => [k, { ...v, code: '<removed>' }])
349
+ // )
350
+ // : undefined,
351
+ // },
352
+ // ]),
353
+ // null,
354
+ // '\t'
355
+ // )
356
+ // );
327
357
328
358
return updateSortAndPriorities ( manifest ) ;
329
359
}
0 commit comments