Skip to content

Commit fd1d9cc

Browse files
Merge pull request #12451 from Snuffleupagus/acorn-8
Upgrade `acorn` to version 8
2 parents 7ae3e13 + bc036c0 commit fd1d9cc

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

external/builder/preprocessor2.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var path = require("path");
88

99
var PDFJS_PREPROCESSOR_NAME = "PDFJSDev";
1010
var ROOT_PREFIX = "$ROOT/";
11+
const ACORN_ECMA_VERSION = 2020;
1112

1213
function isLiteral(obj, value) {
1314
return obj.type === "Literal" && obj.value === value;
@@ -49,7 +50,9 @@ function handlePreprocessorAction(ctx, actionName, args, loc) {
4950
return { type: "Literal", value: result, loc: loc };
5051
}
5152
if (typeof result === "object") {
52-
var parsedObj = acorn.parse("(" + JSON.stringify(result) + ")");
53+
const parsedObj = acorn.parse("(" + JSON.stringify(result) + ")", {
54+
ecmaVersion: ACORN_ECMA_VERSION,
55+
});
5356
parsedObj.body[0].expression.loc = loc;
5457
return parsedObj.body[0].expression;
5558
}
@@ -67,7 +70,9 @@ function handlePreprocessorAction(ctx, actionName, args, loc) {
6770
);
6871
}
6972
var jsonContent = fs.readFileSync(jsonPath).toString();
70-
var parsedJSON = acorn.parse("(" + jsonContent + ")");
73+
const parsedJSON = acorn.parse("(" + jsonContent + ")", {
74+
ecmaVersion: ACORN_ECMA_VERSION,
75+
});
7176
parsedJSON.body[0].expression.loc = loc;
7277
return parsedJSON.body[0].expression;
7378
}
@@ -322,14 +327,16 @@ function preprocessPDFJSCode(ctx, code) {
322327
},
323328
};
324329
var parseOptions = {
325-
ecmaVersion: 2020,
330+
ecmaVersion: ACORN_ECMA_VERSION,
326331
locations: true,
327332
sourceFile: ctx.sourceFile,
328333
sourceType: "module",
329334
};
330335
var codegenOptions = {
331336
format: format,
332-
parse: acorn.parse,
337+
parse: function (input) {
338+
return acorn.parse(input, { ecmaVersion: ACORN_ECMA_VERSION });
339+
},
333340
sourceMap: ctx.sourceMap,
334341
sourceMapWithCode: ctx.sourceMap,
335342
};

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@babel/plugin-transform-runtime": "^7.11.5",
1010
"@babel/preset-env": "^7.11.5",
1111
"@babel/runtime": "^7.11.2",
12-
"acorn": "^7.4.0",
12+
"acorn": "^8.0.4",
1313
"autoprefixer": "^10.0.1",
1414
"babel-loader": "^8.1.0",
1515
"canvas": "^2.6.1",

0 commit comments

Comments
 (0)