Files
rspade_system/node_modules/webpack/lib/optimize/RuntimeChunkPlugin.js
root b5eb27a827 Update npm packages (73 packages including @jqhtml 2.3.36)
Update npm registry domain from privatenpm.hanson.xyz to npm.internal.hanson.xyz

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-20 11:31:28 +00:00

53 lines
1.3 KiB
JavaScript
Executable File

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
/** @typedef {import("../Compilation").EntryData} EntryData */
/** @typedef {import("../Compiler")} Compiler */
const PLUGIN_NAME = "RuntimeChunkPlugin";
/** @typedef {(entrypoint: { name: string }) => string} RuntimeChunkFunction */
class RuntimeChunkPlugin {
/**
* @param {{ name?: RuntimeChunkFunction }=} options options
*/
constructor(options = {}) {
/** @type {{ name: string | RuntimeChunkFunction }} */
this.options = {
name: (entrypoint) => `runtime~${entrypoint.name}`,
...options
};
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.addEntry.tap(PLUGIN_NAME, (_, { name: entryName }) => {
if (entryName === undefined) return;
const data =
/** @type {EntryData} */
(compilation.entries.get(entryName));
if (data.options.runtime === undefined && !data.options.dependOn) {
// Determine runtime chunk name
let name = this.options.name;
if (typeof name === "function") {
name = name({ name: entryName });
}
data.options.runtime = name;
}
});
});
}
}
module.exports = RuntimeChunkPlugin;