Skip to content

refactor: replace memoizee with lighter alternatives#10014

Merged
davidfirst merged 4 commits intomasterfrom
replace-memoizee-with-lighter-alternatives
Sep 26, 2025
Merged

refactor: replace memoizee with lighter alternatives#10014
davidfirst merged 4 commits intomasterfrom
replace-memoizee-with-lighter-alternatives

Conversation

@davidfirst
Copy link
Member

@davidfirst davidfirst commented Sep 25, 2025

Replaces the heavy memoizee dependency (which brings in 100+ files from es5-ext) with lighter alternatives using existing packages in the project:

  • bit-react-transformer: Use lodash.memoize for simple memoization
  • traverse-versions: Replace 1ms TTL cache with WeakMap-based deduplication (more appropriate for preventing duplicate work during same operation)
  • preview.runtime: Use lru-cache directly with 12-hour TTL (instead of harmony cache which isn't browser-compatible)

Performance Impact

The bundle of teambit.preview/preview is reduced from 617K to 589K as a result of this change, since memoizee is no longer part of the bundle.

This eliminates the memoizee dependency while maintaining identical functionality and using packages already available in the project.

- Replace memoizee with lodash.memoize for simple caching in bit-react-transformer
- Use WeakMap-based deduplication instead of 1ms TTL in traverse-versions for same-operation duplicate prevention
- Replace custom memoization with existing createInMemoryCache (LRU + TTL) in preview runtime
- Eliminates heavy memoizee dependency with 100+ es5-ext files while maintaining same functionality
…atibility

The harmony.modules.in-memory-cache is not browser-compatible, so using lru-cache directly in the preview runtime.
@davidfirst davidfirst merged commit dcf0a8d into master Sep 26, 2025
11 checks passed
@davidfirst davidfirst deleted the replace-memoizee-with-lighter-alternatives branch September 26, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants