Skip to content
This repository has been archived by the owner on Jun 3, 2019. It is now read-only.

[Branch: feature/found] Routing with Found #182

Merged
merged 6 commits into from Dec 24, 2016

Conversation

LorbusChris
Copy link
Collaborator

@LorbusChris LorbusChris commented Nov 19, 2016

Uses Found for react routing.

Implements Client & Server Side Rendering with Found.

See #182 (comment)

For now, only supports Client Server Rendering with Found.

I will update this PR as soon as Found's creator @taion adds an SSR API.
We can then determine, whether or not code-split-component's createRenderContext() will work without additional changes to it.

@ctrlplusb

@ctrlplusb
Copy link
Owner

This is great @LorbusChris! Thanks.

I've been following found myself. Had an interesting chat with @taion about it on twitter. Looks like a really awesome and promising project. I am definitely open to this PR. :)

@ctrlplusb
Copy link
Owner

@LorbusChris I see SSR landed. :)

I would hold off doing any coding on this. A big update is in the pipeline which we should probably wait for before doing any more branch work.

@taion
Copy link

taion commented Dec 5, 2016

The Found SSR API is pretty trivial anyway (but it handles waiting for data dependencies for you!).

@ctrlplusb
Copy link
Owner

@taion which is pretty darn amazing! :)

@ctrlplusb
Copy link
Owner

@LorbusChris v10.0.0 is almost ready to ship. :)

@LorbusChris
Copy link
Collaborator Author

LorbusChris commented Dec 8, 2016

Good news first: This is working in development now. 🎉

Unfortunately in production the client is not being loaded and I'm getting this error in the node console:

(node:23095) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Object is not async iterable
(node:23095) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

If I'm not mistaken this has to do with this issue with babel-runtime: babel/#4783:. Maybe we can use babel-polyfill here for the time being?

@ctrlplusb I'm not sure what your plans are in regards to branches using Found (or any other routing lib for that matter), thereby deviating from the base-stack's RRv4. In the mid-run I'm going to be steering this towards relay (with found-relay) and graphql. First, however, I'll connect this to keystone, which provides a neat admin UI and API for managing mongoose models and connecting to MongoDB or Redis. If there's any interest in a boilerplate blog/gallery implementation, I'll happily share :)

FYI @taion
Thanks to you both for the fundamental work beneath!

Everyone, constructive reviews are highly appreciated!

@@ -25,9 +30,7 @@ function renderApp(TheApp) {
render(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem with this Promise

@taion
Copy link

taion commented Dec 8, 2016

Yeah, it is that bug. Interesting. Pulling in the polyfill explicitly would fix things. Let's see.

@ctrlplusb
Copy link
Owner

@LorbusChris great work. In terms of the branch structure I would prefer if you kept the tech stack as purely "found" for now. We could introduce extended versions of the branch that could introduce additional technologies (i.e. "relay"). :)

I think have a base "found" branch will be great, as it opens itself up for solving data fetching needs for many libraries (e.g. redux).

@ctrlplusb
Copy link
Owner

@taion I think the polyfill.io service allows you to specify additional flags for es6 specific features. I believe slate has a similar need. Perhaps the babel-polyfill isn't a strict requirement.

@ctrlplusb
Copy link
Owner

@LorbusChris @taion

Try the following:

<script src="https://cdn.polyfill.io/v2/polyfill.js?features=es6"></script>

@taion
Copy link

taion commented Dec 8, 2016

It's not an ES6 feature. It's stage 3.

@ctrlplusb
Copy link
Owner

Ah oki. 😟

What is the feature? Out of interest.

@taion
Copy link

taion commented Dec 8, 2016

It's async iterator support – it's how Found manages displaying loading states while fetching data.

@ctrlplusb
Copy link
Owner

Of course yes. Thanks.

@LorbusChris LorbusChris changed the base branch from next to master December 8, 2016 15:13
@LorbusChris
Copy link
Collaborator Author

@taion Sorry I'm still in the unclear about this. Is this actionable and can be solved by using the polyfill right now?
AFAIK we're already adding the polyfill in generateHTML(). Would this need a static html with the script tag in it?

@LorbusChris LorbusChris changed the title [WIP][Branch Idea]Use Found as react routing library. [RFC/WIP][Branch Idea]Use Found as react routing library. Dec 8, 2016
@ctrlplusb
Copy link
Owner

@LorbusChris Thinking about this. You may just need to add the babel async-to-generator plugin to the project.

@LorbusChris
Copy link
Collaborator Author

LorbusChris commented Dec 8, 2016

@ctrlplusb Thanks, I'll have a look into that! (probably not before the weekend though)

Edit: Resolved merge conflict.
Note to self: TODO: Comments, BRANCH.md

@taion
Copy link

taion commented Dec 8, 2016

I think babel-polyfill is the way to go pending the runtime fix. It's the symbol polyfill that's broken, not the transpilation.

@LorbusChris LorbusChris changed the title [RFC/WIP][Branch Idea]Use Found as react routing library. [RFC/WIP][Branch][Alt-Base]Found Routing Dec 8, 2016
@ctrlplusb ctrlplusb changed the base branch from master to incubator/routing/found December 11, 2016 09:12
@LorbusChris LorbusChris changed the title [WIP][Branch feature/found] Routing with Found [Branch: feature/found] Routing with Found Dec 19, 2016
@codepunkt
Copy link
Collaborator

If this also handles data fetching and integrates with redux - how does it work with apollo/graphql? :)

@ctrlplusb
Copy link
Owner

Amazing @LorbusChris!!

I can't wait to try it out. Great work!

@ctrlplusb
Copy link
Owner

@codepunkt maybe you could use the client-agnostic APIs of Apollo within the getData bindings?

@taion
Copy link

taion commented Dec 19, 2016

I think that's how I'd do the Apollo integration 👍

@ctrlplusb
Copy link
Owner

Hey @LorbusChris we can merge this in as soon as we do the next release from next.

return <Component {...props} />;
}

function CodeSplitHome() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

It's nice wrapping it up like this.

@@ -125,14 +125,17 @@ export default function webpackConfigFactory(buildOptions: BuildOptions) {
// This makes importing of the output module as simple as:
// import server from './build/server';
index: removeEmpty([
// Required on the server to fix an issue with Found's transpilation
ifNode('core-js/library/fn/symbol'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Well found! Haha, pardon the pun.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... still need to fix this on the babel side, sigh

@ctrlplusb
Copy link
Owner

Really great work here @LorbusChris :)

I'm excited to get this in

@LorbusChris
Copy link
Collaborator Author

@ctrlplusb very glad to hear that! :)

As there's already a merge conflict with the yarn.lock file, I propose the following:

When the next release is out, I'll update the FEATURE.md accordingly and rebase the branch one last time so all changes can be cleanly merged in on top of that release.

Now, with you having already reviewed the PR, please do tell if you'd prefer a merger over a rebase. The diff should stay the same, though.

LorbusChris and others added 5 commits December 24, 2016 13:03
Implements Client & Server Side Rendering with Found
Adds regenerator-runtime on the server
Adds core-js symbol polyfill on the server to fix issue with broken
async generator function transpilation in babel-runtime
Adds acknowledgements
Improves wording
@ctrlplusb ctrlplusb changed the base branch from master to feature/found December 24, 2016 12:16
@LorbusChris
Copy link
Collaborator Author

I believe this is ready to merge now 🎉

@ctrlplusb
Copy link
Owner

Let's do it! 👍😀

@ctrlplusb ctrlplusb merged commit 5af1884 into ctrlplusb:feature/found Dec 24, 2016
@ctrlplusb
Copy link
Owner

💫💥💖

@ctrlplusb
Copy link
Owner

We just need to update the feature branches doc on master now. Thanks for this @LorbusChris !

@taion
Copy link

taion commented Jan 25, 2017

babel/babel#5195 would also fix the babel-runtime issue, BTW.

@ctrlplusb
Copy link
Owner

Awesome news @taion

Thanks for thinking of us! 🙏

@taion
Copy link

taion commented Feb 14, 2017

This should work now with the new babel-runtime 6.23.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants