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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to react-router v4 and code-splitting #841

Closed
wants to merge 8 commits into from

Conversation

Elyx0
Copy link

@Elyx0 Elyx0 commented Mar 21, 2017

As mentioned in #808
This PR switches to React router v4 with dynamic import for code splitting.

I first tried using the bundle-loader but then went toward the import promise as specified from https://reacttraining.com/react-router/web/guides/code-splitting and didn't use System.import as it will deprecate in Webpack3 ( https://survivejs.com/webpack/building/code-splitting/ )

Split point are created like it should:
screen shot 2017-03-21 at 4 38 36 pm

And you can see them being loaded in the Network Devtools when navigating.

Dynamic import provides less functionality than require.ensure. While it's possible to handle errors with it, features like naming are available for require.ensure only.

Great boilerplate guys 馃憤

@Elyx0
Copy link
Author

Elyx0 commented Mar 21, 2017

Since this PR covers #832 (comment) too I've tried everything but it seems flow doesn't like the dynamic import() thus raising error. It's present in babel-eslint since 7.1 ( babel/babel-eslint#413 )
I've checked: import-js/eslint-plugin-import#700 and it seems it comes from flow: facebook/flow#2968

Should we ignore the lines with these declarations?

@amilajack
Copy link
Member

Should we ignore the lines with these declarations?

That would be a good idea for the time being. Also do you know why the end to end testes are failing?

@Elyx0
Copy link
Author

Elyx0 commented Mar 26, 2017

Got it, I think it has to do with the new router that needs wrapping the provider of the test CounterPage because is contains <Link> remix-run/react-router#1660

import type { Children } from 'react';

type Props = {children: Children, load: () => Promise<*>};
class Bundle extends Component {
Copy link
Member

Choose a reason for hiding this comment

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

nit: convention is to use a new line before class declarations

@@ -0,0 +1,45 @@
// @flow
Copy link
Member

Choose a reason for hiding this comment

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

What exactly is this Bundle container necessary? Some inline comments explaining why this is necessary would be nice

}
}

props: Props
Copy link
Member

Choose a reason for hiding this comment

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

nit: Type declarations should come before methods and properties

@amilajack
Copy link
Member

Closing in favor of #884

@amilajack amilajack closed this Mar 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants