node-dev icon indicating copy to clipboard operation
node-dev copied to clipboard

[ESM] Support wrapping a custom loader

Open kherock opened this issue 2 years ago • 2 comments

Closes #242

This adds support for custom ESM loaders options passed via --experimental-loader to node-dev. I accomplish this by passing the resolved loader path as a query string argument to node-dev's own ESM loader implementation.

Also, keeping this as a draft until #279 is merged since those changes are more important and this branch builds on top of those commits.

kherock avatar Mar 25 '22 18:03 kherock

This PR still doesn't solve scenarios where the ESM loader is passed via NODE_OPTIONS, which is a problem for Yarn 2+ users. To make that work properly we need to rewrite process.env.NODE_OPTIONS with the appropriate loader.

Would it be acceptable to always pass the rewritten loader path by appending a string onto process.env.NODE_OPTIONS instead of passing it as a node arg?

kherock avatar Mar 25 '22 20:03 kherock

Would it be acceptable to always pass the rewritten loader path by appending a string onto process.env.NODE_OPTIONS instead of passing it as a node arg?

node-dev should not be manipulating environment variables.

bjornstar avatar Mar 26 '22 20:03 bjornstar