@@ -10,18 +10,24 @@ apploader.init({
1010 DEVICEID : "BANGLEJS2"
1111});*/
1212
13+ var jsparse = ( ( ) => {
14+ var acorn , stage3 ;
15+ try {
16+ acorn = require ( "acorn" ) ;
17+ stage3 = require ( "acorn-stage3" ) ;
18+ } catch ( e ) {
19+ console . log ( "=====================================================" ) ;
20+ console . log ( " ACORN NOT FOUND" ) ;
21+ console . log ( " ---------------" ) ;
22+ console . log ( "" ) ;
23+ console . log ( " This means we won't sanity-check uploaded JSON" ) ;
24+ console . log ( "=====================================================" ) ;
25+ return str => { throw new Error ( "no acorn" ) } ;
26+ }
1327
14- var acorn ;
15- try {
16- acorn = require ( "acorn" ) ;
17- } catch ( e ) {
18- console . log ( "=====================================================" ) ;
19- console . log ( " ACORN NOT FOUND" ) ;
20- console . log ( " ---------------" ) ;
21- console . log ( "" ) ;
22- console . log ( " This means we won't sanity-check uploaded JSON" ) ;
23- console . log ( "=====================================================" ) ;
24- }
28+ var parser = acorn . Parser . extend ( stage3 )
29+ return str => parser . parse ( str , { ecmaVersion : 2020 } ) ;
30+ } ) ( ) ;
2531
2632var BASEDIR = __dirname + "/../" ;
2733var APPSDIR_RELATIVE = "apps/" ;
@@ -399,7 +405,7 @@ apps.forEach((app,appIdx) => {
399405 if ( file . supports && ! Array . isArray ( file . supports ) ) ERROR ( `App ${ app . id } file ${ file . name } supports field is not an array` , { file :metadataFile } ) ;
400406 if ( file . evaluate ) {
401407 try {
402- acorn . parse ( "(" + fileContents + ")" ) ;
408+ jsparse ( "(" + fileContents + ")" ) ;
403409 } catch ( e ) {
404410 console . log ( "=====================================================" ) ;
405411 console . log ( " PARSE OF " + appDir + file . url + " failed." ) ;
@@ -415,7 +421,7 @@ apps.forEach((app,appIdx) => {
415421 // TODO: actual lint?
416422 var ast ;
417423 try {
418- ast = acorn . parse ( fileContents ) ;
424+ ast = jsparse ( fileContents ) ;
419425 } catch ( e ) {
420426 console . log ( "=====================================================" ) ;
421427 console . log ( " PARSE OF " + appDir + file . url + " failed." ) ;
0 commit comments