second-state/rustwasmc

Package built for Deno has errors that prevent it from running

Closed this issue · 2 comments

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');

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

denoland/deno#6737

Thanks a lot @juntao! I did

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

and that solved it.