Skip to main content

Crate fob_bundler

Crate fob_bundler 

Source
Expand description

§fob-bundler

Fob bundler - Rolldown-based bundling on top of fob foundation.

This crate provides full bundling capabilities using Rolldown, building on top of the fob foundation crate for graph analysis and runtime abstraction.

§Quick Start

§Bundle a library

use fob_bundler as fob;

let result = fob::BuildOptions::new("./src/index.js")
    .platform(fob::Platform::Node)  // Uses Node.js export conditions
    .externalize(["react", "react-dom"])
    .sourcemap(true)
    .build()
    .await?;

let bundle = result.output.as_single().expect("single bundle");
for asset in bundle.assets.iter() {
    std::fs::write(format!("dist/{}", asset.filename()), asset.content_as_bytes())?;
}

BuildConfig provides a cleaner API with better type safety:

use fob_bundler::BuildConfig;

let result = BuildConfig::new("./src/index.js")
    .bundle(false)
    .output_dir("dist")
    .build()
    .await?;

result.write_to("dist", true)?;

§Analyze without bundling

use fob_bundler as fob;

let analysis = fob_graph::analyze(["./src/index.js"]).await?;
for unused in analysis.graph.unused_exports()? {
    println!("unused: {} from {}", unused.export.name, unused.module_id);
}

Re-exports§

pub use builders::BuildOptions;
pub use builders::BuildOutput;
pub use builders::BuildResult;
pub use builders::CodeSplittingConfig;
pub use builders::EntryMode;
pub use builders::EntryPoints;
pub use builders::ExternalConfig;
pub use builders::IncrementalConfig;
pub use builders::MinifyLevel;
pub use builders::build;
pub use builtins::CssPlugin;
pub use cache::CacheConfig;
pub use cache::CacheKey;
pub use config::BuildConfig;
pub use config::ExternalPattern;
pub use config::OptimizationConfig;
pub use config::OutputConfig;
pub use config::ResolutionConfig;
pub use output::AppBuild;
pub use output::Bundle as JoyBundle;
pub use output::ComponentBuild;
pub use output::ImportMap;
pub use target::DeploymentTarget;
pub use target::ExportConditions;
pub use target::NodeBuiltins;
pub use target::RuntimeEnvironment;
pub use analysis::AnalyzedBundle;

Modules§

analysis
Bundler-specific analysis types.
builders
Build APIs for Fob’s unified bundling interface.
builtins
Built-in functionality for the bundler.
cache
Persistent build cache for fob-bundler.
collection
Shared collection types for module graph analysis.
config
Build configuration types.
dependency_chain
Dependency chain analysis for understanding module relationships.
diagnostics
Diagnostic extraction from Rolldown errors.
export
external_dep
framework_rules
Framework-aware dead code analysis.
from_collection
Convert intermediate collection types to final graph representation.
from_rolldown
import
module
module_collection_plugin
module_id
output
oxc
OXC (Oxidation Compiler) foundation types re-exported for workspace consistency.
package_json
Package.json parsing and dependency analysis.
plugins
Plugin system for fob-bundler.
runtime
Bundler-specific Runtime implementation
semantic
Semantic analysis engine using Oxc for symbol extraction.
span
statistics
symbol
Symbol tracking for intra-file dead code analysis.
target
Deployment target types and configuration.
test_utilstest-utils and non-target_family=wasm, or non-target_family=wasm

Structs§

