Skip to content

turbopack-230321.2

@alexkirsz alexkirsz tagged this 21 Mar 11:57
### Description

This refactors the EcmaScript chunk evaluate segment logic into a
separate `EcmascriptChunkRuntime` trait.

`ChunkingContext` implementors can now optionally implement the
`EcmascriptChunkContext` trait (which already existed before as a
struct). This trait has two additional methods:
* `EcmascriptChunkContext::ecmascript_runtime()` -> Creates a ES runtime
that only registers chunks' contents
* `EcmascriptChunkContext::evaluated_ecmascript_runtime()` -> Creates an
ES runtime that registers chunks' contents and evaluates its entries

This is important because we are going to start having more than one
runtime evaluation logic with `next build` (and `ncc` and any future
bundler-specific work). In the future, this could even be used to have
non-Ecmascript runtimes.

Also fixes WEB-688

PR for the Next.js side: https://github.com/vercel/next.js/pull/47116

### TODO

- [x] ~~I need to ensure that `waitForChunksToLoad` works as expected on
first load and does not re-create requests to JS and CSS chunks that are
already being loaded.~~

- [x] ~~Looks like there's a hashing problem (module ident perhaps?)
that creates additional snapshots.~~

### Testing Instructions

Snapshots + Integrations tests
Assets 2
Loading