Skip to content

Commit 11b0bb2

Browse files
authored
Merge pull request #251 from mbark/patch-1
Document how to build for older browsers
2 parents 2cf96e2 + b4b80bc commit 11b0bb2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/getting-started/installation.md

+26
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,29 @@ yarn add react-async
1414

1515
> This package requires `react` as a peer dependency. Please make sure to install that as well. If you want to use the
1616
> `useAsync` hook, you'll need `[email protected]` or later.
17+
18+
## Targeting older browsers
19+
20+
If you are targeting older browsers you need to transpile `react-async` with babel.
21+
22+
To transpile `node_modules` with babel you need to use a `babel.config.js`, for more information see [babel's documentation](https://babeljs.io/docs/en/configuration#whats-your-use-case).
23+
24+
In your `webpack.config.js` make sure that the rule for `babel-loader`:
25+
* doesn't exclude `node_modules` from matching via the `exclude` pattern;
26+
* excludes `core-js` as it shouldn't be transpiled;
27+
* is passed the `configFile` option pointing to the `babel.config.js` file.
28+
29+
```
30+
{
31+
test: /\.(js|jsx)$/,
32+
exclude: /\/node_modules\/core-js\//,
33+
use: [{
34+
loader: 'babel-loader',
35+
options: {
36+
configFile: './babel.config.js',
37+
// This is recommended to enable when transpiling node_modules to improve build times for consecutive builds.
38+
cacheDirectory: true,
39+
}
40+
}]
41+
}
42+
```

0 commit comments

Comments
 (0)