Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable feature flags #3979

Merged
merged 3 commits into from
Dec 11, 2015
Merged

Re-enable feature flags #3979

merged 3 commits into from
Dec 11, 2015

Conversation

pangratz
Copy link
Member

@pangratz pangratz commented Dec 8, 2015

This re-enables testing feature flags and stripping disabled feature flags from production build (using ember-cli/babel-plugin-feature-flags).

Feature flags are now possible within ember-data by using the following setup:

import isEnabled from 'ember-data/features';

if (isEnabled("ds-my-feature")) {
  // ...
}

The features need to be defined within config/features.json. Disabled feature flags are also stripped from production builds.


Running the tests with all optional feature flags enabled is possible via ember test --environment=test-optional-features. When the tests are run via ember serve, the optional feature flags can be enabled via a checkbox.


This addresses #3922.

This add the `babel-plugin-feature-flag` BabelJS plugin to the build
pipeline, so all code paths are stripped for features, which are not
enabled in `config/features.json`.

Feature detection within the addon is handled similar to the one in
Ember.js:

```
import isEnabled from 'ember-data/features';

if (isEnabled("ds-new-feature")) {
  // code for the feature
}
```
@rwjblue
Copy link
Member

rwjblue commented Dec 8, 2015

Nice work here @pangratz!

Optional features and the corresponding tests can now be enabled within
the tests by specifying the `test-optional-features` environment:

    ember test --environment=test-optional-features
Optional feature flags can now be enabled via a checkbox, rendered at
the top of the test page. The state of the checkbox is set as query
parameter in the URL.

An in-repo-addon ensures that the ENABLE_OPTIONAL_FEATURES flag works
correctly, when the tests are run inside a browser: the workaround using
the in-repo-addon is needed, since the flag needs to be set before
Ember.js is loaded, but there is currently no other way.

return array.join('\n');
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwjblue do you, as an ember-cli resident, have an idea for a nicer solution than this? Basically EmberENV needs to be modified after QUnit is loaded (so we have access to QUnit.urlconfig and before ember is loaded (so the updated, latest version of EmberENV is considered).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is javascript we should probably use JS comments instead of HTML

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is javascript we should probably use JS comments instead of HTML

👍 absolutely

@bmac
Copy link
Member

bmac commented Dec 9, 2015

👍 You are my hero @pangratz \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants