Skip to content

SWC plugin fails on arrow functions with method calls in CSS interpolations: "Could not parse member expression" #312

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

Open
jantimon opened this issue Apr 10, 2025 · 0 comments
Labels
bug Something isn't working swc plugin

Comments

@jantimon
Copy link
Collaborator

I ran into a bug when trying to use arrow functions with method calls inside a css template literal.
For example:

<Component css={css`animation-delay: ${() => (i * 0.05).toFixed(2)}s`} />

This throws: "Could not parse member expression" error during build

"Could not parse member expression"

It looks like yak-swc tries to statically analyze the code to find constant value and can't handle calls like .toFixed() although these functions run at runtime.

The core of the issue seems to be in how member expressions are analyzed. The current logic tries to convert every member expression into a string path, but it doesn’t distinguish between safe, static accesses (like colors.primary) and method calls (like value.toFixed(2)), which shouldn’t be resolved at build time

@Mad-Kat Mad-Kat added bug Something isn't working swc plugin labels Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working swc plugin
Development

No branches or pull requests

2 participants