Skip to content

Commit

Permalink
fix: ensure signature function don't share identity with stubs (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh authored Sep 13, 2021
1 parent f3990a5 commit 61985e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/utils/getRefreshGlobal.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ function getRefreshGlobal(
`${refreshGlobal}.runtime.register(type, typeId);`,
])}`,
'',
`${refreshGlobal}.signature = ${refreshGlobal}.runtime.createSignatureFunctionForTransform;`,
`${refreshGlobal}.signature = ${RuntimeTemplate.returningFunction(
`${refreshGlobal}.runtime.createSignatureFunctionForTransform()`
)};`,
'',
`${refreshGlobal}.cleanup = ${RuntimeTemplate.basicFunction('cleanupModuleId', [
// Only cleanup if the module IDs match.
Expand Down
4 changes: 2 additions & 2 deletions test/unit/getRefreshGlobal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('getRefreshGlobal', () => {
__webpack_require__.$Refresh$.runtime.register(type, typeId);
}
__webpack_require__.$Refresh$.signature = __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform;
__webpack_require__.$Refresh$.signature = function() { return __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform(); };
__webpack_require__.$Refresh$.cleanup = function(cleanupModuleId) {
if (currentModuleId === cleanupModuleId) {
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('getRefreshGlobal', () => {
__webpack_require__.$Refresh$.runtime.register(type, typeId);
}
__webpack_require__.$Refresh$.signature = __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform;
__webpack_require__.$Refresh$.signature = () => (__webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform());
__webpack_require__.$Refresh$.cleanup = (cleanupModuleId) => {
if (currentModuleId === cleanupModuleId) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/makeRefreshRuntimeModule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ __webpack_require__.$Refresh$ = {
__webpack_require__.$Refresh$.runtime.register(type, typeId);
}
__webpack_require__.$Refresh$.signature = __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform;
__webpack_require__.$Refresh$.signature = function() { return __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform(); };
__webpack_require__.$Refresh$.cleanup = function(cleanupModuleId) {
if (currentModuleId === cleanupModuleId) {
Expand Down Expand Up @@ -162,7 +162,7 @@ __webpack_require__.$Refresh$ = {
__webpack_require__.$Refresh$.runtime.register(type, typeId);
}
__webpack_require__.$Refresh$.signature = __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform;
__webpack_require__.$Refresh$.signature = () => (__webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform());
__webpack_require__.$Refresh$.cleanup = (cleanupModuleId) => {
if (currentModuleId === cleanupModuleId) {
Expand Down

0 comments on commit 61985e1

Please sign in to comment.