Skip to content
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

Test page for page forwarding #806

Merged
merged 5 commits into from
Jan 15, 2017
Merged

Conversation

lidawang
Copy link
Contributor

@lidawang lidawang commented Jan 6, 2017

Specifically, to make sure that data can be passed down from the forwarding page to the forwarded-to page via the data cache, and that we can do code splitting between the forwarded-to pages. (Requirements for a particular use case I'm anticipating.)

…orwarded pages

Also ensure that bundle-splitting works for forwarded-to pages
//then depending on said data, forward to one of two pages, and pass along the data we pre-fetched
if (res.body % 2 === 0) {
if (typeof window !== 'undefined') { //would be nice if this is `process.env.isServer`
require.ensure(["./forwardEven"], () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't quite tell because babelification messes with line numbers, but it looks like the problem is that you're not returning the require.ensure result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh oops - thanks for the catch!

@roblg
Copy link
Member

roblg commented Jan 10, 2017

LGTM

Copy link
Collaborator

@drewpc drewpc left a comment

Choose a reason for hiding this comment

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

Requesting some very minor code changes prior to merge. Thanks for contributing! This is a great example of how to use this feature.


return this.data.then((res) => {
//then depending on said data, forward to one of two pages, and pass along the data we pre-fetched
if (res.body % 2 === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you refactor this section a bit to limit code reuse? Something like this should work:

const pageName = (res.body % 2 === 0) ? "./forwardEven" : "./forwardOdd";
if (typeof window !== 'undefined') { //would be nice if this is `process.env.isServer`
	return require.ensure([pageName], () => {
		return {
			page: require(pageName).default,
		};
	});
} else {
	return {
		page: require(pageName).default,
	};
}

return this.data.then((res) => {
//then depending on said data, forward to one of two pages, and pass along the data we pre-fetched
if (res.body % 2 === 0) {
if (typeof window !== 'undefined') { //would be nice if this is `process.env.isServer`
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you change this comment to be a // TODO:, we can track it better. Eventually when we get server side Webpack up and running, it'll include a fix for this.

@drewpc drewpc merged commit a5d6a4e into redfin:master Jan 15, 2017
@lidawang
Copy link
Contributor Author

Woops I went and neglected this PR, but looks like @drewpc got a handle on things, thank you very much for fixing + merging!

@drewpc drewpc modified the milestone: 0.6.0 Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants