staylor / react-helmet-async

Thread-safe Helmet for React 16+ and friends
Apache License 2.0
2.11k stars 154 forks source link

`/*#__PURE__*/` annotations don't play well with Vite / Rollup #207

Open shellscape opened 10 months ago

shellscape commented 10 months ago

It looks like the build script for this lib is outputting code which contains /*#__PURE__*/ annotation comments. Unfortunately they look like they're misplaced, and we're getting some non-blocking warnings about it. Here's what the warnings look like when compiling an app which uses this lib, with Vite:

"/*#__PURE__*/"

in "../../node_modules/.pnpm/react-helmet-async@1.3.0_react-dom@18.2.0_react@18.2.0/node_modules/react-helmet-async/lib/index.module.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
../../node_modules/.pnpm/react-helmet-async@1.3.0_react-dom@18.2.0_react@18.2.0/node_modules/react-helmet-async/lib/index.module.js (1:13561) A comment

"/*#__PURE__*/"

in "../../node_modules/.pnpm/react-helmet-async@1.3.0_react-dom@18.2.0_react@18.2.0/node_modules/react-helmet-async/lib/index.module.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
goliney commented 7 months ago

It's time to look for alternative libs. Any suggestions? :)

thienandangthanh commented 7 months ago

The warning disappears from version 2.0.0. Because the lib switched to use esbuild. You can give it a try.

Here's the diff: https://github.com/staylor/react-helmet-async/compare/b1ee65880e71df9124c4e01d07c086d8ce2fc63a...a75c3ae812af1608a5f4c65b8c93c29e6896018b

goliney commented 7 months ago

@thienandangthanh thank you for the response. If true, this issue should be closed.