/** * Process polyfill for browser environments * This is used to provide a 'process' global that some * libraries expect to exist */// Simply providing minimal process shim// @ts-ignore - Ignoring type errors to create a simple shimif (typeof window !== 'undefined') { // @ts-ignore - Using any to bypass strict type checking window.process = window.process || { env: {}, version: '0.0.0', };}export {};
The comment is self explanatory, but I am not sure which package in Refly expects window.process to exist.
// @ts-nocheck - Disable all type checking for this file// Workaround for removeChild and insertBefore errors when // google translate is enabled// See https://github.com/facebook/react/issues/11538#issuecomment-417504600.if (typeof Node === 'function' && Node.prototype) { const originalRemoveChild = Node.prototype.removeChild; Node.prototype.removeChild = function (child) { if (child.parentNode !== this) { if (console) { console.error('Cannot remove a child from a different parent', child, this); } return child; } // biome-ignore lint/style/noArguments: using arguments is simpler return originalRemoveChild.apply(this, arguments); }; const originalInsertBefore = Node.prototype.insertBefore; Node.prototype.insertBefore = function (newNode, referenceNode) { if (referenceNode && referenceNode.parentNode !== this) { if (console) { console.error( 'Cannot insert before a reference node from a different parent', referenceNode, this, ); } return newNode; } // biome-ignore lint/style/noArguments: using arguments is simpler return originalInsertBefore.apply(this, arguments); };}
This function has added the check below in removeChild and insertBefore methods:
if (referenceNode && referenceNode.parentNode !== this) { if (console) { console.error( 'Cannot insert before a reference node from a different parent', referenceNode, this, ); } return newNode;}
Why? you might ask. Well, I don’t know. I am thinking this has to do with the comment:
// Workaround for removeChild and insertBefore errors when // google translate is enabled// See https://github.com/facebook/react/issues/11538#issuecomment-417504600.
In the OSS, it is a common practice to leave links in the comments to justify the work arounds/hacks.
There is also a biome/ignore comment:
// biome-ignore lint/style/noArguments: using arguments is simplerreturn originalRemoveChild.apply(this, arguments);
I spent 200+ hours analyzing Supabase, shadcn/ui, LobeChat. Found the patterns that separate AI slop from production code. Stop refactoring AI slop. Start with proven patterns. Check out production-grade projects atthinkthroo.com