Skip to content

fix!: rename Evaluator.eval() to run() so cel-js can be bundled under SES#99

Open
Kukks wants to merge 1 commit into
marcbachmann:mainfrom
Kukks:rename-evaluator-eval-to-run
Open

fix!: rename Evaluator.eval() to run() so cel-js can be bundled under SES#99
Kukks wants to merge 1 commit into
marcbachmann:mainfrom
Kukks:rename-evaluator-eval-to-run

Conversation

@Kukks

@Kukks Kukks commented Jun 25, 2026

Copy link
Copy Markdown

Fixes #98.

The Evaluator's recursive node-evaluation method is named eval. When cel-js gets bundled and minified — for example into a MetaMask Snap — that method ends up as a bare eval(...) in the output, and SES's static "direct eval" check can't tell it apart from a real eval(), so it rejects the whole bundle. That makes cel-js, and anything that depends on it, impossible to use inside a snap.

This renames the method to run: the definition on Evaluator, the internal call sites across operators/macros/optional, and the evaluator.eval(...) examples in the README and index.d.ts. I went with run rather than evaluate because evaluate is already the public string-expression entry point (Environment.evaluate and the top-level evaluate()), so reusing it would be confusing.

It's a breaking change for anyone calling evaluator.eval(node, ctx) directly from a custom function or macro — they'd need to move to evaluator.run(node, ctx). Happy to use a different name if you'd prefer. Worth noting that a deprecated alias wouldn't help: keeping an eval method around leaves the token in the bundle, so SES would still reject it. A plain rename is the only thing that unblocks bundling.

All 1053 tests pass unchanged.

… SES

SES's static "direct eval" check (used by MetaMask Snaps and other
lockdown environments) rejects any bundle that contains a bare `eval(`
token. The Evaluator's recursive node-evaluation method was named `eval`,
so minified cel-js output gets rejected and the library can't be bundled
into a snap.

Rename that method to `run` (definition + all internal call sites in
operators/macros/optional, plus the README and index.d.ts examples).
`evaluate` is already the public string-expression entry point
(Environment.evaluate / the top-level evaluate()), so `run` avoids the
clash.

Fixes marcbachmann#98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Evaluator method named eval breaks SES / MetaMask Snap bundling

1 participant