core
core copied to clipboard
tsconfig.json not detecting properly while interop with rust
🐛 Bug Report
While interoping Rust with .tsx the tsconfig.json is not picked up properly and throws this error when ran cargo run:
Exception in load_from_file /home/tamizh/Metacall_React-Actix_Example/target/debug/App.js:6
return (<h1> Hello {text}</h1>);
^
SyntaxError: Unexpected token '<'
Expected Behavior
The app directory looks something like this:

The app/App.tsx looks like this:
import React from 'react';
import { renderToString } from 'react-dom/server';
export function hello(text: string): string {
return renderToString(<h1>Hello {text}</h1>);
}
Its called in Rust like this:
let scripts = ["app/App.tsx".to_string()];
if let Err(e) = metacall::load_from_file("ts", &scripts) {
println!("{}", e);
panic!();
}
When cargo run was ran it should properly parse the tsx and provide the desired result
Current Behavior
Instead when cargo run is ran it throws the above mentioned error and panics like this:
Exception in load_from_file /home/tamizh/Metacall_React-Actix_Example/target/debug/App.js:6
return (<h1> Hello {text}</h1>);
^
SyntaxError: Unexpected token '<'
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1088:15)
at Module._compile (node:internal/modules/cjs/loader:1123:27)
at Object.writeFile (/usr/local/lib/bootstrap.ts:181:15)
at Object.writeFile (/usr/local/lib/node_modules/typescript/lib/typescript.js:17502:14)
at printSourceFileOrBundle (/usr/local/lib/node_modules/typescript/lib/typescript.js:100995:16)
at emitJsFileOrBundle (/usr/local/lib/node_modules/typescript/lib/typescript.js:100873:13)
at emitSourceFileOrBundle (/usr/local/lib/node_modules/typescript/lib/typescript.js:100796:13)
at forEachEmittedFile (/usr/local/lib/node_modules/typescript/lib/typescript.js:100517:34)
at Object.emitFiles (/usr/local/lib/node_modules/typescript/lib/typescript.js:100776:9)
MetaCall failed to load script from file
thread 'main' panicked at 'explicit panic', src/main.rs:37:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
However when I place the contents in app/ in the root directory like this:
It works as expected
Possible Solution
The metacall module should be able to detect the tsconfig.json file inside the specifed paths too