Skip to content

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

@jantimon

Description

@jantimon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions