Skip to content

Update on babel 6 can cause 'require' to fail properly loading module#12

Open
tcharlat wants to merge 4 commits intoryanflorence:masterfrom
tcharlat:master
Open

Update on babel 6 can cause 'require' to fail properly loading module#12
tcharlat wants to merge 4 commits intoryanflorence:masterfrom
tcharlat:master

Conversation

@tcharlat
Copy link
Copy Markdown

@tcharlat tcharlat commented May 4, 2016

I tried to use the repo code to boiler plate a react-router + webpack lazyloading SPA.

I had the following browser console warning :

Warning: [react-router] Location "/about" did not match any routes

It is because since babel 6, the 'default' keyword is not compatible with 'require' as it was per babel 5

AboutRoute.js :

import About from '../components/About'

export default {
  path: 'about',
  component: About
}

RootRoute.js

  getChildRoutes(location, cb) {
    require.ensure([], (require) => {
-     cb(null, [ require('./AboutRoute')])
+     cb(null, [ require('./AboutRoute').default ])
    })
  },

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.

1 participant