Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Support sourcemap enum
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed May 23, 2020
1 parent 49712e5 commit 63e6737
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rollup-plugin-terser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function terser(userOptions = {}) {
this.numOfBundles++;

const defaultOptions = {
sourceMap: outputOptions.sourcemap,
sourceMap:
outputOptions.sourcemap === true ||
typeof outputOptions.sourcemap === "string",
};
if (outputOptions.format === "es" || outputOptions.format === "esm") {
defaultOptions.module = true;
Expand Down
33 changes: 33 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,39 @@ test("minify with sourcemaps", async () => {
`);
});

test('work with sourcemap: "inline"', async () => {
const bundle = await rollup({
input: "test/fixtures/sourcemap.js",
plugins: [terser()],
});
const result = await bundle.generate({ format: "cjs", sourcemap: "inline" });
expect(result.output).toHaveLength(1);
const [output] = result.output;
expect(output.map).toMatchInlineSnapshot(`
SourceMap {
"file": "sourcemap.js",
"mappings": "aAEAA,QAAQC,ICFO",
"names": Array [
"console",
"log",
],
"sources": Array [
"test/fixtures/sourcemap.js",
"test/fixtures/export-number.js",
],
"sourcesContent": Array [
"import result from './export-number.js';
console.log(result);
",
"export default 5;
",
],
"version": 3,
}
`);
});

test("does not allow to pass sourcemap option", async () => {
try {
const bundle = await rollup({
Expand Down

0 comments on commit 63e6737

Please sign in to comment.