Skip to content

Commit

Permalink
Update min SDK for build web compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Aug 16, 2024
1 parent e5ac4e9 commit ca4b498
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
6 changes: 4 additions & 2 deletions build_web_compilers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## 4.0.12-wip
## 4.0.12

- Bump the min sdk to 3.5.0.
- Support compiling to WebAssembly by using `dart2wasm` as a value for the
compiler option.
- Bump the min sdk to 3.6.0-150.0.dev.

## 4.0.11

Expand Down
40 changes: 36 additions & 4 deletions build_web_compilers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ then all you need is the `dev_dependency` listed above.

### Configuring the default compiler

By default, the [Dart development compiler][] (_dartdevc_, also known as
_DDC_) will be used.
By default, this package uses teh [Dart development compiler][] (_dartdevc_,
also known as _DDC_) to compile Dart to JavaScript. In release builds (running
the build tool with `--release`, the default compiler is `dart2js`).

If you would like to opt into dart2js you will need to add a `build.yaml`
file, which should look roughly like the following:
If you would like to opt into dart2js for all builds, you will need to add a
`build.yaml` file, which should look roughly like the following:

```yaml
targets:
Expand All @@ -63,6 +64,22 @@ targets:
- -O2
```

In addition to DDC and dart2js, this package also supports the dart2wasm
compiler for compiling to JavaScript. It can be enabled by using
`compiler: dart2wasm` in the build configuration:

```yaml
targets:
$default:
builders:
build_web_compilers:entrypoint:
options:
compiler: dart2wasm
# List flags that should be forwarded to `dart compile wasm`
dart2wasm_args:
- -O2
```
### Configuring -D environment variables
dartdevc is a modular compiler, so in order to ensure consistent builds
Expand Down Expand Up @@ -93,6 +110,21 @@ targets:
- -DANOTHER_VAR=true
```

Similarly, options are passed to `dart compile wasm` when using the
`dart2wasm_args` option:

```yaml
targets:
$default:
builders:
build_web_compilers:entrypoint:
options:
compiler: dart2wasm
dart2wasm_args:
- -DSOME_VAR=some value
- -DANOTHER_VAR=true
```

These may also be specified on the command line with a `--define` argument.

```sh
Expand Down
2 changes: 1 addition & 1 deletion build_web_compilers/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository: https://github.com/dart-lang/build/tree/master/build_web_compilers
resolution: workspace

environment:
sdk: '>=3.5.0 <3.7.0'
sdk: '>=3.6.0-150.0.dev <3.7.0'

dependencies:
analyzer: '>=5.1.0 <7.0.0'
Expand Down

0 comments on commit ca4b498

Please sign in to comment.