Skip to content

oxc-transform: jsx.refresh should skip non function #11824

Open
@ArnaudBarre

Description

@ArnaudBarre

swc playground

oxc playground

I think this switch was not implemented: https://github.com/facebook/react/blob/v18.3.1/packages/react-refresh/src/ReactFreshBabelPlugin.js#L120-L150

The issue is that then Vite thinks that a TSX file containing code like this:

const COLORS = ['red', 'blue'].sort();
export const getColorPalette = () => COLORS;

can be self-updated, but when you edit it, it will be invalidated (Stackblitz demo, edit the list of colors)

The implementation seems really far from the Babel one, because either removing the .sort() or remove the reference of COLORS from the getColorPalette function doesn't trigger ReactRefresh wrapper

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions