-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Three-shaking not working properly #12514
Comments
Start a new pull request in StackBlitz Codeflow. |
There's two side effects preventing tree-shaking to work. So to mark these as side-effect free, you have to write it like: const SvgAlarm = (props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => ( /* omit */ )
const ForwardRef = /* #__PURE__ */ (() => {
const r = forwardRef(SvgAlarm);
r.displayName = 'alarm';
return r;
})() Closing as this is not a bug. |
Thanks @sapphi-red! During build time this solution works fine! Is there a way to achieve the same thing in development mode? |
There aren't any builtin solutions, but it seems there's a plugin: #8237 (comment) |
Describe the bug
I'm trying to import a specific icon using named imports ex.
import { Agenda } from './icons';
After running
npm run build
, Vite is including all other icons defined in index.ts during build time so unnecessary code is being included in the final build.Expected behavior:
When importing a specific icon/component using named imports, only the necessary code for that icon should be included in the final build.
Reproduction
https://stackblitz.com/edit/vitejs-vite-hujhcm
Steps to reproduce
npm run build
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: