Skip to content

Commit 61985e1

Browse files
authored
fix: ensure signature function don't share identity with stubs (#505)
1 parent f3990a5 commit 61985e1

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/utils/getRefreshGlobal.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ function getRefreshGlobal(
7171
`${refreshGlobal}.runtime.register(type, typeId);`,
7272
])}`,
7373
'',
74-
`${refreshGlobal}.signature = ${refreshGlobal}.runtime.createSignatureFunctionForTransform;`,
74+
`${refreshGlobal}.signature = ${RuntimeTemplate.returningFunction(
75+
`${refreshGlobal}.runtime.createSignatureFunctionForTransform()`
76+
)};`,
7577
'',
7678
`${refreshGlobal}.cleanup = ${RuntimeTemplate.basicFunction('cleanupModuleId', [
7779
// Only cleanup if the module IDs match.

test/unit/getRefreshGlobal.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('getRefreshGlobal', () => {
3333
__webpack_require__.$Refresh$.runtime.register(type, typeId);
3434
}
3535
36-
__webpack_require__.$Refresh$.signature = __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform;
36+
__webpack_require__.$Refresh$.signature = function() { return __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform(); };
3737
3838
__webpack_require__.$Refresh$.cleanup = function(cleanupModuleId) {
3939
if (currentModuleId === cleanupModuleId) {
@@ -94,7 +94,7 @@ describe('getRefreshGlobal', () => {
9494
__webpack_require__.$Refresh$.runtime.register(type, typeId);
9595
}
9696
97-
__webpack_require__.$Refresh$.signature = __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform;
97+
__webpack_require__.$Refresh$.signature = () => (__webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform());
9898
9999
__webpack_require__.$Refresh$.cleanup = (cleanupModuleId) => {
100100
if (currentModuleId === cleanupModuleId) {

test/unit/makeRefreshRuntimeModule.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ __webpack_require__.$Refresh$ = {
8383
__webpack_require__.$Refresh$.runtime.register(type, typeId);
8484
}
8585
86-
__webpack_require__.$Refresh$.signature = __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform;
86+
__webpack_require__.$Refresh$.signature = function() { return __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform(); };
8787
8888
__webpack_require__.$Refresh$.cleanup = function(cleanupModuleId) {
8989
if (currentModuleId === cleanupModuleId) {
@@ -162,7 +162,7 @@ __webpack_require__.$Refresh$ = {
162162
__webpack_require__.$Refresh$.runtime.register(type, typeId);
163163
}
164164
165-
__webpack_require__.$Refresh$.signature = __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform;
165+
__webpack_require__.$Refresh$.signature = () => (__webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform());
166166
167167
__webpack_require__.$Refresh$.cleanup = (cleanupModuleId) => {
168168
if (currentModuleId === cleanupModuleId) {

0 commit comments

Comments
 (0)