You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was writing a function to create Javascript object (anything contained inside { } are to be made part of the object) from string.
Sample code
functionextractObj(str){constmatchStr=str.match(/(\{.*?\})/)?.[1]?.trim();//?/* Quokka reports SyntaxError on the statement above but if the next 2 lines are commented the statement above works fine */constobj=eval(`(() => (${matchStr}))()`);returnobj;}extractObj(`arbitrary text { country: 'Malaysia', city: 'Kuala Lumpur' } arbitrary text`);// the code above works fine in browser
Sample repository link
(N/A)
Quokka.js Console Output
Quokka 'Untitled-2.js' (node: v15.3.0)
.\quokka.js:4
const matchStr = ($_$w(1, 0, $_$c), $_$wv(1, 0, '1,0', $_$c, 'str.match(/(\\{.*?\\})/)?.[1]?.trim()', str.match(/(\{.*?\})/)?.[1]?.trim(), '$_$ne', 0, 0));
^
SyntaxError: Invalid or unexpected token
at new Promise (<anonymous>)
Code editor version
Visual Studio Code v1.53.2
OS name and version
Windows 10
The text was updated successfully, but these errors were encountered:
The issue is not related to Quokka parser, it is an issue in esm package that Quokka is using by default to support ES imports and top level await. You may turn off esm package by specifying:
Issue description or question
I was writing a function to create Javascript object (anything contained inside { } are to be made part of the object) from string.
Sample code
Sample repository link
(N/A)
Quokka.js Console Output
Code editor version
Visual Studio Code v1.53.2
OS name and version
Windows 10
The text was updated successfully, but these errors were encountered: