olova 2.0.71 → 2.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/compiler.js CHANGED
@@ -1026,14 +1026,20 @@ function collectScriptInfo(script) {
1026
1026
  return false;
1027
1027
  }
1028
1028
  let found = false;
1029
- traverse(parseModule(`(${generate2(node).code})`), {
1030
- JSXElement() {
1031
- found = true;
1032
- },
1033
- JSXFragment() {
1034
- found = true;
1035
- }
1036
- });
1029
+ try {
1030
+ const generated = generate2(node).code;
1031
+ const code = t.isBlockStatement(node) ? `(() => ${generated})` : `(${generated})`;
1032
+ traverse(parseModule(code), {
1033
+ JSXElement() {
1034
+ found = true;
1035
+ },
1036
+ JSXFragment() {
1037
+ found = true;
1038
+ }
1039
+ });
1040
+ } catch {
1041
+ found = false;
1042
+ }
1037
1043
  return found;
1038
1044
  };
1039
1045
  traverse(ast, {