| | |
| | | /** @typedef {() => Server} CreateServerFunction */ |
| | | |
| | | /** |
| | | * @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend |
| | | * Returns backend. |
| | | * @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]> }} options additional options for the backend |
| | | * @returns {BackendHandler} backend |
| | | */ |
| | | module.exports = (options) => (compiler, callback) => { |
| | | const logger = compiler.getInfrastructureLogger("LazyCompilationBackend"); |
| | | /** @type {Map<string, number>} */ |
| | | const activeModules = new Map(); |
| | | const prefix = "/lazy-compilation-using-"; |
| | | |
| | |
| | | server.on( |
| | | "listening", |
| | | /** |
| | | * Handles the callback logic for this hook. |
| | | * @param {Error} err error |
| | | * @returns {void} |
| | | */ |
| | |
| | | const key = `${encodeURIComponent( |
| | | originalModule.identifier().replace(/\\/g, "/").replace(/@/g, "_") |
| | | ).replace(/%(2F|3A|24|26|2B|2C|3B|3D)/g, decodeURIComponent)}`; |
| | | const active = activeModules.get(key) > 0; |
| | | const active = /** @type {number} */ (activeModules.get(key)) > 0; |
| | | return { |
| | | client: `${options.client}?${encodeURIComponent(urlBase + prefix)}`, |
| | | data: key, |