Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
21 changes: 0 additions & 21 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions src/base64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ thiserror.workspace = true

bun_simdutf_sys.workspace = true
bun_collections.workspace = true
# `wyhash_url_safe` (CSS-modules / dependency placeholder hasher) — leaf crates,
# no cycle.
# `wyhash_url_safe` (CSS-modules hasher) — leaf crates, no cycle.
bun_wyhash.workspace = true
bun_alloc.workspace = true
5 changes: 0 additions & 5 deletions src/bun_core/env_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ new!(pub BUN_INSTALL_STREAMING_MIN_SIZE: unsigned, "BUN_INSTALL_STREAMING_MIN_SI
// thread schedules a drain; collapses the per-chunk thread-pool futex wake
// into roughly one per `threshold` bytes.
new!(pub BUN_INSTALL_STREAMING_DRAIN_THRESHOLD: unsigned, "BUN_INSTALL_STREAMING_DRAIN_THRESHOLD", { default: 256 * 1024 });
new!(pub BUN_NEEDS_PROC_SELF_WORKAROUND: boolean, "BUN_NEEDS_PROC_SELF_WORKAROUND", { default: false });
new!(pub BUN_OPTIONS: string, "BUN_OPTIONS", {});
new!(pub BUN_POSTGRES_SOCKET_MONITOR: string, "BUN_POSTGRES_SOCKET_MONITOR", {});
new!(pub BUN_POSTGRES_SOCKET_MONITOR_READER: string, "BUN_POSTGRES_SOCKET_MONITOR_READER", {});
Expand Down Expand Up @@ -147,9 +146,6 @@ platform_specific_new!(pub HOME: string, posix = "HOME", windows = "USERPROFILE"
new!(pub HYPERFINE_RANDOMIZED_ENVIRONMENT_OFFSET: string, "HYPERFINE_RANDOMIZED_ENVIRONMENT_OFFSET", {});
new!(pub IS_BUN_AUTO_UPDATE: boolean, "IS_BUN_AUTO_UPDATE", { default: false });
new!(pub JENKINS_URL: string, "JENKINS_URL", {});
// Dump mimalloc statistics at the end of the process. Note that this is not the same as
// `MIMALLOC_VERBOSE`, documented here: https://microsoft.github.io/mimalloc/environment.html
new!(pub MI_VERBOSE: boolean, "MI_VERBOSE", { default: false });
new!(pub NO_COLOR: boolean, "NO_COLOR", { default: false });
new!(pub NODE_CHANNEL_FD: string, "NODE_CHANNEL_FD", {});
// A string, not a boolean: node suppresses warnings only when the value is
Expand All @@ -175,7 +171,6 @@ new!(pub TERM_PROGRAM: string, "TERM_PROGRAM", {});
platform_specific_new!(pub TMP: string, posix = "TMP", windows = "TMP", {});
platform_specific_new!(pub TMPDIR: string, posix = "TMPDIR", windows = "TMPDIR", {});
new!(pub TMUX: string, "TMUX", {});
new!(pub TODIUM: string, "TODIUM", {});
platform_specific_new!(pub USER: string, posix = "USER", windows = "USERNAME", {});
new!(pub WANTS_LOUD: boolean, "WANTS_LOUD", { default: false });
// The same as system_root.
Expand Down
17 changes: 0 additions & 17 deletions src/bun_core/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,23 +1269,6 @@ impl Stdio {
}
}

/// Niche-packed `Option<Fd>`: the invalid-fd bit pattern is the `none` sentinel.
/// Use instead of encoding the invalid value directly.
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct FdOptional(FdBacking);
impl FdOptional {
pub const NONE: FdOptional = FdOptional(Fd::INVALID.0);
#[inline]
pub const fn unwrap(self) -> Option<Fd> {
if self.0 == FdOptional::NONE.0 {
None
} else {
Some(Fd(self.0))
}
}
}

/// Best-effort fd → path. Returns bytes written (>0), 0 on misc failure,
/// -1 on EBADF/ENOENT (caller may render `[BADF]`). Body is libc-only
/// (`readlink("/proc/self/fd/N")` on Linux, `fcntl(F_GETPATH)` on macOS,
Expand Down
2 changes: 0 additions & 2 deletions src/collections/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ path = "lib.rs"
workspace = true

[dependencies]
strum.workspace = true
# `raw-entry` powers `StringHashMap::{get_hashed, put_static_key_hashed}` — the
# precomputed-hash probe/insert path the resolver's `DirEntry::add_entry` hot
# loop uses so it hashes each basename once instead of on every lookup + insert.
Expand All @@ -29,6 +28,5 @@ bun_wyhash.workspace = true
bun_ptr.workspace = true
rustc-hash = "2"

thiserror.workspace = true

bun_simdutf_sys.workspace = true
5 changes: 0 additions & 5 deletions src/css/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ thiserror.workspace = true
strum.workspace = true
bstr.workspace = true
scopeguard.workspace = true
const_format.workspace = true
enum-map.workspace = true
enumset.workspace = true
libc.workspace = true
bitflags.workspace = true
typed-arena.workspace = true
bun_base64.workspace = true
bun_alloc.workspace = true
bun_core.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions src/css/css_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,7 @@ impl<'a> CssModuleReference<'a> {
/// LAYERING: canonical implementation lives in `bun_base64::wyhash_url_safe`
/// (a leaf crate) so `bun_bundler::LinkerContext::mangle_local_css` can call
/// the *same* hasher without depending on `bun_css`. Re-export here so
/// in-crate callers (`dependencies.rs`, `rules/import.rs`) keep the
/// `css_modules::hash` path.
/// in-crate callers keep the `css_modules::hash` path.
Comment thread
robobun marked this conversation as resolved.
#[inline]
pub(crate) fn hash<'a>(bump: &'a Bump, args: Arguments<'_>, at_start: bool) -> &'a [u8] {
bun_base64::wyhash_url_safe(bump, args, at_start)
Expand Down
2 changes: 1 addition & 1 deletion src/css/css_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use crate::css_modules::{
self, Config as CssModuleConfig, CssModule, CssModuleExports, CssModuleReference,
CssModuleReferences,
};
pub use crate::dependencies::{self, Dependency};
pub use crate::dependencies;
pub use crate::error::{
self as errors_, BasicParseError, BasicParseErrorKind, Err, ErrorLocation, MinifyErr,
MinifyError, MinifyErrorKind, ParseError, ParserError, PrinterError, PrinterErrorKind,
Expand Down
71 changes: 1 addition & 70 deletions src/css/dependencies.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
//! CSS dependency tracking — `@import` and `url()` references collected during printing.
//! Source location for the CSS Modules `composes` property and printer errors.

use crate::SourceLocation;

Comment thread
robobun marked this conversation as resolved.
/// Options for `analyze_dependencies` in `PrinterOptions`.
pub struct DependencyOptions {
/// Whether to remove `@import` rules.
pub(crate) remove_imports: bool,
}

/// A dependency.
pub enum Dependency {
/// An `@import` dependency.
Import(ImportDependency),
/// A `url()` dependency.
Url(UrlDependency),
}

/// A line and column position within a source file.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Location {
Expand All @@ -33,58 +19,3 @@ impl Location {
}
}
}

/// An `@import` dependency.
pub struct ImportDependency {
/// The placeholder that the URL was replaced with.
// Lifetime: arena-allocated by `css_modules::hash`.
pub(crate) placeholder: *const [u8],
}

impl ImportDependency {
pub(crate) fn new<'bump>(
bump: &'bump bun_alloc::Arena,
rule: &crate::css_rules::import::ImportRule,
filename: &[u8],
) -> ImportDependency {
let placeholder = crate::css_modules::hash(
bump,
format_args!(
"{}_{}",
bstr::BStr::new(filename),
bstr::BStr::new(rule.url)
),
false,
);

ImportDependency {
placeholder: std::ptr::from_ref::<[u8]>(placeholder),
}
}
}

/// A `url()` dependency.
pub struct UrlDependency {
/// The placeholder that the URL was replaced with.
// Lifetime: arena-allocated by `css_modules::hash`.
pub(crate) placeholder: *const [u8],
}

impl UrlDependency {
pub(crate) fn new<'bump>(
bump: &'bump bun_alloc::Arena,
url: &crate::values::url::Url,
filename: &[u8],
import_records: &[bun_ast::ImportRecord],
) -> UrlDependency {
let theurl: &[u8] = import_records[url.import_record_idx as usize].path.pretty;
let placeholder = crate::css_modules::hash(
bump,
format_args!("{}_{}", bstr::BStr::new(filename), bstr::BStr::new(theurl)),
false,
);
UrlDependency {
placeholder: std::ptr::from_ref::<[u8]>(placeholder),
}
}
}
15 changes: 0 additions & 15 deletions src/css/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,12 @@ impl fmt::Display for ErrorLocation {
/// A printer error type.
#[allow(non_camel_case_types)]
pub enum PrinterErrorKind {
/// An ambiguous relative `url()` was encountered in a custom property declaration.
ambiguous_url_in_custom_property {
/// The ambiguous URL.
url: Str,
},
/// A [std::fmt::Error](std::fmt::Error) was encountered in the underlying destination.
fmt_error,
/// The CSS modules `composes` property cannot be used within nested rules.
invalid_composes_nesting,
/// The CSS modules `composes` property cannot be used with a simple class selector.
invalid_composes_selector,
/// The CSS modules pattern must end with `[local]` for use in CSS grid.
invalid_css_modules_pattern_in_grid,
/// Substituting parent selectors for `&` while compiling CSS nesting for
/// the configured targets exceeded the expansion limit.
maximum_nesting_expansion,
Expand All @@ -231,21 +224,13 @@ pub enum PrinterErrorKind {
impl fmt::Display for PrinterErrorKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ambiguous_url_in_custom_property { url } => write!(
f,
"Ambiguous relative URL '{}' in custom property declaration",
bs(*url)
),
Self::fmt_error => f.write_str("Formatting error occurred"),
Self::invalid_composes_nesting => {
f.write_str("The 'composes' property cannot be used within nested rules")
}
Self::invalid_composes_selector => {
f.write_str("The 'composes' property can only be used with a simple class selector")
}
Self::invalid_css_modules_pattern_in_grid => {
f.write_str("CSS modules pattern must end with '[local]' when used in CSS grid")
}
Self::maximum_nesting_expansion => f.write_str(
"Maximum nesting expansion exceeded when compiling CSS nesting for the configured targets",
),
Expand Down
4 changes: 1 addition & 3 deletions src/css/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,13 @@ impl core::error::Error for PrintErr {}
/// signal (the *kind* lives in `Printer.error_kind`).
pub(crate) type PrintResult<T = ()> = core::result::Result<T, PrintErr>;

pub use dependencies::Dependency;

// Re-export the hub types at the crate root so `bun_css::Foo` paths resolve
// for css_jsc / bundler.
pub use css_parser::{
DefaultAtRule, LocalsResultsMap, MinifyOptions, Parser, ParserFlags, ParserInput,
ParserOptions, StyleAttribute, StyleSheet, StylesheetExtra, ToCssResult,
};
pub use printer::{ImportInfo, Printer, PrinterOptions, PseudoClasses};
pub use printer::{ImportInfo, Printer, PrinterOptions};
/// Dependent crates name this `ImportRecordHandler`; the surviving type is
/// `printer::ImportInfo`, exposed under both names.
pub type ImportRecordHandler<'a> = printer::ImportInfo<'a>;
Expand Down
Loading
Loading