@@ -474,21 +474,23 @@ This is a monorepo for Socket.dev optimized package overrides, built with JavaSc
474474### Build System
475475- Uses Rollup for building external dependencies
476476- TypeScript support with tsconfig (compiles to CommonJS)
477- - Post-build script fixes CommonJS exports for backward compatibility
477+ - Post-build transforms via Rollup ` writeBundle ` hook
478478- Multiple environment configs (.env.local, .env.test, .env.external)
479479- Dual linting with oxlint and eslint
480480- Formatting with Biome
481481
482482#### CommonJS Export Compatibility (CRITICAL)
483483- ** Issue** : TypeScript compiles ` export default ` to ` exports.default = value ` , requiring ` .default ` in CommonJS
484- - ** Solution** : Post-build script ` registry/scripts/fix -commonjs-exports.mjs` transforms exports
484+ - ** Solution** : Post-build transform in Rollup ` writeBundle ` hook using ` transform -commonjs-exports.mjs`
485485- ** Result** : Direct CommonJS require works: ` require('@socketsecurity/registry/lib/constants/WIN32') ` returns value directly
486486- ** Implementation** :
487487 - Constants use ` export default ` in TypeScript for consistency
488- - Post-build transforms ` exports.default = value ` → ` module.exports = value `
489- - Also fixes imports in other compiled files to remove ` .default ` references
488+ - Transform runs after Rollup bundle write, using Babel AST + magic-string
489+ - First pass: transforms ` exports.default = value ` → ` module.exports = value `
490+ - Second pass: fixes imports to remove ` .default ` references
490491 - Files with type exports keep default export pattern
491- - ** Maintenance** : Script runs automatically as part of build process (` build:fix-cjs ` )
492+ - ** Location** : Transform utility in ` registry/scripts/babel/transform-commonjs-exports.mjs `
493+ - ** Integration** : Called from Rollup config's ` writeBundle ` hook in ` registry/.config/rollup.dist.config.mjs `
492494
493495### Testing
494496- Vitest for unit testing
0 commit comments