function lessPlugin({ sourcemap, mergedAssets, alias }) {
	/** @type {Map<string, Set<string>>} */
	const fileToBundles = new Map();

	return {
		name: 'less',
		async transform(code, id) {
			if (!/\.less$/.test(id)) return;

			// Use absolute file paths, otherwise nested alias resolution
			// fails in less
			const file = resolveAlias(alias, id);
			const result = await renderLess(code, { resolve: this.resolve.bind(this), sourcemap, id: file });

			for (let file of result.imports) {
				mergedAssets.add(file);

				if (!fileToBundles.has(file)) {
					fileToBundles.set(file, new Set());
				}
				this.addWatchFile(file);
				// @ts-ignore
				fileToBundles.get(file).add(id);
			}

			return {
				code: result.css,
				map: result.map || null
			};
		},
		watchChange(id) {
			const bundle = fileToBundles.get(id);
			if (bundle) return Array.from(bundle);
		}
	};
}
@param {object} options
@param {boolean} options.sourcemap
@param {Set<string>} options.mergedAssets
@param {Record<string, string>} options.alias
@returns {import('rollup').Plugin}