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      resolve_options::ResolveOptions,
72      sanitize_filename::SanitizeFilename,
73      source_map_type::SourceMapType,
74      sourcemap_ignore_list::SourceMapIgnoreList,
75      sourcemap_path_transform::SourceMapPathTransform,
76      strict_mode::StrictMode,
77      target::ESTarget,
78      transform_option::{
79        CompilerAssumptions, DecoratorOptions, Either, IsolatedDeclarationsOptions, JsxOptions,
80        PluginsOptions, ReactRefreshOptions, StyledComponentsOptions,
81        TransformOptions as BundlerTransformOptions, TypeScriptOptions,
82      },
83      transform_options::{
84        JsxPreset, RawTransformOptions, TransformOptions, TransformOptionsInner,
85        merge_transform_options_with_tsconfig,
86      },
87      treeshake::{
88        InnerOptions, ModuleSideEffects, ModuleSideEffectsRule, PropertyReadSideEffects,
89        PropertyWriteSideEffects, TreeshakeOptions,
90      },
91      tsconfig::TsConfig,
92      tsconfig_merge::merge_transform_options_with_tsconfig as merge_tsconfig,
93      watch_option::{OnInvalidate, WatchOption},
94    },
95  };
96
97  pub use crate::utils::enhanced_transform::{
98    EnhancedTransformOptions, EnhancedTransformResult, TsconfigOption, enhanced_transform,
99  };
100}
101
102// We don't want internal position adjustment of files affect users, so all items are exported in the root.
103pub use crate::{
104  chunk::{
105    Chunk, ChunkMeta, PostChunkOptimizationOperation,
106    chunk_table::ChunkTable,
107    types::{
108      AddonRenderContext,
109      chunk_debug_info::{ChunkDebugInfo, FacadeChunkEliminationReason},
110      chunk_reason_type::ChunkReasonType,
111      cross_chunk_import_item::CrossChunkImportItem,
112      module_group::ModuleGroup,
113      preliminary_filename::PreliminaryFilename,
114    },
115  },
116  ecmascript::{
117    comment_annotation::get_leading_comment,
118    dynamic_import_usage,
119    ecma_asset_meta::EcmaAssetMeta,
120    ecma_view::{
121      EcmaModuleAstUsage, EcmaView, EcmaViewMeta, PrependRenderedImport, ThisExprReplaceKind,
122      generate_replace_this_expr_map,
123    },
124    json_to_program::{json_value_to_ecma_ast, json_value_to_expression},
125    module_idx::ModuleIdx,
126  },
127  file_emitter::{
128    EmittedAsset, EmittedChunk, EmittedChunkInfo, EmittedPrebuiltChunk, FileEmitter,
129    SharedFileEmitter,
130  },
131  hmr::{
132    client_hmr_input::ClientHmrInput, client_hmr_update::ClientHmrUpdate,
133    hmr_boundary::HmrBoundary, hmr_boundary_output::HmrBoundaryOutput, hmr_patch::HmrPatch,
134    hmr_update::HmrUpdate,
135  },
136  module::{
137    Module,
138    external_module::ExternalModule,
139    normal_module::{ModuleRenderArgs, NormalModule},
140  },
141  module_loader::{
142    AddEntryModuleMsg, ModuleLoaderMsg,
143    runtime_module_brief::{RUNTIME_MODULE_ID, RUNTIME_MODULE_KEY, RuntimeModuleBrief},
144    runtime_task_result::RuntimeModuleTaskResult,
145    task_result::{EcmaRelated, ExternalModuleTaskResult, NormalModuleTaskResult},
146  },
147  source_map_gen_msg::SourceMapGenMsg,
148  type_aliases::{MemberExprRefResolutionMap, SharedModuleInfoDashMap},
149  types::asset::Asset,
150  types::asset_meta::{InstantiationKind, SourcemapAssetMeta},
151  types::ast_scope_idx::AstScopeIdx,
152  types::ast_scopes::AstScopes,
153  types::bundle_mode::BundleMode,
154  types::chunk_idx::ChunkIdx,
155  types::chunk_kind::ChunkKind,
156  types::concatenate_wrapped_module::{
157    ConcatenateWrappedModuleKind, RenderedConcatenatedModuleParts,
158  },
159  types::constant_value::{ConstExportMeta, ConstantValue},
160  types::deconflict::ModuleScopeSymbolIdMap,
161  types::defer_sync_scan_data::DeferSyncScanData,
162  types::entry_point::{EntryPoint, EntryPointKind},
163  types::exports_kind::ExportsKind,
164  types::external_module_idx::ExternalModuleIdx,
165  types::flat_options::FlatOptions,
166  types::hmr_info::HmrInfo,
167  types::hybrid_index_vec::HybridIndexVec,
168  types::import_attribute::ImportAttribute,
169  types::import_kind::ImportKind,
170  types::import_record::{
171    DynamicImportExprInfo, ImportRecordIdx, ImportRecordMeta, ImportRecordStateInit,
172    RawImportRecord, ResolvedImportRecord,
173  },
174  types::importer_record::ImporterRecord,
175  types::ins_chunk_idx::InsChunkIdx,
176  types::instantiated_chunk::InstantiatedChunk,
177  types::interop::Interop,
178  types::lazy_barrel::{
179    BarrelInfo, BarrelState, ExportSource, ImportedExports, LazyBarrelInfo,
180    try_extract_lazy_barrel_info,
181  },
182  types::member_expr_ref::{MemberExprObjectReferencedType, MemberExprProp, MemberExprRef},
183  types::member_expr_ref_resolution::MemberExprRefResolution,
184  types::module_def_format::ModuleDefFormat,
185  types::module_id::{ModuleId, ModuleIdKind},
186  types::module_info::ModuleInfo,
187  types::module_namespace_included_reason::ModuleNamespaceIncludedReason,
188  types::module_render_output::ModuleRenderOutput,
189  types::module_table::{IndexModules, ModuleTable},
190  types::module_tag::{ModuleTag, ModuleTagBitSet, ModuleTagRegistry},
191  types::named_export::LocalExport,
192  types::named_import::{NamedImport, Specifier},
193  types::namespace_alias::NamespaceAlias,
194  types::output::{Output, OutputAsset},
195  types::output_chunk::{Modules, OutputChunk},
196  types::outputs_diagnostics::OutputsDiagnostics,
197  types::package_json::PackageJson,
198  types::plugin_idx::PluginIdx,
199  types::rendered_module::RenderedModule,
200  types::resolved_export::ResolvedExport,
201  types::resolved_id::{ResolvedExternal, ResolvedId},
202  types::rollup_pre_rendered_asset::RollupPreRenderedAsset,
203  types::rollup_pre_rendered_chunk::RollupPreRenderedChunk,
204  types::rollup_rendered_chunk::RollupRenderedChunk,
205  types::scan_mode::ScanMode,
206  types::side_effect_detail::SideEffectDetail,
207  types::side_effects,
208  types::source_mutation::SourceMutation,
209  types::sourcemap_chain_element::SourcemapChainElement,
210  types::stable_module_id::StableModuleId,
211  types::stmt_info::{
212    DebugStmtInfoForTreeShaking, DeclaredSymbols, StmtInfo, StmtInfoIdx, StmtInfoMeta, StmtInfos,
213  },
214  types::str_or_bytes::StrOrBytes,
215  types::symbol_or_member_expr_ref::{SymbolOrMemberExprRef, TaggedSymbolRef},
216  types::symbol_ref::{SymbolRef, common_debug_symbol_ref},
217  types::symbol_ref_db::{
218    GetLocalDb, GetLocalDbMut, SymbolRefDb, SymbolRefDbForModule, SymbolRefFlags,
219  },
220  types::used_symbol_refs::UsedSymbolRefs,
221  types::watch::WatcherChangeKind,
222  types::wrap_kind::WrapKind,
223};
224pub use bundler_options::*;
225#[cfg(debug_assertions)]
226pub use types::idx_ext::IdxDebugExt;