This repository was archived by the owner on Nov 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ function terser(userOptions = {}) {
2828 this . numOfBundles ++ ;
2929
3030 const defaultOptions = {
31- sourceMap : outputOptions . sourcemap ,
31+ sourceMap :
32+ outputOptions . sourcemap === true ||
33+ typeof outputOptions . sourcemap === "string" ,
3234 } ;
3335 if ( outputOptions . format === "es" || outputOptions . format === "esm" ) {
3436 defaultOptions . module = true ;
Original file line number Diff line number Diff line change @@ -128,6 +128,39 @@ test("minify with sourcemaps", async () => {
128128 ` ) ;
129129} ) ;
130130
131+ test ( 'work with sourcemap: "inline"' , async ( ) => {
132+ const bundle = await rollup ( {
133+ input : "test/fixtures/sourcemap.js" ,
134+ plugins : [ terser ( ) ] ,
135+ } ) ;
136+ const result = await bundle . generate ( { format : "cjs" , sourcemap : "inline" } ) ;
137+ expect ( result . output ) . toHaveLength ( 1 ) ;
138+ const [ output ] = result . output ;
139+ expect ( output . map ) . toMatchInlineSnapshot ( `
140+ SourceMap {
141+ "file": "sourcemap.js",
142+ "mappings": "aAEAA,QAAQC,ICFO",
143+ "names": Array [
144+ "console",
145+ "log",
146+ ],
147+ "sources": Array [
148+ "test/fixtures/sourcemap.js",
149+ "test/fixtures/export-number.js",
150+ ],
151+ "sourcesContent": Array [
152+ "import result from './export-number.js';
153+
154+ console.log(result);
155+ ",
156+ "export default 5;
157+ ",
158+ ],
159+ "version": 3,
160+ }
161+ ` ) ;
162+ } ) ;
163+
131164test ( "does not allow to pass sourcemap option" , async ( ) => {
132165 try {
133166 const bundle = await rollup ( {
You can’t perform that action at this time.
0 commit comments