Uh oh!
There was an error while loading. Please reload this page.
vm: SourceTextModule refactor - #29776
Conversation
devsnek
commented
Sep 30, 2019
cc @nodejs/vm |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Sep 30, 2019
guybedford
left a comment
There was a problem hiding this comment.
Great to see these refinements.
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.
There was a problem hiding this comment.
I suggest to abstract this into a private function for less repetition. That way it could be used as: this.#getPrivateProperty(name) where name would e.g., be '#error'.
There was a problem hiding this comment.
obj['#error'] is not the same as obj.#error, also you have to check for this.#getPrivateProperty in the first place 🙃
There was a problem hiding this comment.
Uh, of course! Too bad that it seems like there's no nice way around this 😞
There was a problem hiding this comment.
It's pretty ugly but it should be possible to abstract it like this:
functiongetPrivateProperty(module,name){try{switch(name){case'error':
returnmodule.#error;
...
}}catch{thrownewERR_VM_MODULE_NOT_MODULE();}}There was a problem hiding this comment.
I think how the current code is the best we can get it. you can blame tc39 for not generalizing private fields better 🤷
- Removes redundant `instantiate` method - Refactors `link` to match the spec linking steps more accurately - Removes URL validation from SourceTextModule specifiers - DRYs some dynamic import logic Closesnodejs#29030 Co-Authored-By: Michaël Zasso <targos@protonmail.com>
nodejs-github-bot
commented
Oct 1, 2019
- Removes redundant `instantiate` method - Refactors `link` to match the spec linking steps more accurately - Removes URL validation from SourceTextModule specifiers - DRYs some dynamic import logic Closes: #29030 Co-Authored-By: Michaël Zasso <targos@protonmail.com> PR-URL: #29776 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Trott
commented
Oct 2, 2019
Landed in 5e7946f |
- Removes redundant `instantiate` method - Refactors `link` to match the spec linking steps more accurately - Removes URL validation from SourceTextModule specifiers - DRYs some dynamic import logic Closes: #29030 Co-Authored-By: Michaël Zasso <targos@protonmail.com> PR-URL: #29776 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
instantiatemethodlinkto match the spec linking steps more accuratelyCloses#29030
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes