Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring transformation of output file paths #35

Open
nicky1038 opened this issue May 5, 2023 · 0 comments
Open

Allow configuring transformation of output file paths #35

nicky1038 opened this issue May 5, 2023 · 0 comments

Comments

@nicky1038
Copy link

nicky1038 commented May 5, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant