next.js
4ebf4bd6 - Only track pending imports for real promises (#95789)

Commit
21 hours ago
Only track pending imports for real promises (#95789) Extracted from https://github.com/vercel/next.js/pull/95468. Fixes a module with `then` export hanging the module tracking during the build. --- `trackPendingImport` needs to track actually async modules (top-level await). Before this change, this codepath was happy to adopt any thenable. But since thenables may not be Promises, this could break things downstream, hence why we had `Promise.resolve` there. However, we don't *want* to adopt arbitrary thenables here. **Tracking is for top-level awaited modules.** For example, `module.exports = new Promise(() => {})` has a `.then` but we don't want to track that. It's not TLA. This is why, to catch real top-level await modules, we narrow the check to `instanceof Promise`. We add tests for: - A client module with a `then` function export (**hangs** on Turbopack before this PR with CC on) - Exporting a literal Promise (works before and after, but worth testing for future regressions)
Author
Parents
Loading