Socket
Socket
Sign inDemoInstall

sorcery

Package Overview
Dependencies
2
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

sorcery


Version published
Maintainers
1
Install size
310 kB
Created

Package description

What is sorcery?

The 'sorcery' npm package is used for working with source maps. It allows you to resolve, manipulate, and generate source maps, which are crucial for debugging minified JavaScript code.

What are sorcery's main functionalities?

Resolve Source Maps

This feature allows you to resolve the source maps for a given file. The code sample demonstrates how to load a file and resolve its source maps, then write the resolved source maps back to the file.

const sorcery = require('sorcery');
sorcery.load('path/to/your/file.js').then(function (chain) {
  chain.write();
});

Generate Source Maps

This feature allows you to generate new source maps for a given file. The code sample shows how to load a file, generate source maps with the content included, and write the new source maps back to the file.

const sorcery = require('sorcery');
sorcery.load('path/to/your/file.js').then(function (chain) {
  chain.apply({ includeContent: true }).write();
});

Manipulate Source Maps

This feature allows you to manipulate existing source maps. The code sample demonstrates how to load a file, apply changes to its source maps, and write the manipulated source maps to a new destination file.

const sorcery = require('sorcery');
sorcery.load('path/to/your/file.js').then(function (chain) {
  chain.apply({ includeContent: true });
  chain.write({ dest: 'path/to/output/file.js' });
});

Other packages similar to sorcery

Changelog

Source

0.1.0

  • First release. Here be dragons.

Readme

Source

sorcery.js

Sourcemaps are great - if you have a JavaScript file, and you minify it, your minifier can generate a mapping back that lets you debug as though you were looking at the original uncompressed code.

But if you have more than one transformation - say you want to transpile your JavaScript, concatenate several files into one, and minify the result - it gets a little trickier. Each intermediate step needs to be able to both ingest a sourcemap and generate one, all the time pointing back to the original source.

Most compilers don't do that. (UglifyJS is an honourable exception.) So when you fire up devtools, instead of looking at the original source you find yourself looking at the final intermediate step in the chain of transformations.

Sorcery aims to fix that. Given an file at the end of a transformation chain (e.g., your minified JavaScript), it will follow the entire chain back to the original source, and generate a new sourcemap that describes the whole process. How? Magic.

This is a work-in-progress - suitable for playing around with, but don't rely on it to debug air traffic control software or medical equipment. Other than that, it can't do much harm.

Installation

npm install sorcery

Usage

API still in flux, lots of work to do... instructions coming soon! Try cloning this repo and looking inside the test folder to get started.

License

MIT

FAQs

Last updated on 01 Oct 2014

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc