Hi all,
I’m building a theme with Sage 11 and Vite (using @roots/vite-plugin), and running into a persistent problem with the @wordpress/icons package.
Whenever I import icons like this:
import { sidesBottom } from '@wordpress/icons';
…the resulting build still contains:
import { sidesBottom as nv } from "@wordpress/icons";
Which breaks in the browser (in the editor) with:
Uncaught TypeError: Failed to resolve module specifier "@wordpress/icons". Relative references must start with either "/", "./", or "../".
From what I understand, this happens because @roots/vite-plugin always externalizes all @wordpress/* packages by default, following WordPress plugin/block development conventions.
However, this makes it impossible to actually use @wordpress/icons in a theme, since wp-icons is never enqueued as a script by WordPress for themes (and is not on window.wp either). The result is that you simply cannot use @wordpress/icons with Vite in a theme context out of the box.
Has anyone else run into this issue?
Were you able to find a solution or reliable workaround for using @wordpress/icons?
Any advice would be appreciated!
Thanks!