gcanti / fp-ts

Functional programming in TypeScript
https://gcanti.github.io/fp-ts/
MIT License
10.78k stars 502 forks source link

Comment-related warnings when building with Vite #1916

Closed branko-d closed 9 months ago

branko-d commented 10 months ago

🐛 Bug report

Current Behavior

When building a production bundle with Vite, I get a bunch of warnings like this:

A comment

"/*#__PURE__*/"

in "node_modules/fp-ts/es6/Either.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.

Expected behavior

No build warnings.

Reproducible example

  1. Go here: https://stackblitz.com/edit/vitejs-vite-y7ddkf?file=src%2FApp.tsx
  2. This is just a standard Vite's react-ts example with "fp-ts" added to package.json and imported in App.tsx.
  3. Click on the Terminal panel at the bottom.
  4. Enter q + ENTER to quid Vite dev server.
  5. Type: vite build.

You should be able to see the warnings in the build log.

Suggested solution(s)

Not sure - probably fix the comments somehow?

Your environment

Which versions of fp-ts are affected by this issue?

Software Version(s)
fp-ts 2.16.1
TypeScript 5.2.2

Did this work in previous versions of fp-ts?

Not sure - we just transitioned away from Create React App (where we didn't get these warnings) to Vite recently.

kblcuk commented 9 months ago

FIY I stumbled upon the same issue and after some investigation I think I might have a fix 🤞

cfgs commented 8 months ago

FIY I stumbled upon the same issue and after some investigation I think I might have a fix 🤞

How is the fix going? :)

kblcuk commented 8 months ago

@cfgs you can see a bit above your comment that this issue was closed in https://github.com/gcanti/fp-ts/pull/1919 :)

So once you update to the latest fp-ts, the warnings should disappear for you as well!