@@ -294,6 +294,43 @@ describe('rollup-plugin-import-meta-assets', () => {
294
294
expectAsset ( output , 'snapshots/two.svg' , 'two.svg' , 'assets/two--yckvrYd.svg' ) ,
295
295
expectAsset ( output , 'snapshots/three.svg' , 'three.svg' , 'assets/three-CDdgprDC.svg' ) ,
296
296
expectAsset ( output , 'snapshots/four.svg' , 'four.svg' , 'assets/four-lJVunLww.svg' ) ,
297
+
298
+ it ( 'respects the rollup resolution' , async ( ) => {
299
+ const config = {
300
+ input : { 'simple-bundle-switched' : require . resolve ( './fixtures/simple-entrypoint.js' ) } ,
301
+ plugins : [
302
+ importMetaAssets ( ) ,
303
+ {
304
+ resolveId ( source , importer ) {
305
+ if ( source == './one.svg' ) {
306
+ return path . resolve ( path . dirname ( importer ) , 'two.svg' ) ;
307
+ }
308
+ if ( source == './two.svg' ) {
309
+ return path . resolve ( path . dirname ( importer ) , 'one.svg' ) ;
310
+ }
311
+ if ( source === './three.svg' ) {
312
+ return {
313
+ id : source ,
314
+ external : true ,
315
+ } ;
316
+ }
317
+ return undefined ;
318
+ } ,
319
+ } ,
320
+ ] ,
321
+ } ;
322
+
323
+ const bundle = await rollup . rollup ( config ) ;
324
+ const { output } = await bundle . generate ( outputConfig ) ;
325
+
326
+ expect ( output . length ) . to . equal ( 5 ) ;
327
+ expectChunk ( output , 'snapshots/simple-bundle-switched.js' , 'simple-bundle-switched.js' , [
328
+ expectAsset ( output , 'snapshots/two.svg' , 'two.svg' , 'assets/two--yckvrYd.svg' ) ,
329
+ expectAsset ( output , 'snapshots/one.svg' , 'one.svg' , 'assets/one-ZInu4dBJ.svg' ) ,
330
+ expectAsset ( output , 'snapshots/four.svg' , 'four.svg' , 'assets/four-lJVunLww.svg' ) ,
331
+ expectAsset ( output , 'snapshots/five' , 'five' , 'assets/five-Z74_0e9C' ) ,
332
+ ] ) ;
333
+ } ) ,
297
334
] ) ;
298
335
} ) ;
299
336
} ) ;
0 commit comments