Stephen Mallette created TINKERPOP-3241:
-------------------------------------------

             Summary: Improve javascript translator behavior for web 
applications
                 Key: TINKERPOP-3241
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3241
             Project: TinkerPop
          Issue Type: Improvement
          Components: javascript
    Affects Versions: 3.8.1
            Reporter: Stephen Mallette
            Assignee: Stephen Mallette


A finding from the PR that created gremlator: 

The TranslateVisitor.visit() method dispatches to the correct visitor method 
(e.g. visitStringLiteral, visitIntegerLiteral) by inspecting 
tree.constructor.name at runtime — it expects names like StringLiteralContext 
and strips the Context suffix to find the method.

Vite's production build minifies class names, so StringLiteralContext becomes 
something like Qh. The className.endsWith('Context') check fails, the dispatch 
never matches any specific visitor method, and every rule context falls through 
to the generic visitChildren() path, which just walks down to terminal
tokens and outputs raw text.

That's why step names translate correctly (they're terminal tokens handled by 
visitTerminal) but all arguments — strings, numbers, booleans, collections — 
pass through unmodified. The language-specific visitor overrides for those 
literal types never get called.

The fix is adding esbuild: { keepNames: true } to vite.config.ts so class names 
survive minification. But the deeper issue is in gremlin-js itself: the visit() 
dispatch relies on runtime class name reflection, which is inherently fragile 
under minification. A more robust approach would be to dispatch on
ruleIndex (a stable integer) rather than the class name string.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to