rustyscript icon indicating copy to clipboard operation
rustyscript copied to clipboard

[node_experimental] Using npm module with a dependency on a node standard library

Open silverpill opened this issue 10 months ago • 2 comments

Hello!

When imported npm module attempts to import a standard module such as fs, an error occurs:

Relative import path "fs" not prefixed with / or ./ or ../

Import from "node:fs" works as expected, but I have no control over the npm module. I tried to implement custom ImportProvider, but it appears that the error occurs before ImportProvider::resolve is called.

rustyscript version: 0.11.0

A similar problem was reported by @utyfua in https://github.com/rscarson/rustyscript/pull/147#discussion_r1809214019

silverpill avatar Feb 28 '25 15:02 silverpill

I am using schema_whlist for now but I was considering to add a new method to ImportProvider trait to be able to overwrite deno_core::resolve_import call [ref].

utyfua avatar Feb 28 '25 15:02 utyfua

Fixed in master, will leave this open this the next version publishes.

You can now just import "fs" instead of node:fs for builtins

rscarson avatar Mar 14 '25 14:03 rscarson

Fixed in release 0.12.0

rscarson avatar Aug 16 '25 03:08 rscarson