When a JavaScript is UTF-8 encoded with a BOM (Byte Order Marker), the acorn parser in 'jsrewriter.js' throws an exception.
The exception is
'acorn parsing failed on: const globalConst = "const"; let globalLet = "let"; let globalLetChanged = "x"; ...'
A possible solution is to remove this BOM from the text variable.
parseLetConstGlobals(text) {
const res = acorn.parse(this.removeBOM(text), {ecmaVersion: "latest"});
^^^^^^^^^^^^
Just for illustration, I have made a removeBOM function which does nothing more than replace '' with an empty string.
function removeBOM(text) {
return text.replace(/^\uFEFF/g, "").replace(/^\u00EF?\u00BB\u00BF/g,"");
}
test = "\uFEFFThis is a test"
removeBOM(test) === "This is a test"
`
Without parsing javascript with utf-8 BOM your global let and const variables missing the self. addition which is done in the parseLetConstGlobals function of wabac
When a JavaScript is UTF-8 encoded with a BOM (Byte Order Marker), the acorn parser in 'jsrewriter.js' throws an exception.
The exception is
'acorn parsing failed on: const globalConst = "const"; let globalLet = "let"; let globalLetChanged = "x"; ...'
A possible solution is to remove this BOM from the text variable.
Just for illustration, I have made a removeBOM function which does nothing more than replace '' with an empty string.
`
Without parsing javascript with utf-8 BOM your global let and const variables missing the self. addition which is done in the parseLetConstGlobals function of wabac