Back to Explore

nodejs/cjs-module-lexer

GitHub
2 updates · last 90 daysOpen 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, with recent upstream activity on 2026-10-06 and an update released on 2026-10-05 (2.3.0).
  • Update cadence is fairly steady recently, about 7 weeks between 2.2.1 (2026-08-13) and 2.3.0 (2026-10-05), and roughly yearly for larger feature work (for example, 2.2.0 on 2026-01-02).

AI summary generated

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

Recent updates

  • 2.3.0

    Release 2.3.0 focuses on improving the CommonJS lexer performance and reliability, mainly around WebAssembly initialization and faster scanning paths. The diff shows changes in both the Wasm/low-level lexer (lexer.wat, lexer.c) and the JS/Wasm wrapper (lexer.js), plus added test coverage for initialization, UTF-16 copying, and nesting depth boundaries.

  • 2.2.1

    Release 2.2.1 is primarily a packaging fix related to missing type definitions. The release notes state that lexer.d.mts was not being published, and the package manifest/outputs were adjusted accordingly.

  • 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