-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
uses unsafe-eval #593
Comments
fix #11 i can't upgrade to the latest easily because of protobufjs/protobuf.js#593 auditors: @ayumi
Fallback encoders and decoders were rather slow and large, so I decided to remove them entirely. The alternative here is generating static code instead. |
Closing this issue for now as it hasn't received any replies recently. Feel free to reopen it if necessary! |
I'm generating static code, but still got this warning with RollupJS:
Does it exist some compile option to prevent using |
What's happening there is that the |
I see. I'll take a closer look this weekend and see how to get rid of |
Sure. Not a big fan of the eval solution either. Just seemed to be the only workaround reliably preventing warnings and stuff in webpack. |
I wasn't able to find a common solution which muches all scenarios. This problem is about different bundle tools: Webpack, Rollup, Browserify etc. function inquire(moduleName) {
try {
var mod = require(moduleName)
if (mod && (mod.length || Object.keys(mod).length))
return mod;
} catch (e) {
return null;
} // eslint-disable-line no-empty
return null;
} It's good enough to not have any errors or warnings on build. But Webpack understands this code and still will try to extract some information (https://webpack.js.org/guides/dependency-management/). I do not know much about Browserify, but I suppose to have this kind of problem too. What is common among theses bundlers is that it is possible to specify externals. Thus I think one of the solution would be to use Of course this solution requires an additional step for API consumers if they do not want to see errors/warnings, but eliminates the Let me know how you see this problem. I wish to help to fix it. |
@dcodeIO any thoughts on this? I am trying to switch to this library to get rid of unsafe-evals and this is an issue for me, maybe using |
Temporary solution could be to use a preprocessor. For example for Rollup is import replace from 'rollup-plugin-re'
// ...
plugins: [
replace({
patterns: [
{
test: /eval.*\(moduleName\);/g,
replace: 'undefined;'
}
]
})
]
// ... |
met same problem. Is there any long term solution? |
Any news about this issue? I have the same problem. My two cents here. The proposed solution can be improved by using |
There is an easy workaround for eval like this one aws/amazon-chime-sdk-js#800 (comment) when using Webpack (or this when using Rollup) But now I'm struggling with codegen that has the same problem: #1483 😕 |
@dcodeIO using |
Is this Alternatively, I'd be great if at least the |
protobuf.js version: 6.3.x
it appears that recent versions of protobufjs are using
eval
, which prevents the browserified library from working in web applications that have a Content Security Policy withoutunsafe-eval
, such as is the case for Chrome extensions.The text was updated successfully, but these errors were encountered: