-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Imported components used with <component :is="">
ignored in production
#6
Comments
I'm noticing that even regular use of icons with |
I’ll take a look this afternoon. |
The gist of the problem seems to be that the way the SFCs are being built by Rollup, the template is added as a side-effect, e.g. (the same structure exists in the bundled files, but it's easier to read the ESM version): // dist/esm/components/PhActivity.vue.js
import component from './PhActivity.vue_vue&type=script&lang.js';
export { default } from './PhActivity.vue_vue&type=script&lang.js';
import { render } from './PhActivity.vue_vue&type=template&id=7b9995bc&lang.js';
component.render = render; The problem is the library is marked as entirely side-effect free (that was my mistake) and so Vue CLI/Webpack is stripping out everything except the pass-through re-export when the consumer builds the project for production. The templates-turned-render-functions are just being entirely omitted, and trying to render a Vue component with no render function defined creates the empty HTML comment nodes you can see in the browser. I'll need to do some testing to figure out the right combo of Rollup settings and Side-note, this appears to be a change in the Vue SFC compiler in Vue 3, and something I missed in testing. That's on me. |
Upon further digging, I believe that removing the erroneous |
Using Vue3 and having the same issue -- icons are missing from production build. I tried removing the |
Just wanted to check in and say I'm still watching this, but a proper fix with working tree-shaking is blocked upstream (actually in the Vue 3 core rather than the Rollup plugin, see vuejs/core#2860). It's frustrating that Vue 3 launched with full tree-shaking advertised as a first-class feature, but seven months in it's still half-broken when it comes to anything more complex than the sample apps 😞 |
@brlodi I've found that if you build a library with the |
I have the same issue even in dev mode using nuxt 3.9. To fix this, I use an array with the components themselves instead of their names. And it's work fine. <template>
<div v-for="icon in icons">
<component :is="icon" size="36"></component>
</div>
</template>
<script setup>
import { PhFloppyDisk, PhMoonStars, PhListPlus } from "@phosphor-icons/vue";
let icons = [
PhFloppyDisk,
PhListPlus,
PhMoonStars,
];
</script> |
I'm using a custom component to render all my icons:
It's all fine in development, but the production bundle ignores all icons. I've just switched from another icon pack that does not cause this (but the bundle size is huge) and right now this problem is pretty annoying.
I've also tried registering the global component in
main.ts
, to no avail.Any suggestions are welcome.
The text was updated successfully, but these errors were encountered: