Pub transformer with test dependencies

Issue

I have a dart package (Harvest) that contains a dev (test) dependency on polymer which I use only for integration testing purpose

  dev_dependencies:
    polymer: "^0.16.4+1"
    test: any
  transformers:
  - polymer:
      entry_points:
         - test/harvest_idb_test.html

However in order to run the polymer tests I need to register a polymer transformer. Running this transformer fails unless I move the polymer dependency into the projects main dependencies which I really want to avoid as its only needed for testing purposes.

Is there a way to register a transformer that depends on a dev dependency or can I somehow create a dev_transformer section.

Solution

If you use $include to only include files in your test directory, then you can leave it as a dev_dependency. The transformer won’t attempt to load when your package is used as a dependency of other packages. For example:

dev_dependencies:
  polymer: "^0.16.4+1"
  test: any
transformers:
- polymer:
    entry_points:
      - test/harvest_idb_test.html
    $include: test/**_test{.*,}.{dart,html}

Answered By – Jake MacDonald

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.