You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our project we have alias imports we have written a plugin called aliasResolPlugin which will return absolute path in resolveId
Eg: index.js import js/xyz
after resolveId hook index.js import <absolute_path>/xyz.js
Now
I have written another plugin JsonUpdatePlugin which will add javascript code in *.json files, I have disabled vite:json plugin so that parsing will not throw an error
Eg: index.json import js/xyz
Since vite is not invoking resolveId hook for imports in json file of aliasResolPlugin I am not able replace these aliases with absolute Path
Suggested solution
There has to be a way to treat txt file or json file as javascript so that hook can get triggered
Would you provide a minimal reproduction or a link to the repository so that other people can understand your issue better.
Knowing what to achieve (why you want to add JS code to JSON code), we can discuss how to achieve (currently only how is described).
Since JSON processing is builtin and your project is overriding its behaviour, I'd suggest having your plugin worked around it for now. In resolveId() you can resolve the .json file to e.g. .json.js, that way Vite doesn't see it as a JSON file and will process it.
I don't think Vite should open up or process JSON files as it adds overhead for everyone even if they don't change the JSON handling.
Description
In our project we have alias imports we have written a plugin called aliasResolPlugin which will return absolute path in resolveId
Eg:
index.js
import js/xyz
after resolveId hook
index.js
import <absolute_path>/xyz.js
Now
I have written another plugin JsonUpdatePlugin which will add javascript code in *.json files, I have disabled vite:json plugin so that parsing will not throw an error
Eg:
index.json
import js/xyz
Since vite is not invoking resolveId hook for imports in json file of aliasResolPlugin I am not able replace these aliases with absolute Path
Suggested solution
There has to be a way to treat txt file or json file as javascript so that hook can get triggered
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: