A customized Copy of react-loadable/babel plugin
npm install react-make-async-babel-pluginThis is a replica of react-loadable's babel plugin.
source to specify the name of the imported library, defaults to "react-loadable".if you are using react-loadable/babel this is not needed because sadly the plugin is baked inside the library.
```
yarn add --dev react-make-async-babel-plugin
Included in the react-loadable package is a Babel plugin that can addserverSideRequirePath and webpackRequireWeakId for you.
Input:
`js
import Loadable from 'react-loadable';
Loadable({
loader: () => import('./MyComponent'),
LoadingComponent: () => null,
});
`
Output:
`js
import _path from 'path';
import Loadable from 'react-loadable';
Loadable({
loader: () => import('./MyComponent'),
LoadingComponent: () => null,
serverSideRequirePath: _path.join(__dirname, './MyComponent'),
webpackRequireWeakId: () => require.resolveWeak('./MyComponent'),
});
`
#### Plugin Setup
If you have react-loadable installed already, all you need to do is add this
plugin to your Babel config:
`js`
{
plugins: [
["react-make-async-babel-plugin", {
server: true,
webpack: true
}]
]
}
Options:
- server (default: true) - When true adds serverSideRequirePath config.webpack
- (default: false) - When true adds webpackRequireWeakId config.source
- (default: react-loadable`) - match against the library name to add the properties to its configs object.