Skip to content

feat(pack): bump turbopack & swc to v57#2668

Merged
xusd320 merged 3 commits intonextfrom
bump-next-js
Mar 9, 2026
Merged

feat(pack): bump turbopack & swc to v57#2668
xusd320 merged 3 commits intonextfrom
bump-next-js

Conversation

@fireairforce
Copy link
Contributor

@fireairforce fireairforce commented Mar 6, 2026

Summary

closes: #2657

  • 升级 next.js & turbopack
  • 升级 swc

Test Plan

@fireairforce fireairforce changed the title chore: bump turbopack & swc to v57 chore(pack): bump turbopack & swc to v57 Mar 6, 2026
@fireairforce fireairforce changed the title chore(pack): bump turbopack & swc to v57 feat(pack): bump turbopack & swc to v57 Mar 6, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on a significant version bump for Turbopack and SWC dependencies, bringing them up to version 57. This update necessitated extensive changes across various Rust crates, including core components, NAPI bindings, and testing infrastructure. Additionally, the PR introduces refactored NAPI integration for improved error handling and project lifecycle management, alongside a substantial overhaul of the HMR runtime logic to enhance its shared implementation and module update mechanisms.

Highlights

  • Dependency Updates: Bumped numerous Rust dependencies in Cargo.lock and Cargo.toml, including major version updates for swc_core (from 54.0.0 to 57.0.0/57.0.1), modularize_imports, remove_console, styled_components, styled_jsx, swc_emotion, swc_relay, preset_env_base, lzzzz, ringmap, swc, swc_compiler_base, swc_css_prefixer, and various swc_ecma_* crates.
  • NAPI Integration Enhancements: Introduced new NAPI-related types (TurbopackContext, NapiTurbopackCallbacks, DetachedVc) and refactored project initialization and error handling to improve robustness and provide better internal error reporting to JavaScript.
  • HMR Runtime Refactoring: Significantly refactored the Hot Module Replacement (HMR) runtime logic in JavaScript, introducing shared HMR implementation, new module instantiation types (SourceType, createModuleWithDirectionFlag), and improved handling of module factories and dependency tracking during updates.
  • Project Initialization and Configuration: Updated ProjectContainer initialization and update methods to use OperationVc and improved tracing for environment variable changes. Added PluginRuntimeStrategy to pack-core configuration.
  • Endpoint Handling Refinement: Modified endpoint handling in pack-api to introduce OptionEndpoint for better representation of optional endpoints and updated related operations to handle this new type, including a NotFound variant for output paths.
Changelog
  • Cargo.lock
    • Updated arc-swap from 1.7.1 to 1.8.2 and added rustversion dependency.
    • Updated bitfield and bitfield-macros from 0.18.1 to 0.19.4.
    • Added new package chacha20 version 0.10.0 with its dependencies.
    • Updated hashbrown from 0.16.0 to 0.16.1 across multiple entries.
    • Added new package cpufeatures version 0.3.0.
    • Added new package getrandom version 0.4.2 with its dependencies.
    • Updated indexmap from 2.11.4 to 2.13.0 across multiple entries.
    • Updated lzzzz from 1.1.0 to 2.0.0.
    • Updated modularize_imports from 0.108.0 to 0.110.0 and removed version specifiers for swc_ecma_ast and swc_ecma_visit.
    • Updated preset_env_base from 6.0.0 to 7.0.0.
    • Added new package r-efi version 6.0.0.
    • Added new package rand version 0.10.0 with its dependencies.
    • Added new package rand_core version 0.10.0.
    • Updated remove_console from 0.63.0 to 0.66.0 and removed version specifiers for swc_ecma_ast and swc_ecma_visit.
    • Updated ringmap from 0.1.8 to 0.2.3.
    • Updated rustc-hash dependency cpufeatures to version 0.2.17.
    • Updated styled_components from 0.136.0 to 0.139.0.
    • Updated styled_jsx from 0.111.0 to 0.114.0 and removed version specifiers for swc_ecma_ast, swc_ecma_utils, swc_ecma_visit.
    • Updated swc from 52.0.0 to 55.0.0, with various swc_ecma_* dependency updates.
    • Updated swc_compiler_base from 45.0.0 to 48.0.0, with various swc_ecma_* dependency updates.
    • Updated swc_core from 54.0.0 to 57.0.1 (and added 56.0.0 entry), with numerous swc_ecma_* dependency updates.
    • Updated swc_css_prefixer from 21.0.0 to 22.0.0.
    • Updated swc_ecma_ast from 19.0.0 to 20.0.1.
    • Removed swc_ecma_codegen version 21.0.0 entry.
    • Updated swc_ecma_compat_bugfixes from 39.0.0 to 42.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_compat_common from 30.0.0 to 33.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_compat_es2015 from 39.0.0 to 42.0.0.
    • Updated swc_ecma_compat_es2016 from 35.0.0 to 38.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_compat_es2017 from 35.0.0 to 38.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_compat_es2018 from 36.0.0 to 39.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_compat_es2019 from 35.0.0 to 38.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_compat_es2020 from 37.0.0 to 40.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_compat_es2021 from 35.0.0 to 38.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_compat_es2022 from 37.0.0 to 40.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Removed swc_ecma_compat_es3 package entry.
    • Added new package swc_ecma_compat_regexp version 1.0.0.
    • Updated swc_ecma_ext_transforms from 25.0.0 to 26.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_hooks from 0.3.0 to 0.4.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_lints from 26.0.0 to 27.0.0.
    • Updated swc_ecma_minifier from 41.0.1 to 45.0.1, removing version 42.0.0 entry and updating swc_ecma_* dependencies.
    • Updated swc_ecma_parser from 31.0.0 to 34.0.0, removing versions 32.0.0 and 33.0.1 entries and updating swc_ecma_ast dependency.
    • Updated swc_ecma_preset_env from 45.0.0 to 48.0.0.
    • Updated swc_ecma_quote_macros from 32.0.0 to 34.0.0, updating swc_ecma_* dependencies.
    • Added new package swc_ecma_regexp version 0.7.0 and its related _ast, _common, _visit packages.
    • Updated swc_ecma_transformer from 6.0.0 to 9.0.0, updating swc_ecma_* dependencies and adding new swc_ecma_compat_regexp, swc_ecma_regexp dependencies.
    • Updated swc_ecma_transforms from 43.0.0 to 47.0.0, removing version 44.0.0 entry and updating swc_ecma_* dependencies.
    • Updated swc_ecma_transforms_base from 34.0.0 to 37.0.0, updating indexmap and swc_ecma_* dependencies.
    • Updated swc_ecma_transforms_classes from 35.0.0 to 37.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_transforms_compat from 40.0.0 to 43.0.0, removing swc_ecma_compat_es3 and updating indexmap and swc_ecma_* dependencies.
    • Removed swc_ecma_transforms_module package entry.
    • Updated swc_ecma_transforms_optimization from 36.0.0 to 39.0.0, removing version 37.0.0 entry and updating indexmap and swc_ecma_* dependencies.
    • Updated swc_ecma_transforms_proposal from 35.0.0 to 37.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_transforms_react from 38.0.0 to 41.0.1, updating indexmap and swc_ecma_* dependencies.
    • Updated swc_ecma_transforms_typescript from 38.0.0 to 41.0.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_usage_analyzer from 27.0.0 to 28.0.0, updating indexmap and swc_ecma_* dependencies.
    • Removed swc_ecma_utils version 25.0.0 entry, updated version 26.0.1 entry, and removed version specifiers for swc_ecma_* dependencies.
    • Updated swc_ecma_visit from 19.0.0 to 20.0.0, removing version specifier for swc_ecma_ast.
    • Updated swc_emotion from 0.112.0 to 0.115.0, removing version specifiers for swc_ecma_* dependencies.
    • Updated swc_plugin_backend_wasmer from 6.0.0 to 7.0.0.
    • Updated swc_plugin_proxy from 19.0.0 to 20.0.0, removing version specifier for swc_ecma_ast.
    • Updated swc_plugin_runner from 23.0.0 to 24.0.0, removing version specifier for swc_ecma_ast.
    • Updated swc_relay from 0.82.0 to 0.85.0, removing version specifiers for swc_ecma_* dependencies.
    • Added bincode, data-encoding, sha2 dependencies to turbo-tasks-hash.
    • Added indexmap dependency to turbo-tasks-macros.
    • Removed turbopack-json package entry.
    • Updated turbopack-core with swc_core bump, turbo-esregex addition, and twox-hash removal.
    • Added turbopack-css dependency.
    • Updated turbopack-ecmascript with swc_core bump.
    • Added serde, serde_json, serde_qs dependencies to turbopack-node.
    • Updated turbopack-wasm with swc_core bump.
    • Updated turbopack-binding with indexmap bump.
    • Updated wasip2 with wit-bindgen bump.
    • Added new package wasip3 version 0.4.0.
    • Added new package wasm-encoder version 0.244.0.
    • Added new package wasm-metadata version 0.244.0.
    • Updated wasm-bindgen and related macros with indexmap bumps.
    • Added new package wasmparser version 0.244.0.
    • Updated wit-bindgen from 0.46.0 to 0.51.0.
    • Added new packages wit-bindgen-core, wit-bindgen-rust, wit-bindgen-rust-macro version 0.51.0.
    • Added new package wit-component version 0.244.0.
    • Added new package wit-parser version 0.244.0.
  • Cargo.toml
    • Added futures-util dependency.
    • Added napi and napi-derive dependencies with specific features.
    • Updated swc_core from 54.0.0 to 57.0.0.
    • Updated modularize_imports from 0.108.0 to 0.110.0.
    • Updated remove_console from 0.63.0 to 0.66.0.
    • Updated styled_components from 0.136.0 to 0.139.0.
    • Updated styled_jsx from 0.111.0 to 0.114.0.
    • Updated swc_emotion from 0.112.0 to 0.115.0.
    • Updated swc_relay from 0.82.0 to 0.85.0.
  • crates/pack-api/Cargo.toml
    • Added either, napi, and napi-derive as workspace dependencies.
    • Introduced default, process_pool, and worker_pool features.
  • crates/pack-api/src/app.rs
    • Updated server_entry_path assignment to use clone() instead of to_string().
  • crates/pack-api/src/endpoint.rs
    • Added NotFound variant to EndpointOutputPaths enum.
    • Refactored endpoint_server_changed_operation and endpoint_write_to_disk_operation to accept OptionEndpoint and handle optional endpoints.
    • Introduced OptionEndpoint struct.
    • Updated get_written_endpoint_with_issues_operation to use OptionEndpoint.
  • crates/pack-api/src/library.rs
    • Updated server_entry_path assignment to use path.clone() instead of to_string().
  • crates/pack-api/src/operation.rs
    • Imported OptionEndpoint.
    • Modified EntrypointsOperation to use OperationVc<OptionEndpoint> for apps and libraries.
    • Refactored EntrypointsOperation::new to use wrap_as_option_endpoint and empty_option_endpoint.
    • Renamed wrap function to wrap_as_option_endpoint and adjusted its return type.
    • Added empty_option_endpoint function.
    • Removed LibraryOperation and AppOperation structs.
  • crates/pack-api/src/project.rs
    • Added bincode::{Decode, Encode} and rustc_hash::FxHashMap imports.
    • Conditionally imported PluginRuntimeStrategy, child_process_backend, and worker_threads_backend based on features.
    • Extended WatchOptions and ProjectOptions with additional derives for serialization and tracing.
    • Renamed ProjectContainer::new to new_operation and marked it as an operation.
    • Added project_operation function.
    • Refactored ProjectContainer::initialize and ProjectContainer::update for improved tracing and consistency handling.
    • Added node_backend parameter to Project::execution_context.
    • Removed mark_root() from whole_app_module_graph_operation.
    • Implemented scaling down/zero of Node.js process pools in Project::whole_app_module_graph_operation.
  • crates/pack-api/src/tasks.rs
    • Introduced UtooTurboTasks type alias.
    • Defined new structs: TurbopackContext, NapiTurbopackCallbacks, TurbopackInternalErrorOpts, TurboContextInner, NapiTurbopackCallbacksJsObject for NAPI integration.
    • Refactored BundlerTurboTasks to be a type alias for UtooTurboTasks.
    • Updated RootTask to use turbopack_ctx instead of turbo_tasks.
  • crates/pack-api/src/utils.rs
    • Imported OptionEndpoint.
    • Updated subscribe_issues_and_diags_operation and endpoint_client_changed_operation to use OperationVc<OptionEndpoint>.
  • crates/pack-core/Cargo.toml
    • Added default, process_pool, and worker_pool features.
  • crates/pack-core/src/config.rs
    • Added plugin_runtime_strategy field to Config struct.
    • Introduced PluginRuntimeStrategy enum.
    • Added Config::plugin_runtime_strategy function.
  • crates/pack-core/src/import_map.rs
    • Modified get_postcss_package_mapping to return ImportMapping::External.
  • crates/pack-core/src/library/chunking_context.rs
    • Updated ChunkingContext::get_async_module_chunk_item to use ManifestLoaderModule and handle manifest_chunks.
    • Changed ChunkingContext::asset_path to accept Vc<RcStr> for content_hash.
  • crates/pack-core/src/shared/resolve/externals_plugin.rs
    • Updated ResolveResult::primary calls to return cell().
  • crates/pack-core/src/shared/transforms/swc_ecma_transform_plugins.rs
    • Removed ValueToString import.
    • Adjusted import path for handle_resolve_error.
    • Replaced bail! with turbo_tasks::turbobail!.
  • crates/pack-core/src/shared/webpack_rules/mod.rs
    • Updated ResolveResult::primary call to return resolved_cell().
  • crates/pack-napi/Cargo.toml
    • Migrated napi and napi-derive to workspace dependencies.
    • Added either and futures-util as workspace dependencies.
  • crates/pack-napi/src/pack_api/endpoint.rs
    • Imported DetachedVc.
    • Updated ExternalEndpoint to wrap DetachedVc<OptionEndpoint>.
    • Adjusted NapiWrittenEndpoint::from to handle server_entry_path as owned and EndpointOutputPaths::NotFound.
    • Modified endpoint_write_to_disk to use turbopack_ctx for error handling.
    • Changed endpoint_server_changed_subscribe and endpoint_client_changed_subscribe to use turbopack_ctx.
    • Updated tracing span for server changes subscription to info_span.
  • crates/pack-napi/src/pack_api/project.rs
    • Imported Env, JsObject, NapiTurbopackCallbacksJsObject, TurbopackContext.
    • Refactored project_new to accept NAPI callbacks and return JsObject, using TurbopackContext.
    • Updated project_update, project_shutdown, project_write_all_entrypoints_to_disk, and subscription functions to use turbopack_ctx.
  • crates/pack-napi/src/pack_api/utils.rs
    • Imported either::Either, TurbopackContext, UtooTurboTasks.
    • Modified create_turbo_tasks to return UtooTurboTasks and use Either for backend storage.
    • Updated root_task_dispose to use turbopack_ctx.
    • Refactored subscribe function to accept TurbopackContext and improve error handling.
  • crates/pack-napi/src/util.rs
    • Imported pack_api::tasks::TurbopackContext and turbo_tasks::OperationVc.
    • Introduced DetachedVc struct for NAPI-compatible OperationVc.
  • crates/pack-tests/tests/snapshot.rs
    • Updated apply_effects to get_effects and apply() for effects handling.
    • Removed run_inner_options function.
    • Modified run_test_operation to use new_operation and initialize for ProjectContainer.
  • crates/pack-tests/tests/snapshot/basic/alias/output/_project___ce347b56.js
    • Renamed to _project___63bc685e.js and updated module IDs and imports.
  • crates/pack-tests/tests/snapshot/basic/alias/output/_project___ce347b56.js.map
    • Renamed to _project___63bc685e.js.map and updated module IDs.
  • crates/pack-tests/tests/snapshot/public_path/basic/output/asset.c77b3abb.jpg
    • Renamed to asset.99aa06d3.jpg.
  • crates/pack-tests/tests/snapshot/public_path/basic/output/input_2d0fce75.js
    • Updated asset hash in __turbopack_context__.q.
  • crates/pack-tests/tests/snapshot/public_path/basic/output/main.js
    • Added SourceType enum and createModuleWithDirectionFlag variable.
    • Modified HMR runtime logic for module creation and factory installation.
    • Updated asset hash in __turbopack_context__.q.
  • crates/pack-tests/tests/snapshot/public_path/runtime/output/asset.c77b3abb.jpg
    • Renamed to asset.99aa06d3.jpg.
  • crates/pack-tests/tests/snapshot/public_path/runtime/output/input_066096ff.js
    • Updated asset hash in __turbopack_context__.v.
  • crates/pack-tests/tests/snapshot/public_path/runtime/output/main.js
    • Updated HMR runtime logic, similar to public_path/basic/output/main.js.
  • crates/pack-tests/tests/snapshot/runtime/app_build_runtime/output/main.js
    • Updated HMR runtime logic, similar to public_path/basic/output/main.js.
  • crates/pack-tests/tests/snapshot/runtime/app_dev_runtime/output/main.js
    • Extensively refactored HMR runtime logic, including shared implementation and module state management.
  • crates/pack-tests/tests/snapshot/runtime/export_entry_exports/output/main.js
    • Updated HMR runtime logic, similar to public_path/basic/output/main.js.
  • crates/pack-tests/tests/snapshot/static-assets/json/output/input_Regular_Expressions__JavaScript__tmLanguage_json_9fc1399f.js
    • Removed file.
  • crates/pack-tests/tests/snapshot/static-assets/json/output/input_Regular_Expressions__JavaScript__tmLanguage_json__json__cjs_4cbe784c.js
    • Added new file.
  • crates/pack-tests/tests/snapshot/static-assets/json/output/input_c20e9166.js
    • Renamed to input_b3a6c9f5.js and updated module IDs and imports.
  • crates/pack-tests/tests/snapshot/static-assets/json/output/main.js
    • Updated otherChunks to reflect renamed file.
  • crates/pack-tests/tests/snapshot/static-assets/wasm/output/_project___f7b60d6e.js
    • Updated asset hash in __turbopack_context__.q.
  • crates/pack-tests/tests/snapshot/static-assets/wasm/output/onig.86e14394.wasm
    • Renamed to onig.06d92f9f.wasm.
  • next.js
    • Updated subproject commit from b3e4599d2d02be2c18243afba5108199b9fb5611 to 8c97e3a56323a0f32044e78f4ce0b07bcb961b6a.
  • packages/pack/src/binding.d.ts
    • Added TurbopackInternalErrorOpts and NapiTurbopackCallbacksJsObject interfaces.
    • Updated projectNew function signature to include napiCallbacks.
  • packages/pack/src/core/project.ts
    • Imported TurbopackInternalErrorOpts.
    • Updated TurbopackInternalError constructor to accept TurbopackInternalErrorOpts.
    • Added throwTurbopackInternalError function.
    • Modified withErrorCause to use the new TurbopackInternalError constructor.
    • Updated projectFactory to pass throwTurbopackInternalError to binding.projectNew.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request primarily involves updating Turbopack and SWC dependencies, leading to significant refactoring, an improved project initialization and update flow, the introduction of a TurbopackContext for better state management within the NAPI layer, and a new plugin execution strategy. A security audit identified a potential path traversal vulnerability where the TURBOPACK_TASK_STATISTICS environment variable is used to specify an arbitrary file path for writing task statistics without proper validation, which could allow an attacker to overwrite sensitive files. Additionally, the review identified a potential compilation error due to a typo and a significant logical change in how entrypoints are handled, which might be an unintended regression.

@fireairforce fireairforce force-pushed the bump-next-js branch 3 times, most recently from f98c4fc to 9c00f89 Compare March 7, 2026 17:51
Previously, path.write() effects emitted inside snapshot_issues() were
collected as collectibles of inner_operation itself, but only get_effects(out_op)
(the bundler operation) was applied. This meant UPDATE=1 tests would
pass without ever writing the issues files to disk.

Fix: wrap snapshot_issues in its own turbo_tasks operation
(snapshot_issues_operation). Its path.write() effects become collectibles
of that sub-operation. Inside inner_operation (a turbo-tasks function,
not a top-level task) we can legally call get_effects(snap_op).apply()
to flush those writes before returning the bundler effects.

Also adds the style/less issues snapshot file generated by this fix.
@xusd320 xusd320 merged commit c4af747 into next Mar 9, 2026
31 of 32 checks passed
@xusd320 xusd320 deleted the bump-next-js branch March 9, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Utoopack] unexpected crash on nodejs@22

2 participants