@@ -237,8 +237,8 @@ describe('rollup-plugin-import-meta-assets', () => {
237
237
error = e ;
238
238
}
239
239
240
- expect ( error . message ) . to . eq (
241
- ` Unable to resolve "/ absolute-path.svg" from "/home/loic/git/web/packages/rollup-plugin-import-meta-assets/test/fixtures/ bad-url-entrypoint.js"` ,
240
+ expect ( error . message ) . to . match (
241
+ / U n a b l e t o r e s o l v e " [ / \\ ] a b s o l u t e - p a t h .s v g " f r o m " . * [ / \\ ] b a d - u r l - e n t r y p o i n t .j s " / ,
242
242
) ;
243
243
} ) ;
244
244
@@ -296,4 +296,41 @@ describe('rollup-plugin-import-meta-assets', () => {
296
296
expectAsset ( output , 'snapshots/four.svg' , 'four.svg' , 'assets/four-lJVunLww.svg' ) ,
297
297
] ) ;
298
298
} ) ;
299
+
300
+ it ( 'respects the rollup resolution' , async ( ) => {
301
+ const config = {
302
+ input : { 'simple-bundle-switched' : require . resolve ( './fixtures/simple-entrypoint.js' ) } ,
303
+ plugins : [
304
+ importMetaAssets ( ) ,
305
+ {
306
+ resolveId ( source , importer ) {
307
+ if ( source == './one.svg' ) {
308
+ return path . resolve ( path . dirname ( importer ) , 'two.svg' ) ;
309
+ }
310
+ if ( source == './two.svg' ) {
311
+ return path . resolve ( path . dirname ( importer ) , 'one.svg' ) ;
312
+ }
313
+ if ( source === './three.svg' ) {
314
+ return {
315
+ id : source ,
316
+ external : true ,
317
+ } ;
318
+ }
319
+ return undefined ;
320
+ } ,
321
+ } ,
322
+ ] ,
323
+ } ;
324
+
325
+ const bundle = await rollup . rollup ( config ) ;
326
+ const { output } = await bundle . generate ( outputConfig ) ;
327
+
328
+ expect ( output . length ) . to . equal ( 5 ) ;
329
+ expectChunk ( output , 'snapshots/simple-bundle-switched.js' , 'simple-bundle-switched.js' , [
330
+ expectAsset ( output , 'snapshots/two.svg' , 'two.svg' , 'assets/two--yckvrYd.svg' ) ,
331
+ expectAsset ( output , 'snapshots/one.svg' , 'one.svg' , 'assets/one-ZInu4dBJ.svg' ) ,
332
+ expectAsset ( output , 'snapshots/four.svg' , 'four.svg' , 'assets/four-lJVunLww.svg' ) ,
333
+ expectAsset ( output , 'snapshots/five' , 'five' , 'assets/five-Z74_0e9C' ) ,
334
+ ] ) ;
335
+ } ) ;
299
336
} ) ;
0 commit comments