2016-07-13 17:03:14 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2018-04-25 05:27:25 +08:00
|
|
|
/** @typedef {import("./Chunk")} Chunk */
|
2016-07-13 17:03:14 +08:00
|
|
|
|
2018-01-20 00:06:59 +08:00
|
|
|
const ChunkGroup = require("./ChunkGroup");
|
2018-04-25 05:27:25 +08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @description Entrypoint serves as an encapsulation primitive for chunks that are
|
|
|
|
* apart of a single ChunkGroup. They represent all bundles that need to be loaded for a
|
|
|
|
* single instance of a page. Multipage App Architectures will typically yeild multiple Entrypoint Objects
|
|
|
|
* inside of Compilation, where as a Single Page App, may only contain one with many lazy loaded chunks.
|
|
|
|
* @class Entrypoint
|
|
|
|
* @extends {ChunkGroup}
|
|
|
|
*/
|
2018-01-20 00:06:59 +08:00
|
|
|
class Entrypoint extends ChunkGroup {
|
2018-04-25 05:27:25 +08:00
|
|
|
/**
|
|
|
|
* Creates an instance of Entrypoint.
|
|
|
|
* @param {string} name the name of the entrypoint
|
|
|
|
* @memberof Entrypoint
|
|
|
|
*/
|
2016-12-29 14:58:26 +08:00
|
|
|
constructor(name) {
|
2018-01-20 00:06:59 +08:00
|
|
|
super(name);
|
2018-01-11 00:08:56 +08:00
|
|
|
this.runtimeChunk = undefined;
|
2016-12-29 14:58:26 +08:00
|
|
|
}
|
|
|
|
|
2018-04-25 05:27:25 +08:00
|
|
|
/**
|
|
|
|
* @description isInitial will always return true for Entrypoint ChunkGroup.
|
|
|
|
* @return {true} returns true as all entrypoints are initial ChunkGroups
|
|
|
|
* @memberof Entrypoint
|
|
|
|
*/
|
2018-01-20 00:06:59 +08:00
|
|
|
isInitial() {
|
|
|
|
return true;
|
2018-01-09 16:40:30 +08:00
|
|
|
}
|
|
|
|
|
2018-04-25 05:27:25 +08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @description Sets the runtimeChunk for an entrypoint.
|
|
|
|
* @param {Chunk} chunk the chunk being set as the runtime chunk.
|
|
|
|
* @return {void}
|
|
|
|
* @memberof Entrypoint
|
|
|
|
*/
|
2018-01-11 00:08:56 +08:00
|
|
|
setRuntimeChunk(chunk) {
|
|
|
|
this.runtimeChunk = chunk;
|
|
|
|
}
|
|
|
|
|
2018-04-25 05:27:25 +08:00
|
|
|
/**
|
|
|
|
* @description Fetches the chunk reference containing the webpack bootstrap code
|
|
|
|
* @return {Chunk|false} returns the runtime chunk or false
|
|
|
|
* @memberof Entrypoint
|
|
|
|
*/
|
2017-04-23 00:59:15 +08:00
|
|
|
getRuntimeChunk() {
|
2018-01-11 00:08:56 +08:00
|
|
|
return this.runtimeChunk || this.chunks[0];
|
2017-04-23 00:59:15 +08:00
|
|
|
}
|
2016-11-29 08:38:17 +08:00
|
|
|
}
|
2016-12-29 14:58:26 +08:00
|
|
|
|
|
|
|
module.exports = Entrypoint;
|