Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Command-line --loader argument #305

Open
coreyfarrell opened this issue Apr 1, 2019 · 3 comments
Open

Command-line --loader argument #305

coreyfarrell opened this issue Apr 1, 2019 · 3 comments

Comments

@coreyfarrell
Copy link
Member

I can understand having the --loader argument since custom loader's are ESM files with specific exports, is it possible to implement an API for this (module.addESMLoader or something)? The idea is that during startup of nyc we hook require.extensions for CJS, we'd like to also hook ESM module loaders. If we need to control the --loader argument of node.js this will be difficult.

I suspect this will apply to other transformation plugins. Thinking about how a module like @babel/register gets documented. If users need to use --loader to get babel working with ESM I think that will create confusion.

@devsnek
Copy link
Member

devsnek commented Apr 1, 2019

we're currently trying to keep the loader API very bare as we're experimenting with various concurrency models and stuff of that nature.

after all that is figured out though, it should be easier to come up with a public API.

@bmacnaughton
Copy link

i work on an apm product of which a critical component is being able to patch modules as they are loaded. i think this is a related issue and just want to put in a word that i'm interested in your thoughts and the state of any potential solutions. feel free to point me elsewhere if this isn't the right place.

@Flarna
Copy link
Member

Flarna commented Jun 11, 2019

I'm also interested in getting an API regarding this.

transformation plugins and APM tools currently monkey patch Module.prototype.require, Module._load or similar which is not that nice and will for sure not work with ECMAModules.

The need to specify extra command line arguments, which even have a dependency to other command line arguments (at least currently to --experimental-modules) and fail on older Node.Js versions result in hard to maintain setups.
Currently the only requirement is to have the transformation plugins loaded early and they care about the rest. With ESM it looks like users have to care about one more topic.

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

No branches or pull requests

4 participants