Skip to content

Commit

Permalink
update documentation for babel plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Jul 9, 2023
1 parent e18e37a commit edaf30c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion website/src/pages/docs/babel-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,31 @@ On client side, the two code are completely compatible.

Please note that babel must not be configured [to strip comments](https://babeljs.io/docs/en/options#comments), since the chunk name is defined in a comment.

## Loadable detection
## Loadable Configuration (beta)
> available since 5.16.0
Sometimes you need to wrap loadable with your own custom logic. There are many use cases for it, from injecting telemetry to hiding external libraries behind facade.
By default `loadable-components` are configured to transform dynamic imports used only inside loadable helpers, but can be configured to instrument any other function of your choice.
```json
{
"plugins": ["@loadable/babel-plugin", {
"signatures": [
{ "name": "default", "from": "myLoadableWrapper" }
{ "name": "myLoadableHelper", "from": "myLoadableWrapper" }
]
}]
}
```
```tsx
import {myLoadableHelper} from "myLoadableWrapper";
const Loadable = myLoadableHelper(() => import("./MyComponent"));
// will behave similar to
import loadable from '@loadable/component'
const OtherComponent = loadable(() => import('./OtherComponent'))
```

## Loadable detection (deprecated)
> Please dont use this feature and prefer Loadable Configuration instead
The detection of a loadable component is based on the keyword "loadable". It is an opinionated choice, it gives you flexibility but it could also be restrictive.

Expand Down

0 comments on commit edaf30c

Please sign in to comment.