A Node.js command-line tool to extract source files from JavaScript source maps.
npm install -g sourcemap-extractornpm install sourcemap-extractor# Basic usage
sourcemap-extractor https://example.com/app.js.map
# Specify output file
sourcemap-extractor -o my-sources.zip https://example.com/app.js.map
# Interactive mode (prompts for URL)
sourcemap-extractor-o, --output <path>- Specify output ZIP file path (default:extracted_sources.zip)-h, --help- Show help message-v, --version- Show version
const{ extractSourceMap }=require('sourcemap-extractor');asyncfunctionmain(){awaitextractSourceMap('https://example.com/app.js.map','output.zip');}- 🗂️ Preserves folder structure - Creates proper directory hierarchy in the ZIP file
- 📦 Handles multiple source types - Works with webpack, rollup, vite, and other bundlers
- 🔍 Detects package.json - Automatically identifies and reports package.json files
- 🌐 Fetches missing sources - Attempts to download source files not embedded in the map
- 🛡️ Error handling - Gracefully handles missing or inaccessible files
- ⚡ Fast extraction - Efficiently processes large source maps
sourcemap-extractor https://app.example.com/static/js/main.abc123.js.mapsourcemap-extractor -o ./extracted/sources.zip https://example.com/bundle.js.mapconst{ extractSourceMap }=require('sourcemap-extractor');(async()=>{try{awaitextractSourceMap('https://example.com/app.js.map','extracted-sources.zip');console.log('Extraction completed!');}catch(error){console.error('Extraction failed:',error);}})();The tool preserves the original folder structure:
extracted_sources.zip/
├── src/
│ ├── components/
│ │ ├── Button.js
│ │ └── Modal.js
│ ├── utils/
│ │ └── helpers.js
│ └── index.js
├── node_modules/
│ └── some-package/
│ └── index.js
└── package.json
The tool intelligently handles various path formats:
webpack://./src/file.js→src/file.js./utils/helper.js→utils/helper.js../shared/constants.js→parent/shared/constants.js- Illegal filesystem characters are replaced with underscores
- Node.js 12.0.0 or higher
- Internet connection (for fetching source maps and missing files)
MIT
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request