recma-parse is a unified plugin for the recma ecosystem, designed to transform JavaScript source code into an Abstract Syntax Tree (AST). It leverages `esast-util-from-js` internally to parse JavaScript according to the ECMA-262 standard, producing ASTs in both esast and estree formats. As of its current stable version, 1.0.0, it is an ESM-only package, strictly requiring Node.js 16 or newer for execution. This package is part of the actively maintained `recma` monorepo, which provides a cohesive suite of tools for processing JavaScript ASTs, akin to how `remark` handles Markdown and `rehype` processes HTML. It differentiates itself by offering a robust, standards-compliant parsing step within the unified transformation pipeline, providing a foundational component for various JavaScript code transformations and analyses.
npm install recma-parseVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up a unified pipeline using recma-parse to parse JavaScript, transform JSX elements using recma-jsx and recma-build-jsx, and then serialize the modified AST back into JavaScript code using recma-stringify. It processes a simple JSX expression and outputs the equivalent React.createElement call.
Migrate your project to ESM imports or use dynamic `import()` for compatibility if absolutely necessary. Ensure your Node.js version is 16+.
Never evaluate untrusted JavaScript code directly. Implement strict input validation and sanitization for any code passed to the parser or subsequent plugins.
Ensure your project runs on a currently maintained version of Node.js (16+ for v1.x) to maintain compatibility and receive security updates.
Change the import statement to use the default import syntax: `import recmaParse from 'recma-parse'`.
Convert your consuming module to an ES Module (e.g., by adding `"type": "module"` to your `package.json` or renaming the file to `.mjs`) and use `import recmaParse from 'recma-parse'`.