Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.2k
module: implementregister
utility#46826
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Review requested:
|
Uh oh!
There was an error while loading.Please reload this page.
Use the path.sep variable for handling windows support.Refs:nodejs#46826 (comment)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This would need to be rebased now that the other PR has landed. Let me know if you need help with the process. |
How would this work with |
I think the way this works is it would add loaders to the main loaders thread that applies to the main application thread and all worker threads. (And it would create that main loaders thread if it doesn’t already exist at startup time.) Any modules loaded prior to this registration would be unaffected, of course, so people would need to be careful if they want this to apply to their main app, like: import{registerLoader}from'module'awaitregisterLoader('some-loader')awaitimport('app-entry.js') So long as there’s just one loaders thread that applies to both the main thread and worker threads, it’s all or nothing: |
That's perfect for me. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Not something that needs to be done in this PR, but I think we should consider adding a few supporting APIs:
|
Arguably this should happen at this PR, so there isn’t a gap between being able to register loaders programmatically and preventing people from doing so. Or two PRs but this one is blocked from being released until the permission is added. The risk is relatively low though, because
I assume you mean loader/loaders here, not hooks? This API registers an entire loader, so presumably the complementary API would be |
I did mean loaders instead of hooks here. I apologize for that. |
Okee, sorry for the dump, but I think this is too big to hide in a file comment: I think the tech design here needs to change quite a bit to actually work: esm/worker autonomously handles loader registration for loaders specified via CLI. it currently does not expose this; it would need to do. So what I think needs to happen is:
Perhaps Footnotes:
|
Regarding making the API sync, I’ve been thinking about that and I’m having conflicting thoughts about it: while I 💯 agree that a sync API would produce fewer surprises, but on the same time we probably want the API to work from |
I always assumed it would be an async API; it’s essentially
If the user needs to pass |
aduh95 commentedMay 6, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It loads it in a different thread, comparing it with
If it's async, it would race, so sometimes error, sometimes succeeds. But that sounds like a terrible API 😅
Do you have a use case in mind that would require the loader registration to be async? 🤔
Maybe we should support it only in scripts loaded from |
GeoffreyBooth commentedMay 6, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Sure, but loading modules (whether from disk or network etc) is typically an async operation.
Okay, fair enough, but this is no different than any developer forgetting to await an async API. If the code somehow doesn’t error for them, hopefully their linter or typechecker warns them that they forgot an
Because many loaders will presumably be written as ESM, and loading them means I don’t necessarilywant this API to be async; if it can be sync, great, do it that way. I just assumed that somewhere under the hood it would use the
Needing this to happen from CommonJS and/or from I think we just need to undo the separation of |
But the "import" happens in a different thread, so there’s no reason we couldn’t make it sync, like we do for |
Notable changes:deps: * V8: cherry-pick 93275031284c (Joyee Cheung)#48660doc: * add new TSC members (Michael Dawson)#48841 * add rluvaton to collaborators (Raz Luvaton)#49215esm: * unflag import.meta.resolve (Guy Bedford)#49028 * add `initialize` hook, integrate with `register` (Izaak Schroeder)#48842 * unflag `Module.register` and allow nested loader `import()` (Izaak Schroeder)#48559inspector: * (SEMVER-MINOR) open add `SymbolDispose` (Chemi Atlow)#48765module: * implement `register` utility (João Lenon)#46826 * make CJS load from ESM loader (Antoine du Hamel)#47999src: * add built-in `.env` file support (Yagiz Nizipli)#48890 * initialize cppgc (Daryl Haresign and Joyee Cheung)#48660 and#45704test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)#48975PR-URL:#49185
Notable changes:deps: * V8: cherry-pick 93275031284c (Joyee Cheung)#48660doc: * add new TSC members (Michael Dawson)#48841 * add rluvaton to collaborators (Raz Luvaton)#49215esm: * unflag import.meta.resolve (Guy Bedford)#49028 * add `initialize` hook, integrate with `register` (Izaak Schroeder)#48842 * unflag `Module.register` and allow nested loader `import()` (Izaak Schroeder)#48559inspector: * (SEMVER-MINOR) open add `SymbolDispose` (Chemi Atlow)#48765module: * implement `register` utility (João Lenon)#46826 * make CJS load from ESM loader (Antoine du Hamel)#47999src: * add built-in `.env` file support (Yagiz Nizipli)#48890 * initialize cppgc (Daryl Haresign and Joyee Cheung)#48660 and#45704test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)#48975PR-URL:#49185
Notable changes:deps: * V8: cherry-pick 93275031284c (Joyee Cheung)#48660doc: * add new TSC members (Michael Dawson)#48841 * add rluvaton to collaborators (Raz Luvaton)#49215esm: * unflag import.meta.resolve (Guy Bedford)#49028 * add `initialize` hook, integrate with `register` (Izaak Schroeder)#48842 * unflag `Module.register` and allow nested loader `import()` (Izaak Schroeder)#48559inspector: * (SEMVER-MINOR) open add `SymbolDispose` (Chemi Atlow)#48765module: * implement `register` utility (João Lenon)#46826 * make CJS load from ESM loader (Antoine du Hamel)#47999src: * add built-in `.env` file support (Yagiz Nizipli)#48890 * initialize cppgc (Daryl Haresign and Joyee Cheung)#48660 and#45704test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)#48975PR-URL:#49185
Notable changes:deps: * V8: cherry-pick 93275031284c (Joyee Cheung)#48660doc: * add new TSC members (Michael Dawson)#48841 * add rluvaton to collaborators (Raz Luvaton)#49215esm: * unflag import.meta.resolve (Guy Bedford)#49028 * add `initialize` hook, integrate with `register` (Izaak Schroeder)#48842 * unflag `Module.register` and allow nested loader `import()` (Izaak Schroeder)#48559inspector: * (SEMVER-MINOR) open add `SymbolDispose` (Chemi Atlow)#48765module: * implement `register` utility (João Lenon)#46826 * make CJS load from ESM loader (Antoine du Hamel)#47999src: * add built-in `.env` file support (Yagiz Nizipli)#48890 * initialize cppgc (Daryl Haresign and Joyee Cheung)#48660 and#45704test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)#48975PR-URL:#49185
Notable changes:deps: * V8: cherry-pick 93275031284c (Joyee Cheung)#48660doc: * add new TSC members (Michael Dawson)#48841 * add rluvaton to collaborators (Raz Luvaton)#49215esm: * unflag import.meta.resolve (Guy Bedford)#49028 * add `initialize` hook, integrate with `register` (Izaak Schroeder)#48842 * unflag `Module.register` and allow nested loader `import()` (Izaak Schroeder)#48559inspector: * (SEMVER-MINOR) open add `SymbolDispose` (Chemi Atlow)#48765module: * implement `register` utility (João Lenon)#46826 * make CJS load from ESM loader (Antoine du Hamel)#47999src: * add built-in `.env` file support (Yagiz Nizipli)#48890 * initialize cppgc (Daryl Haresign and Joyee Cheung)#48660 and#45704test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)#48975PR-URL:#49185
Notable changes:deps: * V8: cherry-pick 93275031284c (Joyee Cheung)#48660doc: * add new TSC members (Michael Dawson)#48841 * add rluvaton to collaborators (Raz Luvaton)#49215esm: * unflag import.meta.resolve (Guy Bedford)#49028 * add `initialize` hook, integrate with `register` (Izaak Schroeder)#48842 * unflag `Module.register` and allow nested loader `import()` (Izaak Schroeder)#48559inspector: * (SEMVER-MINOR) open add `SymbolDispose` (Chemi Atlow)#48765module: * implement `register` utility (João Lenon)#46826 * make CJS load from ESM loader (Antoine du Hamel)#47999src: * add built-in `.env` file support (Yagiz Nizipli)#48890 * initialize cppgc (Daryl Haresign and Joyee Cheung)#48660 and#45704test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)#48975PR-URL:#49185
Notable changes:deps: * V8: cherry-pick 93275031284c (Joyee Cheung)#48660doc: * add new TSC members (Michael Dawson)#48841 * add rluvaton to collaborators (Raz Luvaton)#49215esm: * unflag import.meta.resolve (Guy Bedford)#49028 * add `initialize` hook, integrate with `register` (Izaak Schroeder)#48842 * unflag `Module.register` and allow nested loader `import()` (Izaak Schroeder)#48559inspector: * (SEMVER-MINOR) open add `SymbolDispose` (Chemi Atlow)#48765module: * implement `register` utility (João Lenon)#46826 * make CJS load from ESM loader (Antoine du Hamel)#47999src: * add built-in `.env` file support (Yagiz Nizipli)#48890 * initialize cppgc (Daryl Haresign and Joyee Cheung)#48660 and#45704test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)#48975PR-URL:#49185
This does not land cleanly in |
This function was first implemented innodejs#46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:nodejs#46826 (comment)
This function was first implemented innodejs#46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:nodejs#46826 (comment)
This function was first implemented in#46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:#46826 (comment)PR-URL:#48434Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This function was first implemented in#46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:#46826 (comment)PR-URL:#48434Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Notable changes:deps: * V8: cherry-pick 93275031284c (Joyee Cheung)nodejs#48660doc: * add new TSC members (Michael Dawson)nodejs#48841 * add rluvaton to collaborators (Raz Luvaton)nodejs#49215esm: * unflag import.meta.resolve (Guy Bedford)nodejs#49028 * add `initialize` hook, integrate with `register` (Izaak Schroeder)nodejs#48842 * unflag `Module.register` and allow nested loader `import()` (Izaak Schroeder)nodejs#48559inspector: * (SEMVER-MINOR) open add `SymbolDispose` (Chemi Atlow)nodejs#48765module: * implement `register` utility (João Lenon)nodejs#46826 * make CJS load from ESM loader (Antoine du Hamel)nodejs#47999src: * add built-in `.env` file support (Yagiz Nizipli)nodejs#48890 * initialize cppgc (Daryl Haresign and Joyee Cheung)nodejs#48660 andnodejs#45704test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)nodejs#48975PR-URL:nodejs#49185
This function was first implemented innodejs#46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:nodejs#46826 (comment)PR-URL:nodejs#48434Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL:nodejs#46826Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This function was first implemented innodejs#46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:nodejs#46826 (comment)PR-URL:nodejs#48434Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This function was first implemented innodejs#46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:nodejs#46826 (comment)PR-URL:nodejs#48434Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This function was first implemented in#46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:#46826 (comment)PR-URL:#48434Backport-PR-URL:#50669Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL:nodejs/node#46826Backport-PR-URL:nodejs/node#50669Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This function was first implemented in #46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:nodejs/node#46826 (comment)PR-URL:nodejs/node#48434Backport-PR-URL:nodejs/node#50669Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL:nodejs/node#46826Backport-PR-URL:nodejs/node#50669Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This function was first implemented in #46826, but at some pointof the PR implementation this fn was no longer related to the PR.Refs:nodejs/node#46826 (comment)PR-URL:nodejs/node#48434Backport-PR-URL:nodejs/node#50669Reviewed-By: Jacob Smith <jacob@frende.me>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
To-dos:
register
function innode:module
.register
function in the same chain of loaders registered with--loader
CLI flag.