WebWorkerBuilder class

Compiles Dart worker entry points to JavaScript for web platform.

Convention:

  • Manual: lib/worker.dartweb/worker.dart.js
  • Generated: lib/worker_generated.g.dartweb/worker_generated.dart.js

Different output names allow both manual and generated workers to coexist. Manual workers take priority if both exist.

This builder:

  • Only runs for web builds
  • Uses dart compile js with production optimizations
  • Generates source maps for debugging
  • Supports watch mode for incremental rebuilds
  • Materializes same-package *.g.dart imports to the filesystem before invoking the compiler

Compilation Options

  • Minified output for production
  • Sound null safety
  • Omit implicit checks (faster execution)
  • Source maps included

Error Handling

  • Logs compilation errors clearly
  • Fails build if compilation fails
  • Reports compilation time

Constructors

WebWorkerBuilder()

Properties

buildExtensions Map<String, List<String>>
Mapping from input file extension to output file extensions.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildStep buildStep) Future<void>
Generates the outputs for a given BuildStep.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

workerOutput → const String
Output extension for compiled worker.