mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What? Simplifies `turbo-tasks-backend` by removing abstraction layers that each had a single implementation, plus several redundant `Arc` indirections that were no longer load-bearing. **Traits removed / collapsed (each had exactly one implementor):** - **`KeyValueDatabase`** — folded into inherent methods on its only impl, `TurboKeyValueDatabase`. - **`BackingStorage` + `BackingStorageSealed`** — folded into inherent methods on the renamed concrete type `TurboBackingStorage` (was the `KeyValueDatabaseBackingStorage<T>` generic + a type alias). - **`ConcurrentWriteBatch`** — folded into inherent methods on `TurboWriteBatch` (it existed to support an old backend implementation that's gone). - The **`B: BackingStorage` generic parameter** is dropped from `TurboTasksBackend`, `TurboTasksBackendInner`, `ExecuteContextImpl`, and `ChildExecuteContextImpl`. Every instantiation in the workspace already resolved to one concrete type. The only remaining trait in the crate's public role is `Backend` (defined in `turbo-tasks`), which stays — removing it would invert the `turbo-tasks` → backend dependency. **`Arc` indirections removed:** - `TurboKeyValueDatabase.db: Arc<TurboPersistence>` → `TurboPersistence` (the write batch only borrowed it; the clone in `new` was gratuitous). - The `self: &Arc<Self>` receivers and `self.clone()` calls in `run_backend_job`, `idle_start`, and `try_read_task_output` — the deferred/background work reaches the backend through the pinned `turbo_tasks` handle instead, whose `Arc` already keeps the backend alive. - With no remaining sharer, the backend's own `Arc<TurboTasksBackendInner>` and the `TurboTasksBackend` newtype were collapsed: the inner fields now live directly in `TurboTasksBackend`, stored inline in `TurboTasks` (which already shares it via its own `Arc<TurboTasks>`). **Other cleanups surfaced by the above:** - `noop_backing_storage()` is now an empty, read-only instance of the real `TurboPersistence` instead of a separate `NoopKvDb` impl — same concrete type as `turbo_backing_storage()`, so the `Either<…>` wrappers in napi and turbopack-cli go away. - `TurboTasksBackend::backing_storage()` accessor replaced with a focused `invalidate_storage(reason_code)` method, so the backend no longer leaks its storage object. - Dead code removed (`CellDependency::key`, `ExecuteContext::schedule` / `suspending_requested`, the non-stats `execute_with_stats` variant) and feature/test-only items gated behind their corresponding `cfg`. ### Why? The no-op storage work removed the last thing forcing these abstractions to be generic/dynamic, so the single-impl traits and the extra `Arc` layers were pure indirection. This is a self-contained simplification: behavior is unchanged. ### Tradeoff - One `Either`/match in every backing-storage method becomes one `is_empty` atomic load (`Relaxed` `AtomicBool`) in `should_restore` — essentially equivalent. - The backend is now stored inline in `TurboTasks` rather than behind a pointer: one fewer indirection on every backend access, at the cost of a larger `TurboTasks` struct. <!-- NEXT_JS_LLM_PR -->
139 lines
4.1 KiB
TOML
139 lines
4.1 KiB
TOML
[package]
|
|
edition = "2024"
|
|
name = "next-napi-bindings"
|
|
version = "0.0.0"
|
|
publish = false
|
|
|
|
[lib]
|
|
crate-type = ["cdylib"]
|
|
|
|
[features]
|
|
image-webp = ["next-core/image-webp"]
|
|
image-avif = ["next-core/image-avif"]
|
|
# Enable all the available image codec support.
|
|
# Currently this is identical to `image-webp`, as we are not able to build
|
|
# other codecs easily yet.
|
|
image-extended = ["image-webp"]
|
|
|
|
# Enable dhat profiling allocator for heap profiling.
|
|
__internal_dhat-heap = ["dhat"]
|
|
# Enable dhat profiling allocator for ad hoc profiling.
|
|
# [Note]: we do not have any ad hoc event in the codebase yet, so enabling this
|
|
# effectively does nothing.
|
|
__internal_dhat-ad-hoc = ["dhat"]
|
|
|
|
# Enable support for the tokio console: https://github.com/tokio-rs/console
|
|
tokio-console = ["dep:console-subscriber"]
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.cargo-shear]
|
|
ignored = [
|
|
# we need to set features on these packages when building for WASM, but we don't directly use them
|
|
"getrandom",
|
|
"iana-time-zone",
|
|
]
|
|
|
|
[dependencies]
|
|
anyhow = { workspace = true }
|
|
bincode = { workspace = true }
|
|
console-subscriber = { workspace = true, optional = true }
|
|
dhat = { workspace = true, optional = true }
|
|
flate2 = { workspace = true }
|
|
futures-util = { workspace = true }
|
|
owo-colors = { workspace = true }
|
|
napi = { workspace = true }
|
|
napi-derive = { workspace = true }
|
|
next-code-frame = { workspace = true }
|
|
next-custom-transforms = { workspace = true }
|
|
next-taskless = { workspace = true }
|
|
rand = { workspace = true }
|
|
rustc-hash = { workspace = true }
|
|
serde = "1"
|
|
serde_json = "1"
|
|
supports-hyperlinks = "3.1.0"
|
|
terminal_size = { workspace = true }
|
|
terminal_hyperlink = "0.1.0"
|
|
tracing = { workspace = true }
|
|
tracing-subscriber = { workspace = true }
|
|
tracing-chrome = "0.7.2"
|
|
url = { workspace = true }
|
|
urlencoding = { workspace = true }
|
|
regex = { workspace = true }
|
|
|
|
swc_core = { workspace = true, features = [
|
|
"base",
|
|
"base_module",
|
|
"common_concurrent",
|
|
"ecma_ast",
|
|
"ecma_ast_serde",
|
|
"ecma_codegen",
|
|
"ecma_helpers_inline",
|
|
"ecma_loader_lru",
|
|
"ecma_loader_node",
|
|
"ecma_minifier",
|
|
"ecma_parser",
|
|
"ecma_parser_typescript",
|
|
"ecma_transforms",
|
|
"ecma_transforms_optimization",
|
|
"ecma_transforms_react",
|
|
"ecma_transforms_typescript",
|
|
"ecma_utils",
|
|
"ecma_visit",
|
|
"__plugin_transform_host",
|
|
"__plugin_transform_host_schema_v1",
|
|
"plugin_transform_host_native_filesystem_cache",
|
|
] }
|
|
|
|
# Dependencies for the native, non-wasm32 build.
|
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
|
lightningcss-napi = { workspace = true }
|
|
lightningcss = { workspace = true }
|
|
swc_plugin_backend_wasmtime = { workspace = true }
|
|
tokio = { workspace = true, features = ["full"] }
|
|
turbo-rcstr = { workspace = true, features = ["napi"] }
|
|
turbo-tasks = { workspace = true }
|
|
turbo-tasks-backend = { workspace = true }
|
|
turbo-tasks-fs = { workspace = true }
|
|
turbo-unix-path = { workspace = true }
|
|
next-api = { workspace = true, features = ["worker_pool"] }
|
|
next-build = { workspace = true }
|
|
next-core = { workspace = true }
|
|
|
|
mdxjs = { workspace = true, features = ["serializable"] }
|
|
|
|
turbo-tasks-malloc = { workspace = true, default-features = false, features = [
|
|
"custom_allocator",
|
|
] }
|
|
|
|
turbopack-core = { workspace = true }
|
|
turbopack-ecmascript-hmr-protocol = { workspace = true }
|
|
turbopack-trace-utils = { workspace = true }
|
|
turbopack-trace-server = { workspace = true }
|
|
turbopack-node = { workspace = true, default-features = false, features = ["worker_pool"] }
|
|
|
|
[target.'cfg(windows)'.dependencies]
|
|
windows-sys = "0.60"
|
|
|
|
# Dependencies for the wasm32 build.
|
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
|
getrandom = { version = "0.2.9", default-features = false, features = ["js"] }
|
|
iana-time-zone = { version = "*", features = ["fallback"] }
|
|
|
|
mdxjs = { workspace = true }
|
|
|
|
turbo-tasks-malloc = { workspace = true, default-features = false }
|
|
|
|
# wasi-only dependencies.
|
|
[target.wasm32-wasip1-threads.dependencies]
|
|
# this requires tokio_unstable currently.
|
|
tokio = { workspace = true, features = ["full"] }
|
|
|
|
[build-dependencies]
|
|
anyhow = { workspace = true }
|
|
napi-build = { workspace = true }
|
|
serde = { workspace = true }
|
|
serde_json = { workspace = true }
|
|
vergen-gitcl = { workspace = true }
|