Open Marocco2 opened 1 year ago
any ideas as how to do it? maybe it should be implemented in auto-import then pass the path/files list from here?
also, couldn't this (import in every mdx) be opt-in?
Transferred this across from https://github.com/delucis/astro-embed as this functionality, if ever implemented, would likely need to be implemented here in astro-auto-import
.
I haven’t looked into if this is possible reliably. Perhaps if we could enforce somehow a plugin to run last, it could check the final AST for references and only add import statements for the imports that are needed. Doing it earlier would mean astro-auto-import
could miss component usage added by later plugins.
Currently if I use
astro-embed-integration
inastro.config.mjs
it will inject itself (CSS and JS) post compiling to every MDX file, even if there aren't any embeds in the MDX. I propose to check for every file which would got embeds and inject properastro-embed
plugin for each of them