GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — refactor: type html manifest object and resolve unsafeCache without any by alexander-akait · Pull Request #23146 · webpack/webpack Conversation
|
🦋 Changeset detectedLatest commit: 3a51d1b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| 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
d5648The reviewed type refinements and test setup are consistent with the established repository contracts and are mergeable.
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.
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.
e598da63-bc15-4a7e-ae3f-1cfc0c027a82test/configCases/externals/script-external-named-element/index.jsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Reports for 3a51d1b, computed by this pull request's own code. Each section updates when its workflow finishes. Preview packageThis PR is packaged and the instant preview of its latest commit is available. Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@23146
yarn add -D webpack@https://pkg.pr.new/webpack@23146
pnpm add -D webpack@https://pkg.pr.new/webpack@23146 From Preview package run #12137. Generated code sizeComparing base (
Read Sample appsNo sample app changed size. 26 unchanged app(s)
No asset changed size. No runtime gained or lost a runtime module. Built From Generated code size run #6772. Types CoverageTyped lines: 99.68% (172708 of 173264)
Changed by this pull request
What the files this pull request changes still have
56 file(s) in
|
| 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.
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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Merging this PR will improve performance by 52.02%2 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
**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 -->
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.
d5648ee to
3a51d1b
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.