Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Use of eval is strongly discouraged' warning in rollup #428

Closed
neilgd opened this issue May 1, 2022 · 7 comments
Closed

'Use of eval is strongly discouraged' warning in rollup #428

neilgd opened this issue May 1, 2022 · 7 comments

Comments

@neilgd
Copy link

neilgd commented May 1, 2022

When using rollup to package a component that references react-paginate, it spits out the following warning:

(!) Use of eval is strongly discouraged https://rollupjs.org/guide/en/#avoiding-eval node_modules/react-paginate/dist/react-paginate.js

I am using version 8.1.3.

Any ideas? Thank you!

@MonsieurV
Copy link
Collaborator

MonsieurV commented May 2, 2022

Hi @neilgd,

This is certainly due to the Babel dist of react-paginate. (Cf babel.config.js

You can try to transpile yourself from the React-Paginate source code, importing from:

import ReactPaginate from './node_modules/react-paginate/react_components/index.js

(Then you are responsible for the right Babel/transpiling settings, if any is required on your target)

Anyway there is no eval directly in the library code, but only on the Babel output.

@silverwind
Copy link

silverwind commented Nov 3, 2022

The problem comes from react-hot-loader. With it removed, there is no more eval in the compiled file.

@MonsieurV
Copy link
Collaborator

I removed it (trying to replace it by react-refresh in dev). No more eval in the build indeed. Thanks @silverwind.

@AdeleD can you release https://github.com/AdeleD/react-paginate/releases/tag/v8.1.4? Thx

@silverwind
Copy link

Another nice thing about this change is that bundle size goes down from 23kB to 15kB.

@AdeleD
Copy link
Owner

AdeleD commented Nov 5, 2022

Is the replacement of react-hot-loader by react-refresh mandatory? I guess the issue was "just" that react-hot-loader was not correctly removed from the production build, or do I miss something?

@MonsieurV
Copy link
Collaborator

Is the replacement of react-hot-loader by react-refresh mandatory? I guess the issue was "just" that react-hot-loader was not correctly removed from the production build, or do I miss something?

Well, I thought the same, then I read the CHANGELOG on 7.1.3 and related commit, then this comment and quote and finally looked at this (like @silverwind pointed): the issue is that the Babel config does include the react-hot-loader plugin. And that this config is not really meant to

The Babel plugin for the react-hot-loader is (considered) production safe, and is really minimal. But it does includes an eval and some minimal unnecessary code for production. It seems just better for me to do without.

And for the dev experience, react-hot-loader is deprecated, so I tried react-refresh (but my webpack-dev-middleware setup must be wrong atm).

@AdeleD
Copy link
Owner

AdeleD commented Nov 5, 2022

Ok, I understand. Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants