React Shared Library vs UMD
A React shared library is a modular package designed to be imported into modern build pipelines, while a UMD (Universal Module Definition) build is a standalone script designed to run directly in a browser via a <script> tag or legacy module loaders. [ 1 , 2 , 3 ] Key Differences React Shared Library (ESM / CJS): Intended Use: Modern applications using bundlers like Vite, Webpack, or Rollup. Module System: Uses standard import / export (ESM) or Node's require (CommonJS). Optimization: Fully supports tree-shaking (removing unused code) to keep production bundles small. Workflow: Requires a build/bundling step before running in a browser. [ 1 , 2 , 3 , 4 , 5 , 6 ] UMD (Universal Module Definition): Intended Use: Quick prototyping, legacy environments, or loading scripts directly via a CDN (Content Delivery Network). Module System: Universal; it checks at runtime if module.exports , define (AMD), or a global window variable is available and attaches itself acc...