@@ -8,6 +8,7 @@ var path = require("path");
8
8
9
9
var PDFJS_PREPROCESSOR_NAME = "PDFJSDev" ;
10
10
var ROOT_PREFIX = "$ROOT/" ;
11
+ const ACORN_ECMA_VERSION = 2020 ;
11
12
12
13
function isLiteral ( obj , value ) {
13
14
return obj . type === "Literal" && obj . value === value ;
@@ -49,7 +50,9 @@ function handlePreprocessorAction(ctx, actionName, args, loc) {
49
50
return { type : "Literal" , value : result , loc : loc } ;
50
51
}
51
52
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
+ } ) ;
53
56
parsedObj . body [ 0 ] . expression . loc = loc ;
54
57
return parsedObj . body [ 0 ] . expression ;
55
58
}
@@ -67,7 +70,9 @@ function handlePreprocessorAction(ctx, actionName, args, loc) {
67
70
) ;
68
71
}
69
72
var jsonContent = fs . readFileSync ( jsonPath ) . toString ( ) ;
70
- var parsedJSON = acorn . parse ( "(" + jsonContent + ")" ) ;
73
+ const parsedJSON = acorn . parse ( "(" + jsonContent + ")" , {
74
+ ecmaVersion : ACORN_ECMA_VERSION ,
75
+ } ) ;
71
76
parsedJSON . body [ 0 ] . expression . loc = loc ;
72
77
return parsedJSON . body [ 0 ] . expression ;
73
78
}
@@ -322,14 +327,16 @@ function preprocessPDFJSCode(ctx, code) {
322
327
} ,
323
328
} ;
324
329
var parseOptions = {
325
- ecmaVersion : 2020 ,
330
+ ecmaVersion : ACORN_ECMA_VERSION ,
326
331
locations : true ,
327
332
sourceFile : ctx . sourceFile ,
328
333
sourceType : "module" ,
329
334
} ;
330
335
var codegenOptions = {
331
336
format : format ,
332
- parse : acorn . parse ,
337
+ parse : function ( input ) {
338
+ return acorn . parse ( input , { ecmaVersion : ACORN_ECMA_VERSION } ) ;
339
+ } ,
333
340
sourceMap : ctx . sourceMap ,
334
341
sourceMapWithCode : ctx . sourceMap ,
335
342
} ;
0 commit comments