Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
feat(react): Add react-refresh support (#736)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Titor <[email protected]>

closes #734
  • Loading branch information
promer94 authored Aug 19, 2020
1 parent 8fcc7ee commit c9d76e6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
4 changes: 3 additions & 1 deletion core/poi/lib/babel/preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const merge = require('lodash.merge')

const env = process.env.BABEL_ENV || process.env.NODE_ENV
const isTest = env === 'test'
const isDevelopment = env === 'development'

const validateBoolOption = (name, value, defaultValue) => {
if (typeof value === 'undefined') {
Expand Down Expand Up @@ -124,7 +125,8 @@ module.exports = (
)
}
],
require('@babel/plugin-proposal-optional-chaining')
require('@babel/plugin-proposal-optional-chaining'),
isDevelopment && require('react-refresh/babel')
].filter(Boolean)

return {
Expand Down
13 changes: 13 additions & 0 deletions core/poi/lib/plugins/config-react-refresh.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
exports.name = 'builtin:config-react-refresh'

exports.when = api =>
api.hasDependency('react') &&
api.hasDependency('react-dom') &&
process.env.NODE_ENV === 'development'

exports.apply = api => {
api.hook('createWebpackChain', config => {
const reactRefresh = require('@pmmmwh/react-refresh-webpack-plugin')
config.plugin('react-refresh').use(reactRefresh)
})
}
4 changes: 3 additions & 1 deletion core/poi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"webpack": "^4.26.0",
"webpack-chain": "^6.4.0",
"webpack-dev-server": "^3.8.2",
"webpack-merge": "^4.1.4"
"webpack-merge": "^4.1.4",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.1",
"react-refresh": "^0.8.3"
},
"xo": false,
"devDependencies": {
Expand Down
42 changes: 39 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2362,6 +2362,18 @@
universal-user-agent "^3.0.0"
url-template "^2.0.8"

"@pmmmwh/react-refresh-webpack-plugin@^0.4.1":
version "0.4.1"
resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.4.1.tgz#a4db0ed8e58c2f8566161c9a8cdf1d095c9a891b"
integrity sha512-MzM87WdX2r2KRFfhEho7oGyK1XRE/J9WwjB3v6oLQHN0dzBypBZxSWjnoYx+RWneRCsg8Sin1myf+EjX1fqIbQ==
dependencies:
ansi-html "^0.0.7"
error-stack-parser "^2.0.6"
html-entities "^1.2.1"
native-url "^0.2.6"
schema-utils "^2.6.5"
source-map "^0.7.3"

"@samverschueren/stream-to-observable@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
Expand Down Expand Up @@ -2893,7 +2905,7 @@ ansi-escapes@^4.2.1:
dependencies:
type-fest "^0.11.0"

[email protected]:
[email protected], ansi-html@^0.0.7:
version "0.0.7"
resolved "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
integrity sha1-gTWEAhliqenm/QOflA0S9WynhZ4=
Expand Down Expand Up @@ -5951,6 +5963,13 @@ error-ex@^1.2.0, error-ex@^1.3.1:
dependencies:
is-arrayish "^0.2.1"

error-stack-parser@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.0.6.tgz#5a99a707bd7a4c58a797902d48d82803ede6aad8"
integrity sha512-d51brTeqC+BHlwF0BhPtcYgF5nlzf9ZZ0ZIUQNZpc9ZB9qw5IJ2diTrBY9jlCJkTLITYPjmiX6OWCwH+fuyNgQ==
dependencies:
stackframe "^1.1.1"

es-abstract@^1.17.4, es-abstract@^1.17.5:
version "1.17.5"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.5.tgz#d8c9d1d66c8981fb9200e2251d799eee92774ae9"
Expand Down Expand Up @@ -7825,7 +7844,7 @@ html-encoding-sniffer@^1.0.2:
dependencies:
whatwg-encoding "^1.0.1"

html-entities@^1.3.1:
html-entities@^1.2.1, html-entities@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.3.1.tgz#fb9a1a4b5b14c5daba82d3e34c6ae4fe701a0e44"
integrity sha512-rhE/4Z3hIhzHAUKbW8jVcCyuT5oJCXXqhN/6mXXVCpzTmvJnoH2HL/bt3EZ6p55jbFJBeAe1ZNpL5BugLujxNA==
Expand Down Expand Up @@ -10721,6 +10740,13 @@ nanomatch@^1.2.9:
snapdragon "^0.8.1"
to-regex "^3.0.1"

native-url@^0.2.6:
version "0.2.6"
resolved "https://registry.yarnpkg.com/native-url/-/native-url-0.2.6.tgz#ca1258f5ace169c716ff44eccbddb674e10399ae"
integrity sha512-k4bDC87WtgrdD362gZz6zoiXQrl40kYlBmpfmSjwRO1VU0V5ccwJTlxuE72F6m3V0vc1xOf6n3UCP9QyerRqmA==
dependencies:
querystring "^0.2.0"

natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
Expand Down Expand Up @@ -12529,7 +12555,7 @@ querystring-es3@^0.2.0:
resolved "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
integrity sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=

[email protected]:
[email protected], querystring@^0.2.0:
version "0.2.0"
resolved "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=
Expand Down Expand Up @@ -12603,6 +12629,11 @@ react-is@^16.12.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-refresh@^0.8.3:
version "0.8.3"
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.8.3.tgz#721d4657672d400c5e3c75d063c4a85fb2d5d68f"
integrity sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==

read-cmd-shim@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-1.0.1.tgz#2d5d157786a37c055d22077c32c53f8329e91c7b"
Expand Down Expand Up @@ -13951,6 +13982,11 @@ stack-utils@^1.0.1:
resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.2.tgz#33eba3897788558bebfc2db059dc158ec36cebb8"
integrity sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA==

stackframe@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.2.0.tgz#52429492d63c62eb989804c11552e3d22e779303"
integrity sha512-GrdeshiRmS1YLMYgzF16olf2jJ/IzxXY9lhKOskuVziubpTYcYqyOwYeJKzQkwy7uN0fYSsbsC4RQaXf9LCrYA==

[email protected]:
version "1.1.2"
resolved "https://registry.yarnpkg.com/staged-git-files/-/staged-git-files-1.1.2.tgz#4326d33886dc9ecfa29a6193bf511ba90a46454b"
Expand Down

0 comments on commit c9d76e6

Please sign in to comment.