linaria icon indicating copy to clipboard operation
linaria copied to clipboard

When building a Vite+React project, a "/*#__PURE__*/" warning is shown for every component using styled with props

Open rodrigocfd opened this issue 1 year ago • 0 comments

Environment

  • React : 18.3.1
  • TypeScript: 5.7.2
  • @linaria/core: 6.2.0
  • @linaria/react: 6.2.1
  • @wyw-in-js/vite: 0.5.5
  • Bundler: Vite 6.0.3
  • Node.js version: 22.12.0
  • OS: Windows 10 x64

Description

When passing any prop to a component, the following warning appears in npm run build:

src/App.tsx (1:21): A comment

"/*#__PURE__*/"

in "src/App.tsx" contains an annotation that Rollup cannot interpret due to the
position of the comment. The comment will be removed to avoid issues.

During npm run dev no warnings are displayed.

Reproducible Demo

import {styled} from '@linaria/react';

export default function App() {
    return <Div color='red'>Hello</Div>;
}

const Div = styled.div<{color: string}>`
    color: ${props => props.color}
`;

I attached a zip with the minimal reproducible project:

rodrigocfd avatar Dec 09 '24 14:12 rodrigocfd