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

bare-module-lexer

Package Overview
Dependencies
Maintainers
1
Versions
32
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

latest
Source
npmnpm
Version
1.6.6
Version published
Weekly downloads
19K
-46.69%
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.

Threat model

bare-module-lexer is one of the addons Bare compiles into its binary, so it inherits Bare's threat model. See docs/threat-model.md for where this addon sits in it.

License

Apache-2.0

FAQs

Package last updated on 03 Sep 2026

Related posts