Comparing version 1.2.4 to 1.2.5
{ | ||
"name": "flast", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "Flatten JS AST", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -57,3 +57,8 @@ // noinspection JSUnusedGlobalSymbols | ||
const parseOpts = opts.parseOpts || {}; | ||
const rootNode = parseCode(inputCode, parseOpts); | ||
let rootNode; | ||
try { | ||
rootNode = parseCode(inputCode, parseOpts); | ||
} catch (e) { | ||
if (e.message.includes('in strict mode')) rootNode = parseCode(inputCode, {...parseOpts, sourceType: 'script'}); | ||
} | ||
let scopeManager; | ||
@@ -60,0 +65,0 @@ try { |
@@ -89,2 +89,19 @@ const assert = require('node:assert'); | ||
}, | ||
{ | ||
enabled: true, | ||
name: 'Dynamic sourceType switching', | ||
description: `Verify a script is parsed in "sloppy mode" if strict mode is restricting parsing.`, | ||
run() { | ||
const code = `let a; delete a;`; | ||
let ast = []; | ||
let error = ''; | ||
try { | ||
ast = generateFlatAST(code); | ||
} catch (e) { | ||
error = e.message; | ||
} | ||
assert(ast.length, | ||
`Script was not parsed. Got the error "${error}"`); | ||
}, | ||
}, | ||
]; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37121
628