Problem importing the metadata object
See original GitHub issueHi @JonasKruckenberg , I’m trying the plugin with a basic Vite + Svelte setup, scaffolded with @vite/create-app. Thank you for your work, it’s wonderful and it works well.
I encountered this issue using the metadata directive.
With this code:
import {src, width, height} from "$assets/images/usgs-AQ9-jKmebjM-unsplash.jpg?width=375&meta";
I get this error in console:
Uncaught SyntaxError: The requested module '/src/assets/images/usgs-AQ9-jKmebjM-unsplash.jpg?import&width=375&meta' does not provide an export named 'height'
Nonetheless, if I import as a single module the image:
import Meta from "$assets/images/usgs-AQ9-jKmebjM-unsplash.jpg?width=375&meta";
I get the correct metadata object.
//console.log(Meta);
{ "format": "jpeg", "width": 375, "height": 375, "channels": 3, "premultiplied": false, "size": 49715, "src": "node_modules/.cache/vite-imagetools/tmp/47fa4256/usgs-AQ9-jKmebjM-unsplash.jpeg" }
It’s not a big deal, but it’s something worth knowing, or maybe you have any hint about it. I’m using the plugin with the force option as true, and the silent option as false.
✌️
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Hi @JonasKruckenberg , I created a reduced case and the metadata import worked perfectly. I went back to my project and… It worked perfectly. ☺️
The issue is resolved. Sorry for the misleading report, and thanks for your help!
Alright yeah, it should work without explicitly setting that option too. I tried the svelte starter app as well, but I cannot reproduce the missing named import warning. Can you maybe share a reproduction or a code snippet showing how you imported the image?