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

Has anyone ever tried to use "require.ensure' in this project? #1250

Open
jboonmee opened this issue Aug 7, 2016 · 1 comment
Open

Has anyone ever tried to use "require.ensure' in this project? #1250

jboonmee opened this issue Aug 7, 2016 · 1 comment

Comments

@jboonmee
Copy link

jboonmee commented Aug 7, 2016

I've tried to get this (remix-run/react-router#3232 ) to work, but without success. I ran into the following problems.

  • require.ensuire is not a function.
  • After I polly-fill the require.ensure for the server-side, the project builds and runs but the routes are not working.
  • Due to the second problem above, I checked the webpack package using the tool at http://webpack.github.io/analyse/#home where I found that webpack never created the split point chunk.

One curious thing though, when I used the AMD version of require (require([], cb) instead of require.ensure([], cb)), webpack did generated the chunk for the split point. But the routes still didn't work.

Any thoughts?

@mdenisov
Copy link

mdenisov commented Dec 4, 2016

@jboonmee for require.ensure ([], cb)), you must activate the patch_require: true in webpack-isomorphic-tools.js file and wrap render in client.js:

import { Router, browserHistory, match } from 'react-router';

***

match({ routes: getRoutes(store), history }, (error, redirectLocation, renderProps) => {
	ReactDOM.render(
		<Provider store={ store } key="provider">
			<Router
				{ ...renderProps }
				render={ props =>
					<ReduxAsyncConnect { ...props } helpers={ { client } } filter={ item => !item.deferred } />
				}
			>
				{ getRoutes(store) }
			</Router>
		</Provider>,
		dest
	);
});

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

No branches or pull requests

2 participants