ember-cli / ember-compatibility-helpers

Helpers that allow you to write backwards compat Ember addons
MIT License
24 stars 20 forks source link

Add support for dynamic `gte` / `lte` imports. #15

Closed rwjblue closed 6 years ago

rwjblue commented 6 years ago

This PR adds support for (and testing of) the following usage:

import { gte } from 'ember-compatibility-helpers';

const HAS_SPECIAL_SAUCE = gte('3.1.0');

if (HAS_SPECIAL_SAUCE) {
  // ...snip...
}

Into:

const HAS_SPECIAL_SAUCE = true;

if (HAS_SPECIAL_SAUCE) {
  // ...snip...
}

This works by replacing the gte and lte CallExpressions with the literal boolean results at compile time.