Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@parcel/source-map

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parcel/source-map

A source map library purpose-build for the Parcel bundler with a focus on fast combining and manipulating of source-maps.

  • 2.0.0-alpha.4.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
459K
decreased by-5.85%
Maintainers
1
Weekly downloads
 
Created

What is @parcel/source-map?

@parcel/source-map is a library for working with source maps, which are files that map from the transformed source code back to the original source code. This is useful for debugging and understanding the transformations applied to the code.

What are @parcel/source-map's main functionalities?

Creating a Source Map

This feature allows you to create a new source map and add mappings to it using VLQ (Variable Length Quantity) encoding.

const { SourceMap } = require('@parcel/source-map');
const map = new SourceMap();
map.addVLQMap({
  version: 3,
  file: 'out.js',
  sources: ['foo.js', 'bar.js'],
  names: ['src', 'maps', 'are', 'fun'],
  mappings: 'AA,AB;;ABCDE;' // VLQ encoded mappings
});
console.log(map.toBuffer());

Adding a Mapping

This feature allows you to add individual mappings to the source map, specifying the generated and original positions, the source file, and an optional name.

const { SourceMap } = require('@parcel/source-map');
const map = new SourceMap();
map.addMapping({
  generated: { line: 1, column: 5 },
  original: { line: 2, column: 10 },
  source: 'source.js',
  name: 'myFunction'
});
console.log(map.toBuffer());

Loading an Existing Source Map

This feature allows you to load an existing source map into the SourceMap object, enabling further manipulation or inspection.

const { SourceMap } = require('@parcel/source-map');
const existingMap = {
  version: 3,
  file: 'out.js',
  sources: ['foo.js', 'bar.js'],
  names: ['src', 'maps', 'are', 'fun'],
  mappings: 'AA,AB;;ABCDE;'
};
const map = new SourceMap();
map.addVLQMap(existingMap);
console.log(map.toBuffer());

Generating Source Map Buffer

This feature allows you to generate a buffer representation of the source map, which can be written to a file or used in other ways.

const { SourceMap } = require('@parcel/source-map');
const map = new SourceMap();
map.addMapping({
  generated: { line: 1, column: 5 },
  original: { line: 2, column: 10 },
  source: 'source.js',
  name: 'myFunction'
});
const buffer = map.toBuffer();
console.log(buffer);

Other packages similar to @parcel/source-map

FAQs

Package last updated on 11 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc