This repository was archived by the owner on Nov 30, 2023. It is now read-only.
File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ function terser(userOptions = {}) {
28
28
this . numOfBundles ++ ;
29
29
30
30
const defaultOptions = {
31
- sourceMap : outputOptions . sourcemap ,
31
+ sourceMap :
32
+ outputOptions . sourcemap === true ||
33
+ typeof outputOptions . sourcemap === "string" ,
32
34
} ;
33
35
if ( outputOptions . format === "es" || outputOptions . format === "esm" ) {
34
36
defaultOptions . module = true ;
Original file line number Diff line number Diff line change @@ -128,6 +128,39 @@ test("minify with sourcemaps", async () => {
128
128
` ) ;
129
129
} ) ;
130
130
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
+
131
164
test ( "does not allow to pass sourcemap option" , async ( ) => {
132
165
try {
133
166
const bundle = await rollup ( {
You can’t perform that action at this time.
0 commit comments