Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not resolve dependency on bookshop:generate #191

Closed
michaelroper opened this issue Feb 21, 2024 · 3 comments
Closed

Could not resolve dependency on bookshop:generate #191

michaelroper opened this issue Feb 21, 2024 · 3 comments

Comments

@michaelroper
Copy link

Hey team, I have an Astro site that I am using the astro-icon package to inline some custom SVG icons, and while the site itself builds without a problem, when I try to do bookshop:generate, it throws the below error at the end:

📚 Generating Bookshop integrations

Looking for Bookshop component libraries...
Loading Bookshop from ./src
Loaded 15 components
Creating structures for all components...
Hydrating structures for nested components...
Loaded 1 Bookshop

Looking for output sites...
Found 1 site

Modifying output site at ./.
Connected 0 component thumbnail(s)
Added live editing to 24 pages containing Bookshop components
Skipped 63 pages that didn't contain Bookshop components.
 > node_modules/astro-icon/components/Icon.astro:2:30: 
   error: Could not resolve "virtual:astro-icon" (mark it as external to exclude it from the bundle)
    2 │ import icons, { config } from "virtual:astro-icon";
      ╵                               ~~~~~~~~~~~~~~~~~~~~

Does that sound like something I can solve within my site config, even though the error is coming from the dependency itself?
I realise this may not be a bookshop-specific issue, but any pointers on how to resolve would be appreciated.

@Tate-CC
Copy link
Contributor

Tate-CC commented Feb 23, 2024

Hi @michaelroper 👋

It looks like astro-icon integration depends on a Vite plugin in order to build. When bookshop:generate tries to build your components for the browser it runs without that plugin, leading to the error you're seeing.

Unfortunately I don't think there are any great ways to get around this in your config. Bookshop will try and load Vite plugins from your config file when building your components, so if you could find a way to pull the Vite plugin out of astro-icon or write your own plugin that provides a stubbed version of the virtual:astro-icon import that could, in theory, fix your build but may end up being a lot of work.

@Tate-CC
Copy link
Contributor

Tate-CC commented May 21, 2024

Hi again @michaelroper, this issue should be fixed in the latest Bookshop release (3.10.0). Bookshop Astro now looks at your site's integrations and tries to pull out any Vite plugins it finds. This is still relatively experimental so your results might vary integration to integration, but in my testing it did work with astro-icon so you should be able to include it alongside Bookshop without issue!

@Tate-CC Tate-CC closed this as completed May 21, 2024
@michaelroper
Copy link
Author

Thanks @Tate-CC - I'll check it out when i get a chance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants