Skip to content

Commit abdbdb7

Browse files
authored
Turbopack: chore: Remove the serde_regex dependency, which wasn't very heavily used (#85578)
It doesn't seem like it's worth pulling in this dependency anymore. Most of the places we need to serialize a regex, we use `EsRegex`, which handles serialization itself, and is a superset of `Regex`.
1 parent 7fef3a0 commit abdbdb7

File tree

4 files changed

+3
-43
lines changed

4 files changed

+3
-43
lines changed

Cargo.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbopack/crates/turbo-tasks/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ regex = { workspace = true }
3939
rustc-hash = { workspace = true }
4040
serde = { workspace = true, features = ["rc", "derive"] }
4141
serde_json = { workspace = true }
42-
serde_regex = "1.1.0"
4342
shrink-to-fit = { workspace=true,features = ["indexmap", "serde_json", "smallvec", "nightly"] }
4443
smallvec = { workspace = true }
4544
thiserror = { workspace = true }

turbopack/crates/turbo-tasks/src/primitives.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{ops::Deref, time::Duration};
1+
use std::time::Duration;
22

33
use turbo_rcstr::RcStr;
44
use turbo_tasks_macros::primitive as __turbo_tasks_internal_primitive;
@@ -33,27 +33,3 @@ __turbo_tasks_internal_primitive!(serde_json::Value);
3333
__turbo_tasks_internal_primitive!(Duration);
3434
__turbo_tasks_internal_primitive!(Vec<u8>, manual_shrink_to_fit);
3535
__turbo_tasks_internal_primitive!(Vec<bool>, manual_shrink_to_fit);
36-
37-
#[turbo_tasks::value(transparent, eq = "manual")]
38-
#[derive(Debug, Clone)]
39-
pub struct Regex(
40-
#[turbo_tasks(trace_ignore)]
41-
#[serde(with = "serde_regex")]
42-
pub regex::Regex,
43-
);
44-
45-
impl Deref for Regex {
46-
type Target = regex::Regex;
47-
48-
fn deref(&self) -> &Self::Target {
49-
&self.0
50-
}
51-
}
52-
53-
impl PartialEq for Regex {
54-
fn eq(&self, other: &Regex) -> bool {
55-
// Context: https://github.com/rust-lang/regex/issues/313#issuecomment-269898900
56-
self.0.as_str() == other.0.as_str()
57-
}
58-
}
59-
impl Eq for Regex {}

turbopack/crates/turbopack/src/module_options/rule_condition.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use std::{
33
mem::{replace, take},
44
};
55

6-
use anyhow::{Result, bail};
6+
use anyhow::Result;
77
use either::Either;
88
use serde::{Deserialize, Serialize};
99
use smallvec::SmallVec;
1010
use turbo_esregex::EsRegex;
11-
use turbo_tasks::{NonLocalValue, ReadRef, ResolvedVc, primitives::Regex, trace::TraceRawVcs};
11+
use turbo_tasks::{NonLocalValue, ReadRef, ResolvedVc, trace::TraceRawVcs};
1212
use turbo_tasks_fs::{FileContent, FileSystemPath, glob::Glob};
1313
use turbopack_core::{
1414
asset::Asset, reference_type::ReferenceType, source::Source, virtual_source::VirtualSource,
@@ -30,7 +30,6 @@ pub enum RuleCondition {
3030
ResourcePathInExactDirectory(FileSystemPath),
3131
ContentTypeStartsWith(String),
3232
ContentTypeEmpty,
33-
ResourcePathRegex(#[turbo_tasks(trace_ignore)] Regex),
3433
ResourcePathEsRegex(#[turbo_tasks(trace_ignore)] ReadRef<EsRegex>),
3534
ResourceContentEsRegex(#[turbo_tasks(trace_ignore)] ReadRef<EsRegex>),
3635
/// For paths that are within the same filesystem as the `base`, it need to
@@ -268,9 +267,6 @@ impl RuleCondition {
268267
.map_or(path.path.as_str(), |(_, b)| b);
269268
return Ok(glob.matches(basename));
270269
}
271-
RuleCondition::ResourcePathRegex(_) => {
272-
bail!("ResourcePathRegex not implemented yet");
273-
}
274270
RuleCondition::ResourcePathEsRegex(regex) => {
275271
return Ok(regex.is_match(&path.path));
276272
}

0 commit comments

Comments
 (0)