Skip to content

Commit 52217bc

Browse files
committed
Preload react-refresh/babel in babel workers for perf
1 parent f88762a commit 52217bc

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

packages/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
"react-modal": "^3.6.1",
193193
"react-motion": "^0.5.0",
194194
"react-outside-click-handler": "^1.2.3",
195+
"react-refresh": "^0.7.1",
195196
"react-router-dom": "^5.0.1",
196197
"react-scrollbars-custom": "^4.0.20",
197198
"react-show": "^3.0.4",

packages/app/src/sandbox/eval/transpilers/babel/worker/babel-worker.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { flatten } from 'lodash-es';
33
import codeFrame from 'babel-code-frame';
44
import macrosPlugin from 'babel-plugin-macros';
5+
import refreshBabelPlugin from 'react-refresh/babel';
56
import chainingPlugin from '@babel/plugin-proposal-optional-chaining';
67
import coalescingPlugin from '@babel/plugin-proposal-nullish-coalescing-operator';
78

@@ -635,6 +636,13 @@ self.addEventListener('message', async event => {
635636
Babel.registerPlugin('proposal-optional-chaining', chainingPlugin);
636637
}
637638

639+
if (
640+
flattenedPlugins.indexOf('react-refresh/babel') > -1 &&
641+
Object.keys(Babel.availablePlugins).indexOf('react-refresh/babel') === -1
642+
) {
643+
Babel.registerPlugin('react-refresh/babel', refreshBabelPlugin);
644+
}
645+
638646
const coalescingInPlugins =
639647
flattenedPlugins.indexOf('proposal-nullish-coalescing-operator') > -1 ||
640648
flattenedPlugins.indexOf(

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25433,6 +25433,11 @@ react-redux@^7.0.2:
2543325433
prop-types "^15.7.2"
2543425434
react-is "^16.8.6"
2543525435

25436+
react-refresh@^0.7.1:
25437+
version "0.7.1"
25438+
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.7.1.tgz#b9605e4cd0e5366b9cc21705ebe6ee5bda8ccf85"
25439+
integrity sha512-tFM1EmOxub/hMKtXilOslJTEt7ANDMwtjD8psJAFSe1oQl7anmGEQONxSR+hAYePgHGI1eVhRVdprBruXu3wfw==
25440+
2543625441
react-resize-detector@^4.0.5:
2543725442
version "4.2.0"
2543825443
resolved "https://registry.yarnpkg.com/react-resize-detector/-/react-resize-detector-4.2.0.tgz#b87aee6b37c9e8a52daca8736b3230cf6a2a8647"

0 commit comments

Comments
 (0)