Skip to content

Commit 51fe93c

Browse files
committed
types(entrypoint): add typeing support for Entrypoint
1 parent aeaa877 commit 51fe93c

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

lib/Entrypoint.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,54 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
"use strict";
5+
/** @typedef {import("./Chunk")} Chunk */
66

77
const ChunkGroup = require("./ChunkGroup");
8-
8+
/**
9+
*
10+
* @description Entrypoint serves as an encapsulation primitive for chunks that are
11+
* apart of a single ChunkGroup. They represent all bundles that need to be loaded for a
12+
* single instance of a page. Multipage App Architectures will typically yeild multiple Entrypoint Objects
13+
* inside of Compilation, where as a Single Page App, may only contain one with many lazy loaded chunks.
14+
* @class Entrypoint
15+
* @extends {ChunkGroup}
16+
*/
917
class Entrypoint extends ChunkGroup {
18+
/**
19+
* Creates an instance of Entrypoint.
20+
* @param {string} name the name of the entrypoint
21+
* @memberof Entrypoint
22+
*/
1023
constructor(name) {
1124
super(name);
1225
this.runtimeChunk = undefined;
1326
}
1427

28+
/**
29+
* @description isInitial will always return true for Entrypoint ChunkGroup.
30+
* @return {true} returns true as all entrypoints are initial ChunkGroups
31+
* @memberof Entrypoint
32+
*/
1533
isInitial() {
1634
return true;
1735
}
1836

37+
/**
38+
*
39+
* @description Sets the runtimeChunk for an entrypoint.
40+
* @param {Chunk} chunk the chunk being set as the runtime chunk.
41+
* @return {void}
42+
* @memberof Entrypoint
43+
*/
1944
setRuntimeChunk(chunk) {
2045
this.runtimeChunk = chunk;
2146
}
2247

48+
/**
49+
* @description Fetches the chunk reference containing the webpack bootstrap code
50+
* @return {Chunk|false} returns the runtime chunk or false
51+
* @memberof Entrypoint
52+
*/
2353
getRuntimeChunk() {
2454
return this.runtimeChunk || this.chunks[0];
2555
}

0 commit comments

Comments
 (0)