{"library":"rs-module-lexer","title":"rs-module-lexer: Rust-powered ES Module Parser","description":"rs-module-lexer is an ES module parser built with Rust, offering a drop-in compatible output data structure with `es-module-lexer`. Currently at version 2.8.0, it maintains an active release cadence with frequent minor updates. Its key differentiator is the ability to directly parse TypeScript (TS/TSX) and JSX files, unlike `es-module-lexer` which necessitates a prior transformation step. Powered by SWC, this library collapses the transform and parse steps into a single API call, streamlining module analysis in bundlers and build tools. It's designed for scenarios requiring fast and accurate identification of imports and exports across various JavaScript and TypeScript syntaxes, providing a consistent API and data format.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install rs-module-lexer"],"cli":null},"imports":["import { parseAsync } from 'rs-module-lexer'","import { parse } from 'rs-module-lexer'","import type { ModuleInfo } from 'rs-module-lexer'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parseAsync } from 'rs-module-lexer';\n\nasync function analyzeCode() {\n  const tsCode = `\n    import { useState, useEffect } from 'react';\n    import { someUtil } from './utils';\n    export const MyComponent = () => {\n      const [count, setCount] = useState(0);\n      useEffect(() => {\n        console.log('Count:', count);\n      }, [count]);\n      return <div>Hello</div>;\n    };\n    export function helper() { /* ... */ }\n  `;\n\n  const { output } = await parseAsync({\n    input: [\n      {\n        filename: 'my-component.tsx',\n        code: tsCode,\n      },\n      {\n        filename: 'another-file.js',\n        code: 'import { foo } from \"bar\";',\n      }\n    ],\n  });\n\n  // Accessing the results for 'my-component.tsx'\n  const myComponentResult = output[0];\n  console.log('Imports for my-component.tsx:', myComponentResult.imports);\n  console.log('Exports for my-component.tsx:', myComponentResult.exports);\n\n  // Accessing the results for 'another-file.js'\n  const anotherFileResult = output[1];\n  console.log('Imports for another-file.js:', anotherFileResult.imports);\n}\n\nanalyzeCode().catch(console.error);","lang":"typescript","description":"Demonstrates parsing multiple TypeScript and JavaScript files asynchronously, showcasing import and export extraction.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}