browserify / static-eval

evaluate statically-analyzable expressions
MIT License
175 stars 27 forks source link

It does not evaluate functions #41

Open hacknlove opened 1 year ago

hacknlove commented 1 year ago
const { parse } = require('esprima');
const staticEval = require('static-eval');
const ast = parse('(() => 1)()');
const val = staticEval(ast.body[0].expression, {}, { allowAccessToMethodsOnFunctions: true });
// val is undefined

The expression I was actually trying to evaluate looks more like '[1,2,3].map(x => x)'

Is there some workaround?

hacknlove commented 1 year ago

It seems to be related with this: https://github.com/browserify/static-eval/pull/37