Skip to content

Commit 7c5c4d2

Browse files
Improve eval external script.
1 parent 9528ced commit 7c5c4d2

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

Classes/JSBScriptingSupport.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,9 @@ + (id)require:(NSString *)name
151151
script = [NSString stringWithContentsOfFile:[name stringByAppendingPathExtension:@"js"] encoding:NSUTF8StringEncoding error:nil];
152152
}
153153
if (script) {
154-
NSString *closure = [NSString stringWithFormat:
155-
@"(function() {\n"
156-
@" %@\n"
157-
@"})();\n", script];
158-
[globalContext evaluateScript:closure];
154+
JSValue *function = globalContext[@"Function"];
155+
JSValue *value = [function constructWithArguments:@[script]];
156+
[value callWithArguments:nil];
159157
module = globalContext[@"JSB"][@"exports"];
160158
}
161159

0 commit comments

Comments
 (0)