I'm attempting to refactor a growing React App to use lazy loading. Taking the following as an example:
import React, { Component } from 'react'
import { render } from 'react-dom'
import Loadable from 'react-loadable';
const Orders = Loadable({
loader: () => import('./Orders'),
loading() {
return <div>Loading...</div>
}
});
My webpack compile always fails with:
Module build failed: SyntaxError: Unexpected token
...
> 24 | loader: () => import('./Orders'),
It's clearly the import that is choking the code, but I don't understand why.
My .babelrc file looks like this:
{
"presets": ["env", "react"]
}
requireinstead ofimport?import(...)syntax is Stage 3, are you sure you have the necessary options/plugins for it to work in your setup?