gpujs/gpu.js

Cannot handle transpiled imported function

HanchaiN opened this issue · 0 comments

What is wrong?

Cannot handle transpiled imported function (Markup type null not handled)

Where does it happen?

I use Gatsby with Webpack 5 and Typescript and try to add functions imported from different files. The result

How do we replicate the issue?

  1. Create main.ts file.
import {calc} from "./module.ts";
import GPU from "gpu.js";

const gpu = new GPU.GPU();
const kernel = gpu.createKernel(function () {
    return calc(this.thread.x);
}).addFunction(calc, {
    argumentTypes: ["Float"],
    returnType: "Float",
}).setOutput([5]);
const result = kernel();
console.log(result);
  1. Create module.ts file.
export function calc(x: number) {
    return x * 2;
}

How important is this (1-5)?

4 (It is important if I want to use GPU.js here. Alternatively, I could fall back to normal CPU or manually write the shaders.)

Expected behavior (i.e. solution)

Other Comments

There is a less important issue with argumentTypes having to be an array for both addFunction and setArgumentTypes.
Noted that the replication steps are not tested. I only speculated that this will also work with just Typescript and Webpack 5 since I'm working with web framework here.