-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
β Deploy Preview for nuxt3-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
What about instead tree-shaking out the component + its children from the final build, so it really leaves no trace? |
We can add a custom core unplugin like the What do you think @danielroe ? |
Exactly. Might possibly be within the same plugin. |
I created another plugin to remove in templates, since the tree-shake runs on vue script and js/ts files. But this would not tree-shake stateless components call like: <script setup lang="ts">
import { h } from 'vue'
import { DevOnly } from "#components"
const dynamic = () => h(DevOnly, "Should be dev only")
</script>
<template>
<component :is="dynamic" />
</template> Maybe I can take care about this on the initial tree-shake plugin, and rename them to something like Edit: I will use this https://github.com/nuxt/framework/blob/main/packages/nuxt/src/components/tree-shake.ts |
Hey! This is excellent work π€© Can't wait to have this merged, this will be so useful to enhance DX on themes :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR <3 LGTM. Although tree-shaking should happen in SFCs, if we are outside and not happening, the chunk will silently be included but not rendered/loaded.
π Linked issue
resolves nuxt/nuxt#15066
β Type of change
π Description
Introduce
<DevOnly>
component that render its content only in development mode.π Checklist