From f868515a5f96df60fb72e5302b183da2acc2ba1f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 15 Jan 2026 04:56:44 +0000 Subject: [PATCH] fix(plugins): skip binary files in transform (#609) Add binary file detection to prevent atomizer-plugins from processing binary files (images, fonts, etc.) which can cause corruption issues during webpack/vite builds. Skipped extensions include: - Images: .png, .jpg, .gif, .webp, .ico, .svg, etc. - Fonts: .woff, .woff2, .ttf, .otf, .eot - Media: .mp3, .mp4, .wav, .ogg, etc. - Archives: .zip, .tar, .gz, .rar - Binary: .exe, .dll, .so, .dylib - Build artifacts: .map, .lock Fixes #609 --- packages/atomizer-plugins/src/index.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/atomizer-plugins/src/index.ts b/packages/atomizer-plugins/src/index.ts index 4aff451c..23e223a0 100644 --- a/packages/atomizer-plugins/src/index.ts +++ b/packages/atomizer-plugins/src/index.ts @@ -4,6 +4,22 @@ import type { Options } from './types'; import { outputFile } from 'fs-extra'; import { debounce } from 'lodash-es'; +// Binary and non-text file extensions to skip (#609) +const BINARY_EXTENSIONS = [ + '.png', '.jpg', '.jpeg', '.gif', '.webp', '.ico', '.bmp', '.tiff', '.tif', + '.svg', '.woff', '.woff2', '.ttf', '.otf', '.eot', + '.mp3', '.mp4', '.wav', '.ogg', '.webm', '.avi', '.mov', + '.pdf', '.zip', '.tar', '.gz', '.rar', '.7z', + '.exe', '.dll', '.so', '.dylib', + '.map', '.lock' +]; + +// Check if file is binary based on extension +function isBinaryFile(id: string): boolean { + const ext = id.substring(id.lastIndexOf('.')).toLowerCase(); + return BINARY_EXTENSIONS.includes(ext); +} + export const unplugin = createUnplugin((options) => { const atomizer = new Atomizer({ verbose: options.verbose, @@ -43,6 +59,11 @@ export const unplugin = createUnplugin((options) => { return null; } + // Skip binary files to prevent corruption (#609) + if (isBinaryFile(id)) { + return null; + } + // Find atomic classes and add them to our cache lookup.set(id, atomizer.findClassNames(code));