Skip to content

Commit 7580552

Browse files
authored
feat: ship flat bundles (#844)
- Refactor all project - Remove Lerna - Simplify code
1 parent bf519d4 commit 7580552

File tree

107 files changed

+595
-1544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+595
-1544
lines changed

Diff for: .babelrc

+2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
[
44
"env",
55
{
6+
"modules": false,
67
"loose": true
78
}
89
],
910
"react"
1011
],
1112
"plugins": [
13+
1214
["transform-class-properties", { "loose": true }],
1315
"transform-object-rest-spread",
1416
"dynamic-import-node"

Diff for: .eslintignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
node_modules/
22
__babel_fixtures__/
3-
lib/
43
dist/
5-
modules/
6-
coverage
4+
coverage/
75
examples/
6+
babel.js
7+
index.js
8+
patch.js

Diff for: .gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
node_modules
2-
lib
3-
coverage
1+
node_modules/
2+
dist/
3+
coverage/
44
.DS_Store

Diff for: .prettierignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
__babel_fixtures__
1+
__babel_fixtures__/
22
__snapshots__/
33
node_modules/
4-
lib/
5-
package.json
6-
lerna.json
7-
.cache/
84
dist/
5+
package.json
6+
babel.js
7+
index.js
8+
patch.js

Diff for: README.md

+73-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ each module so you might not need source maps at all.
162162

163163
React Native
164164
**[supports hot reloading natively](https://facebook.github.io/react-native/blog/2016/03/24/introducing-hot-reloading.html)**
165-
as of version 0.22.
165+
as of version 0.22.
166166

167167
Using React Hot Loader with React Native can cause unexpected issues (see #824) and is not recommended.
168168

@@ -218,6 +218,78 @@ new ExtractTextPlugin({
218218
})
219219
```
220220

221+
## API
222+
223+
### `hot(module, options)`
224+
225+
Mark a component as hot.
226+
227+
```js
228+
import { hot } from 'react-hot-loader'
229+
230+
const App = () => 'Hello World!'
231+
232+
export default hot(module)(App)
233+
```
234+
235+
### `AppContainer`
236+
237+
Mark application as hot reloadable. Prefer using `hot` helper.
238+
239+
```js
240+
import React from 'react'
241+
import ReactDOM from 'react-dom'
242+
import { AppContainer } from 'react-hot-loader'
243+
import App from './containers/App'
244+
245+
const render = Component => {
246+
ReactDOM.render(
247+
<AppContainer>
248+
<Component />
249+
</AppContainer>,
250+
document.getElementById('root'),
251+
)
252+
}
253+
254+
render(App)
255+
256+
// Webpack Hot Module Replacement API
257+
if (module.hot) {
258+
module.hot.accept('./containers/App', () => {
259+
// if you are using harmony modules ({modules:false})
260+
render(App)
261+
// in all other cases - re-require App manually
262+
render(require('./containers/App'))
263+
})
264+
}
265+
```
266+
267+
### areComponentsEqual(Component1, Component2)
268+
269+
Test if two components have the same type.
270+
271+
```js
272+
import { areComponentsEqual } from 'react-hot-loader'
273+
import Component1 from './Component1'
274+
import Component2 from './Component2'
275+
276+
areComponentsEqual(Component1, Component2) // true or false
277+
```
278+
279+
### setConfig(config)
280+
281+
Set a new configuration for React Hot Loader.
282+
283+
Available options are:
284+
285+
* `logLevel`: specify log level, default to `"error"`, available values are: `['debug', 'log', 'warn', 'error']`
286+
287+
```js
288+
import { setConfig } from 'react-hot-loader'
289+
290+
setConfig({ logLevel: 'debug' })
291+
```
292+
221293
## Migrating from v3
222294

223295
### AppContainer vs hot

Diff for: babel.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict'
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./dist/babel.production.min.js');
5+
} else {
6+
module.exports = require('./dist/babel.development.js');
7+
}

Diff for: examples/styled-components/src/App.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ const indirect = {
2020
),
2121
}
2222

23-
const aNumber = 10
23+
const aNumber = 100500
2424

2525
const App = () => (
2626
<h1>
2727
<BigText>1.Hello, world!! {aNumber} </BigText>
2828
<br />
29-
<SmallText>2.Hello, world---.</SmallText>
29+
<SmallText>2.Hello, world.</SmallText>
3030
<br />
3131
<Counter />
3232
<indirect.element />

Diff for: index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict'
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./dist/react-hot-loader.production.min.js');
5+
} else {
6+
module.exports = require('./dist/react-hot-loader.development.js');
7+
}

Diff for: lerna.json

-8
This file was deleted.

Diff for: package.json

+49-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
2-
"private": true,
2+
"name": "react-hot-loader",
3+
"version": "4.0.0-beta.20",
4+
"description": "Tweak React components in real time.",
5+
"main": "index.js",
6+
"types": "react-hot-loader.d.ts",
7+
"homepage": "https://github.com/gaearon/react-hot-loader",
8+
"repository": "https://github.com/gaearon/react-hot-loader/",
9+
"license": "MIT",
10+
"author": "Dan Abramov",
311
"scripts": {
4-
"bootstrap": "lerna bootstrap",
12+
"build": "rollup -c",
513
"changelog": "conventional-changelog -p angular -r2 -i CHANGELOG.md -s --no-output-unreleased && conventional-github-releaser -p angular",
614
"ci": "scripts/ci.sh",
7-
"dev": "yarn bootstrap && yarn build && lerna-watch",
8-
"build": "lerna-build",
915
"format": "prettier --write \"**/*.{js,md,ts,json}\" *.{js,md,ts,json}",
1016
"lint": "eslint .",
11-
"lint:fix": "eslint . --fix",
1217
"prepublishOnly": "yarn build",
13-
"prebuild": "rm -rf packages/*/lib",
18+
"prebuild": "rm -rf dist",
1419
"precommit": "lint-staged",
1520
"test": "yarn test:es2015 && yarn test:modern",
1621
"test:es2015": "cross-env BABEL_TARGET=es2015 jest --no-cache",
@@ -22,12 +27,32 @@
2227
"git add"
2328
]
2429
},
30+
"files": [
31+
"dist",
32+
"index.js",
33+
"babel.js",
34+
"patch.js",
35+
"react-hot-loader.d.ts"
36+
],
37+
"keywords": [
38+
"react",
39+
"javascript",
40+
"webpack",
41+
"hmr",
42+
"livereload",
43+
"live",
44+
"edit",
45+
"hot",
46+
"loader",
47+
"reload"
48+
],
2549
"devDependencies": {
2650
"babel-cli": "^6.7.5",
2751
"babel-core": "^6.7.6",
2852
"babel-eslint": "^8.2.1",
2953
"babel-jest": "^22.1.0",
3054
"babel-plugin-dynamic-import-node": "^1.2.0",
55+
"babel-plugin-external-helpers": "^6.22.0",
3156
"babel-plugin-transform-class-properties": "^6.24.1",
3257
"babel-plugin-transform-object-rest-spread": "^6.26.0",
3358
"babel-preset-env": "^1.6.0",
@@ -48,16 +73,28 @@
4873
"eslint-plugin-react": "^7.6.1",
4974
"husky": "^0.14.3",
5075
"jest": "^22.1.4",
51-
"lerna": "^2.8.0",
52-
"lerna-tools": "^1.0.0",
5376
"lint-staged": "^6.1.0",
5477
"prettier": "^1.10.2",
55-
"react": "16",
56-
"react-dom": "16",
78+
"react": "^16.2.0",
79+
"react-dom": "^16.2.0",
5780
"react-mount": "^0.1.3",
5881
"react-test-renderer": "16",
5982
"recompose": "^0.26.0",
60-
"rimraf": "^2.5.2"
83+
"rimraf": "^2.5.2",
84+
"rollup": "^0.55.3",
85+
"rollup-plugin-babel": "^3.0.3",
86+
"rollup-plugin-commonjs": "^8.3.0",
87+
"rollup-plugin-json": "^2.3.0",
88+
"rollup-plugin-node-resolve": "^3.0.2",
89+
"rollup-plugin-replace": "^2.0.0",
90+
"rollup-plugin-uglify": "^3.0.0"
91+
},
92+
"dependencies": {
93+
"fast-levenshtein": "^2.0.6",
94+
"global": "^4.3.0",
95+
"hoist-non-react-statics": "^2.3.1",
96+
"prop-types": "^15.6.0",
97+
"shallowequal": "^1.0.2"
6198
},
6299
"engines": {
63100
"node": ">= 6"
@@ -73,6 +110,5 @@
73110
"transform": {
74111
"^.+\\.js$": "<rootDir>/testConfig/babel.js"
75112
}
76-
},
77-
"dependencies": {}
113+
}
78114
}

Diff for: packages/react-hot-loader/README.md

-79
This file was deleted.

Diff for: packages/react-hot-loader/babel.js

-2
This file was deleted.

0 commit comments

Comments
 (0)