Skip to content

Commit

Permalink
Merge pull request #12451 from Snuffleupagus/acorn-8
Browse files Browse the repository at this point in the history
Upgrade `acorn` to version 8
  • Loading branch information
timvandermeij authored Oct 6, 2020
2 parents 7ae3e13 + bc036c0 commit fd1d9cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
15 changes: 11 additions & 4 deletions external/builder/preprocessor2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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,
};
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"@babel/runtime": "^7.11.2",
"acorn": "^7.4.0",
"acorn": "^8.0.4",
"autoprefixer": "^10.0.1",
"babel-loader": "^8.1.0",
"canvas": "^2.6.1",
Expand Down

0 comments on commit fd1d9cc

Please sign in to comment.