build_web_compilers 2.11.0

Dart native
Flutter Android iOS

Builder implementations wrapping Dart compilers.

Web compilers for users of package:build.
Build Status Issues related to build_web_compilers Pub Package Version Latest Dartdocs Join the chat on Gitter

Installation #

This package is intended to be used as a development dependency for users of package:build who want to run code in a browser. Simply add the following to your pubspec.yaml:


Usage #

If you are using the autogenerated build script (going through pub run build_runner <command> instead of handwriting a build.dart file), then all you need is the dev_dependency listed above.

Configuration #

By default, the dartdevc compiler will be used, which is the Dart Development Compiler.

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

        # These are globs for the entrypoints you want to compile.
        - test/**.browser_test.dart
        - web/**.dart
          compiler: dart2js
          # List any dart2js specific args here, or omit it.
          - -O2

Manual Usage #

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).

        (_) => new ModuleBuilder(),
        (_) => new UnlinkedSummaryBuilder(),
        (_) => new LinkedSummaryBuilder(),
        (_) => new DevCompilerBuilder()
        // Recommended, but not required. This makes it so only modules that are
        // imported by entrypoints get compiled.
        isOptional: true,
        hideOutput: true),
        // 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'])),