Skip to content

Commit

Permalink
refactor(turbo-rcstr): Move turbo_tasks::RcStr into it's own crate (#…
Browse files Browse the repository at this point in the history
…72858)

The `RcStr` type doesn't use anything in `turbo-tasks`, so there's no reason it can't be a separate crate that doesn't depend on `turbo-tasks`.

This will let it be used in wasm swc plugins, where turbo-tasks does not currently compile.

Imports were automatically rewritten with:

```
# Fix imports:
sg run --lang rust --pattern 'use $CRATE::{$$$PRE, RcStr};' --rewrite 'use $CRATE::{$$$PRE}; use turbo_rcstr::RcStr;' --update-all
sg run --lang rust --pattern 'use $CRATE::{RcStr, $$$POST};' --rewrite 'use $CRATE::{$$$POST}; use turbo_rcstr::RcStr;' --update-all
sg run --lang rust --pattern 'use $CRATE::{$$$PRE, RcStr, $$$POST};' --rewrite 'use $CRATE::{$$$PRE, $$$POST}; use turbo_rcstr::RcStr;' --update-all
sg run --lang rust --pattern 'use $CRATE::RcStr;' --rewrite 'use turbo_rcstr::RcStr;' --update-all
cargo fmt

# Fix strings in comments:
fastmod crate::RcStr turbo_rcstr::RcStr
fastmod turbo_tasks::RcStr turbo_rcstr::RcStr
```

I had to manually fix the `Cargo.toml` files based on the compilation errors.
  • Loading branch information
