1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Produces source maps for built files.

This commit is contained in:
Yury Delendik 2017-05-03 12:17:18 -05:00
parent c9d3c20e2c
commit 996805f953
3 changed files with 27 additions and 13 deletions

View file

@ -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);
}