Skip to content

parenthesis get added to v-slot destructuring #3

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

Closed
sandros94 opened this issue Apr 4, 2025 · 4 comments
Closed

parenthesis get added to v-slot destructuring #3

sandros94 opened this issue Apr 4, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@sandros94
Copy link

๐Ÿ› The bug

Image

CI build log mocking an end user's project

๐Ÿ› ๏ธ To reproduce

https://stackblitz.com/edit/github-mn4exm3e?file=index.js

๐ŸŒˆ Expected behaviour

no parenthesis when destructuring slots

โ„น๏ธ Additional context

As I'm working on nuxt/ui#3479 I've been following along this development in mkdist, altough I do admit it still feels like magick to me.

We heavily rely on typescript both for internal development of Nuxt UI as well as improve DX for those who use the library, so I think this will be a great way to catch any bugs like this one.

I'll try to understand what might be causing it, tho I'm still navigating this repo on-sight

@sandros94 sandros94 added the bug Something isn't working label Apr 4, 2025
@sandros94
Copy link
Author

Found the issue, I should have read this file fully first ๐Ÿ™„

async function transformJsSnippet(
code: string,
transform: (code: string) => Promise<string>,
): Promise<string> {
// `{ key: val } as any` in `<div :style="{ key: val } as any" />` is a valid js snippet,
// but it can't be transformed.
// We can warp it with `()` to make it a valid js file
let res = await transform(`(${code})`)
res = res.trim()
// result will be wrapped in `{content};\n`, we need to remove it
if (res.endsWith(';')) {
res = res.slice(0, -1)
}
return res
}

@Teages Teages self-assigned this Apr 4, 2025
@Teages
Copy link
Collaborator

Teages commented Apr 4, 2025

I think we need babel to handle this. But I'm worried about speed, I'll do some benchmarks first

@sandros94
Copy link
Author

I think we need babel to handle this. But I'm worried about speed, I'll do some benchmarks first

ideally speaking yes, although I was testing something locally and was about to open a PR for a simple workaround for the moment

@sandros94
Copy link
Author

Closing this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants