glimmerjs / glimmer-application

[MOVED] This package is now part of the Glimmer.js monorepo
https://github.com/glimmerjs/glimmer.js
30 stars 13 forks source link

Allow Application to receive document as option #61

Closed josemarluedke closed 7 years ago

josemarluedke commented 7 years ago

This allow some experimenting with Server Side Rendering. With this change it's possible to use simple-dom to render the application.

Also removes all the usages of window.document to use the new option.

kratiahuja commented 7 years ago

Curious to know about the server side rendering with glimmer app:

  1. Is the glimmer app being booted on server side for every request?
  2. If not, does it have a notion of application and application instance(to hold request specific info) like Ember apps?

Apologies my knowledge of Glimmer apps is very limited.

josemarluedke commented 7 years ago

@kratiahuja so, at this moment I'm just experimenting and seeing what is already possible to do with Glimmer.

I have a working hello world glimmer app been rendered in the server with these changes: https://github.com/josemarluedke/glimmer-ssr-test/commit/f54bb177fa683eb2361b31b96d28431a928cc637 (Note that this example requires the changes in this PR. )

The approach I took was getting a sandbox (copied from FastBoot) then evaluating and booting the app in every request.

As far as I can tell, glimmer apps don't have the idea of application instance, so we need to do the full app boot in every request.

Hopefully some of my learnings can make back to FastBoot itself (if we would use FastBoot to render glimmer apps as well...)

kratiahuja commented 7 years ago

That's the reason I was asking to understand if FastBoot can be used. Looks liek it will need a lot of work.

josemarluedke commented 7 years ago

@rwjblue Updated to use simple-dom in the test. Please check if the way I included that package makes sense.

josemarluedke commented 7 years ago

@rwjblue I see your point on creating some test to that actually renders the application, however, it seems that the right place for such a test would be in the @glimmer/component. See here: https://github.com/glimmerjs/glimmer-component/blob/master/test/rendering-test.ts

After landing this, I could get a PR to @glimmer/component adding tests to use simple-dom to render the components.

rwjblue commented 7 years ago

Yes, I agree that we should also add tests there, but I though since some of the tests in this repo are testing "full stack render" we could also add a high level test here too.

I wasn't thinking something like: https://github.com/glimmerjs/glimmer-application/blob/master/test/render-component-test.ts#L7...

josemarluedke commented 7 years ago

@rwjblue Added a basic test for rendering a component using simple-dom. Let me know if there is anything else I should do in this PR.

rwjblue commented 7 years ago

Thank you for working through this with me @josemarluedke!

dgeb commented 7 years ago

Yeah, thanks much @josemarluedke :100: