Skip to content

Commit 65eca2e

Browse files
committed
expose webpack from Compiler
fix some jsdoc descriptions
1 parent 0f7a17f commit 65eca2e

8 files changed

Lines changed: 34 additions & 14 deletions

File tree

lib/Compiler.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
AsyncSeriesHook
1515
} = require("tapable");
1616
const { SizeOnlySource } = require("webpack-sources");
17+
const webpack = require("./");
1718
const Cache = require("./Cache");
1819
const CacheFacade = require("./CacheFacade");
1920
const Compilation = require("./Compilation");
@@ -170,6 +171,8 @@ class Compiler {
170171
entryOption: new SyncBailHook(["context", "entry"])
171172
});
172173

174+
this.webpack = webpack;
175+
173176
/** @type {string=} */
174177
this.name = undefined;
175178
/** @type {Compilation=} */

lib/Dependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class Dependency {
104104
}
105105

106106
/**
107-
* @deprecated
108107
* Returns the referenced module and export
108+
* @deprecated
109109
* @param {ModuleGraph} moduleGraph module graph
110110
* @returns {never} throws error
111111
*/

lib/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ module.exports = mergeExports(fn, {
480480
},
481481
get serialization() {
482482
return require("./util/serialization");
483+
},
484+
get cleverMerge() {
485+
return require("./util/cleverMerge").cachedCleverMerge;
483486
}
484487
},
485488

lib/stats/StatsPrinter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class StatsPrinter {
4646
}
4747

4848
/**
49+
* get all level hooks
4950
* @private
5051
* @template {Hook} T
51-
* get all level hooks
5252
* @param {HookMap<T>} hookMap HookMap
5353
* @param {string} type type
5454
* @returns {T[]} hooks
@@ -79,10 +79,10 @@ class StatsPrinter {
7979
}
8080

8181
/**
82+
* Run `fn` for each level
8283
* @private
8384
* @template T
8485
* @template R
85-
* Run `fn` for each level
8686
* @param {HookMap<SyncBailHook<T, R>>} hookMap HookMap
8787
* @param {string} type type
8888
* @param {(hook: SyncBailHook<T, R>) => R} fn function

lib/util/Hash.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
class Hash {
99
/* istanbul ignore next */
1010
/**
11-
* @abstract
1211
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
12+
* @abstract
1313
* @param {string|Buffer} data data
1414
* @param {string=} inputEncoding data encoding
1515
* @returns {this} updated hash
@@ -21,8 +21,8 @@ class Hash {
2121

2222
/* istanbul ignore next */
2323
/**
24-
* @abstract
2524
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
25+
* @abstract
2626
* @param {string=} encoding encoding of the return value
2727
* @returns {string|Buffer} digest
2828
*/

lib/util/LazyBucketSortedSet.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
const SortableSet = require("./SortableSet");
99

1010
/**
11+
* Multi layer bucket sorted set:
12+
* Supports adding non-existing items (DO NOT ADD ITEM TWICE),
13+
* Supports removing exiting items (DO NOT REMOVE ITEM NOT IN SET),
14+
* Supports popping the first items according to defined order,
15+
* Supports iterating all items without order,
16+
* Supports updating an item in an efficient way,
17+
* Supports size property, which is the number of items,
18+
* Items are lazy partially sorted when needed
1119
* @template T
1220
* @template K
13-
* Multi layer bucket sorted set
14-
* Supports adding non-existing items (DO NOT ADD ITEM TWICE)
15-
* Supports removing exiting items (DO NOT REMOVE ITEM NOT IN SET)
16-
* Supports popping the first items according to defined order
17-
* Supports iterating all items without order
18-
* Supports updating an item in an efficient way
19-
* Supports size property, which is the number of items
20-
* Items are lazy partially sorted when needed
2121
*/
2222
class LazyBucketSortedSet {
2323
/**

lib/util/cleverMerge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const setPropertyCache = new WeakMap();
1212
const DELETE = Symbol("DELETE");
1313

1414
/**
15+
* Merges two given objects and caches the result to avoid computation if same objects passed as arguments again.
1516
* @template T
1617
* @template O
17-
* Merges two given objects and caches the result to avoid computation if same objects passed as arguments again.
1818
* @example
1919
* // performs cleverMerge(first, second), stores the result in WeakMap and returns result
2020
* cachedCleverMerge({a: 1}, {a: 2})

types.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,7 @@ declare class Compiler {
16181618
afterResolvers: SyncHook<[Compiler], void>;
16191619
entryOption: SyncBailHook<[string, EntryNormalized], boolean>;
16201620
}>;
1621+
webpack: typeof exports;
16211622
name: string;
16221623
parentCompilation: Compilation;
16231624
root: Compiler;
@@ -2222,6 +2223,10 @@ declare class Dependency {
22222223
readonly type: string;
22232224
readonly category: string;
22242225
getResourceIdentifier(): string;
2226+
2227+
/**
2228+
* Returns the referenced module and export
2229+
*/
22252230
getReference(moduleGraph: ModuleGraph): never;
22262231

22272232
/**
@@ -3566,7 +3571,15 @@ declare interface HandleModuleCreationOptions {
35663571
}
35673572
declare class Hash {
35683573
constructor();
3574+
3575+
/**
3576+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
3577+
*/
35693578
update(data: string | Buffer, inputEncoding?: string): Hash;
3579+
3580+
/**
3581+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
3582+
*/
35703583
digest(encoding?: string): string | Buffer;
35713584
}
35723585
type HashFunction = string | typeof Hash;
@@ -10254,6 +10267,7 @@ declare namespace exports {
1025410267
export let createFileSerializer: (fs?: any) => Serializer;
1025510268
export { MEASURE_START_OPERATION, MEASURE_END_OPERATION };
1025610269
}
10270+
export const cleverMerge: <T, O>(first: T, second: O) => T & O;
1025710271
}
1025810272
export namespace sources {
1025910273
export {

0 commit comments

Comments
 (0)