You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One can run node with custom ESM loaders. Though this API is experimental in Node.js, it was added way back in node 8 and can be very handy in some specific cases.
When a custom ESM loader is used, on dynamic import() call, this library will invoke custom ESM loader's logic of module location resolving, passing path of the resolved JS file into the ESM loader as an import() argument. The problem is that custom ESM loader may accept file path strings in shapes different from just "absolute path to file".
My case is: I would like to make Yarn PnP, ESM modules and Typescript work together. So, I would like to use this library with Yarn's .pnp.loader.esm ESM loader. This loader, unfortunately, accepts only URLs beginning from 'file://' and throw errors on regular absolute paths. That is, I cannot use this loader now, because absolute paths are exactly what this library passes into dynamic import().
So my suggestion is to allow users to configure a callback that will be used to transform output js paths into shape that users need, before passing the resulting paths to import() call.
What do you think? Could I make a PR?
The text was updated successfully, but these errors were encountered:
One can run
node
with custom ESM loaders. Though this API is experimental in Node.js, it was added way back in node 8 and can be very handy in some specific cases.When a custom ESM loader is used, on dynamic
import()
call, this library will invoke custom ESM loader's logic of module location resolving, passing path of the resolved JS file into the ESM loader as animport()
argument. The problem is that custom ESM loader may accept file path strings in shapes different from just "absolute path to file".My case is: I would like to make Yarn PnP, ESM modules and Typescript work together. So, I would like to use this library with Yarn's
.pnp.loader.esm
ESM loader. This loader, unfortunately, accepts only URLs beginning from 'file://' and throw errors on regular absolute paths. That is, I cannot use this loader now, because absolute paths are exactly what this library passes into dynamicimport()
.So my suggestion is to allow users to configure a callback that will be used to transform output js paths into shape that users need, before passing the resulting paths to
import()
call.What do you think? Could I make a PR?
The text was updated successfully, but these errors were encountered: