Conversation
…ripping Ember CLI: Production code stripping
|
This RFC is somewhat an extraction of RFC in PR #89, but less controversial in the sense that focuses on standarizing app targets and its syntax but leaves open how ember, ember-cli or addons should use them. I open this in hope that it can be approved faster and independently of the advances in the babel6 migration. |
active/0000-standarise-targets.md
Outdated
| ### Motivation | ||
|
|
||
| Javascript and the platforms it runs on are moving targets. NodeJS and browsers release new | ||
| versions every few weeks. Browsers auto update and each update bings new language features |
active/0000-standarise-targets.md
Outdated
|
|
||
| The syntax for for this configuration option is even simpler, since apps will only run in a single | ||
| version of node and developers are in control of it, so the only thing users must specify is the | ||
| minimum supported version of node. |
There was a problem hiding this comment.
If this is added, I would either let the user specify the node version as they do in the package.json or specify in the name that is the minimum version acceptable. The first option is harder to implement, but people would be more used to it.
There was a problem hiding this comment.
I'd suggest that the default would just do node: require('../package').engine (deferring to the engine listed in package.json).
There was a problem hiding this comment.
I'm also ok with that. We can reuse it.
|
|
||
| Let every addon that wants to deal with targets to have a `targets`-like option in its configuration | ||
| instead of standardizing a single configuration option, which effectively leaves things as they are | ||
| right now. |
There was a problem hiding this comment.
This option opens the door of a misconfiguration, in the sense that you might add support for X browser in autoprefixer but not in babel and suddenly, your life is much more interesting. :)
There was a problem hiding this comment.
I didn't say it was a good alternative 😉 But this is the state of things right now: each addon uses it's own configuration, and possibly its own syntax.
|
big fan of this direction! I'll try and fine time over the next few days to thoroughly review. |
|
@stefanpenner any opinion on core people on this? I could work in the implementation myself. I'm craving for some tooling. |
rwjblue
left a comment
There was a problem hiding this comment.
but this RFC doesn't impose any mandatory behavior on addons
I agree that we shouldn't (or can't) mandate anything, but we should recommend that they honor them...
active/0000-standarise-targets.md
Outdated
|
|
||
| Developers need an easy way to express intention that abstracts them from the ever-changing | ||
| landscape of versions and feature matrices, so this RFC proposes to introduce a universal | ||
| configuration option to let developers express they intended targets |
|
|
||
| Addons that would benefit from this conventions are `babel-preset-env`, `autoprefixer`, | ||
| `stylelint` and `eslint` (vía `eslint-plugin-compat`), but not only those. Even Ember itself could, | ||
| once converted into an addon, take advantage of that to avoid polyfilling or even taking |
There was a problem hiding this comment.
it is an addon as of ember-cli@2.11 / ember-source@2.11.0 🎉
active/0000-standarise-targets.md
Outdated
| once converted into an addon, take advantage of that to avoid polyfilling or even taking | ||
| advantage of some DOM API (`node.classList`?) deep in Glimmer's internals. | ||
|
|
||
| ### Detailed implementation |
There was a problem hiding this comment.
Not sure if this was intentionally left blank?
There was a problem hiding this comment.
It wasn't blank, it's just that it was an h3 and it should be an h1, and the next points are subsections.
active/0000-standarise-targets.md
Outdated
| ``` | ||
|
|
||
| This configuration must be made available to addons. It's up to the addons to use it. | ||
| I suggest to make it available in `app.targets` |
There was a problem hiding this comment.
I would prefer one of these instead:
- add
this.targetsproperty this.project.targets()/this.project.targets
active/0000-standarise-targets.md
Outdated
|
|
||
| ```js | ||
| var app = new EmberApp(defaults, { | ||
| targets: { |
There was a problem hiding this comment.
We should avoid tying this target system to the build time only ember-cli-build.js / EmberApp instance since it will be needed from places outside of the build environment. For example, when editing a project I enjoy utilizing my editors built in eslint system to indicate any linting errors/warnings that I have in my code. If I wanted to utilize eslint-plugin-compat, I would have to duplicate the configuration in ember-cli-build.js and .eslintrc.js (or change ember-cli-build.js to have multiple exports).
I'd prefer that we either:
- put the config in
.ember-clifile which is already in the project - put the config in another file in
config/(e.g.config/supported-targets.js)
There was a problem hiding this comment.
Actually, one interesting approach of this is the one eslint-plugin-compat uses. It reads the browserlist property in the package.json.
If we are cool with reading the engines property of the package.json for the node support it might also be a reasonable place to the list of supporter browsers.
active/0000-standarise-targets.md
Outdated
| included(app) { | ||
| this._super.included.apply(this, arguments); | ||
|
|
||
| console.log(app.targets.browsers); // ['>2%', 'last 3 iOS versions', 'not ie <= 8'] |
There was a problem hiding this comment.
The meaning of app changes when using things like fastboot and ember-engines, this is why I would like to decouple storing of target from app...
active/0000-standarise-targets.md
Outdated
|
|
||
| The syntax for for this configuration option is even simpler, since apps will only run in a single | ||
| version of node and developers are in control of it, so the only thing users must specify is the | ||
| minimum supported version of node. |
There was a problem hiding this comment.
I'd suggest that the default would just do node: require('../package').engine (deferring to the engine listed in package.json).
| traditionally enforced only with peer reviews. | ||
|
|
||
| To ease the transition Ember CLI can also, in the absence of a specific value provided by the user, | ||
| default to a predefined matrix of browsers that matches the browsers officially supported by the framework. |
There was a problem hiding this comment.
👍 - But we should (in this RFC) list out the "default" configuration...
There was a problem hiding this comment.
I'm not sure what Ember supports. I know that IE support starts in 9, but no idea about the policy for other evergreen browsers. Is there one? Who knows it?
active/0000-standarise-targets.md
Outdated
|
|
||
| ```js | ||
| var app = new EmberApp(defaults, { | ||
| targets: { |
There was a problem hiding this comment.
targets object, to be consider together? e.g. lowest common denominator between all properties, or is this 2 separate builds... I believe they should be lowest common denominator
There was a problem hiding this comment.
This is affectively how things like babel-preset-env and eslint-plugin-compat works. Browserlist has an evergreen database from caniuse.com with features by browser version, so it calculates the support on a per-feature basis.
I'll add it.
There was a problem hiding this comment.
Added support matrix from the browsers we test in saucelabs & travis. No mention to ios tho, but likely IE9 will be the weakest ring of the chain in everything anyway.
|
Discussed during ember-cli core team meeting today, we were generally very 👍. Main issues are:
|
|
If the default is dependent on which ember version you may be using, should it be bundled with ember (like its blueprints)? I'm not sure what this would look like in a way you could override it in ember-cli land... |
|
@kellyselden It could be part of ember-cli, because a ember drops browser support in major versions only, which would carry (I think) a major version bump in ember-cli as well. |
|
@cibernox True, but we still allow ember 1.13 in ember-cli 2.x, and will be the same for the next cycles. Might be unnecessary friction to have more code in cli that ties to specific ember versions. |
|
@kellyselden So options:
I lean towards the first. At the end ember.js already has (kind of) this information about browser support in the config files for travis and saucelabs. |
active/0000-standarise-targets.md
Outdated
| This library is very powerful and popular, making relatively easy to integrate with a good amount of | ||
| tools that use it in little time. | ||
|
|
||
| This configuration must be made available to addons but we it's up to the addon authors to take advantage |
|
Feedback applied:
|
|
Does the |
|
@kanongil The node property is basically |
|
Discussed in ember-cli core meeting today, we are 👍 on advancing this to final comment period. One thing that we would like to see before landing the RFC (after FCP is finished and whatnot) is a spike of the implementation in a PR to ember-cli. This is just to confirm that all of the constraints listed here are addressed and we don't find flaws. I believe that I will have time to spike this out in the next couple of days... |
|
Nice! If you don't let me know and I can try. |
|
speaking of targets, is there any consideration for targets like Cordova, Electron, or "Ember Native" (maybe in the future)? |
|
@Cryrivers - Yes, but that is a somewhat separate RFC (see #93 for some background). |
|
@Cryrivers @rwjblue Actually after some investigation there is a small overlapping on the concepts. Some libraries like The targets this RFC targets are the javascript runtimes in which this app is going to run. That is the browser or electron version, or even node version in fastboot. A separate concept is "platforms" (name to be bikeshedded) that only makes sense when you are going to wrap your app and you are going to write javascript code that bridges to the OS using electron/cordoba APIs. In summary, in this RFC a target is "where my Ember app code is going to run on". The electron specific code is probably going to live in a separate folder and RFC #93 wants to solve that. It's an area I don't have any expertise on, TBH. |
|
I'm a bit concerned that the As it is, you can confuse it with other runtime capabilities, like css capabilities, which e.g. https://github.com/kimroen/ember-cli-autoprefixer handles. |
|
@kanongil - I believe that is entirely the point. We want it to be used for both JS transpilation and CSS transpilation targeting. This is mentioned in the Motivation and Detailed Design sections of this RFC. |
|
@kanongil exactly. It's not scoped to js. CSS is part of the plan. My example if my app drops support for IE11 then my |
|
I have a working implementation of this ember-cli/ember-cli#6776 I've also spiked how ember-maybe-import-regenerator (used by ember-concurrency) could use it to conditionally avoid including the regenerator polyfill if the built matrix supports generator functions. |
|
Discussed in ember-cli core team meeting yesterday, and with some small (scope narrowing) changes we are ready to land this. Specifically, we would like to restrict @cibernox - Let me know when you have had a chance to update that, and we are ready to land this... |
|
@rwjblue Amended the RFC to leave node/fastboot out of this RFC, so will cross that bridge another day. |
Implement targets RFC This PR implements ember-cli/rfcs#95 (still unmerged). API example ```js app.project.targets; // { browsers: [...], node: '6.6.0' }; ```
|
In case you missed it, I posted some comments on javascript issues in #104. |
Standarize targets
rendered