release: WRNexusJS 0.2.49
This commit is contained in:
@@ -43,8 +43,19 @@ export function compileNativeWireFile(source: string): string {
|
||||
* Compile `.wrn` source into TypeScript source. Throws `ParseError` on invalid
|
||||
* input (the dev loader surfaces this as a readable error page).
|
||||
*/
|
||||
export function compileWireFile(source: string): string {
|
||||
const ast = parse(source);
|
||||
export function compileWireFile(source: string, filePath = "<inline .wrn>"): string {
|
||||
let ast;
|
||||
|
||||
try {
|
||||
ast = parse(source);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
|
||||
throw new Error(`Failed to parse ${filePath}: ${message}`, {
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
|
||||
return `// compiled from .wrn\n${generate(ast)}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user