Uh oh!
There was an error while loading. Please reload this page.
feat: add dev-only component - #7950
Conversation
|
✅ Deploy Preview for nuxt3-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
danielroe
commented
Oct 2, 2022
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 ? |
danielroe
commented
Oct 5, 2022
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 :) |
🔗 Linked issue
resolvesnuxt/nuxt#15066
❓ Type of change
📚 Description
Introduce
<DevOnly>component that render its content only in development mode.📝 Checklist