Skip to content

Commit

Permalink
fix: import react-refresh without depending on extension (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh committed Feb 7, 2022
1 parent 45db3bd commit ae52385
Show file tree
Hide file tree
Showing 8 changed files with 640 additions and 640 deletions.
4 changes: 2 additions & 2 deletions client/ReactRefreshEntry.js
@@ -1,7 +1,7 @@
/* global __react_refresh_library__ */

const safeThis = require('core-js-pure/features/global-this.js');
const RefreshRuntime = require('react-refresh/runtime.js');
const safeThis = require('core-js-pure/features/global-this');
const RefreshRuntime = require('react-refresh/runtime');

if (process.env.NODE_ENV !== 'production') {
if (typeof safeThis !== 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion loader/index.js
Expand Up @@ -17,7 +17,7 @@ const {
const schema = require('./options.json');

const RefreshRuntimePath = require
.resolve('react-refresh/runtime.js')
.resolve('react-refresh')
.replace(/\\/g, '/')
.replace(/'/g, "\\'");

Expand Down
2 changes: 1 addition & 1 deletion sockets/WPSSocket.js
@@ -1,5 +1,5 @@
/* global ʎɐɹɔosǝʌɹǝs */
const { ClientSocket } = require('webpack-plugin-serve/lib/client/ClientSocket.js');
const { ClientSocket } = require('webpack-plugin-serve/lib/client/ClientSocket');

/**
* Initializes a socket server for HMR for webpack-plugin-serve.
Expand Down
6 changes: 3 additions & 3 deletions test/jest-resolver.js
Expand Up @@ -4,11 +4,11 @@
* @return {string}
*/
function resolver(request, options) {
// This acts as a mock for `require.resolve('react-refresh/runtime.js')`,
// This acts as a mock for `require.resolve('react-refresh')`,
// since the current mocking behaviour of Jest is not symmetrical,
// i.e. only `require` is mocked but not `require.resolve`.
if (request === 'react-refresh/runtime.js') {
return 'react-refresh/runtime.js';
if (request === 'react-refresh') {
return 'react-refresh';
}

return options.defaultResolver(request, options);
Expand Down

0 comments on commit ae52385

Please sign in to comment.