When parsing a module (that has imports and exports), use esprima.parseModule(code, {"jsx": True}).

Furthermore, Esprima does not support React's <> fragment syntax, so you'll have to hack those to their canonical form first (and yes, I'm aware it will happily replace that in e.g. strings within the source too, but can't be helped:

code = code.replace("<>", "<React.Fragment>")
code = code.replace("</>", "</React.Fragment>")
pprint(esprima.parseModule(code, {"jsx": True}))

prints out

{
    type: "Program",
    sourceType: "module",
    body: [
        {
            type: "ImportDeclaration",
            specifiers: [
                {
                    type: "ImportSpecifier",
                    local: {
                        type: "Identifier",
                        name: "Image"
                    },
                    imported: {
                        type: "Identifier",
                        name: "Image"
                    }
                }
            ],
            source: {
                type: "Literal",
                value: "Base",
                raw: "'Base'"
            }
        },
...

(once the missing tags were added ;-) )

Answer from AKX on Stack Overflow
🌐
PyPI
pypi.org › project › esprima
esprima · PyPI
Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser officially written in ECMAScript (also popularly known as JavaScript) and ported to Python.
      » pip install esprima
    
Published   Aug 24, 2018
Version   4.0.1
🌐
GitHub
github.com › Kronuz › esprima-python
GitHub - Kronuz/esprima-python: ECMAScript parsing infrastructure for multipurpose analysis · GitHub
Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser officially written in ECMAScript (also popularly known as JavaScript) and ported to Python.
Starred by 266 users
Forked by 47 users
Languages   Python
🌐
Anaconda.org
anaconda.org › conda-forge › esprima-python
esprima-python - Conda
Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser officially written in ECMAScript (also popularly known as JavaScript) and ported to Python.
🌐
Esprima
esprima.org › doc
Esprima Documentation
The documentation is available in the following formats: · Warning: since this version is still being actively development, the documentation is subject to change without notice
🌐
GitHub
github.com › int3 › pyesprima
GitHub - int3/pyesprima: Python port of Esprima, the Javascript parser.
A Python port of Esprima, the JavaScript parser.
Starred by 11 users
Forked by 4 users
Languages   Python 100.0% | Python 100.0%
🌐
Stack Overflow
stackoverflow.com › questions › tagged › esprima-python
Newest 'esprima-python' Questions - Stack Overflow
Here is my code: import esprima class MyVisitor(esprima.NodeVisitor): def visit_ExpressionStatement(self, node): return None ...
🌐
PyPI
pypi.org › project › pyesprima
pyesprima · PyPI
July 1, 2013 - A Python port of [Esprima][1], the JavaScript parser.
      » pip install pyesprima
    
Published   Jul 02, 2013
Version   1.0.0
Find elsewhere
🌐
Debian
bugs.debian.org › 987923
#987923 - ITP: esprima-python -- ECMAScript parsing infrastructure for multipurpose analysis - Debian Bug report logs
May 2, 2021 - Package: wnpp Severity: wishlist ... Esprima (esprima.org, BSD license) is a high performance, standards compliant ECMAScript/JavaScript parser officially written in JavaScript and ported to Python via line-by-line manual translation....
🌐
Arch Linux
aur.archlinux.org › packages › python-esprima
AUR (en) - python-esprima - Arch Linux
python-setuptools (make) psychopy · https://github.com/Kronuz/esprima-python/archive/v4.0.1.tar.gz · aurweb v6.2.18 · Report issues here. Copyright © 2004-2025 aurweb Development Team. AUR packages are user produced content.
🌐
GitHub
github.com › Kronuz › esprima-python › blob › master › examples › visitor.py
esprima-python/examples/visitor.py at master · Kronuz/esprima-python
ECMAScript parsing infrastructure for multipurpose analysis - esprima-python/examples/visitor.py at master · Kronuz/esprima-python
Author   Kronuz
🌐
Esprima
esprima.org
Esprima
Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) of a JavaScript program.
🌐
GitHub
github.com › austinbyers › esprima-ast-visitor
GitHub - austinbyers/esprima-ast-visitor: Python code to efficiently traverse the AST format saved by the Esprima JavaScript parser
Python code to efficiently traverse the AST format saved by the Esprima JavaScript parser - austinbyers/esprima-ast-visitor
Starred by 32 users
Forked by 9 users
Languages   Python 100.0% | Python 100.0%
🌐
GitHub
github.com › lucasg › esprima-python
GitHub - lucasg/esprima-python: ECMAScript parsing infrastructure for multipurpose analysis
Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser officially written in ECMAScript (also popularly known as JavaScript) and ported to Python.
Author   lucasg
🌐
Esprima
esprima.org › demo › parse.html
Esprima: Parser
Parser produces the (beautiful) syntax tree · // Life, Universe, and Everything var answer = 6 * 7; · Ready · Syntax · Tokens · URL for this code:
🌐
Esprima
docs.esprima.org › en › latest › syntactic-analysis.html
Chapter 2. Syntactic Analysis (Parsing) — Esprima master documentation
Note: In the previous versions (Esprima <= 3.1), there was a single parsing function, parse. To distinguish between parsing a script and a module, the sourceType property in the configuration object needs to be specified, either as "script" (also the default value) or "module".
🌐
Awesomeopensource
awesomeopensource.com › project › Kronuz › esprima-python
Esprima Python Alternatives
Programming Languages > Python · Compilers > Abstract Syntax Tree · Site · Repo · Alternatives To Esprima Python · Alternatives To Esprima Python · Select To Compare · Prettier ⭐ 49,806 · Prettier is an opinionated code formatter. dependent packages 259,630total releases 147most recent commit 2 months ago ·