@parcel/transformer-react-refresh-wrap 2.8.4-nightly.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,33 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _path() {
9
8
  const data = _interopRequireDefault(require("path"));
10
-
11
9
  _path = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _plugin() {
19
15
  const data = require("@parcel/plugin");
20
-
21
16
  _plugin = function () {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
22
  function shouldExclude(asset, options) {
31
23
  return !asset.isSource || !options.hmrOptions || !asset.env.isBrowser() || asset.env.isLibrary || asset.env.isWorker() || asset.env.isWorklet() || options.mode !== 'development' || !asset.getDependencies().find(v => v.specifier === 'react' || v.specifier === 'react/jsx-runtime' || v.specifier === 'react/jsx-dev-runtime' || v.specifier === '@emotion/react' || v.specifier === '@emotion/react/jsx-runtime' || v.specifier === '@emotion/react/jsx-dev-runtime');
32
24
  }
33
-
34
25
  var _default = new (_plugin().Transformer)({
35
26
  async transform({
36
27
  asset,
@@ -39,7 +30,6 @@ var _default = new (_plugin().Transformer)({
39
30
  if (shouldExclude(asset, options)) {
40
31
  return [asset];
41
32
  }
42
-
43
33
  let wrapperPath = `@parcel/transformer-react-refresh-wrap/${_path().default.basename(__dirname)}/helpers/helpers.js`;
44
34
  let code = await asset.getCode();
45
35
  let map = await asset.getMap();
@@ -57,13 +47,12 @@ ${code}
57
47
  window.$RefreshSig$ = prevRefreshSig;
58
48
  }`;
59
49
  asset.setCode(code);
60
-
61
50
  if (map) {
62
51
  map.offsetLines(1, 6);
63
52
  asset.setMap(map);
64
- } // The JSTransformer has already run, do it manually
65
-
53
+ }
66
54
 
55
+ // The JSTransformer has already run, do it manually
67
56
  asset.addDependency({
68
57
  specifier: wrapperPath,
69
58
  specifierType: 'esm',
@@ -71,7 +60,5 @@ ${code}
71
60
  });
72
61
  return [asset];
73
62
  }
74
-
75
63
  });
76
-
77
64
  exports.default = _default;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var Refresh = require('react-refresh/runtime');
4
-
5
4
  function debounce(func, delay) {
6
5
  if (process.env.NODE_ENV === 'test') {
7
6
  return function (args) {
@@ -16,7 +15,6 @@ function debounce(func, delay) {
16
15
  // (for the common case of a single update), and subsequent updates
17
16
  // are batched.
18
17
  let now = Date.now();
19
-
20
18
  if (now - lastTime > delay) {
21
19
  lastTime = now;
22
20
  func.call(null, args);
@@ -31,10 +29,11 @@ function debounce(func, delay) {
31
29
  };
32
30
  }
33
31
  }
34
-
35
32
  var enqueueUpdate = debounce(function () {
36
33
  Refresh.performReactRefresh();
37
- }, 30); // Everthing below is either adapted or copied from
34
+ }, 30);
35
+
36
+ // Everthing below is either adapted or copied from
38
37
  // https://github.com/facebook/metro/blob/61de16bd1edd7e738dd0311c89555a644023ab2d/packages/metro/src/lib/polyfills/require.js
39
38
  // MIT License - Copyright (c) Facebook, Inc. and its affiliates.
40
39
 
@@ -42,167 +41,133 @@ module.exports.prelude = function (module) {
42
41
  window.$RefreshReg$ = function (type, id) {
43
42
  Refresh.register(type, module.id + ' ' + id);
44
43
  };
45
-
46
44
  window.$RefreshSig$ = Refresh.createSignatureFunctionForTransform;
47
45
  };
48
-
49
46
  module.exports.postlude = function (module) {
50
47
  if (isReactRefreshBoundary(module.exports)) {
51
48
  registerExportsForReactRefresh(module);
52
-
53
49
  if (module.hot) {
54
50
  module.hot.dispose(function (data) {
55
51
  if (Refresh.hasUnrecoverableErrors()) {
56
52
  window.location.reload();
57
53
  }
58
-
59
54
  data.prevExports = module.exports;
60
55
  });
61
56
  module.hot.accept(function (getParents) {
62
57
  var prevExports = module.hot.data.prevExports;
63
- var nextExports = module.exports; // Since we just executed the code for it, it's possible
58
+ var nextExports = module.exports;
59
+ // Since we just executed the code for it, it's possible
64
60
  // that the new exports make it ineligible for being a boundary.
65
-
66
- var isNoLongerABoundary = !isReactRefreshBoundary(nextExports); // It can also become ineligible if its exports are incompatible
61
+ var isNoLongerABoundary = !isReactRefreshBoundary(nextExports);
62
+ // It can also become ineligible if its exports are incompatible
67
63
  // with the previous exports.
68
64
  // For example, if you add/remove/change exports, we'll want
69
65
  // to re-execute the importing modules, and force those components
70
66
  // to re-render. Similarly, if you convert a class component
71
67
  // to a function, we want to invalidate the boundary.
72
-
73
68
  var didInvalidate = shouldInvalidateReactRefreshBoundary(prevExports, nextExports);
74
-
75
69
  if (isNoLongerABoundary || didInvalidate) {
76
70
  // We'll be conservative. The only case in which we won't do a full
77
71
  // reload is if all parent modules are also refresh boundaries.
78
72
  // In that case we'll add them to the current queue.
79
73
  var parents = getParents();
80
-
81
74
  if (parents.length === 0) {
82
75
  // Looks like we bubbled to the root. Can't recover from that.
83
76
  window.location.reload();
84
77
  return;
85
78
  }
86
-
87
79
  return parents;
88
80
  }
89
-
90
81
  enqueueUpdate();
91
82
  });
92
83
  }
93
84
  }
94
85
  };
95
-
96
86
  function isReactRefreshBoundary(exports) {
97
87
  if (Refresh.isLikelyComponentType(exports)) {
98
88
  return true;
99
89
  }
100
-
101
90
  if (exports == null || typeof exports !== 'object') {
102
91
  // Exit if we can't iterate over exports.
103
92
  return false;
104
93
  }
105
-
106
94
  var hasExports = false;
107
95
  var areAllExportsComponents = true;
108
96
  let isESM = ('__esModule' in exports);
109
-
110
97
  for (var key in exports) {
111
98
  hasExports = true;
112
-
113
99
  if (key === '__esModule') {
114
100
  continue;
115
101
  }
116
-
117
102
  var desc = Object.getOwnPropertyDescriptor(exports, key);
118
-
119
103
  if (desc && desc.get && !isESM) {
120
104
  // Don't invoke getters for CJS as they may have side effects.
121
105
  return false;
122
106
  }
123
-
124
107
  var exportValue = exports[key];
125
-
126
108
  if (!Refresh.isLikelyComponentType(exportValue)) {
127
109
  areAllExportsComponents = false;
128
110
  }
129
111
  }
130
-
131
112
  return hasExports && areAllExportsComponents;
132
113
  }
133
-
134
114
  function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
135
115
  var prevSignature = getRefreshBoundarySignature(prevExports);
136
116
  var nextSignature = getRefreshBoundarySignature(nextExports);
137
-
138
117
  if (prevSignature.length !== nextSignature.length) {
139
118
  return true;
140
119
  }
141
-
142
120
  for (var i = 0; i < nextSignature.length; i++) {
143
121
  if (prevSignature[i] !== nextSignature[i]) {
144
122
  return true;
145
123
  }
146
124
  }
147
-
148
125
  return false;
149
- } // When this signature changes, it's unsafe to stop at this refresh boundary.
150
-
126
+ }
151
127
 
128
+ // When this signature changes, it's unsafe to stop at this refresh boundary.
152
129
  function getRefreshBoundarySignature(exports) {
153
130
  var signature = [];
154
131
  signature.push(Refresh.getFamilyByType(exports));
155
-
156
132
  if (exports == null || typeof exports !== 'object') {
157
133
  // Exit if we can't iterate over exports.
158
134
  // (This is important for legacy environments.)
159
135
  return signature;
160
136
  }
161
-
162
137
  let isESM = ('__esModule' in exports);
163
-
164
138
  for (var key in exports) {
165
139
  if (key === '__esModule') {
166
140
  continue;
167
141
  }
168
-
169
142
  var desc = Object.getOwnPropertyDescriptor(exports, key);
170
-
171
143
  if (desc && desc.get && !isESM) {
172
144
  // Don't invoke getters for CJS as they may have side effects.
173
145
  continue;
174
146
  }
175
-
176
147
  var exportValue = exports[key];
177
148
  signature.push(key);
178
149
  signature.push(Refresh.getFamilyByType(exportValue));
179
150
  }
180
-
181
151
  return signature;
182
152
  }
183
-
184
153
  function registerExportsForReactRefresh(module) {
185
154
  var exports = module.exports,
186
- id = module.id;
155
+ id = module.id;
187
156
  Refresh.register(exports, id + ' %exports%');
188
-
189
157
  if (exports == null || typeof exports !== 'object') {
190
158
  // Exit if we can't iterate over exports.
191
159
  // (This is important for legacy environments.)
192
160
  return;
193
161
  }
194
-
195
162
  let isESM = ('__esModule' in exports);
196
-
197
163
  for (var key in exports) {
198
164
  var desc = Object.getOwnPropertyDescriptor(exports, key);
199
-
200
165
  if (desc && desc.get && !isESM) {
201
166
  // Don't invoke getters for CJS as they may have side effects.
202
167
  continue;
203
168
  }
204
-
205
169
  var exportValue = exports[key];
206
- Refresh.register(exportValue, id + ' %exports% ' + key);
170
+ var typeID = id + ' %exports% ' + key;
171
+ Refresh.register(exportValue, typeID);
207
172
  }
208
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/transformer-react-refresh-wrap",
3
- "version": "2.8.4-nightly.0+7b79c6d",
3
+ "version": "2.9.0",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,12 +17,12 @@
17
17
  "source": "src/ReactRefreshWrapTransformer.js",
18
18
  "engines": {
19
19
  "node": ">= 12.0.0",
20
- "parcel": "2.8.4-nightly.0+7b79c6d"
20
+ "parcel": "^2.9.0"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/plugin": "2.8.4-nightly.0+7b79c6d",
24
- "@parcel/utils": "2.8.4-nightly.0+7b79c6d",
23
+ "@parcel/plugin": "2.9.0",
24
+ "@parcel/utils": "2.9.0",
25
25
  "react-refresh": "^0.9.0"
26
26
  },
27
- "gitHead": "7b79c6d69ffabef89810a8db61e9abdeb70d6990"
27
+ "gitHead": "dd9435be8afed35c5ffc161cf4b586fd6c78fc1f"
28
28
  }