#Vite transforms .json even when ?flag is present

1 messages · Page 1 of 1 (latest)

merry abyss
#

Hi all! Astro maintainer here. I'm working on JSON support for our data collections format, and I'm attempting to load the module as a transformed JS file using the ?astroContent flag (i.e. import specialParsing from './data.json?astroContent'). Unfortunately, I've found that Vite will transform json even when a flag is present (and even when I have a plugin overriding the load of json files). so I attempt to turn .json?astroContent into a JS module, and Vite later tries to parse this as JSON (and fails). Is there any way around this? Or will I need to ditch ?flags and use a virtual:module prefix instead?

merry abyss
#

Update: was hoping a &lang.js query param would help to mask to file type. Sadly getting the same result 😕

merry abyss
#

I'd submit a PR, but I have a feeling many repos depend on this handling for .json files 😅

torpid burrow