Skip to content

feat: export the UnsafeCache type - #703

Merged
alexander-akait merged 1 commit into
mainfrom
feat/export-unsafe-cache-type
Nov 5, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
feat/export-unsafe-cache-type

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

ResolveOptions.unsafeCache accepts a cache object of type { [k: string]: undefined | ResolveRequest | ResolveRequest[] }. That type, Cache, is declared in lib/UnsafeCachePlugin.js, but the package entry doesn't export it. Consumers can only reach it through the internal types/UnsafeCachePlugin.d.ts file. Webpack restates the shape for its resolve.unsafeCache option (webpack/webpack#23146).

This exports it from lib/index.js as UnsafeCache, next to ResolveRequest and ResolveOptions. It's named UnsafeCache because a bare Cache is ambiguous at the package top level.

The shape matches what UnsafeCachePlugin stores: one ResolveRequest per key for a normal resolve, the yielded ResolveRequest[] for a resolve with yield, and undefined for a miss.

What kind of change does this PR introduce?

feat (types only)

Did you add tests for your changes?

test/yield.test.js now imports the cache type from the package entry (import("../").UnsafeCache) instead of the internal file, so lint:types-test covers the export. I also checked outside the repo that UnsafeCache and webpack's local copy are assignable both ways, that it is accepted as unsafeCache, and that non-request entries are rejected.

Does this PR introduce a breaking change?

No. It only adds a type name, and runtime is unchanged.

If relevant, what needs to be documented once your change is merged or what have you documented already?

Nothing.

Use of AI

Prepared with Claude Code; reviewed by me.


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Exported the UnsafeCache type from the package entry point, making it available to TypeScript consumers.

The `unsafeCache` option accepts a cache object, but its type was only
reachable through the internal `types/UnsafeCachePlugin` file, so consumers
such as webpack had to restate it.
@changeset-bot

changeset-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cb1719b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
enhanced-resolve Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.99%. Comparing base (578b2f8) to head (cb1719b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #703   +/-   ##
=======================================
  Coverage   98.99%   98.99%           
=======================================
  Files          52       52           
  Lines       10932    10933    +1     
=======================================
+ Hits        10822    10823    +1     
  Misses        110      110           
Flag Coverage Δ
integration 98.99% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The package declarations now export UnsafeCache as an alias for UnsafeCachePlugin.Cache. The JSDoc typedef and test refer to the public type. A patch changeset records the export.

Merge Risk: Minimal · up to cb171

The UnsafeCache type export is complete and introduces no identified merge-blocking risk.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely states the main change: exporting the UnsafeCache type.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e6ec3c9b-55a9-4412-a667-5925ade2789c
Commits

Reviewing files that changed from the base of the PR and between 578b2f8 and cb1719b.

Files selected for processing: 4

  • .changeset/export-unsafe-cache-type.md
  • lib/index.js
  • test/yield.test.js
  • types/index.d.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@codspeed

codspeed Bot commented Nov 5, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 2.71%

2 warnings, 1 note

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 2 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 140 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory array-alias: @ -> [preferred, fallback] (warm) 2.2 KB 3.5 KB -37.1%
⚡ Memory node-compare: node require.resolve x 1000 76.1 KB 50.6 KB +50.49%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/export-unsafe-cache-type (cb1719b) with main (578b2f8)

Open in CodSpeed

@alexander-akait
alexander-akait merged commit 976016d into main Nov 5, 2026
39 of 40 checks passed
@alexander-akait
alexander-akait deleted the feat/export-unsafe-cache-type branch November 5, 2026 17:49
alexander-akait pushed a commit that referenced this pull request Nov 12, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## enhanced-resolve@5.26.2

### Patch Changes

- Export the `UnsafeCache` type of the `unsafeCache` option. (by
[@alexander-akait](https://github.com/alexander-akait) in
[#703](#703))

- Resolve tsconfig `extends` the way tsc does, including package
`exports`. (by [@abrahamguo](https://github.com/abrahamguo) in
[#709](#709))

- Resolve `paths` inherited through `extends` (with no `baseUrl`)
relative to the tsconfig that declares them, substitute `${configDir}`
in an inherited `baseUrl`, treat an empty `baseUrl` as the directory of
its tsconfig, like tsc, and stop extending a tsconfig from changing it
for later loads that share the file system cache. (by
[@alexander-akait](https://github.com/alexander-akait) in
[#711](#711))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant