Add module-unification-app blueprint#7488
Conversation
27e3a4b to
6c3406a
Compare
module-unification-app blueprintmodule-unification-app blueprint
| run(commandOptions, rawArgs) { | ||
| if (process.env.MODULE_UNIFICATION === 'true' && commandOptions.blueprint === 'app') { | ||
| commandOptions.blueprint = 'module-unification-app'; | ||
| } |
There was a problem hiding this comment.
I'll extract some of this in a subsequent PR once I've got a second place that needs to use it
@mansona and I have a spike of what the output for addons should look like in https://github.com/stonecircle/ember-addon-output/tree/feature/module-unification-initial-work, hopefully that will help with adding addon support with the env flag... |
rwjblue
left a comment
There was a problem hiding this comment.
Very exciting!
As I am reviewing, I am getting concerned about maintenance of both blueprints over time with the structure here in the PR. Do you think we could refactor things a bit such that we only have to maintain the differences from the main app blueprint? I think that would dramatically reduce the total maintenance burden if we can swing it.
@GavinJoyce - What do you think?
| @@ -0,0 +1,6 @@ | |||
| { | |||
There was a problem hiding this comment.
We don't emit bower.json any longer
There was a problem hiding this comment.
Hmm, maybe we still need one to get ember-canary build? 🤔
There was a problem hiding this comment.
LMK if it's possible to opt in to canary in package.json. Otherwise, I'll leave this as is for now
There was a problem hiding this comment.
We can (via github:emberjs/ember.js) but it requires npm@5 or yarn@1 I believe. Seems good to test if you have time?
There was a problem hiding this comment.
I couldn't seem to get this to work. I'll add to this my list and come back to it in a future PR
| @@ -0,0 +1,13 @@ | |||
| module.exports = { | |||
There was a problem hiding this comment.
Should be sync'ed with app's .eslintrc.js file (we use overrides and such now)...
| @@ -0,0 +1,15 @@ | |||
| <?xml version="1.0"?> | |||
There was a problem hiding this comment.
I think this file is removed for the normal app blueprint?
| @@ -0,0 +1,5 @@ | |||
| module.exports = { | |||
There was a problem hiding this comment.
The usage of overrides in .eslintrc.js should remove the need for these files
| @@ -0,0 +1,5 @@ | |||
| import Component from "@ember/component"; | |||
There was a problem hiding this comment.
We probably don't want to emit a component...
| @@ -0,0 +1,5 @@ | |||
| <code>src/ui/components/my-component/template.hbs</code> | |||
| @@ -0,0 +1,3 @@ | |||
| <code>src/ui/routes/index/template.hbs</code> | |||
|
|
|||
| {{my-component}} | |||
There was a problem hiding this comment.
Should invoke the {{welcome-page}} addon...
There was a problem hiding this comment.
To mirror the app blueprint, I'm going to zap the index route and add {{welcome-page}} to application.hbs
tests/acceptance/new-test.js
Outdated
| ]); | ||
|
|
||
| confirmBlueprintedForDir('blueprints/module-unification-app'); | ||
| process.env.MODULE_UNIFICATION = undefined; |
There was a problem hiding this comment.
Should probably done in an afterEach in case the generation blows up and leaves us in a bad state...
|
Thanks for the feedback @rwjblue. I copied over the content of https://github.com/emberjs/ember-module-unification-blueprint directly and didn't consider making any changes to the content of those files. I'll address your feedback this evening, thanks |
@rwjblue That's interesting, I'll have a think about how we might solve this. Do we know how long we expect to have to maintain the two blueprints for? Are we sure that the pain caused by having to maintain duplicate blueprints outweighs the additional complexity and possible brittleness that would come with a solution to share commonality? |
|
A possible solution would be to define the shared files in one path and the specific files in another, something like: The We'd need to make some changes to how we test too. @rwjblue any thoughts on this approach? |
|
In general, it seems good to me. FWIW, I do agree with your earlier point too (around adding complexity for a temp situation), I’m just not sure how to guess how long we will need to support both. I suspect it will be at least a couple of releases... I’m mostly just trying to set us up for success and I worry that during the time where we maintain both we might accidentally forget to keep them in sync properly and therefore make the end-user tester experience much worse... |
|
How about we live with the duplication for the short term and build out support for module unification This will allow me to initially focus on landing the feature for MU support in blueprints |
|
Ok, sounds good to me. |
9ee97dd to
27cf0f3
Compare
| "ember-welcome-page": "^3.0.0<% } %>", | ||
| "eslint-plugin-ember": "^5.0.0", | ||
| "loader.js": "^4.2.3" | ||
| }, |
There was a problem hiding this comment.
I've updated these dependencies to more closely mirror https://github.com/ember-cli/ember-cli/blob/d9c015974436ab0b80f552ed7689e968e3d50f91/blueprints/app/files/package.json
|
@rwjblue I've addressed your feedback. Here's a repo with the current output of https://github.com/GavinJoyce/module-unification-blueprint-app-output |
| @@ -0,0 +1,13 @@ | |||
| import Resolver from 'ember-resolver/resolvers/glimmer-wrapper'; | |||
There was a problem hiding this comment.
Changing this to ember-resolver/resolvers/fallback should allow "classic" addons to continue to work within module unification apps (and therefore fix {{welcome-page}} without modification). Can you test to confirm?
There was a problem hiding this comment.
Thanks, I've made the change and confirmed that this works
27cf0f3 to
cab2862
Compare
rwjblue
left a comment
There was a problem hiding this comment.
Left some more comments (sorry for the back and forth), also I think we need to add a bower install step to .travis.yml for CI to work properly (since at this point the blueprint still uses bower.json). Mind configuring your module-unification-app-output repo up with Travis and making sure we get a passing run?
| @@ -0,0 +1,11 @@ | |||
| import Resolver from '../../src/resolver'; | |||
| } from 'ember-qunit'; | ||
| import { start } from 'ember-cli-qunit'; | ||
|
|
||
| setResolver(resolver); |
There was a problem hiding this comment.
This should be setApplication instead (see app blueprint for example)
| @@ -0,0 +1,57 @@ | |||
| /* eslint-env node */ | |||
| @@ -0,0 +1,9 @@ | |||
| /* eslint-env node */ | |||
There was a problem hiding this comment.
this comment is no longer needed with overrides config
| @@ -0,0 +1,25 @@ | |||
| /* eslint-env node */ | |||
| @@ -0,0 +1,19 @@ | |||
| /* eslint-env node */ | |||
| @@ -0,0 +1,8 @@ | |||
| import resolver from './helpers/resolver'; | |||
| import { | |||
| setResolver | |||
|
@rwjblue I've addressed your feedback in f8157a5 (I'll squash when we're happy). I've tested the output with and without yarn and all looks good:
https://travis-ci.org/GavinJoyce/module-unification-blueprint-app-output (🍏 )
https://travis-ci.org/GavinJoyce/module-unification-blueprint-app-yarn-output (🍏 ) |
|
@GavinJoyce looks like "blueprints/module-unification-app/files/yarn.lock" added by mistake(couldn't find a way to inline comment in empty file) |
We already have a nice example for sharing files between I'll take a look in this direction and report back. |
|
I've done some experimentation to reduce amount of files to maintain #7500 |
|
|
||
| fileMapTokens(options) { | ||
| return { | ||
| __component__() { return options.locals.component; }, |
There was a problem hiding this comment.
I can't see component defined in a locals. Do we need this?
@ro0gr nice one, this will make sharing files across blueprints easier (we'll still need to change how we test the output, as you noted in your PR). I'm still not clear which is better, 1) maintaining two separate trees and living with duplication for a relatively short amount of time or 2) using your technique with |
@GavinJoyce I'm not sure how short is the "short term" you refer to. But it's pretty obvious that duplication of large amount of files rarely leads to a good consequences. It's quite complicated to sync changes in +24 files(that's an amount of files we drop if share app blueprint files). I think even now we might have syncing issues. Here is the list of files that are different between
I'm not sure if that is intentional but it's much more convenient to have only those parts which are actually different even in a short term. So I would vote to consider sharing files at least because technically it's the same approach we already use for |
9202add to
4a0c774
Compare
| @@ -0,0 +1,13 @@ | |||
| import Resolver from 'ember-resolver/resolvers/fallback'; | |||
There was a problem hiding this comment.
I'd very much like to have the default generated app not use the fallback resolver. IMO new apps should default to the future/optimal mode, and if you want to use a legacy addon or app/ directory you can opt-in to the fallback.
|
Landing this and let's continue to improve it. Both @GavinJoyce and @ro0gr are interested in keeping the iteration moving. |
|
Probably this is a known issue, but once inside an app created with the new blueprint, running I also tried adding |
|
I believe we will need to update those blueprints in ember-source itself. |


This is the first step in a series of PRs which will bring support for Module Unification blueprints and generators.
An app using the module unification layout can now be created as follows:
MODULE_UNIFICATION=true ember new my-appMODULE_UNIFICATION=true ember new my-app --yarnOnce this lands, https://github.com/emberjs/ember-module-unification-blueprint can be removed
TODO:
appblueprint (extracted from https://github.com/emberjs/ember-module-unification-blueprint)TODO in future PRs:
initcommandgeneratecommandsmodule-unification-appblueprint #7488 (comment)){{welcome-page}}addon with component example