{"_id":"textio-sorcery","_rev":"104-0359acb8c404cd54292987cf70450e13","name":"textio-sorcery","dist-tags":{"latest":"0.11.0"},"versions":{"0.11.0":{"name":"textio-sorcery","version":"0.11.0","author":{"name":"Rich Harris"},"license":"MIT","_id":"textio-sorcery@0.11.0","maintainers":[{"name":"textio","email":"admin@textio.com"}],"homepage":"https://github.com/textioHQ/sorcery#readme","bugs":{"url":"https://github.com/textioHQ/sorcery/issues"},"bin":{"sorcery":"bin/sorcery"},"dist":{"shasum":"5d8dfa79758b7445b07cb8591332ac41d4698021","tarball":"https://registry.npmjs.org/textio-sorcery/-/textio-sorcery-0.11.0.tgz","integrity":"sha512-9ZMfCRpSlTF78+pbmkzPZO1NtdrwLN39fDeUItg8/rd3CxDyTyCDB7NecVfzVDwUNXN64puXLDvBigLz+t7x+A==","signatures":[{"sig":"MEUCIQD19FYDJdhOwD5Qip16QjjhVYPFe63I1oPMwnNE0vc5QgIgB8bWfcJeTcIBSfr+LAzvMhB93TB13GMPgTGaQWIZWIA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"dist/sorcery.cjs.js","_from":".","files":["src/","dist/","bin/","README.md"],"_shasum":"5d8dfa79758b7445b07cb8591332ac41d4698021","gitHead":"002d4ddad09f682aa2ec2a8ce096a5867d4f2274","scripts":{"ci":"npm run test-coverage && codecov < coverage/coverage-remapped.lcov","lint":"eslint src","test":"mocha --compilers js:buble/register","build":"rm -rf dist && rollup -c -f cjs -o dist/sorcery.cjs.js && rollup -c -f es6 -o dist/sorcery.es6.js","pretest":"npm run build","prepublish":"npm test","prepare-tests":"node test/samples/prepare-tests.js","test-coverage":"rm -rf coverage/* && istanbul cover --report json node_modules/.bin/_mocha -- -u exports -R spec test/test.js","pretest-coverage":"npm run build","posttest-coverage":"remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.json -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.lcov -t lcovonly -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped -t html -b dist"},"_npmUser":{"name":"textio","email":"admin@textio.com"},"repository":{"url":"git+https://github.com/textioHQ/sorcery.git","type":"git"},"_npmVersion":"3.10.3","description":"Resolve a chain of sourcemaps back to the original source","directories":{},"jsnext:main":"dist/sorcery.es6.js","_nodeVersion":"6.3.1","dependencies":{"sander":"^0.5.0","minimist":"^1.2.0","buffer-crc32":"^0.2.5","sourcemap-codec":"^1.3.0"},"devDependencies":{"glob":"^7.0.3","less":"^2.6.1","buble":"^0.10.4","mocha":"^2.4.5","eslint":"^2.8.0","rollup":"^0.31.0","istanbul":"^0.4.3","uglify-js":"^2.6.2","codecov.io":"^0.1.6","source-map":"^0.5.3","coffee-script":"^1.10.0","remap-istanbul":"^0.6.3","rollup-plugin-npm":"^1.4.0","promise-map-series":"^0.2.2","source-map-support":"^0.4.0","rollup-plugin-buble":"^0.10.0","rollup-plugin-commonjs":"^2.2.1"},"_npmOperationalInternal":{"tmp":"tmp/textio-sorcery-0.11.0.tgz_1472525057766_0.048824352910742164","host":"packages-16-east.internal.npmjs.com"}}},"time":{"created":"2016-08-30T02:44:20.056Z","modified":"2026-07-02T17:22:08.920Z","0.11.0":"2016-08-30T02:44:20.056Z"},"bugs":{"url":"https://github.com/textioHQ/sorcery/issues"},"author":{"name":"Rich Harris"},"license":"MIT","homepage":"https://github.com/textioHQ/sorcery#readme","repository":{"url":"git+https://github.com/textioHQ/sorcery.git","type":"git"},"description":"Resolve a chain of sourcemaps back to the original source","maintainers":[{"email":"admin@textio.com","name":"textio-circle"},{"email":"jensen@textio.com","name":"jensen_textio"},{"email":"bobby@textio.com","name":"bobby_textio"},{"email":"olivia@textio.com","name":"oliviagunton"},{"email":"mattie@textio.com","name":"mattiejean"},{"email":"brad@textio.com","name":"brad2"},{"email":"gregory@textio.com","name":"textio-greg"},{"email":"colin@textio.com","name":"colinjeanne-textio"}],"readme":"# sorcery.js\n\nSourcemaps are great - if you have a JavaScript file, and you minify it, your minifier can generate a map that lets you debug as though you were looking at the original uncompressed code.\n\nBut 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.\n\nMost compilers don't do that. ([UglifyJS](https://github.com/mishoo/UglifyJS2) 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.\n\n**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.\n\nThis 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.\n\n\n## Usage\n\n### As a node module\n\nInstall sorcery locally:\n\n```bash\nnpm install sorcery\n```\n\n```js\nvar sorcery = require( 'sorcery' );\n\nsorcery.load( 'some/generated/code.min.js' ).then( function ( chain ) {\n  // generate a flattened sourcemap\n  var map = chain.apply(); // { version: 3, file: 'code.min.js', ... }\n\n  // get a JSON representation of the sourcemap\n  map.toString(); // '{\"version\":3,\"file\":\"code.min.js\",...}'\n\n  // get a data URI representation\n  map.toUrl(); // 'data:application/json;charset=utf-8;base64,eyJ2ZXJ...'\n\n  // write to a new file - this will create `output.js` and\n  // `output.js.map`, and will preserve relative paths. It\n  // returns a Promise\n  chain.write( 'output.js' );\n\n  // write to a new file but use an absolute path for the\n  // sourceMappingURL\n  chain.write( 'output.js', { absolutePath: true });\n\n  // write to a new file, but append the flattened sourcemap as a data URI\n  chain.write( 'output.js', { inline: true });\n\n  // overwrite the existing file\n  chain.write();\n  chain.write({ inline: true });\n\n  // find the origin of line x, column y. Returns an object with\n  // `source`, `line`, `column` and (if applicable) `name` properties.\n  // Note - for consistency with other tools, line numbers are always\n  // one-based, column numbers are always zero-based. It's daft, I know.\n  var loc = chain.trace( x, y );\n});\n\n// You can also use sorcery synchronously:\nvar chain = sorcery.loadSync( 'some/generated/code.min.js' );\nvar map = chain.apply();\nvar loc = chain.trace( x, y );\nchain.writeSync();\n```\n\n#### Advanced options\n\nYou can pass an optional second argument to `sorcery.load()` and `sorcery.loadSync()`, with zero or more of the following properties:\n\n* `content` - a map of `filename: contents` pairs. `filename` will be resolved against the current working directory if needs be\n* `sourcemaps` - a map of `filename: sourcemap` pairs, where `filename` is the name of the file the sourcemap is related to. This will override any `sourceMappingURL` comments in the file itself.\n\nFor example:\n\n```js\nsorcery.load( 'some/generated/code.min.js', {\n  content: {\n    'some/minified/code.min.js': '...',\n    'some/transpiled/code.js': '...',\n    'some/original/code.js': '...'\n  },\n  sourcemaps: {\n    'some/minified/code.min.js': {...},\n    'some/transpiled/code.js': {...}\n  }\n}).then( chain => {\n  /* ... */\n});\n```\n\nAny files not found will be read from the filesystem as normal.\n\n### On the command line\n\nFirst, install sorcery globally:\n\n```bash\nnpm install -g sorcery\n```\n\n```\nUsage:\n  sorcery [options]\n\nOptions:\n  -h, --help               Show help message\n  -v, --version            Show version\n  -i, --input <file>       Input file\n  -o, --output <file>      Output file (if absent, will overwrite input)\n  -d, --datauri            Append map as a data URI, rather than separate file\n  -x, --excludeContent     Don't populate the sourcesContent array\n```\n\nExamples:\n\n```bash\n# overwrite sourcemap in place (will write map to\n# some/generated/code.min.js.map, and update\n# sourceMappingURL comment if necessary\nsorcery -i some/generated/code.min.js\n\n# append flattened sourcemap as an inline data URI\n# (will delete existing .map file, if applicable)\nsorcery -d -i some/generated/code.min.js\n\n# write to a new file (will create newfile.js and\n# newfile.js.map)\nsorcery -i some/generated/code.min.js -o newfile.js\n```\n\n\n## License\n\nMIT\n","readmeFilename":"README.md"}