Files
Matt Mastracci a1c12562f0 Turbopack: Pass globals to node.js workers as well (#89261)
## What

Changes how Turbopack creates Web Workers and Worker Threads to use a unified factory function pattern. Workers now receive the same runtime globals (like `NEXT_DEPLOYMENT_ID` and `NEXT_CLIENT_ASSET_SUFFIX`) as the parent context, and asset loading works correctly inside workers.

## Why

Previously, worker creation was split between compile-time URL generation and runtime initialization, which made it difficult to:
- Forward runtime globals to worker contexts
- Ensure workers could load chunked assets with the correct suffix
- Maintain consistent initialization logic across browser and Node.js workers

This caused issues when workers needed to dynamically import assets or access deployment-specific configuration.

## How

Worker loader modules now export a factory function that receives the Worker constructor and options, rather than just a URL. The runtime handles all worker initialization, including forwarding necessary globals. This keeps all worker creation logic in a single place (the runtime) rather than being split between Rust code generation and JavaScript execution.

Tests added for PNG asset loading in workers to verify the asset suffix forwarding works correctly in both browser and Node.js contexts.
2026-02-06 10:02:54 -07:00

9 lines
135 B
JavaScript

/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
deploymentId: 'test-deployment-id',
}
module.exports = nextConfig