This repository has been archived by the owner on Jan 20, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ember CLI: Production code stripping
- Loading branch information
1 parent
8c1ec3b
commit 43f4094
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
- Start Date: 2016-04-06 | ||
- RFC PR: (leave this empty) | ||
- ember-cli Issue: (leave this empty) | ||
|
||
# Summary | ||
|
||
A number of Ember framework function calls are no-ops in production. Ember CLI should strip these no-op function invocations from production builds by default. | ||
|
||
# Motivation | ||
|
||
Removing code that isn't required in production results in smaller and faster applications. | ||
|
||
# Detailed design | ||
|
||
The following framework function calls will be removed from ember-cli production builds by default: | ||
|
||
* [`Ember.assert`](http://emberjs.com/api/#method_assert) | ||
* [`Ember.debug`](http://emberjs.com/api/#method_debug) | ||
* [`Ember.deprecate`](http://emberjs.com/api/#method_deprecate) | ||
* [`Ember.info`](http://emberjs.com/api/#method_info) | ||
* [`Ember.runInDebug`](http://emberjs.com/api/#method_runInDebug) | ||
* [`Ember.warn`](http://emberjs.com/api/#method_warn) | ||
|
||
The API documentation will be updated where necessary to indicate that these function calls will be stripped from production. | ||
|
||
A Babel plugin will execute the removal of these function calls. It will either be: | ||
|
||
* [babel-plugin-filter-imports](https://github.com/ember-cli/babel-plugin-filter-imports) with added support for defining module functions for removal ([spike here](https://github.com/GavinJoyce/babel-plugin-filter-imports/pull/1)) | ||
* a new babel plugin which works similarly to `babel-plugin-filter-imports` | ||
|
||
For consistency, this plugin should also be used in Ember Data and other Ember projects which would benefit from the reduced size. | ||
|
||
# How We Teach This | ||
|
||
This change doesn't bring any new functionality or visible changes. Other than updating the Ember API docs, we don't need to make guide or other documentation changes. | ||
|
||
If we want to expose the configuration options so that application authors can customise the settings, we can include a new section in the Ember CLI docs. | ||
|
||
# Drawbacks | ||
|
||
TODO: | ||
|
||
* [ ] Are all these functions already no-ops in production? If so, there are no obvious drawbacks | ||
|
||
# Alternatives | ||
|
||
An Ember addon could provide opt-in function stripping for application who want it. If this RFC isn't deemed a good default for Ember CLI, that option should be explored. | ||
|
||
# Unresolved questions | ||
|
||
* [ ] Should we allow the stripping configuration to be overridden in `ember-cli-build.js`? If so, what should the API be? |