Implement ES2024 `Promise.withResolvers`
Hmm, we have to figure out how to deal with this. The problem is that 01-Promise.js is automatically generated by https://github.com/facebook/hermes/blob/main/utils/gen-promise-internal-bc.sh from https://www.npmjs.com/package/promise.
However, at the same time, we can't be stuck forever with an outdated Promise implementation. The discussion in https://github.com/facebook/hermes/issues/1009 is also relevant here.
So, the question is, should we:
- Essentially fork https://github.com/then/promise, which hasn't been updated in some time and start updating it?
- Extract the promise from https://www.npmjs.com/package/es6-shim. That carries the risk of being incompatible with React Native (unfortunately the RN team hasn't clarified the extent to which they depend on non-spec behavior of the current polyfill).
I think that at least in the short term 1) is the only practical option. Then the question becomes, how to actually modify it? Should we just tweak the built result? (I am on vacation, so I may be slow to respond, but I am curious what others think too)
Forking it does seem like the most straightforward. I suppose the best way to do it comes down to how difficult it is to build the promise implementation. If we could easily copy the original source to our external directory, and point utils/promise to it, then we can freely modify the original input while maintaining its structure. That has some value if we find ourselves digging into the blame for the implementation in the future, or if there is some movement in the repo upstream.
@tmikov still happy to extract the Promise implementation to a separate package, if that'd be helpful - i could include finally and withResolvers in it, since those are already authored as standalone packages. (i can also help you do an optimal build to eliminate parts of the graph that aren't needed in hermes)