second-state / rustwasmc

Tool for building Rust functions for Node.js. Combine the performance of Rust, safety and portability of WebAssembly, and ease of use of JavaScript.
https://www.secondstate.io/articles/rustwasmc/
Apache License 2.0
130 stars 10 forks source link

Package built for Deno has errors that prevent it from running #3

Closed eliorivero closed 4 years ago

eliorivero commented 4 years ago

Hi, this is a nice tool! I tested this last night and it was working fine with a Deno version that I'm unsure what it was but must've been earlier than 1.2.0. It was compiling correctly and Deno was loading it correctly.

I upgraded Deno this morning to the latest version 1.2.0 and it no longer works. While the project compiles, Deno refuses to run it and throws these errors:

error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname
                 ~~~
    at https://deno.land/std/path/win32.ts:917:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname;
                 ~~~
    at https://deno.land/std/path/posix.ts:438:18

Found 2 errors.

These are likely produced by this portion of code in %package_name%.js:

import * as path from 'https://deno.land/std/path/mod.ts';
>> const __dirname = path.dirname(new URL(import.meta.url).pathname); <<
const p = path.join(__dirname, '%package_name%_bg.wasm');
juntao commented 4 years ago

I believe this is an issue with the std module files your old Deno install cached. See this issue to reload the cache.

https://github.com/denoland/deno/issues/6737

eliorivero commented 4 years ago

Thanks a lot @juntao! I did

deno cache --reload my-deno-file.ts

and that solved it.