Skip to content
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

fix(packages/lazy-fn-vite-plugin): make dynamic function detection stricter #223

Merged
merged 3 commits into from
Dec 16, 2024

Conversation

marcalexiei
Copy link
Member

Context & Description

Fix issue 2 reported in #216 (comment)

unknown file: Cannot read properties of undefined (reading 'name') This error appear when dynamic is the only function exported by the tuono library import { dynamic } from 'tuono'. We need to improve the internal vite plugin + adding this test case


To fix the issue I replaced all casting inside turnLazyIntoStatic with helper function from @babel/types that provide check the correct node runtime and provide types accordingly.
E.g.:

isCallExpression(node: Node | null | undefined, opts?: Opts<CallExpression> | null): node is CallExpression;

I also refactored types by giving them name to reference babel or vite to avoid any confusion.

@marcalexiei marcalexiei added bug Something isn't working typescript Requires typescript knowledge labels Dec 15, 2024
@marcalexiei marcalexiei self-assigned this Dec 15, 2024
@marcalexiei marcalexiei force-pushed the dynamic-only-error branch 2 times, most recently from b74cf6e to ad20299 Compare December 15, 2024 15:36
@marcalexiei marcalexiei marked this pull request as ready for review December 15, 2024 17:23
Copy link
Member

@Valerioageno Valerioageno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks

@marcalexiei marcalexiei merged commit 7626ed8 into main Dec 16, 2024
4 checks passed
@marcalexiei marcalexiei deleted the dynamic-only-error branch December 16, 2024 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript Requires typescript knowledge
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants