This change moves runtime code that does not use a module system and is concatenated by Rust into a dedicated `runtime/` directory so it's not confused with other code. It also codifies this in a README and instructs agents to read nearby READMEs so they enforce this convention. **This change only moves code and does not refactor any further.** Snapshot updates reflect the new file paths in the generated runtime code. **Test Plan:** CI, existing tests
1.1 KiB
Turbopack Ecmascript Runtime
This package holds the JavaScript code that is injected at runtime for Turbopack to function, such as chunk loading and module factory instantiation. In development, this includes hot module reload (a.k.a. fast refresh) runtime code.
Turbopack JavaScript runtime code
This Turbopack browser runtime JavaScript code lives as TypeScript files in the following directories named runtime:
turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtimeturbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtimeturbopack/crates/turbopack-ecmascript-runtime/js/src/shared/runtime
Files in these directories are compiled and concatenated at Rust build-time to form the code that gets executed in browser and Node at runtime. These files are not EcmaScript modules nor CommonJS modules -- instead, the TypeScript uses <reference> tags to reference other values and types in scope when the files are concatenated. Other ts code in the runtime crate can use esm though, such as: turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/dev/hmr-client/.