|
| 1 | +- Start Date: 2018-05-08 |
| 2 | +- RFC PR: https://github.com/emberjs/rfcs/pull/331 |
| 3 | +- Ember Issue: (leave this empty) |
| 4 | + |
| 5 | +# Summary |
| 6 | + |
| 7 | +Deprecate all use of: |
| 8 | + |
| 9 | +- Ember Globals Resolver (looks up a class via a global namespace such as "App") |
| 10 | +- Creation of a Global Namespace (`var App = Ember.Namespace.create();`) |
| 11 | +- Ember.TEMPLATES array |
| 12 | +- <script type="text/handlebars" data-template-name="path/to/template"> |
| 13 | + |
| 14 | +Use of any of the above should trigger a deprecation warning, with a target |
| 15 | +of version 4.0 |
| 16 | + |
| 17 | +# Motivation |
| 18 | + |
| 19 | +Over the past years we have transitioned to using Ember-CLI as the main way |
| 20 | +to compile Ember apps. The globals resolver is a holdover and primarily |
| 21 | +facilitates use of Ember without Ember-CLI. |
| 22 | + |
| 23 | +# The Globals Resolver |
| 24 | + |
| 25 | +For those who are not aware, the globals resolver is available via `@ember/globals-resolver` or |
| 26 | +`Ember.DefaultResolver`. For more information, see the |
| 27 | +[api](https://www.emberjs.com/api/ember/release/classes/GlobalsResolver/properties). |
| 28 | +Using it looks like the following: |
| 29 | + |
| 30 | +```js |
| 31 | +// app.js |
| 32 | +var App = Ember.Application.create(); |
| 33 | + |
| 34 | +App.Router.map(function() { |
| 35 | + this.route('about'); |
| 36 | +}); |
| 37 | + |
| 38 | +App.AboutRoute = Ember.Route.extend({ |
| 39 | + model: function() { |
| 40 | + return ['red', 'yellow', 'blue']; |
| 41 | + } |
| 42 | +}); |
| 43 | +``` |
| 44 | + |
| 45 | +```html |
| 46 | +// index.html |
| 47 | +<script type="text/x-handlebars" data-template-name="about"> |
| 48 | + <ul> |
| 49 | + {{#each model as |item|}} |
| 50 | + <li>{{item}}</li> |
| 51 | + {{/each}} |
| 52 | + </ul> |
| 53 | +</script> |
| 54 | +``` |
| 55 | + |
| 56 | +# Implementation Details |
| 57 | + |
| 58 | +One small detail required to implement this RFC: ember-cli's own default resolver, |
| 59 | +[ember-resolver](https://github.com/ember-cli/ember-resolver) |
| 60 | +currently still extends from the globals resolver. |
| 61 | +In order to implement this RFC, the ember-cli resolver will need to be changed |
| 62 | +so that it does *not* extend from the globals resolver, or otherwise ember-cli users |
| 63 | +will get a deprecation warning as well. |
| 64 | +However, changing the base class of the ember cli classic resolver is a breaking change, |
| 65 | +so prior to ember/ember-cli version 4.0 we need to take another step. |
| 66 | +In the ember-cli classic resolver, deprecate any runtime calls where there is fallback to the globals mode resolver. This would be a deprecation in ember-cli's resolver. We could bump a major version of ember-cli-resolver removing the base class and release it in ember-cli after an LTS of ember-cli. |
| 67 | + |
| 68 | +# Transition Path |
| 69 | + |
| 70 | +Primarily, the transition path is to recommend using Ember-CLI. |
| 71 | + |
| 72 | +During the 3.x timeframe, it MAY become increasingly difficult to use this old functionality. |
| 73 | +For example, with the release of 3.0, we already stopped publishing builds that support |
| 74 | +globals mode. Here are some of the changes that have impacted or may soon impact users of globals mode: |
| 75 | + |
| 76 | +## Impact of ES6 modules |
| 77 | + |
| 78 | +Users of ES6 modules must use their own build tooling to convert them to named AMD modules via Babel. |
| 79 | +No support is provided for <script type="module"> at this time, although that may change. |
| 80 | + |
| 81 | +## Impact of New Module Imports |
| 82 | + |
| 83 | +Globals based apps are only able to use new module imports via the polyfill available at |
| 84 | +https://github.com/ember-cli/babel-plugin-ember-modules-api-polyfill No build support for this is provided. |
| 85 | + |
| 86 | +## Impact of not publishing globals builds |
| 87 | + |
| 88 | +It is necessary to get a globals build of Ember.js from the npm package now that globals builds |
| 89 | +are no longer published to S3, builds.emberjs.com, and CDNs. |
| 90 | + |
| 91 | +## Impact of not Generating a Globals Build in Ember.js Package |
| 92 | + |
| 93 | +At some point during the 3.x cycle, it may be that we no longer publish a globals build in the |
| 94 | +npm package. At that point, it may become necessary to use Ember-CLI to generate a globals build |
| 95 | +of Ember.js |
| 96 | + |
| 97 | +## Impact of Package Splitting |
| 98 | + |
| 99 | +Work has started on package splitting. It is likely that the globals resolver may not be included |
| 100 | +in a default partial build of Ember.js and may be moved to its own package for easy removal. |
| 101 | + |
| 102 | +## Impact of Tree Shaking |
| 103 | + |
| 104 | +If the globals resolver is moved to a separate package, it will likely not be included in a build |
| 105 | +of Ember.js by default unless tree shaking is turned off. |
| 106 | + |
| 107 | +# How We Teach This |
| 108 | + |
| 109 | +We already do teach this and don't teach the globals resolver. No changes required here. |
| 110 | + |
| 111 | +## Deprecation Guide |
| 112 | + |
| 113 | +A draft deprecation guide has been pull requested at https://github.com/ember-learn/deprecation-app/pull/155 |
| 114 | + |
| 115 | +# Drawbacks |
| 116 | + |
| 117 | +A drawback is that people may want alternate build tooling to Ember-CLI. |
| 118 | +We have mitigated this by openly publishing the ember-cli resolver and all parts of the |
| 119 | +ember-cli ecosystem under the MIT license. |
| 120 | +Alternate build tooling may simply use this open source code to build a competing |
| 121 | +infrastructure to ember-cli. |
| 122 | + |
| 123 | +# Alternatives |
| 124 | + |
| 125 | +Without doing this, we will have to continue to ship and maintain this rarely used functionality. |
| 126 | +We don't believe this is a reasonable alternative. |
| 127 | + |
| 128 | +# Unresolved questions |
| 129 | + |
| 130 | +There has never been a transition guide for transitioning an old codebase to Ember-CLI. |
| 131 | +Do we want to create one at this late date? |
0 commit comments