Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.2k
esm: addinitialize
hook, integrate withregister
#48842
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.
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.
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.
The docs need updating as part of this PR. That would help in reviews, as we can see the intended usage from the example in the new docs. Since |
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.
Thanks for all the feedback! Work is a bit busy, but I will get to this later tonight (Friday) 😄 |
@GeoffreyBooth how/where do I update the docs? |
Edit the You’ll find loaders documented in |
@GeoffreyBooth while I do up the docs, is the CJS test here sufficient or do you want to see something more? |
We should add a test that specifically uses |
@GeoffreyBooth I added two more tests but one of them is failing. I added |
Please don't add |
Oh, sorry, removing skip 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is looking good!
If you'd like help with anything, I have some time this weekend (and then I'm away starting Wednesday for ~2 weeks)
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.
Uh oh!
There was an error while loading.Please reload this page.
@GeoffreyBooth yes: this addresses a specific need; I can't remember what it is, but I'm sure it was discussed. I can try to find it if you'd like. |
Yes, if you can find the reason, I’d appreciate it. I assume it’s because we can’t figure out how to search for And if How do others feel about this? |
I would prefer the signature to be |
aduh95 commentedJul 22, 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.
You would not get the expected result if you try to register a
Note that's almost certainly the case, the only case I can think of where resolving relative to the CWD makes sense is to parse a relative path passed as CLI argument, I expect this will not be the case for the vast majority of |
For a package you would just pass the specifier, e.g.
Yes, except that’s how |
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)#48765test_runner: * (SEMVER-MINOR) expose location of tests (Colin Ihrig)#48975module: * 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)#48890PR-URL:#49185
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
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
Based on the note from@GeoffreyBooth on#46826 (comment) I'm going ahead and adding a backport-requested label to this PR too. Ideally you can organize it so that it can be a single backport PR containing all the required commits 😊 |
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
PR-URL:nodejs#49530Refs:nodejs#48842Refs:nodejs#47999Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Jacob Smith <jacob@frende.me>
Follows@giltayar's proposed API:> `register` can pass any data it wants to the loader, which will bepassed to the exported `initialize` function of the loader.Additionally, if the user of `register` wants to communicate with theloader, it can just create a `MessageChannel` and pass the port to theloader as data.The `register` API is now:```tsinterface Options { parentUrl?: string; data?: any; transferList?: any[];}function register(loader: string, parentUrl?: string): any;function register(loader: string, options?: Options): any;```This API is backwards compatible with the old one (new arguments areoptional and at the end) and allows for passing data into the new`initialize` hook. If this hook returns data it is passed back to`register`:```tsfunction initialize(data: any): Promise<any>;```**NOTE**: Currently there is no mechanism for a loader to exchangeownership of something back to the caller.Refs:nodejs/loaders#147PR-URL:nodejs#48842Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>Reviewed-By: Matteo Collina <matteo.collina@gmail.com>Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
…5961)**What's the problem this PR addresses?**nodejs/node#48842 changed it so that our fspatch is loaded after the internal translators so ESM importing namedCJS exports in loaders doesn't work.Fixes#5951**How did you fix it?**Updated our ESM loader patching to target the `fs` bindings usedinternally.**Checklist**- [x] I have read the [ContributingGuide](https://yarnpkg.com/advanced/contributing).- [x] I have set the packages that need to be released for my changes tobe effective.- [x] I will check that all automated PR checks pass before the PR getsreviewed.
…5961)**What's the problem this PR addresses?**nodejs/node#48842 changed it so that our fspatch is loaded after the internal translators so ESM importing namedCJS exports in loaders doesn't work.Fixes#5951**How did you fix it?**Updated our ESM loader patching to target the `fs` bindings usedinternally.**Checklist**- [x] I have read the [ContributingGuide](https://yarnpkg.com/advanced/contributing).- [x] I have set the packages that need to be released for my changes tobe effective.- [x] I will check that all automated PR checks pass before the PR getsreviewed.(cherry picked from commit6e920f9)
Follows@giltayar's proposed API:> `register` can pass any data it wants to the loader, which will bepassed to the exported `initialize` function of the loader.Additionally, if the user of `register` wants to communicate with theloader, it can just create a `MessageChannel` and pass the port to theloader as data.The `register` API is now:```tsinterface Options { parentUrl?: string; data?: any; transferList?: any[];}function register(loader: string, parentUrl?: string): any;function register(loader: string, options?: Options): any;```This API is backwards compatible with the old one (new arguments areoptional and at the end) and allows for passing data into the new`initialize` hook. If this hook returns data it is passed back to`register`:```tsfunction initialize(data: any): Promise<any>;```**NOTE**: Currently there is no mechanism for a loader to exchangeownership of something back to the caller.Refs:nodejs/loaders#147PR-URL:#48842Backport-PR-URL:#50669Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>Reviewed-By: Matteo Collina <matteo.collina@gmail.com>Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Follows@giltayar's proposed API:> `register` can pass any data it wants to the loader, which will bepassed to the exported `initialize` function of the loader.Additionally, if the user of `register` wants to communicate with theloader, it can just create a `MessageChannel` and pass the port to theloader as data.The `register` API is now:```tsinterface Options { parentUrl?: string; data?: any; transferList?: any[];}function register(loader: string, parentUrl?: string): any;function register(loader: string, options?: Options): any;```This API is backwards compatible with the old one (new arguments areoptional and at the end) and allows for passing data into the new`initialize` hook. If this hook returns data it is passed back to`register`:```tsfunction initialize(data: any): Promise<any>;```**NOTE**: Currently there is no mechanism for a loader to exchangeownership of something back to the caller.Refs:nodejs/loaders#147PR-URL:nodejs/node#48842Backport-PR-URL:nodejs/node#50669Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>Reviewed-By: Matteo Collina <matteo.collina@gmail.com>Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Follows@giltayar's proposed API:> `register` can pass any data it wants to the loader, which will bepassed to the exported `initialize` function of the loader.Additionally, if the user of `register` wants to communicate with theloader, it can just create a `MessageChannel` and pass the port to theloader as data.The `register` API is now:```tsinterface Options { parentUrl?: string; data?: any; transferList?: any[];}function register(loader: string, parentUrl?: string): any;function register(loader: string, options?: Options): any;```This API is backwards compatible with the old one (new arguments areoptional and at the end) and allows for passing data into the new`initialize` hook. If this hook returns data it is passed back to`register`:```tsfunction initialize(data: any): Promise<any>;```**NOTE**: Currently there is no mechanism for a loader to exchangeownership of something back to the caller.Refs:nodejs/loaders#147PR-URL:nodejs/node#48842Backport-PR-URL:nodejs/node#50669Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>Reviewed-By: Matteo Collina <matteo.collina@gmail.com>Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Uh oh!
There was an error while loading.Please reload this page.
Follows@giltayar's proposed API:
The
register
API is now:This API is backwards compatible with the old one (new arguments are optional and at the end) and allows for passing data into the new
initialize
hook. If this hook returns data it is passed back toregister
:NOTE: Currently there is no mechanism for a loader to exchange ownership of something back to the caller.
Refs:nodejs/loaders#147
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.