mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Upgrade acorn
to version 8
I've run `gulp mozcentral`, `gulp generic`, and `gulp generic-es5` with `master` respectively this patch and then diffed the build output. With the (obvious) exception of increased version/build numbers, there were no actual changes from the updated Acorn version.
This commit is contained in:
parent
7ae3e13f16
commit
bc036c05bd
3 changed files with 15 additions and 8 deletions
15
external/builder/preprocessor2.js
vendored
15
external/builder/preprocessor2.js
vendored
|
@ -8,6 +8,7 @@ var path = require("path");
|
|||
|
||||
var PDFJS_PREPROCESSOR_NAME = "PDFJSDev";
|
||||
var ROOT_PREFIX = "$ROOT/";
|
||||
const ACORN_ECMA_VERSION = 2020;
|
||||
|
||||
function isLiteral(obj, value) {
|
||||
return obj.type === "Literal" && obj.value === value;
|
||||
|
@ -49,7 +50,9 @@ function handlePreprocessorAction(ctx, actionName, args, loc) {
|
|||
return { type: "Literal", value: result, loc: loc };
|
||||
}
|
||||
if (typeof result === "object") {
|
||||
var parsedObj = acorn.parse("(" + JSON.stringify(result) + ")");
|
||||
const parsedObj = acorn.parse("(" + JSON.stringify(result) + ")", {
|
||||
ecmaVersion: ACORN_ECMA_VERSION,
|
||||
});
|
||||
parsedObj.body[0].expression.loc = loc;
|
||||
return parsedObj.body[0].expression;
|
||||
}
|
||||
|
@ -67,7 +70,9 @@ function handlePreprocessorAction(ctx, actionName, args, loc) {
|
|||
);
|
||||
}
|
||||
var jsonContent = fs.readFileSync(jsonPath).toString();
|
||||
var parsedJSON = acorn.parse("(" + jsonContent + ")");
|
||||
const parsedJSON = acorn.parse("(" + jsonContent + ")", {
|
||||
ecmaVersion: ACORN_ECMA_VERSION,
|
||||
});
|
||||
parsedJSON.body[0].expression.loc = loc;
|
||||
return parsedJSON.body[0].expression;
|
||||
}
|
||||
|
@ -322,14 +327,16 @@ function preprocessPDFJSCode(ctx, code) {
|
|||
},
|
||||
};
|
||||
var parseOptions = {
|
||||
ecmaVersion: 2020,
|
||||
ecmaVersion: ACORN_ECMA_VERSION,
|
||||
locations: true,
|
||||
sourceFile: ctx.sourceFile,
|
||||
sourceType: "module",
|
||||
};
|
||||
var codegenOptions = {
|
||||
format: format,
|
||||
parse: acorn.parse,
|
||||
parse: function (input) {
|
||||
return acorn.parse(input, { ecmaVersion: ACORN_ECMA_VERSION });
|
||||
},
|
||||
sourceMap: ctx.sourceMap,
|
||||
sourceMapWithCode: ctx.sourceMap,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue