or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

index.mddocs/

@babel/plugin-syntax-bigint

@babel/plugin-syntax-bigint is a Babel syntax plugin that enables parsing of BigInt literals in JavaScript code. This is a syntax-only plugin that doesn't transform code but allows Babel to recognize and parse BigInt literal syntax (e.g., 123n). The plugin was designed to provide BigInt syntax support before it became part of the default parser configuration.

Package Information

  • Package Name: @babel/plugin-syntax-bigint
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install --save-dev @babel/plugin-syntax-bigint

Core Imports

// Default import (the plugin factory function)
import plugin from "@babel/plugin-syntax-bigint";

For CommonJS:

const plugin = require("@babel/plugin-syntax-bigint");

Basic Usage

This plugin is used by adding it to your Babel configuration, not imported directly in your code:

{
  "plugins": ["@babel/plugin-syntax-bigint"]
}

Or with options:

// babel.config.js
module.exports = {
  plugins: [
    ["@babel/plugin-syntax-bigint"]
  ]
};

Once enabled, your code can use BigInt literals:

// This syntax becomes parseable with the plugin
const bigNumber = 123456789012345678901234567890n;
const anotherBig = BigInt("123456789012345678901234567890");

Capabilities

Plugin Factory Function

The main export is a Babel plugin factory function that creates the syntax plugin.

/**
 * Creates a Babel plugin that enables BigInt literal syntax parsing
 * @param {Object} api - Babel API object with version assertion capabilities
 * @returns {Object} Plugin configuration object
 */
function plugin(api: BabelAPI): BabelPlugin;

interface BabelAPI {
  assertVersion(version: number): void;
}

interface BabelPlugin {
  name: string;
  manipulateOptions(opts: BabelOptions, parserOpts: ParserOptions): void;
}

interface BabelOptions {
  [key: string]: any;
}

interface ParserOptions {
  plugins: string[];
}

Plugin Properties:

  • name: "syntax-bigint" - Plugin identifier
  • manipulateOptions: Function that adds "bigInt" to the parser plugins array

Parser Integration

The plugin works by modifying Babel's parser options to include BigInt syntax support.

/**
 * Modifies parser options to enable BigInt literal parsing
 * @param {Object} opts - Babel transformation options
 * @param {Object} parserOpts - Parser-specific options with plugins array
 */
manipulateOptions(opts: BabelOptions, parserOpts: ParserOptions): void;

Behavior: Pushes "bigInt" string to the parserOpts.plugins array, enabling the parser to recognize BigInt literal syntax.

Usage Notes

  • This is a syntax-only plugin - it enables parsing but doesn't transform BigInt literals
  • The plugin was archived in newer Babel versions as BigInt parsing became enabled by default
  • Use this plugin for backward compatibility with older Babel configurations
  • No runtime dependencies beyond @babel/helper-plugin-utils
  • Requires @babel/core ^7.0.0-0 as a peer dependency

Migration Notes

In newer Babel versions (7.8.3+), BigInt literal parsing is enabled by default, making this plugin unnecessary for most modern projects. This plugin should only be used when:

  • Working with older Babel configurations
  • Maintaining backward compatibility
  • Explicitly controlling parser plugin inclusion