Produces source maps for built files.
This commit is contained in:
		
							parent
							
								
									c9d3c20e2c
								
							
						
					
					
						commit
						996805f953
					
				
							
								
								
									
										15
									
								
								external/builder/preprocessor2.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								external/builder/preprocessor2.js
									
									
									
									
										vendored
									
									
								
							| @ -347,28 +347,23 @@ function traverseTree(ctx, node) { | ||||
| } | ||||
| 
 | ||||
| function preprocessPDFJSCode(ctx, code) { | ||||
|   var saveComments = !!ctx.saveComments; | ||||
|   var format = ctx.format || { | ||||
|     indent: { | ||||
|       style: ' ', | ||||
|       adjustMultilineComment: saveComments, | ||||
|     } | ||||
|   }; | ||||
|   var comments; | ||||
|   var parseComment = { | ||||
|   var parseOptions = { | ||||
|     locations: true, | ||||
|     onComments: saveComments || (comments = []), | ||||
|     sourceFile: ctx.sourceFile, | ||||
|     sourceType: 'module', | ||||
|   }; | ||||
|   var codegenOptions = { | ||||
|     format: format, | ||||
|     comment: saveComments, | ||||
|     parse: acorn.parse, | ||||
|     sourceMap: ctx.sourceMap, | ||||
|     sourceMapWithCode: ctx.sourceMap, | ||||
|   }; | ||||
|   var syntax = acorn.parse(code, parseComment); | ||||
|   if (saveComments) { | ||||
|     escodegen.attachComments(syntax, comments); | ||||
|   } | ||||
|   var syntax = acorn.parse(code, parseOptions); | ||||
|   traverseTree(ctx, syntax); | ||||
|   return escodegen.generate(syntax, codegenOptions); | ||||
| } | ||||
|  | ||||
							
								
								
									
										19
									
								
								external/webpack/pdfjsdev-loader.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								external/webpack/pdfjsdev-loader.js
									
									
									
									
										vendored
									
									
								
							| @ -17,6 +17,7 @@ | ||||
| 'use strict'; | ||||
| 
 | ||||
| var preprocessor2 = require('../builder/preprocessor2.js'); | ||||
| var path = require('path'); | ||||
| 
 | ||||
| module.exports = function (source) { | ||||
|   // Options must be specified, ignoring request if not.
 | ||||
| @ -24,7 +25,19 @@ module.exports = function (source) { | ||||
|     return source; | ||||
|   } | ||||
|   this.cacheable(); | ||||
|   var ctx = this.query; | ||||
|   source = preprocessor2.preprocessPDFJSCode(ctx, source); | ||||
|   return source; | ||||
| 
 | ||||
|   var filePath = this.resourcePath; | ||||
|   var context = this.options.context; | ||||
|   var sourcePath = path.relative(context, filePath).split(path.sep).join('/'); | ||||
| 
 | ||||
|   var ctx = Object.create(this.query); | ||||
|   ctx.sourceMap = true; | ||||
|   ctx.sourceFile = sourcePath; | ||||
| 
 | ||||
|   var callback = this.callback; | ||||
|   var sourceAndMap = preprocessor2.preprocessPDFJSCode(ctx, source); | ||||
|   var map = sourceAndMap.map.toJSON(); | ||||
|   // escodegen does not embed source -- setting map's sourcesContent.
 | ||||
|   map.sourcesContent = [source]; | ||||
|   callback(null, sourceAndMap.code, map); | ||||
| }; | ||||
|  | ||||
| @ -129,6 +129,8 @@ function createWebpackConfig(defines, output) { | ||||
|     BUNDLE_BUILD: versionInfo.commit | ||||
|   }); | ||||
|   var licenseHeader = fs.readFileSync('./src/license_header.js').toString(); | ||||
|   var enableSourceMaps = !bundleDefines.FIREFOX && !bundleDefines.MOZCENTRAL && | ||||
|                          !bundleDefines.CHROME; | ||||
| 
 | ||||
|   return { | ||||
|     output: output, | ||||
| @ -142,6 +144,7 @@ function createWebpackConfig(defines, output) { | ||||
|         'pdfjs-web': path.join(__dirname, 'web'), | ||||
|       } | ||||
|     }, | ||||
|     devtool: enableSourceMaps ? 'source-map' : undefined, | ||||
|     module: { | ||||
|       loaders: [ | ||||
|         { | ||||
| @ -1329,8 +1332,11 @@ gulp.task('dist-repo-prepare', ['dist-pre'], function () { | ||||
|         .pipe(gulp.dest(DIST_DIR)), | ||||
|     gulp.src([ | ||||
|       GENERIC_DIR + 'build/pdf.js', | ||||
|       GENERIC_DIR + 'build/pdf.js.map', | ||||
|       GENERIC_DIR + 'build/pdf.worker.js', | ||||
|       GENERIC_DIR + 'build/pdf.worker.js.map', | ||||
|       SINGLE_FILE_DIR + 'build/pdf.combined.js', | ||||
|       SINGLE_FILE_DIR + 'build/pdf.combined.js.map', | ||||
|       SRC_DIR + 'pdf.worker.entry.js', | ||||
|     ]).pipe(gulp.dest(DIST_DIR + 'build/')), | ||||
|     gulp.src(MINIFIED_DIR + 'build/pdf.js') | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user