Uh oh!
There was an error while loading. Please reload this page.
esm: Modify getFormat and getSource loader hooks - #34144
Conversation
hybrist
commented
Jun 30, 2020
This came up when trying to implement hooks that would get sources from a location with its own meta data (e.g. HTTPS). The current model requires that the format is determined before trying to load the source which isn't really possible there. Allowing |
devsnek
commented
Jun 30, 2020
I agree with the motivation but I'm not sure about this specific solution, specifically with the disagreement among hooks as that could be difficult to debug. |
One thing @GeoffreyBooth brought up: If the hooks get reshuffled, it may be possible to only get
The downside is that we'd have to decide what the default I think my current vote would be to reorder (call |
hybrist
commented
Jun 30, 2020
/cc @nodejs/modules-active-members (since the discussion has started anyhow :)) |
julian-londono
commented
Jun 30, 2020
Looking forward to any further thoughts/insight on this! |
guybedford
commented
Jul 18, 2020
@julian-londono just post a comment when you are ready for further review here. Another question I had about this - would it make sense for the |
julian-londono
commented
Jul 20, 2020
Good question, I could see this having valid use cases, but it was not under the original scope of this change - I can explore this more and get back to you @guybedford |
julian-londono
commented
Jul 22, 2020
I've created an doc summarizing my exploration into this issue and potential solutions (RFC): @guybedford : We think that allowing |
julian-londono
commented
Jul 24, 2020
Looking forward to some thoughts about my exploration into the issue - after this I could move forward with adding potential documentation updates 👍 |
guybedford
commented
Jul 29, 2020
It still feels to me a little inconsistent to have transformSource not fit the model. For example, how would a loader be written to support TypeScript if it were to compose with an existing loader that returned the source from getSource? It would need to override both hooks... most users wouldn't hit that until the composition case actually happens making this somewhat of a composition footgun. Trying to think of alternatives here... would it be an option to reorder getFormat to be called after getSource so that the internal cache can be used without needing to trigger the fetch separately? |
julian-londono
commented
Jul 30, 2020
Seems like a good alternative is to remove the
In this case, |
guybedford
commented
Jul 30, 2020
This sounds like a great concept to me! |
This PR aims to amend the current behavior of the
getFormatandgetSourceexperimental loader hooks by allowinggetSourceto optionally override the format of the source that had been defined bygetFormat.This is an active WIP ; I am working under the guidance of contributor @jkrems
Checklist
make -j4 test(UNIX) passes