Skip to content

Commit 49c6f6a

Browse files
authored
Merge pull request #132 from smooth-code/fix-peers
Fix peer dependencies
2 parents 6075cb0 + bf1ab76 commit 49c6f6a

File tree

6 files changed

+687
-1566
lines changed

6 files changed

+687
-1566
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8
1+
10

README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,32 @@
1010
![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)
1111
[![Dependencies](https://img.shields.io/david/smooth-code/loadable-components.svg?path=packages%2Fcomponent)](https://david-dm.org/smooth-code/loadable-components?path=packages/component)
1212
[![DevDependencies](https://img.shields.io/david/dev/smooth-code/loadable-components.svg)](https://david-dm.org/smooth-code/loadable-components?type=dev)
13-
[![Small size][https://img.badgesize.io/https://unpkg.com/@loadable/component/dist/loadable.min.js?compression=gzip]][https://unpkg.com/@loadable/component/dist/loadable.min.js]
13+
[![Small size](https://img.badgesize.io/https://unpkg.com/@loadable/component/dist/loadable.min.js?compression=gzip)](https://unpkg.com/@loadable/component/dist/loadable.min.js)
1414

1515
```sh
1616
npm install @loadable/component
1717
```
1818

1919
## Introduction
2020

21-
Code Splitting can be done easily using [`React.lazy`](https://reactjs.org/docs/code-splitting.html#reactlazy). It is true if you don't need Server Side Rendering or complex features like [full dynamic imports](https://webpack.js.org/api/module-methods/#import-).
21+
Code splitting is supported out of the box by React using [`React.lazy`](https://reactjs.org/docs/code-splitting.html#reactlazy). So what is the goal of this library?
2222

23-
Loadable leverage the limit of Code Splitting and give you access to all features.
23+
`@loadable/component` pushes the limit of Code splitting, it offers several features:
2424

25-
Code Splitting + Server Side Rendering is something very complex. Several libraries tried to solve this problem successfully or not. The goal of this library is to follow as much as possible the philosophy of React and give a developer-experience first solution to solve this complex problem. It takes the best from all libraries and provide an elegant solution to this problem.
25+
- 📚 Library splitting
26+
- ⚡️ Prefetching
27+
- 💫 Server Side Rendering
28+
- 🎛 Full dynamic import `` import(`./${value}`) ``
2629

27-
## Differences with React.lazy & react-loadable
30+
## Comparison with React.lazy & react-loadable
2831

29-
[`React.lazy`](https://reactjs.org/docs/code-splitting.html#reactlazy) doesn't support full dynamic import and SSR. Loadable uses the same API with more features (SSR, full dynamic import, library import). If you don't need them, you don't need `loadable`.
32+
| Library | Suspense | SSR | Library splitting | `` import(`./${value}`) `` |
33+
| --------------------- | -------- | --- | ----------------- | -------------------------- |
34+
| `React.lazy` |||||
35+
| `react-loadable` || 🔶 |||
36+
| `@loadable/component` |||||
3037

31-
| Library | Suspense | SSR | Library loading | import(`./${x}`) |
32-
| --------------------- | -------- | --- | --------------- | ---------------- |
33-
| `React.lazy` |||||
34-
| `react-loadable` || 🔶 |||
35-
| `@loadable/component` |||||
36-
37-
Even if [`react-loadable` is recommended by React team](https://reactjs.org/docs/code-splitting.html#reactlazy), the project does not accept any GitHub issues and is no longer maintained.
38+
Even if [`react-loadable` is recommended by React team](https://reactjs.org/docs/code-splitting.html#reactlazy), the project does not accept any GitHub issue and is no longer maintained.
3839

3940
## Getting started
4041

@@ -74,7 +75,7 @@ function FromNow({ date }) {
7475
}
7576
```
7677

77-
You can also use a `ref` that will be populated when the library will be loaded.
78+
You can also use a `ref`, populated when the library is loaded.
7879

7980
```js
8081
import loadable from '@loadable/component'
@@ -101,11 +102,11 @@ class MyComponent {
101102
}
102103
```
103104
104-
> You can also pass a function to `ref`, called when the library will be loaded.
105+
> You can also pass a function to `ref`, called when the library is loaded.
105106
106107
### Full dynamic import
107108
108-
Webpack accepts [full dynamic imports](https://webpack.js.org/api/module-methods/#import-) and you can also use them with `@loadable/component` to create dynamic components.
109+
Webpack accepts [full dynamic imports](https://webpack.js.org/api/module-methods/#import-), you can use them to create a reusable Loadable Component.
109110
110111
```js
111112
import loadable from '@loadable/component'
@@ -144,7 +145,7 @@ function MyComponent() {
144145
145146
> Use `lazy.lib` for libraries.
146147
147-
> Suspense is not yet available for server-side rendering.
148+
> ⚠️ Suspense is not yet available for server-side rendering.
148149
149150
### Fallback without Suspense
150151
@@ -213,6 +214,8 @@ export const OtherComponent = loadable(() =>
213214
)
214215
```
215216
217+
> With suspense, use `<Suspense maxDuration={200}>` to have the same effect.
218+
216219
### Timeout
217220
218221
Infinite loading is not good for user experience, to avoid it implementing a timeout is a good workaround. You can do it using a third party module like [`promise-timeout`](https://github.com/building5/promise-timeout):
@@ -268,7 +271,7 @@ function MyComponent() {
268271
269272
> `prefetch` and `Prefetch` are also available for components created with `lazy`, `loadable.lib` and `lazy.lib`.
270273
271-
> Only component based prefetching is compatible with Server Side Rendering.
274+
> Only component based prefetching (`<Prefetch>`) is compatible with Server Side Rendering.
272275
273276
## API
274277

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"babel-core": "^7.0.0-bridge.0",
2929
"babel-eslint": "^10.0.1",
3030
"babel-jest": "^23.6.0",
31-
"babel-loader": "^8.0.4",
3231
"bundlesize": "^0.17.0",
3332
"conventional-github-releaser": "^3.1.2",
3433
"cross-env": "^5.2.0",

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"prepublishOnly": "yarn run build"
2222
},
2323
"peerDependencies": {
24-
"@loadable/component": "^3.0.0",
24+
"@loadable/component": "^4.0.0",
2525
"react": ">=16.3.0"
2626
}
2727
}

packages/webpack-plugin/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
"prebuild": "shx rm -rf dist",
2020
"build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
2121
"prepublishOnly": "yarn run build"
22+
},
23+
"peerDependencies": {
24+
"webpack": ">=4.0.0"
2225
}
2326
}

0 commit comments

Comments
 (0)