Skip to main content

rolldown_common/
lib.rs

1mod chunk;
2mod ecmascript;
3mod file_emitter;
4mod generated;
5mod hmr;
6mod inner_bundler_options;
7mod module;
8mod module_loader;
9mod source_map_gen_msg;
10mod type_aliases;
11mod types;
12mod utils;
13
14/// This module is to help `rolldown` crate could export types related bundler options easily.
15/// `rolldown` crate could use `pub use rolldown_common::bundler_options::*;` to export all types, so we don't need write
16/// the same code in `rolldown` crate again.
17pub mod bundler_options {
18  pub use crate::generated::{
19    checks_options::ChecksOptions,
20    runtime_helper::{DependedRuntimeHelperMap, RUNTIME_HELPER_NAMES, RuntimeHelper},
21  };
22
23  #[cfg(feature = "deserialize_bundler_options")]
24  pub use crate::inner_bundler_options::types::optimization::deserialize_inline_const;
25  pub use crate::inner_bundler_options::{
26    BundlerOptions,
27    types::{
28      attach_debug_info::AttachDebugInfo,
29      chunk_import_map::ChunkImportMap,
30      chunk_modules_order::ChunkModulesOrderBy,
31      code_splitting_mode::CodeSplittingMode,
32      comments::CommentsOptions,
33      defer_sync_scan_data_option::DeferSyncScanDataOption,
34      dev_mode_options::DevModeOptions,
35      devtools_options::DevtoolsOptions,
36      es_module_flag::EsModuleFlag,
37      experimental_options::{
38        ChunkOptimizationOption, ChunkOptimizationOptions, ExperimentalOptions,
39      },
40      filename_template::{FilenameTemplate, is_path_fragment},
41      generated_code_options::GeneratedCodeOptions,
42      hash_characters::HashCharacters,
43      inject_import::InjectImport,
44      input_item::InputItem,
45      invalidate_js_side_cache::InvalidateJsSideCache,
46      is_external::IsExternal,
47      legal_comments::LegalComments,
48      log_level::LogLevel,
49      make_absolute_externals_relative::MakeAbsoluteExternalsRelative,
50      manual_code_splitting_options::{
51        ChunkingContext, ManualCodeSplittingOptions, MatchGroup, MatchGroupName, MatchGroupTest,
52      },
53      minify_options::{
54        MinifyOptions, RawCompressOptions, RawMangleOptions, RawMinifyOptions,
55        RawMinifyOptionsDetailed,
56      },
57      module_type::ModuleType,
58      normalized_bundler_options::{NormalizedBundlerOptions, SharedNormalizedBundlerOptions},
59      on_log::{Log, LogLocation, LogWithoutPlugin, OnLog},
60      optimization::{
61        InlineConstConfig, InlineConstMode, InlineConstOption, OptimizationOption,
62        normalize_optimization_option,
63      },
64      output_exports::OutputExports,
65      output_format::OutputFormat,
66      output_option::{
67        AddonFunction, AddonOutputOption, AssetFilenamesOutputOption, ChunkFilenamesOutputOption,
68        GlobalsOutputOption, PathsOutputOption, PreserveEntrySignatures,
69      },
70      platform::Platform,
71      plugin_timings_option::PluginTimingsOption,
72      resolve_options::ResolveOptions,
73      sanitize_filename::SanitizeFilename,
74      source_map_type::SourceMapType,
75      sourcemap_ignore_list::SourceMapIgnoreList,
76      sourcemap_path_transform::SourceMapPathTransform,
77      strict_mode::StrictMode,
78      target::ESTarget,
79      transform_option::{
80        CompilerAssumptions, DecoratorOptions, Either, IsolatedDeclarationsOptions, JsxOptions,
81        PluginsOptions, ReactRefreshOptions, StyledComponentsOptions,
82        TransformOptions as BundlerTransformOptions, TypeScriptOptions,
83      },
84      transform_options::{
85        JsxPreset, RawTransformOptions, TransformOptions, TransformOptionsInner,
86        merge_transform_options_with_tsconfig,
87      },
88      treeshake::{
89        InnerOptions, ModuleSideEffects, ModuleSideEffectsRule, PropertyReadSideEffects,
90        PropertyWriteSideEffects, TreeshakeOptions,
91      },
92      tsconfig::TsConfig,
93      tsconfig_merge::merge_transform_options_with_tsconfig as merge_tsconfig,
94      watch_option::{OnInvalidate, WatchOption},
95    },
96  };
97
98  pub use crate::utils::enhanced_transform::{
99    EnhancedTransformOptions, EnhancedTransformResult, TsconfigOption, enhanced_transform,
100  };
101}
102
103// We don't want internal position adjustment of files affect users, so all items are exported in the root.
104pub use crate::{
105  chunk::{
106    Chunk, ChunkMeta, PostChunkOptimizationOperation,
107    chunk_table::ChunkTable,
108    types::{
109      AddonRenderContext,
110      chunk_debug_info::{ChunkDebugInfo, FacadeChunkEliminationReason},
111      chunk_reason_type::ChunkReasonType,
112      cross_chunk_import_item::CrossChunkImportItem,
113      module_group::ModuleGroup,
114      preliminary_filename::PreliminaryFilename,
115    },
116  },
117  ecmascript::{
118    comment_annotation::get_leading_comment,
119    dynamic_import_usage,
120    ecma_asset_meta::EcmaAssetMeta,
121    ecma_view::{
122      EcmaModuleAstUsage, EcmaView, EcmaViewMeta, ExportOrigin, PrependRenderedImport,
123      RolldownFileUrlReference, ThisExprReplaceKind, generate_replace_this_expr_map,
124    },
125    json_to_program::{json_value_to_ecma_ast, json_value_to_expression},
126    module_idx::ModuleIdx,
127  },
128  file_emitter::{
129    EmittedAsset, EmittedChunk, EmittedChunkInfo, EmittedPrebuiltChunk, FileEmitter,
130    SharedFileEmitter,
131  },
132  hmr::{
133    client_hmr_input::ClientHmrInput, client_hmr_update::ClientHmrUpdate,
134    hmr_boundary::HmrBoundary, hmr_patch::HmrPatch, hmr_stamp_table::HmrStampTable,
135    hmr_update::HmrUpdate, lazy_chunk_output::HmrLazyChunkOutput,
136  },
137  module::{
138    Module,
139    external_module::ExternalModule,
140    normal_module::{ModuleRenderArgs, NormalModule},
141  },
142  module_loader::{
143    AddEntryModuleMsg, ModuleLoaderMsg,
144    runtime_module_brief::{RUNTIME_MODULE_ID, RUNTIME_MODULE_KEY, RuntimeModuleBrief},
145    runtime_task_result::RuntimeModuleTaskResult,
146    task_result::{EcmaRelated, ExternalModuleTaskResult, NormalModuleTaskResult},
147  },
148  source_map_gen_msg::SourceMapGenMsg,
149  type_aliases::{MemberExprRefResolutionMap, SharedModuleInfoDashMap},
150  types::asset::Asset,
151  types::asset_meta::{InstantiationKind, SourcemapAssetMeta},
152  types::ast_scope_idx::AstScopeIdx,
153  types::ast_scopes::AstScopes,
154  types::bundle_mode::BundleMode,
155  types::chunk_idx::ChunkIdx,
156  types::chunk_kind::ChunkKind,
157  types::concatenate_wrapped_module::{
158    ConcatenateWrappedModuleKind, RenderedConcatenatedModuleParts,
159  },
160  types::constant_value::{ConstExportMeta, ConstantValue},
161  types::deconflict::ModuleScopeSymbolIdMap,
162  types::defer_sync_scan_data::DeferSyncScanData,
163  types::entry_point::{EntryPoint, EntryPointKind},
164  types::exports_kind::ExportsKind,
165  types::external_module_idx::ExternalModuleIdx,
166  types::flat_options::FlatOptions,
167  types::hmr_info::HmrInfo,
168  types::hybrid_index_vec::HybridIndexVec,
169  types::import_attribute::ImportAttribute,
170  types::import_kind::ImportKind,
171  types::import_record::{
172    DynamicImportExprInfo, ImportRecordIdx, ImportRecordMeta, ImportRecordStateInit,
173    RawImportRecord, ResolvedImportRecord,
174  },
175  types::importer_record::ImporterRecord,
176  types::ins_chunk_idx::InsChunkIdx,
177  types::instantiated_chunk::InstantiatedChunk,
178  types::interop::Interop,
179  types::lazy_barrel::{
180    BarrelInfo, BarrelState, ExportSource, ImportedExports, LazyBarrelInfo,
181    try_extract_lazy_barrel_info,
182  },
183  types::member_expr_ref::{MemberExprObjectReferencedType, MemberExprProp, MemberExprRef},
184  types::member_expr_ref_resolution::MemberExprRefResolution,
185  types::module_def_format::ModuleDefFormat,
186  types::module_id::{ModuleId, ModuleIdKind},
187  types::module_info::ModuleInfo,
188  types::module_namespace_included_reason::ModuleNamespaceIncludedReason,
189  types::module_render_output::ModuleRenderOutput,
190  types::module_table::{IndexModules, ModuleTable},
191  types::module_tag::{ModuleTag, ModuleTagBitSet, ModuleTagRegistry},
192  types::named_export::LocalExport,
193  types::named_import::{NamedImport, Specifier},
194  types::namespace_alias::NamespaceAlias,
195  types::output::{Output, OutputAsset},
196  types::output_chunk::{Modules, OutputChunk},
197  types::outputs_diagnostics::OutputsDiagnostics,
198  types::package_json::PackageJson,
199  types::plugin_idx::PluginIdx,
200  types::rendered_module::RenderedModule,
201  types::resolved_export::ResolvedExport,
202  types::resolved_id::{ResolvedExternal, ResolvedId},
203  types::retained_export_symbols::RetainedExportSymbols,
204  types::rollup_pre_rendered_asset::RollupPreRenderedAsset,
205  types::rollup_pre_rendered_chunk::RollupPreRenderedChunk,
206  types::rollup_rendered_chunk::RollupRenderedChunk,
207  types::scan_mode::ScanMode,
208  types::side_effects,
209  types::source_mutation::SourceMutation,
210  types::sourcemap_chain_element::SourcemapChainElement,
211  types::stable_module_id::StableModuleId,
212  types::stmt_eval_flags::StmtEvalFlags,
213  types::stmt_info::{
214    DebugStmtInfoForTreeShaking, DeclaredSymbols, StmtInfo, StmtInfoIdx, StmtInfoMeta, StmtInfos,
215  },
216  types::str_or_bytes::StrOrBytes,
217  types::symbol_or_member_expr_ref::{SymbolOrMemberExprRef, TaggedSymbolRef},
218  types::symbol_ref::{SymbolRef, common_debug_symbol_ref},
219  types::symbol_ref_db::{
220    GetLocalDb, GetLocalDbMut, SymbolRefDb, SymbolRefDbForModule, SymbolRefFlags,
221  },
222  types::used_external_symbols::{ExternalInteropUse, UsedExternalSymbols},
223  types::used_symbol_refs::{UsedSymbolRefs, UsedSymbolRefsBuilder},
224  types::watch::WatcherChangeKind,
225  types::wrap_kind::WrapKind,
226};
227pub use bundler_options::*;
228#[cfg(debug_assertions)]
229pub use types::idx_ext::IdxDebugExt;