@@ -42,6 +42,18 @@ class BuildCommand extends BaseCommand with ProxyHelper, FlutterHelper {
42
42
help: 'Compile to wasm' ,
43
43
negatable: false ,
44
44
);
45
+ argParser.addMultiOption (
46
+ 'extra-js-compiler-option' ,
47
+ help: 'Extra flags to pass to `dart compile js`.' ,
48
+ defaultsTo: [],
49
+ hide: true ,
50
+ );
51
+ argParser.addMultiOption (
52
+ 'extra-wasm-compiler-option' ,
53
+ help: 'Extra flags to pass to `dart compile wasm`.' ,
54
+ defaultsTo: [],
55
+ hide: true ,
56
+ );
45
57
argParser.addOption (
46
58
'optimize' ,
47
59
abbr: 'O' ,
@@ -240,7 +252,17 @@ class BuildCommand extends BaseCommand with ProxyHelper, FlutterHelper {
240
252
241
253
final compiler = useWasm ? 'dart2wasm' : 'dart2js' ;
242
254
final entrypointBuilder = '${config !.usesJasprWebCompilers ? 'jaspr' : 'build' }_web_compilers:entrypoint' ;
243
- final userDefines = getClientDartDefines ().entries.map ((e) => ',"-D${e .key }=${e .value }"' ).join ();
255
+
256
+ final args = [
257
+ '-Djaspr.flags.release=true' ,
258
+ '-O${argResults !['optimize' ]}' ,
259
+ if (useWasm) //
260
+ ...argResults! ['extra-wasm-compiler-option' ]
261
+ else
262
+ ...argResults! ['extra-js-compiler-option' ],
263
+ for (final entry in getClientDartDefines ().entries) //
264
+ '-D${entry .key }=${entry .value }' ,
265
+ ];
244
266
245
267
final client = await d.connectClient (
246
268
Directory .current.path,
@@ -249,7 +271,7 @@ class BuildCommand extends BaseCommand with ProxyHelper, FlutterHelper {
249
271
'--verbose' ,
250
272
'--delete-conflicting-outputs' ,
251
273
'--define=$entrypointBuilder =compiler=$compiler ' ,
252
- '--define=$entrypointBuilder =${compiler }_args=["-Djaspr.flags.release=true","-O${ argResults ![ 'optimize' ]}"$ userDefines ]' ,
274
+ '--define=$entrypointBuilder =${compiler }_args=[${ args . map (( a ) => '"$ a "' ). join ( ',' )} ]' ,
253
275
],
254
276
logger.writeServerLog,
255
277
);
0 commit comments