Skip to content

Commit 1c067f2

Browse files
feat(util): export RequestShortener
The root shim told plugin authors to migrate to compiler.webpack.RequestShortener, which no export answered — the class is in lib/util/, so util is the scope, and the shim now names it.
1 parent aa65e2e commit 1c067f2

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎.changeset/007-export-module-type-and-target-plugins.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"webpack": minor
33
---
44

5-
Export the asset, json, bun, deno and TypeScript plugins, move eleven loose exports under the scope their directory implies, and deprecate the old flat names.
5+
Export the asset, json, bun, deno and TypeScript plugins and `util.RequestShortener`, move eleven loose exports under the scope their directory implies, and deprecate the old flat names.

‎lib/RequestShortener.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"use strict";
77

88
// TODO in the next major release: remove
9-
// Some old plugins use `require("webpack/lib/RequestShortener")`, in the next major release developer should migrate to `compiler.webpack.RequestShortener`
9+
// Some old plugins use `require("webpack/lib/RequestShortener")`, in the next major release developer should migrate to `compiler.webpack.util.RequestShortener`
1010
module.exports = require("./util/RequestShortener");

‎lib/index.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,9 @@ module.exports = mergeExports(fn, {
873873
get LazySet() {
874874
return require("./util/LazySet");
875875
},
876+
get RequestShortener() {
877+
return require("./util/RequestShortener");
878+
},
876879
get compileBooleanMatcher() {
877880
return require("./util/compileBooleanMatcher");
878881
},

‎types.d.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25420,7 +25420,12 @@ declare interface RequestRecord {
2542025420
* Shortens absolute or verbose request strings so diagnostics and stats output
2542125421
* can be rendered relative to a chosen base directory.
2542225422
*/
25423-
declare abstract class RequestShortener {
25423+
declare class RequestShortener {
25424+
/**
25425+
* Binds a context-aware shortening function to the provided directory and
25426+
* optional cache owner.
25427+
*/
25428+
constructor(dir: string, associatedObjectForCache?: object);
2542425429
contextify: (value: string) => string;
2542525430

2542625431
/**
@@ -33731,7 +33736,7 @@ declare namespace exports {
3373133736
export let languageOfMediaType: (mediaType: string) => undefined | string;
3373233737
export let parseDataURI: (uri: string) => null | ParsedDataURI;
3373333738
}
33734-
export { LazySet };
33739+
export { LazySet, RequestShortener };
3373533740
}
3373633741
export namespace sources {
3373733742
export {

0 commit comments

Comments
 (0)