Skip to content

refactor: 👞 memoize#1040

Merged
sverweij merged 8 commits intomainfrom
refactor/replace-memoize-with-internal-cache
Dec 25, 2025
Merged

refactor: 👞 memoize#1040
sverweij merged 8 commits intomainfrom
refactor/replace-memoize-with-internal-cache

Conversation

@sverweij
Copy link
Copy Markdown
Owner

@sverweij sverweij commented Dec 25, 2025

Description

  • replaces the use of memoize with internal cache representations (Maps)
  • removes the memoize package from the manifest and the lock file

Previous commits already replaced memoize with internal caches in other parts
of the code.

Motivation and Context

Our caching needs previously solved with memoize are pretty trivial. They're just as easy and just as maintainable implemented with internal caches. This reduces our direct runtime dependencies with 2 external packages (memoize and its dependency mimic-function).

B.t.w. memoize is a very decent package and I still think memoization is an elegant abstraction. So I'm not dropping it out of any concern or issues on the memoize package itself.

How Has This Been Tested?

  • green ci

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation only change
  • Refactor (non-breaking change which fixes an issue without changing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • 📖

    • My change doesn't require a documentation update, or ...
    • it does and I have updated it
  • ⚖️

    • The contribution will be subject to The MIT license, and I'm OK with that.
    • The contribution is my own original work.
    • I am ok with the stuff in CONTRIBUTING.md.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors AST parsing and module resolution caching by replacing the external memoize library with internal Map-based caches. The change removes a dependency while maintaining the same caching functionality.

Key Changes:

  • Replaced memoize library with native JavaScript Map objects for caching
  • Implemented explicit cache logic with has(), get(), and set() operations
  • Updated all cache clearing functions to use Map.clear() method

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/extract/tsc/parse.mjs Replaced memoize with Map-based cache for TypeScript AST parsing
src/extract/swc/parse.mjs Replaced memoize with Map-based cache for SWC AST parsing
src/extract/resolve/resolve-amd.mjs Replaced memoize with Map-based cache for file existence checks
src/extract/resolve/get-manifest.mjs Replaced memoize with two separate Map-based caches for single and combined package manifests
src/extract/resolve/external-module-helpers.mjs Replaced memoize with Map-based cache for package.json lookups using composite cache keys
src/extract/acorn/parse.mjs Replaced memoize with Map-based cache for Acorn JavaScript AST parsing
package.json Removed memoize dependency
package-lock.json Removed memoize and updated mimic-function to dev dependency only

Comment thread src/extract/tsc/parse.mjs Outdated
Comment thread src/extract/swc/parse.mjs Outdated
Comment thread src/extract/acorn/parse.mjs Outdated
Comment thread src/extract/tsc/parse.mjs Outdated
Comment thread src/extract/swc/parse.mjs Outdated
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Comment thread src/extract/resolve/external-module-helpers.mjs
@sverweij sverweij changed the title refactor(extract): replaces ast parsing memoization with internal caches; 👞 memoize refactor(extract): 👞 memoize Dec 25, 2025
@sverweij sverweij changed the title refactor(extract): 👞 memoize refactor: 👞 memoize Dec 25, 2025
@sverweij sverweij merged commit d58c78a into main Dec 25, 2025
18 checks passed
@sverweij sverweij deleted the refactor/replace-memoize-with-internal-cache branch December 25, 2025 20:25
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