-
Notifications
You must be signed in to change notification settings - Fork 204
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
eval()
causing warning with Rollup / ESBuild
#1760
Comments
Hello. The
afaik Rollup does not seem to have a way to ignore a specific warning at a specific location, e.g:
So it seems like you would need to use the I could try to modify the code so it won't trigger a warning, but that is such strange voodoo magic This discussion also makes me wonder if I should test newer implementations of this "fastProps" magic, e.g:
|
Thanks @bd82 for the quick reply and for your care in considering this issue. I've decided to use // rollup.config.js
export default {
...
onwarn(warning, warn) {
// skip `EVAL``warnings related to Chevrotain
// https://github.com/Chevrotain/chevrotain/issues/1760
if (warning.code === 'EVAL' && warning.id?.includes('chevrotain')) return
// Use default behavior for everything else
warn(warning)
},
} I understood that the code was unreachable, but I was concerned that using
I agree that would be very handy for this!
If you think it is better, and it would fix this issue, then I fully support it! |
The warning is caused by an unreachable `eval` call. GitHub issue: Chevrotain/chevrotain#1760
I did a mini prototype with https://github.com/sindresorhus/to-fast-properties/ I will close this issue for now, I believe it should be revisited once Chevrotain itself goes ESM only as well |
I’m suggesting copying the code actually. |
That is a good idea, but I don't want to mess with copying of the license/copyright notice just for 31 LOC bruto. :( And I am not sure what it means if the source code is partially MIT and partially Apache |
I've recently come across this warning using Rollup as well. For the time being, considering the conversation here that mentions it is unlikely to be a threat since it is unreachable code. That being said, I recently modified my local version of the to-fast-properties.js file using the suggestions provided here: https://rollupjs.org/troubleshooting/#avoiding-eval, creating a global scoped eval2 from the This removed the warning, but I am unsure if this has other unwanted effects. Is this a potential change that could remove the warning for others without changing the operation of this package? |
Hello @arcasoy The purpose of this "eval" is as a flag to V8 engine and without it performance is impacted. So I would recommend testing two scenarios with the local performance benchmark
I can also think of a third option, The bundling tools are static analysis tools are have limited capability to "understand" complex expressions. so what would happen if we change the code to access the eval function in a more dynamic manner, e.g:
Perhaps there is a gap between the "understanding" of V8 and rollup's parser that could be "exploited" to disable the warning while keeping the functionality. |
There is a guide in esbuild docs on avoiding direct eval. |
eval()
causing issue with Rollupeval()
causing warnning with Rollup / ESBuild
I've applied the pattern suggested by esbuild's docs and it solved the warnning on esbuild. |
No performance regressions were measured... |
eval()
causing warnning with Rollup / ESBuildeval()
causing warning with Rollup / ESBuild
A Rollup package that I'm creating depends on
three-stdlib
, which depends onchevrotain
. When I try to build my project, I get this warning:The documentation linked to in the warning offers a couple solutions. Here's one:
Is this is something that could be implemented with Cevrotain to prevent this warning and related problems with Rollup?
Thank you for your help on this issue and your work on this package :)
The text was updated successfully, but these errors were encountered: