Socket
Socket
Sign inDemoInstall

@babel/parser

Package Overview
Dependencies
0
Maintainers
4
Versions
190
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/parser

A JavaScript parser


Version published
Maintainers
4
Weekly downloads
52,349,102
decreased by-6.4%

Weekly downloads

Package description

What is @babel/parser?

The @babel/parser package is a JavaScript parser that allows you to convert ECMAScript 2015+ code into a parse tree. This package is part of the Babel toolchain and is primarily used for transforming JavaScript code. It provides a flexible and extensible framework for parsing modern JavaScript syntax, enabling developers to analyze, understand, and manipulate the code structure.

What are @babel/parser's main functionalities?

Parsing JavaScript

This feature allows you to parse JavaScript code into an abstract syntax tree (AST). The code sample demonstrates how to parse a simple piece of JavaScript code, specifying the source type and enabling plugins for JSX and TypeScript support.

const babelParser = require('@babel/parser');
const code = 'let x = 1;';
const ast = babelParser.parse(code, {
  sourceType: 'module',
  plugins: [
    'jsx',
    'typescript'
  ]
});

Using Plugins for Syntax Support

The @babel/parser package supports various plugins to extend its parsing capabilities to include newer JavaScript syntax and experimental features. This example shows how to enable the 'asyncGenerators' and 'classProperties' plugins to parse code using these features.

const astWithPlugins = babelParser.parse(code, {
  plugins: [
    'asyncGenerators',
    'classProperties'
  ]
});

Other packages similar to @babel/parser

Changelog

Source

v7.18.4 (2022-05-29)

:eyeglasses: Spec Compliance
  • babel-types
    • #14591 fix: remove TSDeclareFunction from ExportDefaultDeclaration (@JLHwung)
:bug: Bug Fix
  • babel-plugin-transform-typescript
  • babel-parser
  • babel-helper-check-duplicate-nodes, babel-parser
:house: Internal
  • babel-plugin-transform-block-scoping, babel-plugin-transform-classes, babel-plugin-transform-modules-systemjs

Readme

Source

@babel/parser

A JavaScript parser

See our website @babel/parser for more information or the issues associated with this package.

Install

Using npm:

npm install --save-dev @babel/parser

or using yarn:

yarn add @babel/parser --dev

Keywords

FAQs

Last updated on 29 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc