@@ -43,7 +43,8 @@ Use mark mode to mark flags for later substitution:
4343
4444### Shake Mode (Direct Optimization with DCE)
4545
46- Use shake mode to directly substitute flag values and eliminate dead code:
46+ Use shake mode to directly substitute flag values and eliminate dead code.
47+ This mode operates on ` __SWC_FLAGS__ ` markers and does not use ` libraries ` :
4748
4849``` json
4950{
@@ -52,11 +53,6 @@ Use shake mode to directly substitute flag values and eliminate dead code:
5253 "plugins" : [
5354 [" @swc/plugin-experimental-feature-flags" , {
5455 "mode" : " shake" ,
55- "libraries" : {
56- "@their/library" : {
57- "functions" : [" useExperimentalFlags" ]
58- }
59- },
6056 "flagValues" : {
6157 "featureA" : true ,
6258 "featureB" : false
@@ -117,11 +113,8 @@ function App() {
117113```
118114
119115The plugin in shake mode:
120- 1 . Removes import statements from configured libraries
121- 2 . Detects destructuring patterns from configured functions
122- 3 . Directly substitutes flag identifiers with boolean literals
123- 4 . Performs dead code elimination (DCE)
124- 5 . Removes the hook call statements
116+ 1 . Substitutes ` __SWC_FLAGS__ ` markers with boolean literals
117+ 2 . Performs dead code elimination (DCE)
125118
126119## Configuration
127120
@@ -141,6 +134,7 @@ interface FeatureFlagsConfig {
141134
142135 /**
143136 * Library configurations: library name -> config
137+ * Required in mark mode, not used in shake mode
144138 *
145139 * @example
146140 * {
@@ -154,13 +148,6 @@ interface FeatureFlagsConfig {
154148 */
155149 libraries: Record <string , LibraryConfig >;
156150
157- /**
158- * Flags to exclude from transformation
159- *
160- * @default []
161- */
162- excludeFlags? : string [];
163-
164151 /**
165152 * Global object name for markers
166153 * Only used in mark mode
@@ -227,29 +214,6 @@ You can configure multiple libraries:
227214}
228215```
229216
230- ## Excluding Flags
231-
232- You can exclude specific flags from transformation:
233-
234- ``` json
235- {
236- "jsc" : {
237- "experimental" : {
238- "plugins" : [
239- [" @swc/plugin-experimental-feature-flags" , {
240- "libraries" : {
241- "@their/library" : {
242- "functions" : [" useExperimentalFlags" ]
243- }
244- },
245- "excludeFlags" : [" quickToggle" , " tempDebugFlag" ]
246- }]
247- ]
248- }
249- }
250- }
251- ```
252-
253217## Custom Marker Object
254218
255219You can customize the marker object name:
0 commit comments