ember-cli-code-coverage icon indicating copy to clipboard operation
ember-cli-code-coverage copied to clipboard

Transpilation issue with v2 beta

Open rmachielse opened this issue 3 years ago • 0 comments

First of all, thanks a lot for the v2 refactor! It must be much more efficient because the build time of our large app in CI went down by many minutes❗ by upgrading to the v2 beta.

Unfortunately, we ran into a strange issue that we are only seeing when building with COVERAGE=true.

I was able to reduce the reproduction to just this:

import { assign, merge } from '@ember/polyfills';

const test = assign || merge;

When building without coverage, this properly transpiles to:

const test = Ember.assign || Ember.merge;

However when building with coverage, it transpiles to:

const test = (cov_...().s[0]++, (cov_...().b[0][0]++, assign) || (cov_...().b[0][1]++, merge));

This doesn't work because assign and merge are undefined. However when using this line:

const test = assign;

It works fine as this transpiles correctly to:

cov_...();
const test = Ember.assign;

The issue is not related to assign/merge, because the same happens when using isPresent/isEmpty from @ember/utils.

We can avoid the issue by not using any || operator with imported functions, but I wanted to report this anyway.

rmachielse avatar Nov 04 '21 20:11 rmachielse