Skip to content

Commit

Permalink
build - Improve native invoke errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Oct 19, 2024
1 parent d05c560 commit f20ac28
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ const neptuneNativeImports: esbuild.Plugin = {

const output = Object.values(metafile.outputs)[0];

const registerExports = `__${output.entryPoint}_registerExports`;
const invokeExport = `__${output.entryPoint}`;
const entryPoint = output.entryPoint?.replace("plugins/", "");

const registerExports = `__${entryPoint}_registerExports`;
const invokeExport = `__${entryPoint}`;

return {
contents: `
Expand All @@ -120,8 +122,8 @@ const neptuneNativeImports: esbuild.Plugin = {
// Helper function for invoking exports
const invokeNative = (exportName) => (...args) => window.electron.ipcRenderer.invoke("${invokeExport}", exportName, ...args).catch((err) => {
err.stack = err.stack?.replaceAll("Error invoking remote method '${invokeExport}': Error: ", "");
throw err;
const msg = err.stack?.replaceAll("Error invoking remote method '${invokeExport}': Error: ", "");
throw new Error(\`[${entryPoint}.\${exportName}] \${msg}\`);
});
// Expose built exports via ipc
Expand Down

0 comments on commit f20ac28

Please sign in to comment.