Minify multiple files with sourcemap inline
Bug report or Feature request?
The following works with uglify-js (for JS but not ES) but not with terser:
const result = await minify(files, {
sourceMap: {
content: 'inline',
includeSources: true,
filename: `out.js`,
url: `out.js.map`
}
})
see proper file names on the right side
But with terser I get the following output:
Error: inline source map only works with singular input
Version (complete output of terser -V or specific git commit)
5.5.1
Complete CLI command or minify() options used
See here https://github.com/PascalSalesch/minify-error/blob/master/test.js#L6
minify(files, {
sourceMap: {
content: 'inline',
includeSources: true,
filename: `out.js`,
url: `out.js.map`
}
})
terser input
https://github.com/PascalSalesch/minify-error/blob/master/test.js#L6
terser output or error
> node -r esm test.js
/node_modules/terser/dist/bundle.min.js:26240
throw new Error("inline source map only works with singular input");
^
Error: inline source map only works with singular input
at minify (/node_modules/terser/dist/bundle.min.js:26240:27)
at main (/test.js:7:24)
at Object.<anonymous> (/test.js:18:1)
at Generator.next (<anonymous>)
Expected result
To not throw
Hey there!
This should totally be a thing. I also checked out your PR and it looks pretty good.
Source maps are always a tricky thing to change for me. Even after reading the docs in the readme a million times, I always forget how they're supposed to be configured.
It should totally be simplified, probably with an "auto" mode that defines sane defaults, but that's a topic for another time I guess.
@fabiosantoscode @PascalSalesch what happened to this PR? From what I can tell it was never merged and this problem is still present in the latest version of terser.
sourceMap: { content: 'inline' }
is not working for me
okay babel minify worked for me
minify(
fs.readFileSync(path + ".js", "utf8"),
undefined,
{ sourceType: 'module', inputSourceMap: true, sourceMaps: 'inline' }
)
this is still happening for me, any workaround for this issue?
@fabiosantoscode @PascalSalesch what happened to this PR? From what I can tell it was never merged and this problem is still present in the latest version of terser.
Unfortunately I never got around to write tests for it and I didn't want to open a PR where I comment out tests. Feel free to open a PR with the changes from https://github.com/PascalSalesch/terser/pull/1/files
I'm not sure when I'll have time to polish it
Looks like it's easier than I thought! Testing would help but also some feedback on real world use. Source maps are tricky to get right