Merge pull request #12210 from Snuffleupagus/minified-keep-names
Keep the original class/function names when minifying code (issue 12209)
This commit is contained in:
		
						commit
						9be177d2de
					
				
							
								
								
									
										24
									
								
								gulpfile.js
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								gulpfile.js
									
									
									
									
									
								
							| @ -909,18 +909,30 @@ function parseMinified(dir) { | |||||||
|   console.log("### Minifying js files"); |   console.log("### Minifying js files"); | ||||||
| 
 | 
 | ||||||
|   var Terser = require("terser"); |   var Terser = require("terser"); | ||||||
|   // V8 chokes on very long sequences. Works around that.
 |   var options = { | ||||||
|   var optsForHugeFile = { compress: { sequences: false } }; |     compress: { | ||||||
|  |       // V8 chokes on very long sequences, work around that.
 | ||||||
|  |       sequences: false, | ||||||
|  |     }, | ||||||
|  |     keep_classnames: true, | ||||||
|  |     keep_fnames: true, | ||||||
|  |   }; | ||||||
| 
 | 
 | ||||||
|   fs.writeFileSync(dir + "/web/pdf.viewer.js", Terser.minify(viewerFiles).code); |   fs.writeFileSync( | ||||||
|   fs.writeFileSync(dir + "/build/pdf.min.js", Terser.minify(pdfFile).code); |     dir + "/web/pdf.viewer.js", | ||||||
|  |     Terser.minify(viewerFiles, options).code | ||||||
|  |   ); | ||||||
|  |   fs.writeFileSync( | ||||||
|  |     dir + "/build/pdf.min.js", | ||||||
|  |     Terser.minify(pdfFile, options).code | ||||||
|  |   ); | ||||||
|   fs.writeFileSync( |   fs.writeFileSync( | ||||||
|     dir + "/build/pdf.worker.min.js", |     dir + "/build/pdf.worker.min.js", | ||||||
|     Terser.minify(pdfWorkerFile, optsForHugeFile).code |     Terser.minify(pdfWorkerFile, options).code | ||||||
|   ); |   ); | ||||||
|   fs.writeFileSync( |   fs.writeFileSync( | ||||||
|     dir + "image_decoders/pdf.image_decoders.min.js", |     dir + "image_decoders/pdf.image_decoders.min.js", | ||||||
|     Terser.minify(pdfImageDecodersFile).code |     Terser.minify(pdfImageDecodersFile, options).code | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
|   console.log(); |   console.log(); | ||||||
|  | |||||||
| @ -2271,11 +2271,16 @@ class WorkerTransport { | |||||||
|           reason = new UnknownErrorException(ex.message, ex.details); |           reason = new UnknownErrorException(ex.message, ex.details); | ||||||
|           break; |           break; | ||||||
|       } |       } | ||||||
|  |       if (!(reason instanceof Error)) { | ||||||
|  |         const msg = "DocException - expected a valid Error."; | ||||||
|         if ( |         if ( | ||||||
|           typeof PDFJSDev === "undefined" || |           typeof PDFJSDev === "undefined" || | ||||||
|           PDFJSDev.test("!PRODUCTION || TESTING") |           PDFJSDev.test("!PRODUCTION || TESTING") | ||||||
|         ) { |         ) { | ||||||
|         assert(reason instanceof Error, "DocException: expected an Error."); |           unreachable(msg); | ||||||
|  |         } else { | ||||||
|  |           warn(msg); | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|       loadingTask._capability.reject(reason); |       loadingTask._capability.reject(reason); | ||||||
|     }); |     }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user