-
Notifications
You must be signed in to change notification settings - Fork 184
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
Conversation
…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"], () => { |
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.
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.
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.
Oh oops - thanks for the catch!
LGTM |
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.
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) { |
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.
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` |
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.
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.
Committing changes after review.
Woops I went and neglected this PR, but looks like @drewpc got a handle on things, thank you very much for fixing + merging! |
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.)