Socket
Socket
Sign inDemoInstall

@babel/parser

Package Overview
Dependencies
0
Maintainers
4
Versions
192
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
44,287,565
decreased by-18.7%
Install size
1.80 MB

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.24.4 (2024-04-03)

:eyeglasses: Spec Compliance
  • babel-parser
    • #16403 Forbid initializerless using (@JLHwung)
  • babel-helpers, babel-plugin-proposal-decorators, babel-runtime-corejs3
:bug: Bug Fix
  • babel-generator
  • babel-compat-data, babel-plugin-bugfix-firefox-class-in-computed-class-key, babel-preset-env
  • babel-helper-create-class-features-plugin, babel-plugin-proposal-decorators
  • babel-plugin-transform-block-scoping
  • babel-core, babel-plugin-transform-block-scoped-functions, babel-plugin-transform-block-scoping

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 03 Apr 2024

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