GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: type html manifest object and resolve unsafeCache without any by alexander-akait · Pull Request #23146 · webpack/webpack

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Nov 5, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary

Two option shapes were typed { [key: string]: any } even though their contents are known:

  • output.html.manifest: the object form (and the function's return) is serialized with JSON.stringify into a .webmanifest, so it is now JsonObject (lib/fs/fs.js). This catches functions, Dates and other non-JSON values at type level.
  • resolve.unsafeCache: the object form is enhanced-resolve's unsafe cache, a map of resolved requests. It is now UnsafeCache = { [key: string]: undefined | ResolveRequest | ResolveRequest[] }, declared in lib/resolve/ResolverFactory.js. enhanced-resolve only exports its Cache type from an internal types/ file, and depending on that layout from public types would be fragile.

Only tsType changes. The JSON schema still says type: object, additionalProperties: true, and the precompiled validators are byte-identical, so validation is unchanged.

types:cover (lib/hot/declarations/bin): any 51 → 48, untyped 121 → 105. HtmlModulesPlugin.js and ResolverFactory.js are now fully typed.

What kind of change does this PR introduce?

refactor (types)

Did you add tests for your changes?

Existing tests cover this. The output-html-manifest config case now uses the option type instead of a local Record<string, EXPECTED_ANY> typedef, so lint:types-test checks it against the real type.

Does this PR introduce a breaking change?

No. Validation is unchanged. Type-wise, the manifest only rejects non-JSON values, which could not survive serialization anyway.

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

  • Improvements
    • HTML manifest configuration types now describe JSON object values and callbacks that return false, strings, or JSON objects.
    • Resolver unsafeCache types now describe boolean values and supported cache entries.
    • These updates affect TypeScript type checking and editor guidance only; runtime behavior is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3a51d1b

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

This PR includes changesets to release 1 package
Name Type
webpack 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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai coderabbitai Bot added area: config Options, defaults, validation (lib/config, schemas/) area: types types.d.ts, JSDoc annotations, hand-maintained declarations labels Nov 5, 2026
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Files ignored due to path filters: 1

  • types.d.ts is excluded by !types.d.ts
Run configuration

  • Source mode: Auto
  • Repository: webpack/webpack
  • Branch: fix/typed-manifest-and-unsafe-cache
  • File: .coderabbit.yaml
  • Commit: 3a51d1b
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1589ad70-6210-4a85-90a5-1ea4165e2a25
Commits

Reviewing files that changed from the base of the PR and between d5648ee and 3a51d1b.

Files ignored due to path filters: 1

  • types.d.ts is excluded by !types.d.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The change narrows the declared types for output.html.manifest values and resolve.unsafeCache entries. The option schema and HTML manifest config-case typedef reflect these types. The script external config-case test sets up a named element through its module scope.

Changes: Option Type Refinements

Layer / File(s) Summary
HTML manifest typing
.changeset/246-typed-manifest-and-unsafe-cache.md, declarations/WebpackOptions.ts, schemas/WebpackOptions.json, test/configCases/html/output-html-manifest/webpack.config.js
Manifest objects and callback results use JsonObject in the declarations and schema. The config-case typedef derives its type from OutputHtmlOptions. The changeset records the type updates.
Resolver unsafe-cache typing
lib/resolve/ResolverFactory.js, declarations/WebpackOptions.ts, schemas/WebpackOptions.json
ResolverFactory.js defines UnsafeCache entries as undefined, a single request, or an array of requests. The declaration and schema use this type for the object alternative. The schema retains its permissive additionalProperties setting.

Named Element Test Setup

Layer / File(s) Summary
Module-scope named element setup
test/configCases/externals/script-external-named-element/index.js, test/configCases/externals/script-external-named-element/test.config.js
The test config creates a div and assigns it to scope.myGlobal. The test removes the prototype setup, checks that window has no own myGlobal property, and assigns through the bare identifier myGlobal.

Suggested labels: area: config, area: types

Suggested reviewers: avivkeller

Change: Refactor

Merge Risk: Minimal · previous review d5648

The reviewed type refinements and test setup are consistent with the established repository contracts and are mergeable.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the conventional-commit form with type "refactor", which is an allowed type. The PR changes the declared types of output.html.manifest and resolve.unsafeCache to replace untyped `an…
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: Title check

Explanation

The title uses the conventional-commit form with type "refactor", which is an allowed type. The PR changes the declared types of output.html.manifest and resolve.unsafeCache to replace untyped any object types with JsonObject and UnsafeCache, which matches the title's subject. The title says "without any", which matches the reduction of any usages reported in the objectives. No scope is given, which the requirement allows. The title does not state a branch prefix, so the branch-match part of the requirement cannot be verified from the provided context.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

  • X
  • Mastodon
  • Reddit
  • LinkedIn
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: webpack/webpack
  • Branch: fix/typed-manifest-and-unsafe-cache
  • File: .coderabbit.yaml
  • Commit: d5648ee
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e598da63-bc15-4a7e-ae3f-1cfc0c027a82
Commits

Reviewing files that changed from the base of the PR and between dd6eda1 and d5648ee.

Files selected for processing: 1

  • test/configCases/externals/script-external-named-element/index.js

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Nov 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Reports for 3a51d1b, computed by this pull request's own code. Each section updates when its workflow finishes.


Preview package

This PR is packaged and the instant preview of its latest commit is available.

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@23146
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@23146
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@23146

From Preview package run #12137.


Generated code size

Comparing base (384dfaa) to head (3a51d1b). Merging this pull request will not change the code webpack generates.

What moved Tests Assets Gzip Raw Test edit
Changed, test untouched 0 0 — — —
Changed, test edited 0 0 — — —
New 0 0 — — —
Deleted 0 0 — — —
Unchanged — 10008 — — —

Read Changed, test untouched first: the test is byte-identical on both sides, so webpack generated the difference. Changed, test edited moved partly because the test did — Test edit is how many bytes the test gained, and a bundle that grew by less is not a regression. New and Deleted are whole files, not deltas — a new asset was created, not grown, so it reads gray (⚪ added) — and adding tests cannot bury a real change. Gzip decides, because that is what users download; raw is the tiebreak, and brotli and zstd are per asset below.

Sample apps

No sample app changed size.

26 unchanged app(s)
App Gzip Gzip change Raw Raw change
library amd 1.38 KiB — 2.68 KiB —
library amd-require 1.38 KiB — 2.67 KiB —
library assign 1.38 KiB — 2.67 KiB —
library assign-properties 1.42 KiB — 2.80 KiB —
library commonjs 1.38 KiB — 2.66 KiB —
library commonjs-module 1.38 KiB — 2.67 KiB —
library commonjs-static 1.55 KiB — 3.54 KiB —
library commonjs2 1.38 KiB — 2.67 KiB —
library global 1.38 KiB — 2.66 KiB —
library jsonp 1.37 KiB — 2.66 KiB —
library module 1.21 KiB — 2.35 KiB —
library self 1.38 KiB — 2.66 KiB —
library system 1.41 KiB — 2.73 KiB —
library this 1.38 KiB — 2.66 KiB —
library umd 1.44 KiB — 2.86 KiB —
library umd2 1.44 KiB — 2.86 KiB —
library var 1.38 KiB — 2.67 KiB —
library window 1.38 KiB — 2.66 KiB —
node-ssr 96.36 KiB — 371.30 KiB —
node-ssr-esm 96.61 KiB — 372.00 KiB —
react-100 32.17 KiB — 150.55 KiB —
react-1k 73.34 KiB — 907.38 KiB —
react-1k-esm 72.54 KiB — 906.44 KiB —
react-5k 191.49 KiB — 4.08 MiB —
webworker 36.60 KiB — 95.02 KiB —
webworker-esm 35.67 KiB — 94.21 KiB —

No asset changed size.

No runtime gained or lost a runtime module.

Built test/configCases with the defaults a user gets, and the apps in test/sizeCoreReports (apps/): 2392 test(s), 10008 asset(s), 104 emitted nothing.

From Generated code size run #6772.


Types Coverage

Typed lines: 99.68% (172708 of 173264)

Kind Base Head Change
any 51 48 🟢 −3
unknown 50 50 —
object 18 18 —
Function 1 1 —
untyped 121 105 🟢 −16

any counts EXPECTED_ANY, a written any and the any TypeScript infers where no type is written, such as const map = new Map() or const list = []. unknown counts a written unknown; ThrownValue, the unknown a throw or a rejected promise hands on, is left out. object counts EXPECTED_OBJECT and Object, Function counts EXPECTED_FUNCTION. Untyped counts the identifiers whose type is or holds any, wherever it comes from; the any TypeScript's built-in lib and Node.js's @​types/node write in their own signatures, such as the replacer of String#replace or a stream's chunk, is left out, and so is the open fallback beside declared fields, such as KnownBuildInfo & Record<string, any>, though reading a key no field declares is counted.

Changed by this pull request

File Typed lines any unknown object Function untyped
declarations/WebpackOptions.ts 100.00% 12 (🟢 −3) 2 (🟢 −3)
lib/html/HtmlModulesPlugin.js 100.00% 0 (🟢 −11)
lib/resolve/ResolverFactory.js 100.00% 0 (🟢 −2)
What the files this pull request changes still have
  • declarations/WebpackOptions.ts:72 any
  • declarations/WebpackOptions.ts:883 any
  • declarations/WebpackOptions.ts:1370 any
  • declarations/WebpackOptions.ts:1904 any
  • declarations/WebpackOptions.ts:2824 any
  • declarations/WebpackOptions.ts:3446 any
  • declarations/WebpackOptions.ts:4618 any
  • declarations/WebpackOptions.ts:5079 any
  • declarations/WebpackOptions.ts:5207 any
  • declarations/WebpackOptions.ts:5299 any
  • declarations/WebpackOptions.ts:5299 untyped generator: { [key: string]: any; } | undefined
  • declarations/WebpackOptions.ts:5342 any
  • declarations/WebpackOptions.ts:5342 untyped parser: { [key: string]: any; } | undefined
  • declarations/WebpackOptions.ts:6297 any
56 file(s) in lib/, hot/, declarations/ and bin/ still have an escape hatch, `any` or untyped identifiers
File Typed lines any unknown object Function untyped
lib/Compilation.js 99.75% 5 15
lib/logging/createConsoleLogger.js 99.00% 15
lib/module/NormalModule.js 99.54% 4 11
lib/module/NormalModuleFactory.js 99.41% 15
declarations/WebpackOptions.ts 100.00% 12 (🟢 −3) 2 (🟢 −3)
lib/javascript/syntax-parser.js 100.00% 10
lib/asset/AssetModulesPlugin.js 99.38% 9
lib/Compiler.js 100.00% 2 4
lib/javascript/syntax-printer.js 100.00% 1 5
lib/loaders/LoaderPlugin.js 99.42% 6
lib/util/SourceProcessor.js 100.00% 6
lib/MultiCompiler.js 100.00% 5
lib/dependencies/amd/AMDPlugin.js 99.31% 5
lib/dependencies/amd/AMDRuntimeModules.js 95.45% 4
lib/javascript/JavascriptModulesPlugin.js 100.00% 4
lib/loaders/LoaderOptionsPlugin.js 100.00% 4
lib/module/Module.js 100.00% 4
lib/resolve/getResolveOptionsKey.js 100.00% 4
lib/serialization/ObjectMiddleware.js 100.00% 4
lib/util/SortableSet.js 100.00% 4
lib/config/normalization.js 99.57% 3
lib/css/syntax-parser.js 100.00% 3
lib/hmr/HotModuleReplacement.runtime.js 100.00% 2 1
lib/html/syntax-parser.js 100.00% 3
lib/javascript/JavascriptParser.js 100.00% 1 2
lib/stats/StatsFactory.js 100.00% 2 1
lib/config/defineConfig.js 100.00% 2
lib/css/syntax.js 100.00% 2
lib/define/DefinePlugin.js 100.00% 1 1
lib/hmr/HotModuleReplacementPlugin.js 100.00% 1 1
lib/hmr/JavascriptHotModuleReplacement.runtime.js 100.00% 2
lib/html/syntax.js 100.00% 2
lib/index.js 100.00% 2
lib/loaders/LoaderRunner.js 100.00% 2
lib/module/Parser.js 100.00% 2
lib/node/nodeConsole.js 100.00% 2
lib/rules/BasicEffectRulePlugin.js 93.75% 2
lib/rules/UseEffectRulePlugin.js 99.06% 2
lib/util/cleverMerge.js 100.00% 2
lib/util/implicitTypeLoaderFallback.js 100.00% 2
lib/config/WebpackOptionsApply.js 100.00% 1
lib/config/cli.js 100.00% 1
lib/dependencies/import/ImportParserPlugin.js 100.00% 1
lib/dll/DllReferencePlugin.js 100.00% 1
lib/errors/JSONParseError.js 100.00% 1
lib/graph/ModuleGraph.js 100.00% 1
lib/javascript/syntax.js 100.00% 1
lib/logging/Logger.js 100.00% 1
lib/output/ManifestPlugin.js 100.00% 1
lib/serialization/types.js 100.00% 1
lib/stats/DefaultStatsFactoryPlugin.js 100.00% 1
lib/stats/StatsPrinter.js 100.00% 1
lib/template/Template.js 100.00% 1
lib/util/magicComment.js 100.00% 1
lib/util/makeSerializable.js 100.00% 1
lib/util/terminalColors.js 100.00% 1

From Types Coverage run #3110.


Module loading

How many files a fresh Node.js process loads (require or import) to do each thing below; a change from the pull request's base is marked 🔴 when it grew and 🟢 when it shrank. Every file is startup time, so fewer is better. webpack files are this package's own (lib/, hot/); node_modules files are its dependencies'.

What the process does webpack files node_modules files
require("webpack") 2 0
import "webpack" 2 0
JavaScript syntax 11 0
CSS syntax 12 0
HTML syntax 11 0
XML syntax 11 0
JavaScript minifier 12 0
CSS minifier 14 0
HTML minifier 19 0
XML minifier 14 0
JSON minifier 1 0
development build 438 103
production build 445 133
watch with HMR, one rebuild 448 110

From Module loading run #354.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codspeed

codspeed Bot commented Nov 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Merging this PR will improve performance by 52.02%

2 warnings, 1 note

⚠️ 117 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

⚠️ 1 benchmark with a significant change ran on different hardware

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

Learn more about Macro Runners

See affected benchmarks

ℹ️ 40 benchmarks have 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
✅ 350 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory benchmark "devtool-source-map", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 274.1 KB 180.3 KB +52.02%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/typed-manifest-and-unsafe-cache (3a51d1b) with main (384dfaa)

Open in CodSpeed
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait alexander-akait mentioned this pull request Nov 5, 2026
feat: export the UnsafeCache type webpack/enhanced-resolve#703
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Nov 5, 2026
fix: make automatic public path, script external and Trusted Types detection more robust #23145
Merged
alexander-akait added a commit to webpack/enhanced-resolve that referenced this pull request Nov 5, 2026
@alexander-akait
feat: export the UnsafeCache type (#703)
976016d
**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](https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh)_

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

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

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
alexander-akait added 3 commits November 5, 2026 17:54
@alexander-akait
refactor: type html manifest object and resolve unsafeCache without any
8c83180
Type the object form of output.html.manifest (and the function's return) as
the JsonObject it is serialized as, and resolve.unsafeCache's object form as
enhanced-resolve's unsafe cache map of resolved requests. Only tsType changes;
validation is unchanged.
@alexander-akait
chore: shorten changeset
505b78f
@alexander-akait
chore: shorten changeset
3a51d1b
@alexander-akait
alexander-akait force-pushed the fix/typed-manifest-and-unsafe-cache branch from d5648ee to 3a51d1b Compare November 5, 2026 19:01
@alexander-akait
alexander-akait merged commit 1f27498 into main Nov 5, 2026
54 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
alexander-akait deleted the fix/typed-manifest-and-unsafe-cache branch November 5, 2026 20:00
@github-actions github-actions Bot mentioned this pull request Nov 5, 2026
chore(release): new release #22874
Merged
@alexander-akait alexander-akait mentioned this pull request Nov 5, 2026
fix: report no result from runWithDependencies instead of nested empty arrays #23150
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area: config Options, defaults, validation (lib/config, schemas/) area: types types.d.ts, JSDoc annotations, hand-maintained declarations

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@alexander-akait
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.