@@ -12,6 +12,7 @@ import commander from 'commander';
12
12
import path from 'path' ;
13
13
import getPort from 'get-port' ;
14
14
import { version } from '../package.json' ;
15
+ import { DEFAULT_FEATURE_FLAGS } from '@parcel/feature-flags' ;
15
16
16
17
const program = new commander . Command ( ) ;
17
18
@@ -103,6 +104,30 @@ const commonOptions = {
103
104
} ,
104
105
[ ] ,
105
106
] ,
107
+ '--feature-flag <name=value>' : [
108
+ 'sets the value of a feature flag' ,
109
+ ( value , previousValue ) => {
110
+ let [ name , val ] = value . split ( '=' ) ;
111
+ if ( name in DEFAULT_FEATURE_FLAGS ) {
112
+ let featureFlagValue ;
113
+ if ( typeof DEFAULT_FEATURE_FLAGS [ name ] === 'boolean' ) {
114
+ if ( val !== 'true' && val !== 'false' ) {
115
+ throw new Error (
116
+ `Feature flag ${ name } must be set to true or false` ,
117
+ ) ;
118
+ }
119
+ featureFlagValue = val ;
120
+ }
121
+ previousValue [ name ] = featureFlagValue ?? String ( val ) ;
122
+ } else {
123
+ INTERNAL_ORIGINAL_CONSOLE . warn (
124
+ `Unknown feature flag ${ name } specified, it will be ignored` ,
125
+ ) ;
126
+ }
127
+ return previousValue ;
128
+ } ,
129
+ { } ,
130
+ ] ,
106
131
} ;
107
132
108
133
var hmrOptions = {
@@ -509,5 +534,6 @@ async function normalizeOptions(
509
534
publicUrl : command . publicUrl ,
510
535
distDir : command . distDir ,
511
536
} ,
537
+ featureFlags : command . featureFlag ,
512
538
} ;
513
539
}
0 commit comments