Web compilers for users of
If you are using the autogenerated build script (going through
pub run build_runner <command> instead of handwriting a
then all you need is the
dev_dependency listed above.
By default, the
dartdevc compiler will be used, which is the Dart Development
If you would like to opt into
dart2js you will need to add a
file, which should look roughly like the following:
targets: $default: builders: build_web_compilers|entrypoint: # These are globs for the entrypoints you want to compile. generate_for: - test/**.browser_test.dart - web/**.dart options: compiler: dart2js # List any dart2js specific args here, or omit it. dart2js_args: - --checked
If you are using a custom build script, you will need to add the following builder applications to what you already have, almost certainly at the end of the list (unless you need to post-process the js files).
[ apply( 'build_web_compilers|ddc', [ (_) => new ModuleBuilder(), (_) => new UnlinkedSummaryBuilder(), (_) => new LinkedSummaryBuilder(), (_) => new DevCompilerBuilder() ], toAllPackages(), // Recommended, but not required. This makes it so only modules that are // imported by entrypoints get compiled. isOptional: true, hideOutput: true), apply('build_web_compilers|entrypoint', // You can also use `WebCompiler.Dart2Js`. If you don't care about // dartdevc at all you may also omit the previous builder application // entirely. [(_) => new WebEntrypointBuilder(WebCompiler.DartDevc)], toRoot(), hideOutput: true, // These globs should match your entrypoints only. defaultGenerateFor: const InputSet( include: const ['web/**', 'test/**.browser_test.dart'])), ]