web icon indicating copy to clipboard operation
web copied to clipboard

[@web/rollup-plugin-import-meta-assets] Add originalFileName to emitFile

Open dmnsgn opened this issue 1 month ago • 0 comments

Relevant Rollup documentation

Note that when emitting assets that correspond to an existing file, it is recommended to set the originalFileName property in the this.emitFile call instead as that will not only watch the file but also make the connection transparent to other plugins. Link

Change required

Add:

 const ref = this.emitFile({ 
   type: 'asset', 
   name: assetName, 
+  originalFileName: absoluteAssetPath,
   source: transformedAssetContents, 
 }); 

to this call:

https://github.com/modernweb-dev/web/blob/b304034e51b8e03bba53d79d6b4ab3374a06e001/packages/rollup-plugin-import-meta-assets/src/rollup-plugin-import-meta-assets.js#L176-L180

Use case

Trying to map the source of some emitted assets in a plugin's writeBundle and getting null.

dmnsgn avatar Dec 12 '25 14:12 dmnsgn