gulp-community / gulp-terser-js

A Terser-js plugin for Gulp
MIT License
12 stars 4 forks source link

sourcemap is incorrect when processing multiple files with existing sourcemaps #36

Open youngderekm opened 2 years ago

youngderekm commented 2 years ago

I have a collection of js files that were compiled from Typescript. I want to minify these with terser. They have existing sourcemaps. When I do this, some of the sourcemaps produced look incorrect. They have the wrong "sources" listed. It looks like they have the sources of the first file processed.

From my quick read of the code, it looks like options.sourceMap is modified and then passed into terser.

opts.sourceMap.filename = file.sourceMap.file
// ...
opts.sourceMap.content = file.sourceMap

Maybe opts.sourceMap should be clone from the original options each time?