Back to Explore

nodejs/cjs-module-lexer

GitHub
1 watchersOpen source

Last release:

A fast JavaScript lexer that analyzes CommonJS module source code to detect the most likely named exports (for example, assignments like `exports.name = ...` and `Object.defineProperty(exports, 'name', ...)`) and possible reexports via `module.exports = require(...)`. It is used in Node.js core to infer named exports when importing CommonJS into ESM, and it focuses on comprehensive CommonJS syntax handling while staying small and fast.

Project status

  • Actively maintained: The repository has recent activity (last upstream push on 2026-08-10), and recent version updates exist (notably 2.2.0 on 2026-01-02).
  • Update cadence (evident from listed updates): 2.1.1 (2025-11-07) to 2.2.0 (2026-01-02) is roughly 2 months, with an earlier 2.1.0 (2025-02-20) about 9 months before that. Overall cadence looks irregular but ongoing, not dormant.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • 2.2.0

    Release 2.2.0 replaces the lexer’s use of indirect eval for decoding string literals with a custom string-literal scanner that parses escapes without executing code. The release notes only mention the removal of eval and the switch to internal parsing, but the diff shows additional behavior, testing, and tooling changes around string decoding.

    Security
  • 2.1.1

    Version 2.1.1 contains two targeted lexer fixes related to parsing of `__exportStar` patterns. The code changes focus on correcting an off-by-one style cursor advancement around the `r` character, and on ensuring a local variable is declared properly during parsing.

  • 2.1.0

    Release 2.1.0 primarily updates developer/maintainer documentation by adding a section on how to create and publish a GitHub release. The actual diff also refactors the WASM build command in build/Makefile and bumps the package version, but does not show any application/source changes related to the release notes mention of restoring configuration via environment variables.

    Features
  • 2.0.0

    Release 2.0.0 is documented as including CI workflow updates (Ubuntu 22) and enabling/altering the WASM build via a shared wasm-builder. However, the provided code diff only shows version number bumps in package.json and package-lock.json, with no other implementation changes visible.

  • 1.4.2

    Release 1.4.2 updates the project build pipeline. It adds a shared WebAssembly build step and changes the GitHub Actions runner to Ubuntu 22, which primarily affects maintainers and release artifact generation rather than documented runtime APIs.

    Features