New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

bare-module-lexer

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bare-module-lexer

Heuristic lexer for detecting imports and exports in JavaScript modules

Source
npmnpm
Version
1.6.5
Version published
Weekly downloads
39K
100.55%
Maintainers
1
Weekly downloads
 
Created
Source

bare-module-lexer

Heuristic lexer for detecting imports and exports in JavaScript modules. It trades off correctness for performance, aiming to reliably support the most common import and export patterns with as little overhead as possible.

Usage

const lex = require('bare-module-lexer')

lex(`
  const foo = require('./foo.js')
  exports.bar = 42
`)

// {
//   imports: [
//     { specifier: './foo.js', type: REQUIRE, names: [], position: [ 15, 24, 32 ] }
//   ],
//   exports: [
//     { name: 'bar', position: [ 37, 45, 48 ] }
//   ]
// }

API

See the bare-module-lexer reference.

License

Apache-2.0

FAQs

Package last updated on 02 Sep 2026

Related posts