Skip to content

Commit

Permalink
restore readme
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Dec 17, 2018
1 parent 70f7291 commit 73d30df
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
target
target
yarn-error.log
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
react-dom - hot-loader edition
=====
This is normal `react-dom` with some patches applied to be more
[React-Hot-Loader](https://github.com/gaearon/react-hot-loader) friendly.

Use it to obtain more 🔥 dev experience.

# Differences from react
There are just 4 lines changed, see `patch.js` for details

# Using this module

## Install
```text
yarn add @hot-loader/react-dom@YOUR_REACT_VERSION
```
> Right now only 16.7.0-alpha.2 version is available
## Rewire
To use this version of React-dom you have to rewire your application

### Webpack
just configure your webpack to alias this package, instead of a real react-dom.
See https://webpack.js.org/configuration/resolve/#resolve-alias
```js
// webpack.conf
...
resolve: {
alias: {
'react-dom': '@hot-loader/react-dom'
}
}
...
```
You may set configuration to only use react-🔥-dom only in dev mode.
### Parcel
Use `alias` field in `package.json` to rewire your project. This will affect dev and production modes.
See https://github.com/parcel-bundler/parcel/pull/850
```js
{
"alias": {
"react-dom": "@hot-loader/react-dom"
}
}
```

### (Yarn) Any other system
For any other build system, which may not support aliasing - use yarn name resolution.
See https://twitter.com/sebmck/status/873958247304232961?lang=en for details.
```text
yarn add @hot-loader/react-dom@npm:react-dom
```

# Using webpack-loader
React-hot-loader's webpack-loader could land necessary patches on
build time. If you can use it instead of this package, if you can.

# Production ready
production bundle, exported by this package is __identical to the original
react-dom.production.min.js__. It is safe to keep rewiring in production.


# License
React is MIT licensed. This library is still react
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"description": "The Hot version of React-DOM",
"main": "index.js",
"scripts": {
"build": "rm -Rf target && mkdir target && cd patch && node build.js"
"clean": "rm -Rf target",
"prepare": "mkdir target && cp ./README.md ./source/README.md",
"patch": "cd patch && node build.js",
"build": "run-s clean prepare patch"
},
"repository": {
"type": "git",
Expand All @@ -23,6 +26,7 @@
},
"homepage": "https://github.com/hot-loader/react-dom#readme",
"devDependencies": {
"npm-run-all": "^4.1.5",
"react-dom": "^16.7.0-alpha.2"
},
"dependencies": {
Expand All @@ -31,4 +35,4 @@
"prop-types": "^15.6.2",
"scheduler": "^0.12.0-alpha.2"
}
}
}
4 changes: 2 additions & 2 deletions patch/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const injectionEnd = {
'16.4-compact': defaultEndCompact,
};

const sign = '/** this is hot-loader/react-dom */';
const sign = '/** 🔥 this is hot-loader/react-dom 🔥 */';

function additionalTransform(source) {
for (const key in additional) {
Expand All @@ -96,7 +96,7 @@ function transform(source) {
.replace(injectionStart[key][0], injectionStart[key][1])
.replace(injectionEnd[key][0], injectionEnd[key][1])
);
return sign + result + sign;
return `${sign}\n${result}\n${sign}`;
}
}
return false;
Expand Down
Loading

0 comments on commit 73d30df

Please sign in to comment.