From 5d3f8adb51489a9ae3bb8c8782b39efa3456d790 Mon Sep 17 00:00:00 2001 From: Alon Bukai Date: Wed, 29 Aug 2018 20:34:15 +0300 Subject: [PATCH 1/2] Add section on Module Unification Packages This might be a bit too long? Not sure where to cut it or if I maybe need to add more? --- .../2018-08-31-the-ember-times-issue-62.md | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/source/blog/2018-08-31-the-ember-times-issue-62.md b/source/blog/2018-08-31-the-ember-times-issue-62.md index b99793cb39..57dd20120f 100644 --- a/source/blog/2018-08-31-the-ember-times-issue-62.md +++ b/source/blog/2018-08-31-the-ember-times-issue-62.md @@ -41,8 +41,47 @@ Read more in the [rendered pull request on GitHub](https://github.com/emberjs/rf --- -## [SECTION TITLE](#section-url) +## [Module Unification with Ember Addons](https://github.com/emberjs/rfcs/pull/367) 🎁 +[Module Unification Packages](https://github.com/emberjs/rfcs/pull/367) is a new RFC, created by [@mixonic](https://github.com/mixonic), that sets out to describe how packages, **Ember Addons**, work and how apps and addons will migrate to the new [Module Unification](https://github.com/emberjs/rfcs/blob/master/text/0143-module-unification.md) structure from the classic structure. This RFC iterates on and is set to replace another RFC called [Module Unification Namespaces](https://github.com/emberjs/rfcs/pull/309) which had some syntax, like the `::` syntax, that proved problematic. + +This RFC proposes to add a new `{{use}}` helper that will be used to call external components that are provided by addons. This helper is a subset of the javascript imports that we are used to. + +An example: In this template the `{{use}}` helper imports a component `Widget` from the `gadget` addon. + +```hbs +{{! invokes node_modules/gadget/src/ui/components/Widget/component.js }} + +{{use Widget from 'gadget'}} + +``` + +Something else that is proposed in this RFC is the use of a template `prelude.hbs` that, **at compile time**, will be injected into every template in the app. This can be used to inject global components such as the widely used `{{t 'token'}}` component used for *internationalization*. + +Services also get some **love** in this RFC. The suggestion is that all service calls to addons will become more verbose in that the injected service will need to provide where to inject from. + +An example: + +```js +export default Ember.Component.extend({ + + // inject src/services/geo.js + geo: inject(), + + // inject node_modules/ember-stripe-service/src/services/store.js + checkoutService: inject('stripe', { package: 'ember-stripe-service' }), + + // inject node_modules/ember-simple-auth/src/services/session.js + session: inject({ package: 'ember-simple-auth' }) + +}); +``` + +There is also some proposals regarding `owner` APIs such as `owner.lookup()` and `owner.factoryFor()` which have also become more explicit. + +All in all this, **very well written**, RFC is a great chance to learn about possible changes to Ember and the Module Unification structure. +If you have any concerns or questions feel free to ask in the [RFC issue](https://github.com/emberjs/rfcs/pull/367) and join in on the conversation. +This RFC is not complete and is a bit rough around the edges but it is a step in the right direction and will hopefully be finalized soon so that we can start using it in an Ember version in the near future. --- From 10fb0e07d449b87b3b48e0aa18259d47278c39ce Mon Sep 17 00:00:00 2001 From: Alon Bukai Date: Thu, 30 Aug 2018 19:58:05 +0300 Subject: [PATCH 2/2] Fixed comments by @mixonic --- source/blog/2018-08-31-the-ember-times-issue-62.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blog/2018-08-31-the-ember-times-issue-62.md b/source/blog/2018-08-31-the-ember-times-issue-62.md index 57dd20120f..f40e7c15db 100644 --- a/source/blog/2018-08-31-the-ember-times-issue-62.md +++ b/source/blog/2018-08-31-the-ember-times-issue-62.md @@ -42,9 +42,9 @@ Read more in the [rendered pull request on GitHub](https://github.com/emberjs/rf --- ## [Module Unification with Ember Addons](https://github.com/emberjs/rfcs/pull/367) 🎁 -[Module Unification Packages](https://github.com/emberjs/rfcs/pull/367) is a new RFC, created by [@mixonic](https://github.com/mixonic), that sets out to describe how packages, **Ember Addons**, work and how apps and addons will migrate to the new [Module Unification](https://github.com/emberjs/rfcs/blob/master/text/0143-module-unification.md) structure from the classic structure. This RFC iterates on and is set to replace another RFC called [Module Unification Namespaces](https://github.com/emberjs/rfcs/pull/309) which had some syntax, like the `::` syntax, that proved problematic. +[Module Unification Packages](https://github.com/emberjs/rfcs/pull/367) is a new RFC, created by [@mixonic](https://github.com/mixonic), that sets out to describe how Ember apps and addons will migrate to the new [Module Unification](https://github.com/emberjs/rfcs/blob/master/text/0143-module-unification.md) structure from the classic structure. This RFC iterates on and is set to replace another RFC called [Module Unification Namespaces](https://github.com/emberjs/rfcs/pull/309) which had some syntax, like the `::` syntax, that proved problematic. -This RFC proposes to add a new `{{use}}` helper that will be used to call external components that are provided by addons. This helper is a subset of the javascript imports that we are used to. +This RFC proposes to add a new `{{use}}` helper. This helper imports components from an addon into an application's template. This helper provides a subset of the functionality of the JavaScript imports that we are used to, albeit with a slightly different syntax. An example: In this template the `{{use}}` helper imports a component `Widget` from the `gadget` addon. @@ -52,12 +52,12 @@ An example: In this template the `{{use}}` helper imports a component `Widget` f {{! invokes node_modules/gadget/src/ui/components/Widget/component.js }} {{use Widget from 'gadget'}} - + ``` Something else that is proposed in this RFC is the use of a template `prelude.hbs` that, **at compile time**, will be injected into every template in the app. This can be used to inject global components such as the widely used `{{t 'token'}}` component used for *internationalization*. -Services also get some **love** in this RFC. The suggestion is that all service calls to addons will become more verbose in that the injected service will need to provide where to inject from. +Services also get some **love** in this RFC. The suggestion is that all service injections from an addon to an app will need to be explicit about their source package. This results in more verbosity, but also greater clarity and opportunity for optimizations. An example: @@ -76,10 +76,10 @@ export default Ember.Component.extend({ }); ``` -There is also some proposals regarding `owner` APIs such as `owner.lookup()` and `owner.factoryFor()` which have also become more explicit. +There are also some proposals regarding `owner` APIs such as `owner.lookup()` and `owner.factoryFor()` which have also become more explicit. All in all this, **very well written**, RFC is a great chance to learn about possible changes to Ember and the Module Unification structure. -If you have any concerns or questions feel free to ask in the [RFC issue](https://github.com/emberjs/rfcs/pull/367) and join in on the conversation. +If you have any concerns or questions feel free to ask in the [RFC issue](https://github.com/emberjs/rfcs/pull/367) and join in on the conversation by visiting `#st-module-unification` on the Ember.js Community Slack. This RFC is not complete and is a bit rough around the edges but it is a step in the right direction and will hopefully be finalized soon so that we can start using it in an Ember version in the near future.