Skip to content

Commit 6b0dd00

Browse files
authored
Merge pull request webpack#7119 from webpack/feature/types-entrypoint
types(entrypoint): add typeing support for Entrypoint
2 parents 7543c45 + f596f60 commit 6b0dd00

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lib/Entrypoint.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,46 @@
66

77
const ChunkGroup = require("./ChunkGroup");
88

9+
/** @typedef {import("./Chunk.js")} Chunk */
10+
11+
/**
12+
* Entrypoint serves as an encapsulation primitive for chunks that are
13+
* a part of a single ChunkGroup. They represent all bundles that need to be loaded for a
14+
* single instance of a page. Multi-page application architectures will typically yield multiple Entrypoint objects
15+
* inside of the compilation, whereas a Single Page App may only contain one with many lazy-loaded chunks.
16+
*/
917
class Entrypoint extends ChunkGroup {
18+
/**
19+
* Creates an instance of Entrypoint.
20+
* @param {string} name the name of the entrypoint
21+
*/
1022
constructor(name) {
1123
super(name);
24+
/** @type {Chunk=} */
1225
this.runtimeChunk = undefined;
1326
}
1427

28+
/**
29+
* isInitial will always return true for Entrypoint ChunkGroup.
30+
* @return {true} returns true as all entrypoints are initial ChunkGroups
31+
*/
1532
isInitial() {
1633
return true;
1734
}
1835

36+
/**
37+
* Sets the runtimeChunk for an entrypoint.
38+
* @param {Chunk} chunk the chunk being set as the runtime chunk.
39+
* @return {void}
40+
*/
1941
setRuntimeChunk(chunk) {
2042
this.runtimeChunk = chunk;
2143
}
2244

45+
/**
46+
* Fetches the chunk reference containing the webpack bootstrap code
47+
* @return {Chunk} returns the runtime chunk or first chunk in `this.chunks`
48+
*/
2349
getRuntimeChunk() {
2450
return this.runtimeChunk || this.chunks[0];
2551
}

0 commit comments

Comments
 (0)