Skip to content

Instantly share code, notes, and snippets.

View noherczeg's full-sized avatar

Norbert Csaba Herczeg noherczeg

View GitHub Profile
description
Technical specification for HMR support and tree shaking in React 19 / Rolldown architectures.

Technical Specification: Industry Standard Practices for HMR Support and Tree Shaking in React 19 / Rolldown Architectures

1. Executive Technical Summary

The migration to React 19, coupled with the Vite 6+ ecosystem utilizing Rolldown (the Rust-based successor to Rollup), fundamentally alters the optimization landscape for frontend applications. This document serves as a comprehensive technical specification for Senior Frontend Architects and Lead Engineers. It details the precise coding standards, configuration patterns, and architectural constraints required to achieve two specific critical objectives: Deterministic Hot Module Replacement (HMR) stability and Aggressive Tree Shaking (Dead Code Elimination).

import { type Plugin } from 'vite';
import { existsSync, readFileSync } from 'node:fs';
import { resolve } from 'node:path';
interface ImportmapConfig {
appendSuffix?: Record<string, string>,
keepExternals?: string[],
}
function vitePluginImportmap(configOverrides: ImportmapConfig = {}): Plugin {
# sudo dnf install screenfetch
# screenfetch
import { type SetStateAction, type Dispatch, useEffect, useRef, useState, useMemo } from 'react';
export function useDerivedState<T>(prop: T): [T, Dispatch<SetStateAction<T>>] {
const [internalVal, setInternalVal] = useState<T>(prop);
const previousProp = useRef<any>(null);
useEffect(() => {
if (previousProp.current !== prop) {
previousProp.current = prop;
setInternalVal(prop);
#!/bin/bash
set -e
find . -type f \( -name "*.ts" -o -name "*.tsx" \) -exec cat {} + | wc -l
import { createHash } from 'node:crypto';
const hash = createHash('md5');
hash.update('asdasdasdasd2323');
console.log(hash.digest('hex'));
#!/bin/bash
unameOut=$(uname -a)
case "${unameOut}" in
*Microsoft*) OS="WSL";; #must be first since Windows subsystem for linux will have Linux in the name too
*microsoft*) OS="WSL2";; #WARNING: My v2 uses ubuntu 20.4 at the moment slightly different name may not always work
Linux*) OS="Linux";;
Darwin*) OS="Mac";;
CYGWIN*) OS="Cygwin";;
MINGW*) OS="Windows";;
ffmpeg -i https://56cf3370d8dd3.streamlock.net:1935/live/cedar1.stream/playlist.m3u8 \
-c copy \
-f segment \
-segment_time 3600 \
-segment_format mkv \
-segment_atclocktime 1 \
-reset_timestamps 1 \
-strftime 1 "streamname_%Y-%m-%d_%H-%M-%S_%z.mkv"
@noherczeg
noherczeg / index.html
Last active December 19, 2022 02:09
preloader css
<section>
<br />
<br />
<br />
<div class="preloader-whirlpool">
<div class="whirlpool"></div>
</div>
</section>