Skip to content

Commit

Permalink
feat: ship flat bundles (#844)
Browse files Browse the repository at this point in the history
- Refactor all project
- Remove Lerna
- Simplify code
  • Loading branch information
gregberge authored Feb 7, 2018
1 parent bf519d4 commit 7580552
Show file tree
Hide file tree
Showing 107 changed files with 595 additions and 1,544 deletions.
2 changes: 2 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
[
"env",
{
"modules": false,
"loose": true
}
],
"react"
],
"plugins": [

["transform-class-properties", { "loose": true }],
"transform-object-rest-spread",
"dynamic-import-node"
Expand Down
7 changes: 4 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
node_modules/
__babel_fixtures__/
lib/
dist/
modules/
coverage
coverage/
examples/
babel.js
index.js
patch.js
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
lib
coverage
node_modules/
dist/
coverage/
.DS_Store
10 changes: 5 additions & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
__babel_fixtures__
__babel_fixtures__/
__snapshots__/
node_modules/
lib/
package.json
lerna.json
.cache/
dist/
package.json
babel.js
index.js
patch.js
74 changes: 73 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ each module so you might not need source maps at all.

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

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

Expand Down Expand Up @@ -218,6 +218,78 @@ new ExtractTextPlugin({
})
```

## API

### `hot(module, options)`

Mark a component as hot.

```js
import { hot } from 'react-hot-loader'

const App = () => 'Hello World!'

export default hot(module)(App)
```

### `AppContainer`

Mark application as hot reloadable. Prefer using `hot` helper.

```js
import React from 'react'
import ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'
import App from './containers/App'

const render = Component => {
ReactDOM.render(
<AppContainer>
<Component />
</AppContainer>,
document.getElementById('root'),
)
}

render(App)

// Webpack Hot Module Replacement API
if (module.hot) {
module.hot.accept('./containers/App', () => {
// if you are using harmony modules ({modules:false})
render(App)
// in all other cases - re-require App manually
render(require('./containers/App'))
})
}
```

### areComponentsEqual(Component1, Component2)

Test if two components have the same type.

```js
import { areComponentsEqual } from 'react-hot-loader'
import Component1 from './Component1'
import Component2 from './Component2'

areComponentsEqual(Component1, Component2) // true or false
```

### setConfig(config)

Set a new configuration for React Hot Loader.

Available options are:

* `logLevel`: specify log level, default to `"error"`, available values are: `['debug', 'log', 'warn', 'error']`

```js
import { setConfig } from 'react-hot-loader'

setConfig({ logLevel: 'debug' })
```

## Migrating from v3

### AppContainer vs hot
Expand Down
7 changes: 7 additions & 0 deletions babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/babel.production.min.js');
} else {
module.exports = require('./dist/babel.development.js');
}
4 changes: 2 additions & 2 deletions examples/styled-components/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const indirect = {
),
}

const aNumber = 10
const aNumber = 100500

const App = () => (
<h1>
<BigText>1.Hello, world!! {aNumber} </BigText>
<br />
<SmallText>2.Hello, world---.</SmallText>
<SmallText>2.Hello, world.</SmallText>
<br />
<Counter />
<indirect.element />
Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/react-hot-loader.production.min.js');
} else {
module.exports = require('./dist/react-hot-loader.development.js');
}
8 changes: 0 additions & 8 deletions lerna.json

This file was deleted.

62 changes: 49 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{
"private": true,
"name": "react-hot-loader",
"version": "4.0.0-beta.20",
"description": "Tweak React components in real time.",
"main": "index.js",
"types": "react-hot-loader.d.ts",
"homepage": "https://github.com/gaearon/react-hot-loader",
"repository": "https://github.com/gaearon/react-hot-loader/",
"license": "MIT",
"author": "Dan Abramov",
"scripts": {
"bootstrap": "lerna bootstrap",
"build": "rollup -c",
"changelog": "conventional-changelog -p angular -r2 -i CHANGELOG.md -s --no-output-unreleased && conventional-github-releaser -p angular",
"ci": "scripts/ci.sh",
"dev": "yarn bootstrap && yarn build && lerna-watch",
"build": "lerna-build",
"format": "prettier --write \"**/*.{js,md,ts,json}\" *.{js,md,ts,json}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "yarn build",
"prebuild": "rm -rf packages/*/lib",
"prebuild": "rm -rf dist",
"precommit": "lint-staged",
"test": "yarn test:es2015 && yarn test:modern",
"test:es2015": "cross-env BABEL_TARGET=es2015 jest --no-cache",
Expand All @@ -22,12 +27,32 @@
"git add"
]
},
"files": [
"dist",
"index.js",
"babel.js",
"patch.js",
"react-hot-loader.d.ts"
],
"keywords": [
"react",
"javascript",
"webpack",
"hmr",
"livereload",
"live",
"edit",
"hot",
"loader",
"reload"
],
"devDependencies": {
"babel-cli": "^6.7.5",
"babel-core": "^6.7.6",
"babel-eslint": "^8.2.1",
"babel-jest": "^22.1.0",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.0",
Expand All @@ -48,16 +73,28 @@
"eslint-plugin-react": "^7.6.1",
"husky": "^0.14.3",
"jest": "^22.1.4",
"lerna": "^2.8.0",
"lerna-tools": "^1.0.0",
"lint-staged": "^6.1.0",
"prettier": "^1.10.2",
"react": "16",
"react-dom": "16",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-mount": "^0.1.3",
"react-test-renderer": "16",
"recompose": "^0.26.0",
"rimraf": "^2.5.2"
"rimraf": "^2.5.2",
"rollup": "^0.55.3",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-commonjs": "^8.3.0",
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^3.0.0"
},
"dependencies": {
"fast-levenshtein": "^2.0.6",
"global": "^4.3.0",
"hoist-non-react-statics": "^2.3.1",
"prop-types": "^15.6.0",
"shallowequal": "^1.0.2"
},
"engines": {
"node": ">= 6"
Expand All @@ -73,6 +110,5 @@
"transform": {
"^.+\\.js$": "<rootDir>/testConfig/babel.js"
}
},
"dependencies": {}
}
}
79 changes: 0 additions & 79 deletions packages/react-hot-loader/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions packages/react-hot-loader/babel.js

This file was deleted.

Loading

0 comments on commit 7580552

Please sign in to comment.