mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
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.
13 lines
411 B
Rust
13 lines
411 B
Rust
use std::path::PathBuf;
|
|
|
|
use dunce::canonicalize;
|
|
use once_cell::sync::Lazy;
|
|
use turbo_rcstr::RcStr;
|
|
|
|
/// The turbo repo root. Should be used as the root when building with turbopack
|
|
/// against fixtures in this crate.
|
|
pub static REPO_ROOT: Lazy<RcStr> = Lazy::new(|| {
|
|
let package_root = PathBuf::from(env!("TURBO_PNPM_WORKSPACE_DIR"));
|
|
canonicalize(package_root).unwrap().to_str().unwrap().into()
|
|
});
|