fix!: rename Evaluator.eval() to run() so cel-js can be bundled under SES#99
Open
Kukks wants to merge 1 commit into
Open
fix!: rename Evaluator.eval() to run() so cel-js can be bundled under SES#99Kukks wants to merge 1 commit into
Kukks wants to merge 1 commit into
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 bareeval(...)in the output, and SES's static "direct eval" check can't tell it apart from a realeval(), 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 onEvaluator, the internal call sites across operators/macros/optional, and theevaluator.eval(...)examples in the README and index.d.ts. I went withrunrather thanevaluatebecauseevaluateis already the public string-expression entry point (Environment.evaluateand the top-levelevaluate()), 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 toevaluator.run(node, ctx). Happy to use a different name if you'd prefer. Worth noting that a deprecated alias wouldn't help: keeping anevalmethod 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.