This tool extracts all import and require statements from JavaScript/TypeScript code:
Supported Import Types:
- ES6 Imports:
import ... from 'path'
- TypeScript Type-only Imports:
import type ... from 'path'
- Dynamic Imports:
import('path')
- CommonJS Requires:
require('path')
- Export From:
export ... from 'path'
Path Categories:
- Package Imports: node_modules packages (e.g., 'react', 'lodash')
- Relative Imports: Local files (e.g., './utils', '../components')
- Absolute Imports: Absolute paths (e.g., '/src/config')
Features:
- Line number tracking for each import
- Deduplication of import paths
- Grouping by import type
- Filtering by package/relative paths
- Support for both JavaScript and TypeScript
Example Usage:
import React from 'react'
import { useState } from 'react'
import type { User } from './types'
import * as lodash from 'lodash'
const utils = require('./utils')
import('./lazyModule').then(module => {})
export { Component } from './Component'
Use Cases:
- Analyze code dependencies
- Find all imported modules
- Identify external dependencies
- Refactor import statements
- Audit code for unused imports