A customized Copy of react-loadable/babel plugin
This is a replica of react-loadable's babel plugin.
Notable Differences:
- Removed flow based personal preference.
- Added an option
source
to specify the name of the imported library, defaults to "react-loadable". - Split into a seprate repository as this is a development dependency, while the main library is not.
install
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
Babel Plugin
Included in the react-loadable
package is a Babel plugin that can add
serverSideRequirePath
and webpackRequireWeakId
for you.
Input:
; ;
Output:
;; ;
Plugin Setup
If you have react-loadable
installed already, all you need to do is add this
plugin to your Babel config:
plugins: "react-make-async-babel-plugin" server: true webpack: true
Options:
server
(default:true
) - Whentrue
addsserverSideRequirePath
config.webpack
(default:false
) - Whentrue
addswebpackRequireWeakId
config.source
(default:react-loadable
) - match against the library name to add the properties to its configs object.