Skip to content

Commit ff4d368

Browse files
authored
feat: stabilize inline exports (#12475)
1 parent ec646eb commit ff4d368

File tree

52 files changed

+334
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+334
-444
lines changed

crates/node_binding/napi-binding.d.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,9 +2129,6 @@ rspackFuture?: RawRspackFuture
21292129
cache: boolean | { type: "persistent" } & RawExperimentCacheOptionsPersistent | { type: "memory" }
21302130
useInputFileSystem?: false | Array<RegExp>
21312131
css?: boolean
2132-
inlineConst: boolean
2133-
inlineEnum: boolean
2134-
typeReexportsPresence: boolean
21352132
lazyBarrel: boolean
21362133
deferImport: boolean
21372134
}
@@ -2355,11 +2352,6 @@ commonjs?: boolean | { exports?: boolean | 'skipInEsm' }
23552352
*/
23562353
importDynamic?: boolean
23572354
commonjsMagicComments?: boolean
2358-
/**
2359-
* This option is experimental in Rspack only and subject to change or be removed anytime.
2360-
* @experimental
2361-
*/
2362-
inlineConst?: boolean
23632355
/**
23642356
* This option is experimental in Rspack only and subject to change or be removed anytime.
23652357
* @experimental
@@ -2583,6 +2575,7 @@ export interface RawOptimizationOptions {
25832575
innerGraph: boolean
25842576
realContentHash: boolean
25852577
mangleExports: boolean | string
2578+
inlineExports: boolean
25862579
concatenateModules: boolean
25872580
avoidEntryIife: boolean
25882581
}

crates/rspack/src/builder/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,6 @@ impl ModuleOptionsBuilder {
17261726
}),
17271727
import_dynamic: Some(true),
17281728
commonjs_magic_comments: Some(false),
1729-
inline_const: Some(false),
17301729
jsx: Some(false),
17311730
..Default::default()
17321731
}),
@@ -3209,6 +3208,8 @@ pub struct OptimizationOptionsBuilder {
32093208
inner_graph: Option<bool>,
32103209
/// Whether to enable mangle exports.
32113210
mangle_exports: Option<MangleExportsOption>,
3211+
/// Whether to enable inline exports.
3212+
inline_exports: Option<bool>,
32123213
/// Whether to enable concatenate modules.
32133214
concatenate_modules: Option<bool>,
32143215
/// Whether to enable real content hash.
@@ -3233,6 +3234,7 @@ impl From<Optimization> for OptimizationOptionsBuilder {
32333234
used_exports: Some(value.used_exports),
32343235
inner_graph: Some(value.inner_graph),
32353236
mangle_exports: Some(value.mangle_exports),
3237+
inline_exports: Some(value.inline_exports),
32363238
concatenate_modules: Some(value.concatenate_modules),
32373239
avoid_entry_iife: Some(value.avoid_entry_iife),
32383240
remove_empty_chunks: None,
@@ -3264,6 +3266,7 @@ impl From<&mut OptimizationOptionsBuilder> for OptimizationOptionsBuilder {
32643266
used_exports: value.used_exports.take(),
32653267
inner_graph: value.inner_graph.take(),
32663268
mangle_exports: value.mangle_exports.take(),
3269+
inline_exports: value.inline_exports.take(),
32673270
concatenate_modules: value.concatenate_modules.take(),
32683271
real_content_hash: value.real_content_hash.take(),
32693272
avoid_entry_iife: value.avoid_entry_iife.take(),
@@ -3559,6 +3562,7 @@ impl OptimizationOptionsBuilder {
35593562
.push(BuiltinPluginOptions::SideEffectsFlagPlugin);
35603563
}
35613564

3565+
let inline_exports = d!(self.inline_exports, production);
35623566
let mangle_exports = f!(self.mangle_exports.take(), || {
35633567
if production {
35643568
MangleExportsOption::Deterministic
@@ -3662,6 +3666,7 @@ impl OptimizationOptionsBuilder {
36623666
used_exports,
36633667
inner_graph,
36643668
mangle_exports,
3669+
inline_exports,
36653670
concatenate_modules,
36663671
avoid_entry_iife,
36673672
real_content_hash,
@@ -3815,10 +3820,7 @@ impl ExperimentsBuilder {
38153820
parallel_code_splitting,
38163821
cache,
38173822
css: d!(self.css, false),
3818-
inline_const: false,
3819-
inline_enum: false,
3820-
type_reexports_presence: false,
3821-
lazy_barrel: false,
3823+
lazy_barrel: true,
38223824
defer_import: false,
38233825
})
38243826
}

crates/rspack/tests/snapshots/defaults__default_options.snap

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: crates/rspack/tests/defaults.rs
3-
assertion_line: 16
43
expression: options
54
---
65
CompilerOptions {
@@ -1477,9 +1476,6 @@ CompilerOptions {
14771476
commonjs_magic_comments: Some(
14781477
false,
14791478
),
1480-
inline_const: Some(
1481-
false,
1482-
),
14831479
jsx: Some(
14841480
false,
14851481
),
@@ -1521,10 +1517,7 @@ CompilerOptions {
15211517
rspack_future: RspackFuture,
15221518
cache: Disabled,
15231519
css: false,
1524-
inline_const: false,
1525-
inline_enum: false,
1526-
type_reexports_presence: false,
1527-
lazy_barrel: false,
1520+
lazy_barrel: true,
15281521
defer_import: false,
15291522
},
15301523
node: Some(
@@ -1540,6 +1533,7 @@ CompilerOptions {
15401533
provided_exports: true,
15411534
used_exports: False,
15421535
inner_graph: false,
1536+
inline_exports: false,
15431537
mangle_exports: False,
15441538
concatenate_modules: false,
15451539
avoid_entry_iife: false,

crates/rspack_binding_api/src/raw_options/raw_experiments/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ pub struct RawExperiments {
2626
#[napi(ts_type = "false | Array<RegExp>")]
2727
pub use_input_file_system: Option<WithFalse<Vec<RspackRegex>>>,
2828
pub css: Option<bool>,
29-
pub inline_const: bool,
30-
pub inline_enum: bool,
31-
pub type_reexports_presence: bool,
3229
pub lazy_barrel: bool,
3330
pub defer_import: bool,
3431
}
@@ -48,9 +45,6 @@ impl From<RawExperiments> for Experiments {
4845
rspack_future: value.rspack_future.unwrap_or_default().into(),
4946
cache: normalize_raw_experiment_cache_options(value.cache),
5047
css: value.css.unwrap_or(false),
51-
inline_const: value.inline_const,
52-
inline_enum: value.inline_enum,
53-
type_reexports_presence: value.type_reexports_presence,
5448
lazy_barrel: value.lazy_barrel,
5549
defer_import: value.defer_import,
5650
}

crates/rspack_binding_api/src/raw_options/raw_module/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ pub struct RawJavascriptParserOptions {
305305
pub commonjs_magic_comments: Option<bool>,
306306
/// This option is experimental in Rspack only and subject to change or be removed anytime.
307307
/// @experimental
308-
pub inline_const: Option<bool>,
309-
/// This option is experimental in Rspack only and subject to change or be removed anytime.
310-
/// @experimental
311308
pub type_reexports_presence: Option<String>,
312309
/// This option is experimental in Rspack only and subject to change or be removed anytime.
313310
/// @experimental
@@ -389,7 +386,6 @@ impl From<RawJavascriptParserOptions> for JavascriptParserOptions {
389386
}),
390387
import_dynamic: value.import_dynamic,
391388
commonjs_magic_comments: value.commonjs_magic_comments,
392-
inline_const: value.inline_const,
393389
jsx: value.jsx,
394390
defer_import: value.defer_import,
395391
}

crates/rspack_binding_api/src/raw_options/raw_optimization.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct RawOptimizationOptions {
1616
pub real_content_hash: bool,
1717
#[napi(ts_type = "boolean | string")]
1818
pub mangle_exports: WithBool<String>,
19+
pub inline_exports: bool,
1920
pub concatenate_modules: bool,
2021
pub avoid_entry_iife: bool,
2122
}
@@ -49,6 +50,7 @@ impl TryFrom<RawOptimizationOptions> for Optimization {
4950
used_exports: value.used_exports.into(),
5051
inner_graph: value.inner_graph,
5152
mangle_exports: value.mangle_exports.into(),
53+
inline_exports: value.inline_exports,
5254
concatenate_modules: value.concatenate_modules,
5355
avoid_entry_iife: value.avoid_entry_iife,
5456
real_content_hash: value.real_content_hash,

crates/rspack_core/src/concatenated_module.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,8 @@ impl Module for ConcatenatedModule {
683683
.module_by_identifier(&self.root_module_ctxt.id)
684684
.expect("should have root module");
685685

686-
// populate root collected_typescript_info
687-
if let Some(collected_typescript_info) = &root_module.build_info().collected_typescript_info {
688-
self.build_info.collected_typescript_info = Some(collected_typescript_info.clone());
689-
}
686+
// populate root inline_exports
687+
self.build_info.inline_exports = root_module.build_info().inline_exports;
690688

691689
for m in self.modules.iter() {
692690
let module = module_graph

crates/rspack_core/src/module.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub struct BuildInfo {
7373
pub module_concatenation_bailout: Option<String>,
7474
pub assets: BindingCell<HashMap<String, CompilationAsset>>,
7575
pub module: bool,
76+
pub inline_exports: bool,
7677
pub collected_typescript_info: Option<CollectedTypeScriptInfo>,
7778
/// Stores external fields from the JS side (Record<string, any>),
7879
/// while other properties are stored in KnownBuildInfo.
@@ -101,6 +102,7 @@ impl Default for BuildInfo {
101102
module_concatenation_bailout: None,
102103
assets: Default::default(),
103104
module: false,
105+
inline_exports: false,
104106
collected_typescript_info: None,
105107
extras: Default::default(),
106108
}

crates/rspack_core/src/options/experiments/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ pub struct Experiments {
1515
pub rspack_future: RspackFuture,
1616
pub cache: ExperimentCacheOptions,
1717
pub css: bool,
18-
pub inline_const: bool,
19-
pub inline_enum: bool,
20-
pub type_reexports_presence: bool,
2118
pub lazy_barrel: bool,
2219
pub defer_import: bool,
2320
}

crates/rspack_core/src/options/module.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ pub struct JavascriptParserOptions {
307307
pub commonjs: Option<JavascriptParserCommonjsOptions>,
308308
pub import_dynamic: Option<bool>,
309309
pub commonjs_magic_comments: Option<bool>,
310-
pub inline_const: Option<bool>,
311310
pub jsx: Option<bool>,
312311
pub defer_import: Option<bool>,
313312
}

0 commit comments

Comments
 (0)