AnalysisResult
AnalyzeOptions
Options for the analyze() function.
Analyzer
Fast standalone analyzer for module graphs.
BundleOutput
Bundler
BundlerBuilder
BundlerOptions
BundlerTransformOptions
CacheAnalysis
ChainAnalysis
Analysis of all dependency chains to a module.
ClassMemberInfo
Information about a class member symbol
ClassMemberMetadata
Additional metadata for class member symbols
CollectedImport
Represents an import statement in a module
CollectedModule
Represents a collected module with all its metadata
CollectionState
Shared state for collecting module information during bundling or analysis
Configured
Typestate marker for a configured analyzer (has entry points).
DecoratorOptions
DependencyChain
A chain of dependencies from an entry point to a target module.
DependencyCoverage
Coverage statistics for dependencies.
EmittedAsset
EnumMemberInfo
Information about an enum member
EnumMemberMetadata
Metadata for enum member tracking
Export
Complete metadata describing a module export.
ExternalDependency
Represents an external dependency (e.g. npm package) and modules that import it.
FileMetadata
File metadata
GraphStatistics
Basic statistics about a ModuleGraph useful for dashboards or logging.
HookGenerateBundleArgs
HookLoadArgs
HookLoadOutput
HookResolveIdArgs
HookResolveIdOutput
HookTransformArgs
HookTransformOutput
HookUsage
Import
Complete analysis of a dependency edge.
ImportResolution
InputItem
IsolatedDeclarationsOptions
LogWithoutPlugin
Module
Resolved module metadata used by graph algorithms and builders.
ModuleGraph
In-memory module dependency graph.
ModuleId
Canonical identifier for a module in the Joy graph.
NamespaceImportInfo
Information about a namespace import
NativeRuntimeNon-target_family=wasm
Native filesystem Runtime implementation using std::fs.
OutputAsset
OutputChunk
PackageJson
Parsed package.json structure.
RenameEvent
ResolveOptions
A simple wrapper around oxc_resolver::ResolveOptions to make it easier to use in the rolldown_resolver crate. See oxc_resolver::ResolveOptions for more information.
SideEffectImport
A side-effect-only import (no bindings, just execution)
SourceSpan
Byte range within a source file used for diagnostics and tooling.
Symbol
A symbol declared within a module (variable, function, class, etc.).
SymbolSpan
Source location information for a symbol.
SymbolStatistics
Statistics about symbols across the entire graph.
SymbolTable
Collection of all symbols in a module.
TestRuntime(test-utils and non-target_family=wasm, or non-target_family=wasm) and non-target_family=wasm
Simple test runtime that wraps std::fs for native tests.
TransformationTrace
TypeCoverage
Coverage for a specific dependency type.
TypeOnlyImport
A type-only import (TypeScript)
TypeScriptOptions
Unconfigured
Typestate marker for an unconfigured analyzer (no entry points yet).
UnreachableCode
Unreachable code detected in a module.
UnusedDependency
An npm dependency that is declared but never imported.
UnusedExport
Output entry for unused exports.
UnusedSymbol
An unused symbol in a specific module.

Enums§

AnalyzeError
Error that can occur during analysis.
CacheEffectiveness
CollectedExport
Represents an export declaration in a module
CollectedImportSpecifier
CollectionGraphError
Errors that can occur during collection-to-graph conversion
DependencyType
Type of dependency in package.json.
EnumMemberValue
Enum member value types
Error
Error types for fob-bundler operations.
ExportKind
Export declaration kind.
GlobalsOutputOption
ImportKind
Mechanism used to load the dependency.
ImportOutcome
ImportSpecifier
Individual import binding from a module.
IsExternal
ModuleIdError
Error type for ModuleId construction failures.
ModuleType
Output
OutputFormat
Platform
PluginContext
RawMinifyOptions
RenamePhase
RuntimeError
Errors that can occur during runtime operations
SourceMapType
SourceType
Resolved module source type derived from file extensions.
SymbolKind
Classification of symbol types for better diagnostics.
SymbolMetadata
Symbol metadata (extensible for different symbol kinds)
Visibility
Visibility modifier for class members

Traits§

FrameworkRule
Framework-specific rule for marking exports as used by framework conventions.
Plugin
Runtime

Functions§

analyze
Convenience function using default options.
analyze_with_options
Analyze module graph with custom options.
extract_package_name
Extract the base package name from an npm import specifier.
parse_module_structure
Parse a JavaScript/TypeScript module to extract its import/export structure

Type Aliases§

HookLoadReturn
HookNoopReturn
HookResolveIdReturn
HookTransformReturn
Result
Result type alias for fob-bundler operations.
RuntimeResult
Result type for runtime operations
SharedPluginable
SharedTransformPluginContext