How meta/jscodeshift works
jscodeshift is a JavaScript and TypeScript codemod toolkit: a user supplies source paths and a transform, the runner processes files, and transforms can use an AST-based Recast wrapper to inspect and modify code. The graph preserves the documented CLI and library workflows, parser choices, and major transformation APIs. Runner internals and several modules are unsampled, so uncertain control-flow links are omitted or marked unverified rather than inferred.
Main entry points: getParser.js Parser selection · Worker.js Transform worker · Collection.js AST collections · JSXElement.js JSX operations
Components 23
Execution
- CLI entry
bin/jscodeshift.js - Option parser
src/argsParser.js - File runner
src/Runner.js - Transform worker
src/Worker.js
Parsing
- Parser selection
src/getParser.js - Babel parser
parser/babel5Compat.js - Babylon parser
parser/babylon.js - Flow parser
parser/flow.js - TypeScript parser
parser/ts.js - TSX parser
parser/tsx.js
AST toolkit
- jscodeshift API
src/core.js - AST collections
src/Collection.js - Node operations
src/collections/Node.js - JSX operations
src/collections/JSXElement.js - Variable operations
src/collections/VariableDeclarator.js - Import operations
src/collections/ImportDeclaration.js - AST templates
src/template.js
Utilities
- Node matching
src/matchNode.js - Type intersection
src/utils/intersection.js - Once registration
src/utils/once.js
Other components
- Codemod user
- User transform
- Source files
Connections 27
- Codemod user → CLI entry: supplies options
- CLI entry → Option parser: parses arguments
bin/jscodeshift.js - CLI entry → File runner: starts run
bin/jscodeshift.js - Codemod user → User transform: provides transform
- Codemod user → Source files: selects paths
- File runner → Transform worker: dispatches files
- Transform worker → User transform: invokes transform
src/Worker.js - Transform worker → Source files: reads and writes
src/Worker.js - Transform worker → Parser selection: selects parser
src/Worker.js - Transform worker → jscodeshift API: loads API
src/Worker.js - User transform → jscodeshift API: uses API
- jscodeshift API → AST collections: exposes collections
- AST collections → Type intersection: uses helper
src/Collection.js - Node operations → AST collections: extends collections
src/collections/Node.js - Node operations → Node matching: matches nodes
src/collections/Node.js - JSX operations → AST collections: extends collections
src/collections/JSXElement.js - JSX operations → Node operations: uses node methods
src/collections/JSXElement.js - JSX operations → Variable operations: uses module filter
src/collections/JSXElement.js - Variable operations → AST collections: extends collections
src/collections/VariableDeclarator.js - Node operations → Once registration: guards registration
src/collections/Node.js - JSX operations → Once registration: guards registration
src/collections/JSXElement.js - Variable operations → Once registration: guards registration
src/collections/VariableDeclarator.js - Parser selection → Babel parser: selects parser
src/getParser.js - Parser selection → Babylon parser: selects parser
src/getParser.js - Parser selection → Flow parser: selects parser
src/getParser.js - Parser selection → TypeScript parser: selects parser
src/getParser.js - Parser selection → TSX parser: selects parser
src/getParser.js