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 {
122
122
Box :: new ( dep) as BoxDependency
123
123
} else {
124
124
let inlinable = parser
125
- . get_tag_data ( export_name , INLINABLE_CONST_TAG )
125
+ . get_tag_data ( local_id , INLINABLE_CONST_TAG )
126
126
. map ( InlinableConstData :: downcast)
127
127
. map ( |data| data. value ) ;
128
128
let enum_value = parser
129
129
. build_info
130
130
. collected_typescript_info
131
131
. as_ref ( )
132
- . and_then ( |info| info. exported_enums . get ( export_name ) . cloned ( ) ) ;
132
+ . and_then ( |info| info. exported_enums . get ( local_id ) . cloned ( ) ) ;
133
133
if enum_value. is_some ( ) && !parser. compiler_options . experiments . inline_enum {
134
134
parser. add_error ( rspack_error:: error!( "inlineEnum is still an experimental feature. To continue using it, please enable 'experiments.inlineEnum'." ) . into ( ) ) ;
135
135
}
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";
6
6
import * as reexportedBarrelSideEffects from "./re-export.barrel-side-effects.js" ;
7
7
import * as reexportedDestructingBarrelSideEffects from "./re-export.destructing-barrel-side-effects.js" ;
8
8
import * as constantsCjs from "./constants.cjs" ;
9
+ import * as constantsNoInline from "./constants.no-inline.js" ;
9
10
10
11
const generated = /** @type {string } */ ( __non_webpack_require__ ( "fs" ) . readFileSync ( __filename , "utf-8" ) ) ;
11
12
@@ -175,3 +176,7 @@ it("should keep the module if part of the exports is inlined and side effects fr
175
176
} )
176
177
}
177
178
} )
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";
4
4
import * as sideEffects from "./enum.side-effects" ;
5
5
import * as reexportedSideEffects from "./re-export.side-effects" ;
6
6
import * as notOnlyPropertiesUsed from "./enum.not-only-properties-used" ;
7
+ import * as exportAs from "./enum.export-as" ;
7
8
8
9
const generated = /** @type {string } */ ( __non_webpack_require__ ( "fs" ) . readFileSync ( __filename , "utf-8" ) ) ;
9
10
@@ -117,3 +118,8 @@ it("should keep the module if part of the enum members are inlined and side effe
117
118
} )
118
119
}
119
120
} )
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