rsnext/packages
Janka Uryga 663488cf52
unstable_after: support nested unstable_after calls (#65950)
Adds support for nested `unstable_after()`.

This pattern previously threw a "Not supported yet" error, but works
now:

```js
function MyComponent() {
  after(() => asyncWork());
  return <div>...</div>
}

async function asyncWork() {
  after(() => { /* look ma, nesting!*/ })
  // more stuff...
}
```

### Implementation notes
Switched `AfterContext` to use a proper promise queue
([`p-queue`](https://www.npmjs.com/package/p-queue)) instead of plain a
callback array to support adding more callbacks as we execute (i.e. from
nested `after`s). Used a package because I didn't want to reinvent the
wheel here.

As a nice bonus, `p-queue` lets us limit the concurrency of running
tasks if we're worried about resource consumption. **This PR doesn't do
that**, but it's very easy to add. That could be controlled via
`process.env.NEXT_AFTER_MAX_CONCURRENT_TASKS`, a next.config.js option
(`unstable_after: { maxConcurrentTasks: 5 }`), or something like that.
2024-05-20 15:09:16 +00:00
..
create-next-app v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
eslint-config-next v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
eslint-plugin-next v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
font Update font data (#65961) 2024-05-20 14:35:39 +00:00
next unstable_after: support nested unstable_after calls (#65950) 2024-05-20 15:09:16 +00:00
next-bundle-analyzer v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
next-codemod v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
next-env v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
next-mdx v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
next-plugin-storybook v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
next-polyfill-module v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
next-polyfill-nomodule v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
next-swc v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
react-refresh-utils v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
third-parties v14.3.0-canary.72 2024-05-20 10:35:37 +00:00