bgw authored and wyattjoh committed Nov 28, 2024
1 parent 177a7e4 commit 3291d1f
Show file tree
Hide file tree
Showing 305 changed files with 638 additions and 313 deletions.
40 changes: 40 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ next-custom-transforms = { path = "crates/next-custom-transforms" }
auto-hash-map = { path = "turbopack/crates/turbo-tasks-auto-hash-map" }
swc-ast-explorer = { path = "turbopack/crates/turbopack-swc-ast-explorer" }
turbo-prehash = { path = "turbopack/crates/turbo-prehash" }
turbo-rcstr = { path = "turbopack/crates/turbo-rcstr" }
turbo-tasks-malloc = { path = "turbopack/crates/turbo-tasks-malloc", default-features = false }
turbo-tasks = { path = "turbopack/crates/turbo-tasks" }
turbo-tasks-backend = { path = "turbopack/crates/turbo-tasks-backend" }
Expand Down
1 change: 1 addition & 0 deletions crates/napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ swc_core = { workspace = true, features = [
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
lightningcss-napi = { workspace = true }
tokio = { workspace = true, features = ["full"] }
turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true }
turbo-tasks-memory = { workspace = true }
turbo-tasks-backend = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/napi/src/next_api/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use rand::Rng;
use tokio::{io::AsyncWriteExt, time::Instant};
use tracing::Instrument;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry};
use turbo_tasks::{Completion, RcStr, ReadRef, TransientInstance, UpdateInfo, Vc};
use turbo_rcstr::RcStr;
use turbo_tasks::{Completion, ReadRef, TransientInstance, UpdateInfo, Vc};
use turbo_tasks_fs::{
util::uri_from_file, DiskFileSystem, FileContent, FileSystem, FileSystemPath,
};
Expand Down
1 change: 1 addition & 0 deletions crates/next-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
shadow-rs = { workspace = true }
tracing = { workspace = true }
turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true }
turbo-tasks-env = { workspace = true }
turbo-tasks-fs = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ use next_core::{
};
use serde::{Deserialize, Serialize};
use tracing::Instrument;
use turbo_rcstr::RcStr;
use turbo_tasks::{
fxindexset, trace::TraceRawVcs, Completion, FxIndexMap, FxIndexSet, RcStr, ResolvedVc,
TryJoinIterExt, Value, ValueToString, Vc,
fxindexset, trace::TraceRawVcs, Completion, FxIndexMap, FxIndexSet, ResolvedVc, TryJoinIterExt,
Value, ValueToString, Vc,
};
use turbo_tasks_env::{CustomProcessEnv, ProcessEnv};
use turbo_tasks_fs::{File, FileContent, FileSystemPath};
Expand Down
3 changes: 2 additions & 1 deletion crates/next-api/src/dynamic_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ use swc_core::ecma::{
visit::{Visit, VisitWith},
};
use tracing::{Instrument, Level};
use turbo_rcstr::RcStr;
use turbo_tasks::{
graph::{GraphTraversal, NonDeterministic, VisitControlFlow, VisitedNodes},
trace::TraceRawVcs,
FxIndexMap, RcStr, ReadRef, ResolvedVc, TryJoinIterExt, Value, ValueToString, Vc,
FxIndexMap, ReadRef, ResolvedVc, TryJoinIterExt, Value, ValueToString, Vc,
};
use turbopack_core::{
chunk::{
Expand Down
3 changes: 2 additions & 1 deletion crates/next-api/src/entrypoints.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use turbo_tasks::{FxIndexMap, RcStr, Vc};
use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, Vc};

use crate::{
project::{Instrumentation, Middleware},
Expand Down
3 changes: 2 additions & 1 deletion crates/next-api/src/font.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::Result;
use next_core::{all_assets_from_entries, next_manifests::NextFontManifest};
use turbo_tasks::{RcStr, ResolvedVc, ValueToString, Vc};
use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbo_tasks_fs::{File, FileSystemPath};
use turbopack_core::{
asset::AssetContent,
Expand Down
3 changes: 2 additions & 1 deletion crates/next-api/src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use next_core::{
next_server::{get_server_runtime_entries, ServerContextType},
};
use tracing::Instrument;
use turbo_tasks::{Completion, RcStr, ResolvedVc, Value, Vc};
use turbo_rcstr::RcStr;
use turbo_tasks::{Completion, ResolvedVc, Value, Vc};
use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use turbopack_core::{
asset::AssetContent,
Expand Down
3 changes: 2 additions & 1 deletion crates/next-api/src/loadable_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::collections::HashMap;

use anyhow::Result;
use next_core::next_manifests::LoadableManifest;
use turbo_tasks::{RcStr, ResolvedVc, TryFlatJoinIterExt, Vc};
use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, Vc};
use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use turbopack_core::{
asset::AssetContent,
Expand Down
3 changes: 2 additions & 1 deletion crates/next-api/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use next_core::{
util::{parse_config_from_source, MiddlewareMatcherKind},
};
use tracing::Instrument;
use turbo_tasks::{Completion, RcStr, ResolvedVc, Value, Vc};
use turbo_rcstr::RcStr;
use turbo_tasks::{Completion, ResolvedVc, Value, Vc};
use turbo_tasks_fs::{self, File, FileContent, FileSystemPath};
use turbopack_core::{
asset::AssetContent,
Expand Down
3 changes: 2 additions & 1 deletion crates/next-api/src/nft_json.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{bail, Result};
use serde_json::json;
use turbo_tasks::{RcStr, ResolvedVc, ValueToString, Vc};
use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbo_tasks_fs::{DiskFileSystem, File, FileSystem, FileSystemPath, VirtualFileSystem};
use turbopack_core::{
asset::{Asset, AssetContent},
Expand Down
4 changes: 2 additions & 2 deletions crates/next-api/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ use next_core::{
};
use serde::{Deserialize, Serialize};
use tracing::Instrument;
use turbo_rcstr::RcStr;
use turbo_tasks::{
trace::TraceRawVcs, Completion, FxIndexMap, RcStr, ResolvedVc, TaskInput, TryJoinIterExt,
Value, Vc,
trace::TraceRawVcs, Completion, FxIndexMap, ResolvedVc, TaskInput, TryJoinIterExt, Value, Vc,
};
use turbo_tasks_fs::{
self, File, FileContent, FileSystem, FileSystemPath, FileSystemPathOption, VirtualFileSystem,
Expand Down
Loading

0 comments on commit 3291d1f

Please sign in to comment.