fast-source-map icon indicating copy to clipboard operation
fast-source-map copied to clipboard

bin/{encode,decode}-source-map don't support inline sourcemaps (data URI)

Open hjdivad opened this issue 9 years ago • 4 comments

but they should

hjdivad avatar Nov 22 '16 22:11 hjdivad

> let s = 'eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJmaXJzdCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiZmlyc3QtY29udGVudCIsICJleHRyYS1jb250ZW50Il19'
undefined
> s
'eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJmaXJzdCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiZmlyc3QtY29udGVudCIsICJleHRyYS1jb250ZW50Il19'
> Buffer
{ [Function: Buffer]
  poolSize: 8192,
  from: [Function],
  alloc: [Function],
  allocUnsafe: [Function],
  allocUnsafeSlow: [Function],
  isBuffer: [Function: isBuffer],
  compare: [Function: compare],
  isEncoding: [Function],
  concat: [Function],
  byteLength: [Function: byteLength] }
> buf = new Buffer(s, 'base64')
<Buffer 7b 22 76 65 72 73 69 6f 6e 22 3a 33 2c 22 66 69 6c 65 22 3a 22 74 79 70 65 73 2e 6a 73 22 2c 22 73 6f 75 72 63 65 52 6f 6f 74 22 3a 22 22 2c 22 73 6f ... >
> buf+''
'{"version":3,"file":"types.js","sourceRoot":"","sources":["first"],"names":[],"mappings":"","sourcesContent":["first-content", "extra-content"]}'
> console.log(buf+'')
{"version":3,"file":"types.js","sourceRoot":"","sources":["first"],"names":[],"mappings":"","sourcesContent":["first-content", "extra-content"]}

hjdivad avatar Nov 22 '16 22:11 hjdivad

we should also support easy transformation between inline and external sourcemaps.

hjdivad avatar Nov 23 '16 17:11 hjdivad

@hjdivad is the idea that it would be a command line switch?

krisselden avatar Nov 25 '16 23:11 krisselden

@krisselden if necessary, but it would be nice to autodetect. We already read the entire file into memory before processing, so we should be able to just check the last (couple?) lines for a sourceMappingURL=data:application/json;base64, comment.

hjdivad avatar Nov 29 '16 16:11 hjdivad