Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

# Build artifacts
/target/
/codemod/target/
/react-compiler/target/
/node_modules/
13 changes: 9 additions & 4 deletions codemod/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
//! - inherits version/edition/license/description/repository from `[workspace.package]`
//! - internal deps become `{ workspace = true }`
//! - any `regex` dep is swapped to a `regex-lite` package rename (import name kept)
//! - `publish` = true for `react_compiler` and its (transitive) deps; false for the rest
//! - `publish` = true for the publish roots (`react_compiler`, `react_compiler_swc`) and
//! their (transitive) deps; false for the rest
//! Root `[workspace.dependencies]` maps each import name to its published package:
//! `react_compiler_X = { package = "nextjs_react_compiler_X", version, path }`
//!
Expand All @@ -30,6 +31,10 @@ const EDITION: &str = "2024";
const LICENSE: &str = "MIT";
const DESCRIPTION: &str = "Rust port of the React Compiler, vendored from facebook/react.";
const REPOSITORY: &str = "https://github.com/vercel/forked-react-compiler";
/// Crates whose `publish` flag is set to `true` (along with their transitive
/// internal deps). Everything else gets `publish = false`. Import names (not
/// published `nextjs_*` names).
const PUBLISH_ROOTS: &[&str] = &["react_compiler", "react_compiler_swc"];
/// React's MIT LICENSE, kept as a local copy (`./LICENSE`) and linked into the
/// tool so syncing needs no network for it.
const LICENSE_TEXT: &str = include_str!("../../LICENSE");
Expand Down Expand Up @@ -176,8 +181,8 @@ fn edit_root_manifest(root: &Path, members: &[Member], version: &str) {
fs::write(&path, doc.to_string()).expect("write workspace Cargo.toml");
}

/// Crates reachable from `react_compiler` over internal `[dependencies]` /
/// `[build-dependencies]` — the set to publish — including `react_compiler` itself.
/// Crates to publish: the publish roots (`react_compiler`, `react_compiler_swc`) plus
/// everything reachable from them over internal `[dependencies]` / `[build-dependencies]`.
fn publish_closure(members: &[Member], internal: &BTreeSet<&str>) -> BTreeSet<String> {
let mut adjacency: HashMap<String, Vec<String>> = HashMap::new();
for member in members {
Expand All @@ -196,7 +201,7 @@ fn publish_closure(members: &[Member], internal: &BTreeSet<&str>) -> BTreeSet<St
}

let mut closure = BTreeSet::new();
let mut queue = VecDeque::from(["react_compiler".to_string()]);
let mut queue: VecDeque<_> = PUBLISH_ROOTS.iter().map(|s| s.to_string()).collect();
while let Some(name) = queue.pop_front() {
if !closure.insert(name.clone()) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion react-compiler/crates/react_compiler_swc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition.workspace = true
license.workspace = true
description.workspace = true
repository.workspace = true
publish = false
publish = true

[dependencies]
react_compiler_ast = { workspace = true }
Expand Down
Loading