File tree Expand file tree Collapse file tree 5 files changed +26
-2
lines changed
crates/rspack_plugin_javascript/src/parser_plugin
tests/rspack-test/configCases Expand file tree Collapse file tree 5 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -122,14 +122,14 @@ impl JavascriptParserPlugin for ESMExportDependencyParserPlugin {
122122 Box :: new ( dep) as BoxDependency
123123 } else {
124124 let inlinable = parser
125- . get_tag_data ( export_name , INLINABLE_CONST_TAG )
125+ . get_tag_data ( local_id , INLINABLE_CONST_TAG )
126126 . map ( InlinableConstData :: downcast)
127127 . map ( |data| data. value ) ;
128128 let enum_value = parser
129129 . build_info
130130 . collected_typescript_info
131131 . as_ref ( )
132- . and_then ( |info| info. exported_enums . get ( export_name ) . cloned ( ) ) ;
132+ . and_then ( |info| info. exported_enums . get ( local_id ) . cloned ( ) ) ;
133133 if enum_value. is_some ( ) && !parser. compiler_options . experiments . inline_enum {
134134 parser. add_error ( rspack_error:: error!( "inlineEnum is still an experimental feature. To continue using it, please enable 'experiments.inlineEnum'." ) . into ( ) ) ;
135135 }
Original file line number Diff line number Diff line change 1+ const INLINE_1 = 1 ;
2+ const NOINLINE_1 = { } ;
3+ export { NOINLINE_1 as INLINE_1 }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import * as reexportedSideEffects from "./re-export.side-effects.js";
66import * as reexportedBarrelSideEffects from "./re-export.barrel-side-effects.js" ;
77import * as reexportedDestructingBarrelSideEffects from "./re-export.destructing-barrel-side-effects.js" ;
88import * as constantsCjs from "./constants.cjs" ;
9+ import * as constantsNoInline from "./constants.no-inline.js" ;
910
1011const generated = /** @type {string } */ ( __non_webpack_require__ ( "fs" ) . readFileSync ( __filename , "utf-8" ) ) ;
1112
@@ -175,3 +176,7 @@ it("should keep the module if part of the exports is inlined and side effects fr
175176 } )
176177 }
177178} )
179+
180+ it ( "should not inline no-inlinable constants" , ( ) => {
181+ expect ( constantsNoInline . INLINE_1 ) . toEqual ( { } ) ;
182+ } )
Original file line number Diff line number Diff line change 1+ enum InlineE1 {
2+ A ,
3+ }
4+
5+ const InlineE = {
6+ A : { } ,
7+ }
8+
9+ export { InlineE1 as InlineE }
10+ export { InlineE as InlineE1 }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import * as destructing from "./enum.destructing";
44import * as sideEffects from "./enum.side-effects" ;
55import * as reexportedSideEffects from "./re-export.side-effects" ;
66import * as notOnlyPropertiesUsed from "./enum.not-only-properties-used" ;
7+ import * as exportAs from "./enum.export-as" ;
78
89const generated = /** @type {string } */ ( __non_webpack_require__ ( "fs" ) . readFileSync ( __filename , "utf-8" ) ) ;
910
@@ -117,3 +118,8 @@ it("should keep the module if part of the enum members are inlined and side effe
117118 } )
118119 }
119120} )
121+
122+ it ( "should not inline no-inlinable enums" , ( ) => {
123+ expect ( exportAs . InlineE1 . A ) . toEqual ( { } ) ;
124+ expect ( exportAs . InlineE . A ) . toBe ( 0 ) ;
125+ } )
You can’t perform that action at this time.
0 commit comments