-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use -in-element
to render at appropriate time
#37
Use -in-element
to render at appropriate time
#37
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I am +1 to this approach. It also makes sense to do a major version bump.
@@ -26,6 +26,7 @@ | |||
"ember-cli-app-version": "^1.0.0", | |||
"ember-cli-dependency-checker": "^1.3.0", | |||
"ember-cli-eslint": "^3.0.0", | |||
"ember-cli-fastboot": "^1.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is added as a devDependnecy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Primarily to ensure this approach worked in fastboot. Means that we can run ember s
and disable JS then inspect the head
element. I can remove if that is a problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely makes for easier local testing. Not sure if there are any ramifications to the ember-cli-addon-tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue but I think you could write the tests in fastboot-tests
? If it is more against the dummy app, it's fine too.
This should be ready for another review. 🍻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay here @rondale-sc.
- Can you add a
ember-lts-2-12
scenario to.travis.yml
andconfig/ember-try.js
? - Should we consider adding a blueprint that automatically puts
{{head-layout}}
to the application'sapplication.hbs
? This would be much easier than trying to do it automatically per-build (in a blueprint we can just useBlueprint.prototype.insertIntoFile
)...
@@ -1 +1,3 @@ | |||
<meta name="ember-cli-head-start">{{head-content}}<meta name="ember-cli-head-end"> | |||
{{#-in-element headElement}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI - We have started taking steps to make this public API from the Glimmer VM perspective (see glimmerjs/glimmer-vm#619). It is unclear what Ember version that PR will correspond to, but it is a good step forward for our use case (and shows a future where we can drop the private -
prefix).
2b24a6e
to
1fc2703
Compare
@rwjblue Added 2.12 to the ember-try config. I'm not sure where to begin with the blueprint idea. |
RE: the blueprint I'm suggesting that we update the blueprint to use Blueprint.prototype.insertIntoFile to insert |
@rwjblue That's an excellent idea. Will give that a try. |
I think this is ready to go now. |
blueprints/ember-cli-head/index.js
Outdated
fs.writeFileSync(fullPath, toWrite, { encoding: 'utf-8' }); | ||
} else { | ||
let str = `You must add {{head-layout}} component to your topmost UI. | ||
This is usually your application.hbs, but was not found on your system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use the full path (e.g. app/templates/application.hbs
) in the message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! 🍻
blueprints/ember-cli-head/index.js
Outdated
normalizeEntityName: function() { } | ||
normalizeEntityName: function() { }, | ||
afterInstall() { | ||
let fullPath = path.join(this.project.root, 'app/templates/applicati.hbs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here (should be app/templates/application.hbs
)
5a5306a
to
5295c57
Compare
5295c57
to
9b1fad8
Compare
LGTM, thanks for working through this with us! @kratiahuja - Would you like to do a final review before landing and releasing? |
Sure I'll take a look at it in a while |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks @rondale-sc for the work here. I also think this needs a README update for folks needing to do the major version bump.
427b9de
to
5dc82a3
Compare
@kratiahuja Thank you for reviewing. I added a section to the README and blueprint to help people moving from earlier versions. I wasn't sure what the version would be for this so I guessed and used 0.4.x for the README section title, but I'll update that once this is ready to go. 👍 |
Is there anything else blocking this before we cut a release? |
Thank you for all of your hard work here @rondale-sc! |
@rondale-sc @rwjblue am I interpreting correctly that this PR dropped support for Ember 2.4 and 2.8? might be worth it to mention that explicitly in the README and point to the v0.3.x releases for those Ember versions |
@Turbo87 - Yep, you are correct. Happy to review and land a PR updating the README... |
Hmm I just noticed this in the README:
Since 0.3.x was still tested against Ember 2.4 and 2.8 is that statement actually valid? I'm a little confused... 🤔 |
This PR attempts to address the fact that in ember-cli-head's initializer we call
component.appendTo(document.head)
. This triggers a rendering cycle where Glimmer fully processes thehead-layout
component and then appends it to the document head before the application's main rendering process.We decided not to do this:
If we don't want to do a major version bump we need to do the following:move head-browser-initializer to the addon folderUse ember-compatibility-helpers to remove thecomponent.appendTo(document.head)
only whenGLIMMER_2
is foundUse thetreeForFastboot
hook to emit the old fastboot files when Ember version of application is < 2.10Use an AST transform to modify the user's application.hbs to include the invocation of{{head-layout}}
component.In an ideal world we'd be able to do this more naively in a broccoli-plugin where we just find the actual template file and add it there, but unsure how/if we could do that.Details
Currently it appends before the
didTransition
hook from the router happens, which means it is doing this work in the wrong phase of execution. I did some benchmarking with ember-macro-benchmark and noticed this change when using this PR. The experiment is our PR here.Which shows that we are moving the work to the correct place. We can observe this more clearly in the Chrome timeline.
You can see in the above that ember-cli-head triggers a render before the main rendering pass for our application's first frame.
With this PR it looks more like this:
That's the TL;DR (which is too long)
But this is still very much WIP. After discussing this with @rwjblue we decided that this would necessitate a major version bump unless we did a few things to make it backward compat.
Benefits
I'd like to start a discussion about the possible benefits here. With my benchmarking tools I couldn't see a pronounced difference (it isn't 100% clear yet). Though, I would imagine there is some duplicated effort in starting the rendering process from a cold-start twice.
Any thoughts or ideas would be very much appreciated.