I had made an error with the way I was setting up the path for dynamic imports, and it was crashing showing a thread panic on the rust side. I checked the path, and it was using the actual absolute path on windows (C:...). I fixed this to use the relative path, and it loads fine. The problem, in my opinion, is that it panics when the path provided is not using the file:/// prefix, or a relative path.
Can you provide the actual panic?
[Code]
const imp = await import(`${Deno.cwd()}\\commands\\echo.ts`);
console.log(imp);
[Panic]
thread 'main' panicked at 'internal error: entered unreachable code', cli\state.rs:361:12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Output after adding file:/// to the beginning of the path]
Module { default: [AsyncFunction: default], Symbol(Symbol.toStringTag): "Module" }
@envis10n thanks!
It is a bug, this:
https://github.com/denoland/deno/blob/6720a0dc02dc5a93472520e6d23ca033d7ec9d88/cli/state.rs#L372
Should return an OpError instead of using the unreachable macro. Should be an easy fix for someone if they wanted to contribute to Deno.
Actually it might be related to https://github.com/denoland/deno/issues/3355. The unreachable!() statement is there for a reason - it shouldn't ever be hit as "previous" layers should resolve or reject the invalid specifier.
Actually it's definitely #3355 I had encountered this problem a while ago - quick solution was to prefix the import with file://, but we need to fix the underlying problem.
@bartlomieju shall I remove / close #4646 PR and work it out some other way ?
Most helpful comment
@envis10n thanks!
It is a bug, this:
https://github.com/denoland/deno/blob/6720a0dc02dc5a93472520e6d23ca033d7ec9d88/cli/state.rs#L372
Should return an
OpErrorinstead of using the unreachable macro. Should be an easy fix for someone if they wanted to contribute to Deno.