Skip to content

Commit f30f84a

Browse files
authored
Merge pull request #397 from mkustermann/extra-compiler-option
Add --extra-js-compiler-option/--extra-wasm-compiler-option
2 parents 6d081a5 + a2a51b6 commit f30f84a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

packages/jaspr/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Unreleased patch
22

33
- Added `onClick` override to `a` html tag. Fixing issues with default action handling.
4+
- Added `--extra-js-compiler-option` and `--extra-wasm-compiler-option` to `jaspr build` command.
45

56
## 0.18.0
67

packages/jaspr_cli/lib/src/commands/build_command.dart

+24-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ class BuildCommand extends BaseCommand with ProxyHelper, FlutterHelper {
4242
help: 'Compile to wasm',
4343
negatable: false,
4444
);
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+
);
4557
argParser.addOption(
4658
'optimize',
4759
abbr: 'O',
@@ -240,7 +252,17 @@ class BuildCommand extends BaseCommand with ProxyHelper, FlutterHelper {
240252

241253
final compiler = useWasm ? 'dart2wasm' : 'dart2js';
242254
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+
];
244266

245267
final client = await d.connectClient(
246268
Directory.current.path,
@@ -249,7 +271,7 @@ class BuildCommand extends BaseCommand with ProxyHelper, FlutterHelper {
249271
'--verbose',
250272
'--delete-conflicting-outputs',
251273
'--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(',')}]',
253275
],
254276
logger.writeServerLog,
255277
);

0 commit comments

Comments
 (0)