Skip to content

Commit

Permalink
update webpack plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWangJustToDo committed Dec 11, 2023
1 parent b271ca3 commit 7df3700
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/myreact-reconciler/src/runtimeHook/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export const createHookNode = ({ type, value, reducer, deps }: RenderHookParams,
const typedHook = hookNode as MyReactHookNodeDev;

typedHook._debugType = HOOK_TYPE[hookNode.type];

typedHook._debugIndex = currentHookIndex;
}

return hookNode;
Expand Down
1 change: 1 addition & 0 deletions packages/myreact-reconciler/src/runtimeHook/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ export class MyReactHookNode extends MyReactInternalInstance implements RenderHo

export interface MyReactHookNodeDev extends MyReactHookNode {
_debugType: string;
_debugIndex: number;
_debugUpdateQueue: ListTree<UpdateQueueDev>;
}
2 changes: 1 addition & 1 deletion packages/myreact-refresh-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@my-react/react-refresh-tools",
"version": "0.0.7",
"version": "0.0.8",
"description": "An experimental package providing utilities for @my-react Refresh.",
"files": [
"dist",
Expand Down
24 changes: 21 additions & 3 deletions packages/myreact-refresh-tools/src/internal/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ function registerExportsForReactRefresh(moduleExports: any, moduleID: string) {
if (isSafeExport(key)) {
continue;
}
const exportValue = moduleExports[key];
let exportValue = undefined;
try {
exportValue = moduleExports[key];
} catch {
// This might fail due to circular dependencies
continue
}
const typeID = moduleID + " %exports% " + key;
RefreshRuntime.register(exportValue, typeID);
}
Expand All @@ -80,7 +86,13 @@ function getRefreshBoundarySignature(moduleExports: any): Array<unknown> {
if (isSafeExport(key)) {
continue;
}
const exportValue = moduleExports[key];
let exportValue = undefined;
try {
exportValue = moduleExports[key];
} catch {
// This might fail due to circular dependencies
continue
}
signature.push(key);
signature.push(RefreshRuntime.getFamilyByType(exportValue));
}
Expand All @@ -102,7 +114,13 @@ function isReactRefreshBoundary(moduleExports: any): boolean {
if (isSafeExport(key)) {
continue;
}
const exportValue = moduleExports[key];
let exportValue = undefined;
try {
exportValue = moduleExports[key];
} catch {
// This might fail due to circular dependencies
return false
}
if (!RefreshRuntime.isLikelyComponentType(exportValue)) {
areAllExportsComponents = false;
}
Expand Down
1 change: 1 addition & 0 deletions packages/myreact-refresh-tools/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ self.$RefreshInterceptModuleExecution$ = function (webpackModuleId) {
self.$RefreshReg$ = function (type, id) {
RefreshRuntime.register(type, webpackModuleId + " " + id);
};

self.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;

// Modeled after `useEffect` cleanup pattern:
Expand Down

0 comments on commit 7df3700

Please sign in to comment.