Sha256: 1fe53d2dab56c8645b7e006bda0d9215d6566ddcbfa52ade3a4e7deb1b7db494

Contents?: true

Size: 1.79 KB

Versions: 26

Compression:

Stored size: 1.79 KB

Contents

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";

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

/** @typedef {import("./Chunk")} Chunk */

/**
 * Entrypoint serves as an encapsulation primitive for chunks that are
 * a part of a single ChunkGroup. They represent all bundles that need to be loaded for a
 * single instance of a page. Multi-page application architectures will typically yield multiple Entrypoint objects
 * inside of the compilation, whereas a Single Page App may only contain one with many lazy-loaded chunks.
 */
class Entrypoint extends ChunkGroup {
	/**
	 * Creates an instance of Entrypoint.
	 * @param {string} name the name of the entrypoint
	 */
	constructor(name) {
		super(name);
		/** @type {Chunk=} */
		this.runtimeChunk = undefined;
	}

	/**
	 * isInitial will always return true for Entrypoint ChunkGroup.
	 * @returns {true} returns true as all entrypoints are initial ChunkGroups
	 */
	isInitial() {
		return true;
	}

	/**
	 * Sets the runtimeChunk for an entrypoint.
	 * @param {Chunk} chunk the chunk being set as the runtime chunk.
	 * @returns {void}
	 */
	setRuntimeChunk(chunk) {
		this.runtimeChunk = chunk;
	}

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

	/**
	 * @param {Chunk} oldChunk chunk to be replaced
	 * @param {Chunk} newChunk New chunk that will be replaced with
	 * @returns {boolean} returns true if the replacement was successful
	 */
	replaceChunk(oldChunk, newChunk) {
		if (this.runtimeChunk === oldChunk) this.runtimeChunk = newChunk;
		return super.replaceChunk(oldChunk, newChunk);
	}
}

module.exports = Entrypoint;

Version data entries

26 entries across 25 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.18.0 test/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.18.2 test/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.16.1 test/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.15.2 test/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.18.4 test/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.18.1 test/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.14.0 test/dummy/node_modules/webpack/lib/Entrypoint.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/webpack/lib/Entrypoint.js
tang-0.2.1 spec/tang_app/node_modules/webpack/lib/Entrypoint.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/webpack/lib/Entrypoint.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/webpack/lib/Entrypoint.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/webpack/lib/Entrypoint.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/webpack/lib/Entrypoint.js
tang-0.2.0 spec/tang_app/node_modules/webpack/lib/Entrypoint.js
tang-0.1.0 spec/tang_app/node_modules/webpack/lib/Entrypoint.js
tang-0.0.9 spec/tang_app/node_modules/webpack/lib/Entrypoint.js
enju_library-0.3.8 spec/dummy/node_modules/webpack/lib/Entrypoint.js
jester-data-8.0.0 node_modules/webpack/lib/Entrypoint.js