diff --git a/README.md b/README.md index 65adcf94a4..f9c47a3540 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ source map to `script-compiled.js.map`. Compile the file `script.js` and output it to `script-compiled.js` with a source map embedded in a comment at the bottom. - $ 6to5 script.js --source-maps-comment --out-file script-compiled.js + $ 6to5 script.js --source-maps-inline --out-file script-compiled.js Compile the entire `src` directory and output it to the `lib` directory. @@ -133,7 +133,7 @@ to5.transformFile("filename.js", options, function (err, result) { whitelist: [], // If truthy, adds a `map` property to returned output. - // If set to "comment", the sourceMappingURL directive is added at the bottom + // If set to "inline", a comment with a sourceMappingURL directive is added to the bottom sourceMap: false, // Filename for use in errors etc. diff --git a/bin/6to5 b/bin/6to5 index 095ce1de96..de3da0f239 100755 --- a/bin/6to5 +++ b/bin/6to5 @@ -9,7 +9,7 @@ var to5 = require("../lib/6to5/node"); var fs = require("fs"); var _ = require("lodash"); -commander.option("-t, --source-map-type [type]", "Specify a custom sourcemap type such as `comment`"); +commander.option("-t, --source-maps-inline", "Append sourceMappingURL comment to bottom of code"); commander.option("-s, --source-maps", "Save source map alongside the compiled code when using --out-file and --out-dir flags"); //commander.option("-w, --watch", "Watch, only works with --out-dir"); @@ -58,10 +58,14 @@ var readdirFilter = function (filename) { var mainOpts = { blacklist: commander.blacklist, whitelist: commander.whitelist, - sourceMap: commander.sourceMapType || commander.sourceMaps, + sourceMap: commander.sourceMaps, tolerant: commander.tolerant }; +if (commander.sourceMapsInline) { + mainOpts.sourceMap = "inline"; +} + var data = []; var compile = function (filename) { @@ -81,7 +85,7 @@ if (commander.outDir) { var up = path.normalize(dest + "/.."); mkdirp.sync(up); - if (commander.sourceMaps && !commander.sourceMapType) { + if (commander.sourceMaps) { fs.writeFileSync(dest + ".map", data.map.toJSON()); } diff --git a/lib/6to5/transform.js b/lib/6to5/transform.js index b25c48fb00..4551c97844 100644 --- a/lib/6to5/transform.js +++ b/lib/6to5/transform.js @@ -54,7 +54,7 @@ transform._run = function (code, tree, opts) { var result = util.generate(tree, genOpts); if (opts.sourceMap) { - if (opts.sourceMap === "comment") { + if (opts.sourceMap === "inline") { result.code += "\n" + util.sourceMapToComment(result.map); } diff --git a/package.json b/package.json index 136bb0ad8e..14b5b9ae48 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "6to5", "description": "Turn ES6 code into vanilla ES5 with source maps and no runtime", - "version": "1.2.0", + "version": "1.3.0", "author": "Sebastian McKenzie ", "homepage": "https://github.com/sebmck/6to5", "repository": {