-
Notifications
You must be signed in to change notification settings - Fork 9
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
Avoid using 'eval' for statically known strings #24
Conversation
1f0a9eb
to
9ddbe64
Compare
When using functions such as `Js.Unsafe.eval_string` in Wasm, when the string is known at compile time, it can be emitted as an external Javascript fragment, rather than using the infamous `eval`. Co-authored-by: Jérôme Vouillon <[email protected]>
9ddbe64
to
0a8a736
Compare
Could you reformat |
Done. |
runtime/wasm/runtime.js
Outdated
start_fiber = wrap_fun( | ||
{parameters: ['eqref'], results: ['externref']}, | ||
caml_start_fiber, {promising: 'first'} | ||
) | ||
var _initialize = wrap_fun( | ||
{parameters: [], results: ['externref']}, | ||
_initialize, {promising: 'first'} | ||
) | ||
var process = globalThis.process; | ||
if(process && process.on) { | ||
process.on('uncaughtException', (err, origin) => | ||
caml_handle_uncaught_exception(err)) | ||
} | ||
else if(globalThis.addEventListener){ | ||
globalThis.addEventListener('error', event=> | ||
event.error&&caml_handle_uncaught_exception(event.error)) | ||
} | ||
await _initialize(); | ||
})(((joo_global_object,jsoo_exports,globalThis)=>(x)=>{return eval("("+x+")")})(globalThis,globalThis?.module?.exports||globalThis,globalThis), | ||
PRIMITIVES, STRINGS, | ||
((joo_global_object,jsoo_exports,globalThis)=>FRAGMENTS)(globalThis,globalThis?.module?.exports||globalThis,globalThis)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, also...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what happened here. I think it should be right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vouillon I don’t really understand this file, so I don’t remember what was the right way to do this.
94ba315
to
1a8fc19
Compare
Co-authored-by: Jérôme Vouillon <[email protected]>
When using functions such as
Js.Unsafe.eval_string
in Wasm, when the string is known at compile time, it can be emitted as an external Javascript fragment, rather than using the infamouseval
.