Aliu
Aliu

Reputation: 99

Combine javascript files and their source maps

I am struggling with the combination of multiple javascript files and their source maps.

The problem is: I use Google Closure Compiler to obfuscate two javascript files A and B, with generated source maps A.map and B.map. Since I apply different compilation options on them, so compiling A and B into a single file does not work for me. Now, I want to combine A and B to AB, and also combine A.map and B.map into AB.map.

How should I do this? Any existing tools suitable for this purpose?

Upvotes: 0

Views: 1860

Answers (2)

D.H.Lolo
D.H.Lolo

Reputation: 115

try remapping, @babel/core use it for transform inputSourceMap

Upvotes: 0

BhavO
BhavO

Reputation: 2399

There are a number of packages out there that will do the job for example with the grunt-concat-sourcemap package for node you can do the following:

grunt.initConfig({
  concat_sourcemap: {
    options: {},
    target: {
      files: {
        'dest/out.js': ['src/a.js', 'src/b.js']
      }
    }
  }
})

this will concatenate the two specified source files(in order), and write the output to dest/out.js and dest/out.js.map

here are some links to packages for grunt, gulp and plain node:

https://www.npmjs.com/package/grunt-concat-sourcemap

https://github.com/mikach/gulp-concat-sourcemap

https://www.npmjs.com/package/source-map-concat

Upvotes: 0

Related Questions