- Build systems automatically pass flags to dart2js to make it easy for developers to get the best of dart2js production capabilities out of the box without any configuration: this may include compiling with
--omit-implicit-checkstoday. Our flags will change, and we want that change to be transparent and not a breaking change for build systems.
- We want users to be aware of how safe/unsafe certain flags are. Documentation is not enough for this.
To improve the build system integration and prevent having to change tools downstream on every change to our compiler, we were planning to add a new set of flags that will evolve in time. Because the main goal build systems have is to have a flag to build apps at production level, we could focus on a single flag for that, e.g.
--production. The means of a production compile may vary as we implement more features. For example, once we implement our optimizations for Dart2, we can deprecate the behavior of
omit-implicit-checks, but may introduce a new option to allow unsafe casts in certain framework’s code.
--production would be equivalent to
--minify --omit-implicit-checks, but later it will be equivalent to
--minify --allow-unsafe-cast-operator or something else.
One suggestion to address the second problem is to purposely use a naming convention of flags that makes it easier for users to see how safe or unsafe the flag is. For example: it has been proposed to add
--safe-optimizations flags that take as arguments an optional list of optimizations.
- Accepted unsafe optimizations:
default, all, none, allow-unsafe-cast-operator, lax-runtime-type, omit-parameter-checks, omit-implicit-downcasts, trust-primitives
- Accepted safe optimizations:
default, all, none, minify, inlining, type-inference, rti, runtime-type(and in the future some SSA optimizer steps can be listed here).
defaultsafe optimizations are all but
defaultunsafe optimizations may only include
Another suggestion: allow values to
--production (with no args) default to
The idea is that we could also provide a warning if an underlying flag is used without using the production flag. For example:
dart2js --production=unsafe # produces no warnings dart2js --omit-implicit-checks # produces a warning about how you should test your app.
I’m starting to like this last approach. Thoughts?