When required script contains syntax errors, it silently skips it just like file was not included. ``` $v8 = new V8Js(); $v8->setModuleLoader(function ($path) { return 'synta}{ error!'; // returns undefined // return 'module.exports = 1'; // this works }); $script = 'let a = require("file.js"); print(a)'; $r = $v8->executeString($script); echo $r; ``` Is there any way to get syntax error exception when module loader returns invalid code?
Activity
redbullmarky commentedon Jun 1, 2022
@stesie is this literally as simple as adding (in v8js_methods.cc):
v8js_throw_script_exception(c->isolate, &try_catch);in place of:
to somewhat match the one found in
v8js_compile_script? or perhaps refactoring to use v8js_compile_script for modules, too?trying it out seems to do what you'd want; i'm just not 100% sure what the other side-effects of doing so might be.
redbullmarky commentedon Feb 27, 2023
@stesie here's what i'm proposing in v8js_methods.cc:
produces (using the OP's test example):
If that seems fine, i'll get a PR for php7 & 8 sorted :)