Skip to content

Reduce @openuidev/react-ui package size while preserving source maps #849

Description

@zahlekhan

Problem

The published @openuidev/react-ui@0.13.0 package is larger than necessary because its package contents include:

  • source maps for Storybook stories, tests, test helpers, and package build scripts
  • repeated TypeScript source embedded as sourcesContent in generated maps
  • source maps that reference TypeScript files which are not present in the published package

This creates package-size overhead while providing inconsistent source-level debugging.

Expected outcome

  • Keep external JavaScript and declaration source maps for debugging and editor navigation.
  • Avoid embedding repeated source content in every map.
  • Publish each referenced production TypeScript file once.
  • Exclude stories, tests, test helpers, and build scripts from the package.
  • Preserve existing runtime JavaScript, CSS, exports, and dependency behavior.

Measured impact

Measured with npm pack --dry-run --json:

Metric Published 0.13.0 Optimized build Improvement
Tarball 2,471,762 bytes 1,681,784 bytes 789,978 bytes smaller (32.0%)
Unpacked 13,366,704 bytes 9,471,011 bytes 3,895,693 bytes smaller (29.1%)
Source maps 1,107 973 134 fewer (12.1%)

The optimized artifact retains all production source maps with zero embedded sourcesContent and no development-only artifacts.

Proposed implementation

  • Set Rolldown's supported outputOptions.sourcemapExcludeSources option through tsdown.
  • Use a production TypeScript build configuration that excludes development-only inputs.
  • Include referenced production TypeScript under src/ through the npm package allowlist.

Compatibility considerations

  • Source maps are no longer self-contained. Debuggers can resolve the TypeScript shipped in the package, but error-monitoring workflows that upload only dist/*.map may also need to upload src/ or use repository source integration.
  • Production TypeScript source becomes present in installed packages, which may affect tools that scan or watch node_modules.
  • Unsupported deep imports into stories, tests, helpers, or build scripts will no longer resolve; none of those paths are part of the public package exports.

Related pull request

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions