Anber / wyw-in-js

MIT License
240 stars 16 forks source link

vite + react: PURE annotation that Rollup cannot interpret #74

Open BPreisner opened 6 months ago

BPreisner commented 6 months ago

Packages:

Description

There is an issue with simple styled interpolation upon vite build.

image

When building with Vite:

image

I was trying to switch from styled-components to linaria for our components library and this error is populated for every interpolation in the project. I worry that it's not just a polite warning and may lead to breaking something later.

Reproducible Demo

https://stackblitz.com/edit/vitejs-vite-gfwqu5?file=src%2FApp.tsx

$ npm run build

(There is no issue when running dev command)

aeharding commented 2 weeks ago

Related to https://github.com/Anber/wyw-in-js/issues/62 probably?

kriakiku commented 2 weeks ago

Same. With rollup:

{
  "@wyw-in-js/rollup": "0.5.4",
  "@linaria/react": "6.2.1",
  "rollup": "4.24.0"
}

Example of how JS differs after bundling (Left is version 4 of linaria, right is version 6): image

agriffis commented 2 weeks ago

I tried to use patch-package to change these to /*#__NO_SIDE_EFFECTS__*/ but still got a bunch of complaints from rollup. Has anybody else tried this?

aeharding commented 4 days ago

I tried to use patch-package to change these to /#NO_SIDE_EFFECTS/ but still got a bunch of complaints from rollup. Has anybody else tried this?

No... but it seems harmless enough. I am using Rollup's 'onwarn' option to ignore the warnings for this.

agriffis commented 4 days ago

No... but it seems harmless enough. I am using Rollup's 'onwarn' option to ignore the warnings for this.

Sure, you can ignore the warnings. I was hoping to enable the optimization that the pragma intends to achieve, which the warnings indicate is not working.