Skip to content

Commit 88564a6

Browse files
author
Dimitri Kopriwa
committed
fix(react-loadable): Upgrade to babel 7, fix warnings (see jamiebuilds/react-loadable#216)
1 parent fd8a77f commit 88564a6

File tree

17 files changed

+311
-4860
lines changed

17 files changed

+311
-4860
lines changed

.babelrc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"presets": [
3-
["es2015", {
4-
"loose": true,
5-
}],
6-
"react",
3+
[
4+
"@babel/preset-env",
5+
{
6+
"loose": true
7+
}
8+
],
9+
"@babel/preset-react",
10+
"@babel/preset-flow"
711
],
812
"plugins": [
9-
"transform-class-properties",
10-
"transform-object-assign",
11-
],
13+
"@babel/plugin-proposal-class-properties",
14+
"@babel/plugin-transform-object-assign"
15+
]
1216
}

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[ignore]
2-
<PROJECT_ROOT>/node_modules/chalk/.*
2+
.*/node_modules/chalk/.*
33

44
[include]
55

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
lib
55
coverage
66
example/dist
7+
reports

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.travis.yml

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,85 @@
11
language: node_js
2-
node_js:
3-
- '4'
4-
- '6'
5-
- '8'
6-
- '10'
7-
cache: yarn
8-
script: yarn test -- --runInBand --coverage && yarn flow
2+
sudo: required
3+
dist: trusty
4+
5+
# Blocklist
6+
branches:
7+
except:
8+
- gh-pages # will be deployed to, no need to build it
9+
10+
cache:
11+
directories:
12+
- node_modules
13+
14+
before_install:
15+
- npm install -g npm
16+
# const
17+
- export PACKAGE_NAME=$(node -p "require('./package.json').name")
18+
- export PACKAGE_VERSION=$(node -p "require('./package.json').version")
19+
- export SONAR_VERSION=${PACKAGE_VERSION}-b${TRAVIS_BUILD_ID}-${TRAVIS_BRANCH}
20+
- export NODE_VERSION=$(node --version)
21+
- export NPM_VERSION=$(npm --version)
22+
23+
# logging
24+
- npm --version || echo npm not installed
25+
- node --version || echo node not installed
26+
- echo "package version $PACKAGE_VERSION"
27+
28+
stages:
29+
- build
30+
- test
31+
- release
32+
- deploy
33+
34+
jobs:
35+
include:
36+
37+
# Job: Build
38+
- stage: build
39+
node_js:
40+
- 'lts/*'
41+
- '10'
42+
- '8'
43+
script:
44+
- npm run build
45+
# Job: Test
46+
- stage: test
47+
node_js:
48+
- 'lts/*'
49+
- '10'
50+
- '8'
51+
addons:
52+
sonarcloud:
53+
organization: $(echo $TRAVIS_REPO_SLUG | awk -F '/' '{print $1}')
54+
script:
55+
- npm run test -- --coverage --runInBand
56+
# - npm run flow (Disable reason: https://github.com/jamiebuilds/react-loadable/pull/216#issuecomment-566027008)
57+
58+
# Job: Release
59+
- stage: release
60+
if: branch = master AND type = push AND fork = false
61+
node_js:
62+
- 'lts/*'
63+
skip_cleanup: true
64+
script:
65+
- npx semantic-release
66+
67+
# # Job: Page
68+
# - stage: deploy
69+
# if: branch = master AND type = push AND fork = false
70+
# node_js:
71+
# - 'lts/*'
72+
# script:
73+
# - git fetch --tags
74+
# - git checkout refs/tags/$(git describe --tags `git rev-list --tags --max-count=1`)
75+
# - npm install
76+
# - chmod +x styleguide/prepare.sh
77+
# - styleguide/prepare.sh
78+
# - npm run styleguide:build
79+
# deploy:
80+
# - provider: pages
81+
# skip_cleanup: true
82+
# github_token: $GH_TOKEN # Set in the settings page of your repository, as a secure variable
83+
# keep_history: true
84+
# local_dir: public/
85+
#

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Why did we fork
2+
3+
This project was originally hosted at https://github.com/jamiebuilds/react-loadable
4+
5+
Since PR https://github.com/jamiebuilds/react-loadable/pull/216, we marked this project being unmaintained.
6+
7+
## Readme
8+
19
![React Loadable](http://thejameskyle.com/img/react-loadable-header.png)
210

311
> A higher order component for loading components with dynamic imports.
@@ -11,7 +19,7 @@ yarn add react-loadable
1119
## Example
1220

1321
```js
14-
import Loadable from 'react-loadable';
22+
import Loadable from '@yeutech-lab/react-loadable';
1523
import Loading from './my-loading-component';
1624

1725
const LoadableComponent = Loadable({
@@ -174,7 +182,7 @@ class MyComponent extends React.Component {
174182
Bar: null
175183
};
176184

177-
componentWillMount() {
185+
UNSAFE_componentWillMount() {
178186
import('./components/Bar').then(Bar => {
179187
this.setState({ Bar: Bar.default });
180188
});
@@ -197,7 +205,7 @@ What about when `import()` fails? What about server-side rendering?
197205
Instead you can use `Loadable` to abstract away the problem.
198206

199207
```js
200-
import Loadable from 'react-loadable';
208+
import Loadable from '@yeutech-lab/react-loadable';
201209

202210
const LoadableBar = Loadable({
203211
loader: () => import('./components/Bar'),
@@ -527,7 +535,7 @@ For this, there is [`Loadable.Capture`](#loadablecapture) component which can
527535
be used to collect all the modules that were rendered.
528536

529537
```js
530-
import Loadable from 'react-loadable';
538+
import Loadable from '@yeutech-lab/react-loadable';
531539

532540
app.get('/', (req, res) => {
533541
let modules = [];
@@ -578,7 +586,7 @@ To convert from modules to bundles, import the [`getBundles`](#getbundles)
578586
method from `react-loadable/webpack` and the data from Webpack.
579587

580588
```js
581-
import Loadable from 'react-loadable';
589+
import Loadable from '@yeutech-lab/react-loadable';
582590
import { getBundles } from 'react-loadable/webpack'
583591
import stats from './dist/react-loadable.json';
584592

@@ -655,7 +663,7 @@ which on resolution means that we can hydrate our app.
655663
// src/entry.js
656664
import React from 'react';
657665
import ReactDOM from 'react-dom';
658-
import Loadable from 'react-loadable';
666+
import Loadable from '@yeutech-lab/react-loadable';
659667
import App from './components/App';
660668

661669
Loadable.preloadReady().then(() => {
@@ -1063,7 +1071,7 @@ you:
10631071
**Input**
10641072

10651073
```js
1066-
import Loadable from 'react-loadable';
1074+
import Loadable from '@yeutech-lab/react-loadable';
10671075

10681076
const LoadableMyComponent = Loadable({
10691077
loader: () => import('./MyComponent'),
@@ -1080,7 +1088,7 @@ const LoadableComponents = Loadable.Map({
10801088
**Output**
10811089

10821090
```js
1083-
import Loadable from 'react-loadable';
1091+
import Loadable from '@yeutech-lab/react-loadable';
10841092
import path from 'path';
10851093

10861094
const LoadableMyComponent = Loadable({
@@ -1154,7 +1162,7 @@ Specifying the same `loading` component or `delay` every time you use
11541162
own Higher-Order Component (HOC) to set default options.
11551163

11561164
```js
1157-
import Loadable from 'react-loadable';
1165+
import Loadable from '@yeutech-lab/react-loadable';
11581166
import Loading from './my-loading-component';
11591167

11601168
export default function MyLoadable(opts) {

__tests__/.babelrc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
22
"presets": [
3-
["es2015", {
4-
"loose": true,
5-
}],
6-
"react",
3+
[
4+
"@babel/preset-env",
5+
{
6+
"loose": true
7+
}
8+
],
9+
"@babel/preset-react",
10+
"@babel/preset-flow"
711
],
812
"plugins": [
9-
"transform-async-to-generator",
10-
],
13+
"@babel/plugin-transform-async-to-generator"
14+
]
1115
}

__tests__/test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
2+
require('babel-polyfill');
33
const path = require('path');
44
const React = require('react');
55
const renderer = require('react-test-renderer');
@@ -34,7 +34,7 @@ function MyComponent(props) {
3434
afterEach(async () => {
3535
try {
3636
await Loadable.preloadAll();
37-
} catch (err) {}
37+
} catch (err) { }
3838
});
3939

4040
test('loading success', async () => {
@@ -140,7 +140,7 @@ test('render', async () => {
140140
loader: createLoader(400, () => ({ MyComponent })),
141141
loading: MyLoadingComponent,
142142
render(loaded, props) {
143-
return <loaded.MyComponent {...props}/>;
143+
return <loaded.MyComponent {...props} />;
144144
}
145145
});
146146
let component = renderer.create(<LoadableMyComponent prop="baz" />);
@@ -161,8 +161,8 @@ test('loadable map success', async () => {
161161
render(loaded, props) {
162162
return (
163163
<div>
164-
<loaded.a.MyComponent {...props}/>
165-
<loaded.b.MyComponent {...props}/>
164+
<loaded.a.MyComponent {...props} />
165+
<loaded.b.MyComponent {...props} />
166166
</div>
167167
);
168168
}
@@ -186,8 +186,8 @@ test('loadable map error', async () => {
186186
render(loaded, props) {
187187
return (
188188
<div>
189-
<loaded.a.MyComponent {...props}/>
190-
<loaded.b.MyComponent {...props}/>
189+
<loaded.a.MyComponent {...props} />
190+
<loaded.b.MyComponent {...props} />
191191
</div>
192192
);
193193
}
@@ -272,9 +272,9 @@ describe('preloadReady', () => {
272272
delay: 0,
273273
timeout: 200,
274274
});
275-
275+
276276
let loadingComponent = renderer.create(<LoadableMyComponent prop="foo" />);
277-
277+
278278
expect(loadingComponent.toJSON()).toMatchSnapshot(); // loading
279279
});
280280
});

example/.babelrc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
{
22
"presets": [
3-
"es2015",
4-
"react",
3+
"@babel/preset-env",
4+
"@babel/preset-react",
5+
"@babel/preset-flow"
56
],
67
"plugins": [
78
"dynamic-import-node",
8-
"transform-class-properties",
9+
"@babel/plugin-proposal-class-properties",
910
"../babel",
10-
["module-resolver", {
11-
"alias": {
12-
"react-loadable": "./src/index.js",
13-
"react-loadable/server": "./src/server.js",
14-
"react-loadable/webpack": "./src/webpack.js",
15-
},
16-
}]
17-
],
11+
[
12+
"module-resolver",
13+
{
14+
"alias": {
15+
"@yeutech-lab/react-loadable": "./src/index.js",
16+
"@yeutech-lab/react-loadable/server": "./src/server.js",
17+
"@yeutech-lab/react-loadable/webpack": "./src/webpack.js"
18+
}
19+
}
20+
]
21+
]
1822
}

example/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import Loadable from 'react-loadable';
3+
import Loadable from '@yeutech-lab/react-loadable';
44
import App from './components/App';
55

66
window.main = () => {

0 commit comments

Comments
 (0)