Skip to content

Instantly share code, notes, and snippets.

View ScriptedAlchemy's full-sized avatar
🎯
Focusing

Zack Jackson ScriptedAlchemy

🎯
Focusing
View GitHub Profile
@ScriptedAlchemy
ScriptedAlchemy / share-table.md
Created July 11, 2025 20:16
netjs-mf sharing table

Next.js Module Federation Plugin Sharing Mechanism Documentation

Overview

This document details the sharing mechanism in the Next.js Module Federation plugin, showing how it handles sharing between client and server environments across Next.js versions 14 and 15.

Architecture Flow Diagram

flowchart TB
@ScriptedAlchemy
ScriptedAlchemy / hmr.md
Last active June 25, 2025 06:45
next hmr flow

Next.js Server-Side Hot Module Replacement (HMR) Architecture

Overview

Next.js implements a sophisticated server-side HMR system that coordinates multiple webpack compilers, handles server component updates, and manages complex caching mechanisms. This document provides a comprehensive analysis of the server-side HMR architecture.

High-Level Server Architecture

graph TB
@ScriptedAlchemy
ScriptedAlchemy / 01_export_info_dependency_analysis.md
Created June 19, 2025 20:02
Rspack Export Usage Tracking Research Documentation

Export Info Dependency Analysis

Overview

The ExportInfoDependency is a critical component in rspack's export tracking system that provides runtime access to export metadata during code generation. It acts as a bridge between the analysis phase (where export usage information is collected) and the runtime phase (where this information is used for optimizations).

Core Functionality

Purpose

  • Runtime Export Information Access: Provides a way to inject export metadata into the generated code at runtime
@ScriptedAlchemy
ScriptedAlchemy / compression_results.md
Created June 13, 2025 16:37
Custom Compression Dictionary

Advanced Dictionary Compression (ADC) Performance Results

🎯 Quick Summary

TL;DR: We tested Advanced Dictionary Compression (ADC) technology on real-world JavaScript files (4MB each). The results demonstrate significant improvements:

  • 🚀 86-92% better compression than current web standards
  • 💰 500+ MB bandwidth savings per 1000 downloads
  • Faster loading times for web app updates
  • 🌍 Massive cost savings for high-traffic websites
@ScriptedAlchemy
ScriptedAlchemy / hmr.md
Created June 4, 2025 15:43
HMR api specs

HMR Runtime API Specification (Node.js readFileVm Variant)

1. Introduction

This document provides a comprehensive specification for the Hot Module Replacement (HMR) runtime, specifically tailored for a Node.js environment where update chunks are loaded from the filesystem and executed within the current V8 context using the vm module. This runtime enables developers to update modules in a running Node.js application without a full server restart, significantly speeding up development workflows.

1.1. Purpose of this HMR Runtime

The primary purpose of this HMR runtime is to:

  • Detect changes to modules in a running application
@ScriptedAlchemy
ScriptedAlchemy / intput.js
Created June 4, 2025 06:39
Tree shake macro results
// Utility functions that would only be used by newFeature
function formatMessage(message) {
return `[NEW] ${message}`;
}
function validateFeature() {
return true;
}
function logFeatureUsage(featureName) {
@ScriptedAlchemy
ScriptedAlchemy / CursorTools.json
Created January 31, 2025 03:54
Reverse Engineering cursor prompts
{
"tools": [
{
"type": "function",
"function": {
"name": "codebase_search",
"description": "Find snippets of code from the codebase most relevant to the search query.\nThis is a semantic search tool, so the query should ask for something semantically matching what is needed.\nIf it makes sense to only search in particular directories, please specify them in the target_directories field.\nUnless there is a clear reason to use your own search query, please just reuse the user's exact query with their wording.\nTheir exact wording/phrasing can often be helpful for the semantic search query. Keeping the same exact question format can also be helpful.",
"parameters": {
"type": "object",
"properties": {
@ScriptedAlchemy
ScriptedAlchemy / plugin.js
Created September 15, 2023 01:15
Module Federation Nonce Plugin
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {ModuleFederationPlugin} = require('webpack').container;
const {RuntimeGlobals, RuntimeModule} = require('webpack');
const path = require('path');
const deps = require('./package.json').dependencies;
class Testing123RuntimeModule extends RuntimeModule {
constructor() {
super('testing123', RuntimeModule.STAGE_BASIC + 1);
}
@ScriptedAlchemy
ScriptedAlchemy / runtimeModule.js
Created February 16, 2023 21:01
Async-node + async fetch chunk loading
/******/ // load script equivalent for server side
/******/ __webpack_require__.l = function(url,callback,chunkId) {
/******/ if(!global.__remote_scope__) {
/******/ // create a global scope for container, similar to how remotes are set on window in the browser
/******/ global.__remote_scope__ = {
/******/ _config: {},
/******/ }
/******/ }
/******/
/******/ function executeLoad(url, callback, name) {
@ScriptedAlchemy
ScriptedAlchemy / getOrLoadRemote.js
Last active May 31, 2025 08:42
The Right Way to Load Dynamic Remotes
import { injectScript } from '@module-federation/utilities';
// example of dynamic remote import on server and client
const isServer = typeof window === 'undefined';
//could also use
// getModule({
// remoteContainer: {
// global: 'app2',
// url: 'http://localhost:3002/remoteEntry.js',
// },
// modulePath: './sample'