Skip to content
This repository has been archived by the owner on Jul 20, 2018. It is now read-only.

Aggregate Transformer Build Error #72

Open
kzhdev opened this issue Apr 4, 2016 · 0 comments
Open

Aggregate Transformer Build Error #72

kzhdev opened this issue Apr 4, 2016 · 0 comments

Comments

@kzhdev
Copy link

kzhdev commented Apr 4, 2016

I have an aggregate transformer which combines two JavaScript files into one. The transformer always cause an build error:

Build error:
Transforms {AlgoStoreMirror on adl_client|workerJs} all emitted asset adl_client|web/js/algo_store_mirror_worker.js.

Here is description of aggregate transformer on the web:

An aggregate transformer processes multiple assets in a single pass–for example, collaging multiple images into a single image.

Why it causes this build error?

Here is my transformer:

library adl_client.lib.algo_store_mirror_transformer;

import 'dart:async';
import 'package:barback/barback.dart';

class AlgoStoreMirrorTransformer extends AggregateTransformer {

  final List<String> includes = [
    'lib/js_src/vendor/q/q.js',
    'lib/js_src/services/algo-store/algo-store-mirror-worker.js.tpl'
  ];

  AlgoStoreMirrorTransformer.asPlugin();

  classifyPrimary(AssetId id) {
    if (includes.contains(id.path)) {
      return 'workerJs';
    }
    return null;
  }

  Future apply(AggregateTransform transform) async {
    var buffer = new StringBuffer();
    var assets = await transform.primaryInputs.toList();
    for (var asset in assets) {
      buffer.write(await asset.readAsString());
      buffer.write('\n');
    }
    var id = new AssetId(transform.package, 'web/js/algo_store_mirror_worker.js');
    transform.addOutput(new Asset.fromString(id, buffer.toString()));
  }
}
@kzhdev kzhdev changed the title Build Error? Aggregate Transformer Build Error Apr 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant