rollup / rollup
Showing 5 of 32 files from the diff.
Newly tracked file
src/utils/queue.ts created.
Other files ignored by Codecov

@@ -0,0 +1,36 @@
Loading
1 +
export class Queue {
2 +
	private queue = new Array<{
3 +
		reject: (reason?: any) => void;
4 +
		resolve: (value: any) => void;
5 +
		task: () => any;
6 +
	}>();
7 +
	private workerCount = 0;
8 +
9 +
	constructor(public maxParallel = 1) {}
10 +
11 +
	run<T>(task: () => T | Promise<T>): Promise<T> {
12 +
		return new Promise((resolve, reject) => {
13 +
			this.queue.push({ reject, resolve, task });
14 +
			this.work();
15 +
		});
16 +
	}
17 +
18 +
	private async work() {
19 +
		if (this.workerCount >= this.maxParallel) return;
20 +
		this.workerCount++;
21 +
22 +
		let entry;
23 +
		while ((entry = this.queue.shift())) {
24 +
			const { reject, resolve, task } = entry;
25 +
26 +
			try {
27 +
				const result = await task();
28 +
				resolve(result);
29 +
			} catch (err) {
30 +
				reject(err);
31 +
			}
32 +
		}
33 +
34 +
		this.workerCount--;
35 +
	}
36 +
}

@@ -50,6 +50,7 @@
Loading
50 50
		input: getInput(config),
51 51
		makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? true,
52 52
		manualChunks: getManualChunks(config, onwarn, strictDeprecations),
53 +
		maxParallelFileReads: getMaxParallelFileReads(config),
53 54
		moduleContext: getModuleContext(config, context),
54 55
		onwarn,
55 56
		perf: config.perf || false,
@@ -175,6 +176,17 @@
Loading
175 176
	return configManualChunks;
176 177
};
177 178
179 +
const getMaxParallelFileReads = (
180 +
	config: InputOptions
181 +
): NormalizedInputOptions['maxParallelFileReads'] => {
182 +
	const maxParallelFileReads = config.maxParallelFileReads as unknown;
183 +
	if (typeof maxParallelFileReads === 'number') {
184 +
		if (maxParallelFileReads <= 0) return Infinity;
185 +
		return maxParallelFileReads;
186 +
	}
187 +
	return 20;
188 +
};
189 +
178 190
const getModuleContext = (
179 191
	config: InputOptions,
180 192
	context: string

@@ -30,6 +30,7 @@
Loading
30 30
} from './utils/error';
31 31
import { readFile } from './utils/fs';
32 32
import { isAbsolute, isRelative, resolve } from './utils/path';
33 +
import { Queue } from './utils/queue';
33 34
import relativeId from './utils/relativeId';
34 35
import { resolveId } from './utils/resolveId';
35 36
import { timeEnd, timeStart } from './utils/timers';
@@ -53,6 +54,7 @@
Loading
53 54
	private readonly indexedEntryModules: { index: number; module: Module }[] = [];
54 55
	private latestLoadModulesPromise: Promise<unknown> = Promise.resolve();
55 56
	private nextEntryModuleIndex = 0;
57 +
	private readQueue = new Queue();
56 58
57 59
	constructor(
58 60
		private readonly graph: Graph,
@@ -63,6 +65,7 @@
Loading
63 65
		this.hasModuleSideEffects = options.treeshake
64 66
			? options.treeshake.moduleSideEffects
65 67
			: () => true;
68 +
		this.readQueue.maxParallel = options.maxParallelFileReads;
66 69
	}
67 70
68 71
	async addAdditionalModules(unresolvedModules: string[]): Promise<Module[]> {
@@ -217,7 +220,9 @@
Loading
217 220
		timeStart('load modules', 3);
218 221
		let source: string | SourceDescription;
219 222
		try {
220 -
			source = (await this.pluginDriver.hookFirst('load', [id])) ?? (await readFile(id));
223 +
			source =
224 +
				(await this.pluginDriver.hookFirst('load', [id])) ??
225 +
				(await this.readQueue.run(async () => readFile(id)));
221 226
		} catch (err) {
222 227
			timeEnd('load modules', 3);
223 228
			let msg = `Could not load ${id}`;

@@ -1,4 +1,4 @@
Loading
1 -
import * as fs from 'fs';
1 +
import fs from 'fs';
2 2
import { dirname } from './path';
3 3
4 4
export * from 'fs';

@@ -120,6 +120,7 @@
Loading
120 120
		input: getOption('input') || [],
121 121
		makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
122 122
		manualChunks: getOption('manualChunks'),
123 +
		maxParallelFileReads: getOption('maxParallelFileReads'),
123 124
		moduleContext: getOption('moduleContext'),
124 125
		onwarn: getOnWarn(config, defaultOnWarnHandler),
125 126
		perf: getOption('perf'),
Files Coverage
cli 94.74%
src 98.63%
browser/path.ts 76.92%
Project Totals (202 files) 98.34%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading