forked from vercel/next.js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(next-swc): introduce next-binding to consolidate dependencie…
…s. (vercel#43473) <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change that you're making: --> Partial solutions for WEB-225. One of the issue we want to improve is version bump process across multiple dependencies sharing same transitive dependencies. There were known cases of last-minute build failures of next-swc due to this. The biggest thing is we have lot of dependenceis rely on swc_core, and consolidating it altogether is tricky. PR introduces `next-binding`, which reexports all the related dependencies that next-swc and turbopack commonly uses. Unfortunately, this is not a complete solution, but at least it'll make `upfront` cost to turbopack when it try to update swc_core and others, so by the time upgrading it in next-swc we expect minimal friction. Note not 0 friction: due to how cargo behaves for the merging all of the features, there's still chances to have some build failures but meaningfully less I believe. I think the easiest way to describe before / after is having some diagrams. This is rather simplified to illustrate problems easily, i.e when it comes to actual build if there are same version of deps cargo will dedupe, so below illustaration only would occur for non-compatible version cases, etcs. **Before** ```mermaid graph TD A[next-swc] --> B(next-dev) A --> C(swc_core) A --> D(swc_emotion) D --> E(swc_core) A --> F(styled_jsx) F --> E A --> G(mdxrs) G --> H(swc_core) B --> I(swc_core) B --> J(swc_emotion) J --> K(swc_core) ``` **After** ```mermaid graph TD A[next-swc] --> B(next-binding) B --> C[swc_core] B --> D[swc_emotion] D --> I[swc_core] B --> H[styled_jsx] B --> F[next-dev] B --> J[node-file-trace] F --> C H --> I B --> E(mdxrs) E --> G(swc_core) ``` You can see repeated dependencies (`swc_core`, `swc_emotion`) occurs lot more in next-swc in `before`, including next-swc top level direct import itself. In result, update process have to align between next-swc, turbopack, swc-plugins and others. With newly proposed changes, `next-swc` no longer directly owns deps reduces those repetaed deps. At the moment of version bump, only `next-binding` need to be updated. This brings small caveat however : next-swc does not directly update `swc_core`, but have to bump turbopack and its transitive dependencies. Given our bump process usually requires to bump up turbopack anyway, I wouldn't consider this as hard blocking though.
- Loading branch information
Showing
34 changed files
with
181 additions
and
186 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use swc_core::{ | ||
use next_binding::swc::core::{ | ||
ecma::ast::*, | ||
ecma::visit::{Visit, VisitWith}, | ||
}; | ||
|
2 changes: 1 addition & 1 deletion
2
packages/next-swc/crates/core/src/disallow_re_export_all_in_page.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/next-swc/crates/core/src/next_font_loaders/find_functions_outside_module_scope.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/next-swc/crates/core/src/next_font_loaders/font_functions_collector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/next-swc/crates/core/src/next_font_loaders/font_imports_generator.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.