Skip to content

Cannot handle transpiled imported functionΒ #825

@HanchaiN

Description

@HanchaiN

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions