-
Notifications
You must be signed in to change notification settings - Fork 251
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
Rollupjs build complains about the use of eval in this library. #18
Comments
This is because emn178/js-md5#8 |
Can it be changed to a dynamic import or anything along those lines to avoid the use of |
Even more, this prevents us from not using 'unsafe-eval' in our Content Security Policy. Any chance that this one get fixed? |
It also breaks in vitejs. We need a fix. |
As a fix, you can replace the eval strings in the library during build. import replace from "rollup-plugin-re";
export default {
...,
plugins: [
replace({
patterns: [
{
match: /js-sha256/,
test: `eval("require('crypto')")`,
replace: `require('crypto')`
},
{
match: /js-sha256/,
test: `eval("require('buffer').Buffer")`,
replace: `require('buffer').Buffer`
}
],
}),
]
} |
An alternative to suppress warnings in export default defineConfig({
build: {
rollupOptions: {
onwarn: ({ loc }) => {
if (loc?.file?.match(/js-sha256\/src\/sha256.js$/))
return;
}
}
}); |
remove eval in v0.10.0 |
(!) Use of eval is strongly discouraged
https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval
node_modules/js-sha256/src/sha256.js
84:
85: var nodeWrap = function (method, is224) {
86: var crypto = eval("require('crypto')");
^
87: var Buffer = eval("require('buffer').Buffer");
88: var algorithm = is224 ? 'sha224' : 'sha256';
...and 1 other occurrence
created dist/transactionmgmt.dev.js in 4.7s
[2018-06-21 10:33:00] waiting for changes...

The text was updated successfully, but these errors were encountered: