Skip to content

Commit

Permalink
chore: cleanup code and lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh committed Mar 2, 2020
1 parent 37bc524 commit 0646f4e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ module.exports = api => {
This plugin accepts a few options that are specifically targeted for advanced users.
The allowed values are as follows:

| Name | Type | Default | Description |
| :-----------------------: | :-------: | :-----: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`disableRefreshCheck`** | `boolean` | `false` | Disables detection of react-refresh's Babel plugin. Useful if you do not parse JS files within `node_modules`, or if you have a Babel setup not entirely controlled by Webpack. |
| **`forceEnable`** | `boolean` | `false` | Enables the plugin forcefully. Useful if you want to use the plugin in production, or if you are using Webpack's `none` mode without `NODE_ENV`, for example. |
| **`useLegacyWDSSockets`** | `boolean` | `false` | Set this to true if you are using a webpack-dev-server version prior to 3.8 as it requires a custom SocketJS implementation. |
| Name | Type | Default | Description |
| :-----------------------: | :-------: | :-----: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`disableRefreshCheck`** | `boolean` | `false` | Disables detection of react-refresh's Babel plugin. Useful if you do not parse JS files within `node_modules`, or if you have a Babel setup not entirely controlled by Webpack. |
| **`forceEnable`** | `boolean` | `false` | Enables the plugin forcefully. Useful if you want to use the plugin in production, or if you are using Webpack's `none` mode without `NODE_ENV`, for example. |
| **`useLegacyWDSSockets`** | `boolean` | `false` | Set this to true if you are using a webpack-dev-server version prior to 3.8 as it requires a custom SocketJS implementation. If you use this, you will also need to install `sockjs-client` as a peer depencency. |

## Related Work

Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@
],
"scripts": {
"lint": "eslint --report-unused-disable-directives \"**/*.js\"",
"lint:fix": "yarn run lint:eslint --fix",
"lint:fix": "yarn lint --fix",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"format:heck": "prettier --check \"**/*.{js,jsx,json,md}\""
"format:check": "prettier --check \"**/*.{js,jsx,json,md}\""
},
"dependencies": {
"ansi-html": "^0.0.7",
"error-stack-parser": "^2.0.4",
"html-entities": "^1.2.1",
"lodash.debounce": "^4.0.8",
"react-dev-utils": "^9.1.0",
"sockjs-client": "^1.4.0"
"react-dev-utils": "^9.1.0"
},
"devDependencies": {
"eslint": "^6.7.2",
Expand All @@ -53,9 +52,13 @@
},
"peerDependencies": {
"react-refresh": ">= 0.7",
"sockjs-client": "^1.4.0",
"webpack-hot-middleware": "^2.25.0"
},
"peerDependenciesMeta": {
"sockjs-client": {
"optional": true
},
"webpack-hot-middleware": {
"optional": true
}
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/createRefreshTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ const { Template } = require('webpack');
*/
const beforeModule = `
let cleanup = function NoOp() {};
let check = function (it) {
const check = function(it) {
return it && it.Math == Math && it;
};
let safeThis =
const safeThis =
check(typeof globalThis == 'object' && globalThis) ||
check(typeof window == 'object' && window) ||
check(typeof self == 'object' && self) ||
Expand All @@ -37,10 +38,9 @@ const afterModule = `
/**
* Creates a module wrapped by a refresh template.
* @param {string} source The source code of a module.
* @param {import('webpack').compilation.Chunk} chunk A Webpack chunk.
* @returns {string} A refresh-wrapped module.
*/
function createRefreshTemplate(source, chunk) {
function createRefreshTemplate(source) {
const lines = source.split('\n');

// Webpack generates this line whenever the mainTemplate is called
Expand Down

0 comments on commit 0646f4e

Please sign in to comment.