diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md
index cd4d760ddaf..e09c71af6f8 100755
--- a/docs/999-big-list-of-options.md
+++ b/docs/999-big-list-of-options.md
@@ -333,11 +333,11 @@ For this case, choosing `"ifRelativeSource"` will check if the original import w
Note that when a relative path is directly marked as "external" using the [`external`](guide/en/#external) option, then it will be the same relative path in the output. When it is resolved first via a plugin or Rollup core and then marked as external, the above logic will apply.
-#### maxParallelFileReads
+#### maxParallelFileOps
-Type: `number`
CLI: `--maxParallelFileReads `
Default: 20
+Type: `number`
CLI: `--maxParallelFileOps `
Default: 20
-Limits the number of files rollup will open in parallel when reading modules. Without a limit or with a high enough value, builds can fail with an "EMFILE: too many open files". This dependes on how many open file handles the os allows.
+Limits the number of files rollup will open in parallel when reading modules or writing chunks. Without a limit or with a high enough value, builds can fail with an "EMFILE: too many open files". This depends on how many open file handles the operating system allows.
#### onwarn
@@ -1869,6 +1869,12 @@ _Use the [`output.inlineDynamicImports`](guide/en/#outputinlinedynamicimports) o
_Use the [`output.manualChunks`](guide/en/#outputmanualchunks) output option instead, which has the same signature._
+#### maxParallelFileReads
+
+_Use the [`maxParallelFileOps`](guide/en/#maxParallelFileOps) option instead._
Type: `number`
CLI: `--maxParallelFileReads `
Default: 20
+
+Limits the number of files rollup will open in parallel when reading modules. Without a limit or with a high enough value, builds can fail with an "EMFILE: too many open files". This depends on how many open file handles the os allows.
+
#### output.dynamicImportFunction
_Use the [`renderDynamicImport`](guide/en/#renderdynamicimport) plugin hook instead._
Type: `string`
CLI: `--dynamicImportFunction `
Default: `import`
diff --git a/src/Graph.ts b/src/Graph.ts
index 2bc50b79764..e3fc9d1b364 100644
--- a/src/Graph.ts
+++ b/src/Graph.ts
@@ -14,6 +14,7 @@ import type {
WatchChangeHook
} from './rollup/types';
import { PluginDriver } from './utils/PluginDriver';
+import Queue from './utils/Queue';
import { BuildPhase } from './utils/buildPhase';
import { errImplicitDependantIsNotIncluded, error } from './utils/error';
import { analyseModuleExecution } from './utils/executionOrder';
@@ -48,6 +49,7 @@ export default class Graph {
readonly cachedModules = new Map();
readonly deoptimizationTracker = new PathTracker();
entryModules: Module[] = [];
+ readonly fileOperationQueue: Queue;
readonly moduleLoader: ModuleLoader;
readonly modulesById = new Map();
needsTreeshakingPass = false;
@@ -87,6 +89,7 @@ export default class Graph {
this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
this.acornParser = acorn.Parser.extend(...(options.acornInjectPlugins as any));
this.moduleLoader = new ModuleLoader(this, this.modulesById, this.options, this.pluginDriver);
+ this.fileOperationQueue = new Queue(options.maxParallelFileOps);
}
async build(): Promise {
diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts
index 729afd56185..e630b868c5a 100644
--- a/src/ModuleLoader.ts
+++ b/src/ModuleLoader.ts
@@ -16,7 +16,6 @@ import type {
ResolveIdResult
} from './rollup/types';
import type { PluginDriver } from './utils/PluginDriver';
-import Queue from './utils/Queue';
import { EMPTY_OBJECT } from './utils/blank';
import {
errBadLoader,
@@ -72,7 +71,6 @@ export class ModuleLoader {
private readonly modulesWithLoadedDependencies = new Set();
private nextChunkNamePriority = 0;
private nextEntryModuleIndex = 0;
- private readonly readQueue: Queue;
constructor(
private readonly graph: Graph,
@@ -83,8 +81,6 @@ export class ModuleLoader {
this.hasModuleSideEffects = options.treeshake
? options.treeshake.moduleSideEffects
: () => true;
-
- this.readQueue = new Queue(options.maxParallelFileReads);
}
async addAdditionalModules(unresolvedModules: readonly string[]): Promise {
@@ -252,7 +248,7 @@ export class ModuleLoader {
timeStart('load modules', 3);
let source: LoadResult;
try {
- source = await this.readQueue.run(
+ source = await this.graph.fileOperationQueue.run(
async () =>
(await this.pluginDriver.hookFirst('load', [id])) ?? (await fs.readFile(id, 'utf8'))
);
diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts
index ed52b7dacc9..f3809b8bf8d 100644
--- a/src/rollup/rollup.ts
+++ b/src/rollup/rollup.ts
@@ -174,7 +174,9 @@ function handleGenerateWrite(
});
}
await Promise.all(
- Object.values(generated).map(chunk => writeOutputFile(chunk, outputOptions))
+ Object.values(generated).map(chunk =>
+ graph.fileOperationQueue.run(() => writeOutputFile(chunk, outputOptions))
+ )
);
await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
}
diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts
index 193e780e6e6..3528f98209b 100644
--- a/src/rollup/types.d.ts
+++ b/src/rollup/types.d.ts
@@ -553,6 +553,8 @@ export interface InputOptions {
makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource';
/** @deprecated Use the "manualChunks" output option instead. */
manualChunks?: ManualChunksOption;
+ maxParallelFileOps?: number;
+ /** @deprecated Use the "maxParallelFileOps" option instead. */
maxParallelFileReads?: number;
moduleContext?: ((id: string) => string | null | void) | { [id: string]: string };
onwarn?: WarningHandlerWithDefault;
@@ -581,6 +583,8 @@ export interface NormalizedInputOptions {
makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource';
/** @deprecated Use the "manualChunks" output option instead. */
manualChunks: ManualChunksOption | undefined;
+ maxParallelFileOps: number;
+ /** @deprecated Use the "maxParallelFileOps" option instead. */
maxParallelFileReads: number;
moduleContext: (id: string) => string;
onwarn: WarningHandler;
diff --git a/src/utils/Queue.ts b/src/utils/Queue.ts
index d5afd5072e1..9638387fe75 100644
--- a/src/utils/Queue.ts
+++ b/src/utils/Queue.ts
@@ -1,20 +1,20 @@
interface Task {
- (): T | Promise;
+ (): Promise;
}
-interface QueueItem {
+interface QueueItem {
reject: (reason?: unknown) => void;
- resolve: (value: T) => void;
- task: Task;
+ resolve: (value: any) => void;
+ task: Task;
}
-export default class Queue {
- private readonly queue: QueueItem[] = [];
+export default class Queue {
+ private readonly queue: QueueItem[] = [];
private workerCount = 0;
constructor(private maxParallel: number) {}
- run(task: Task): Promise {
+ run(task: Task): Promise {
return new Promise((resolve, reject) => {
this.queue.push({ reject, resolve, task });
this.work();
@@ -25,7 +25,7 @@ export default class Queue {
if (this.workerCount >= this.maxParallel) return;
this.workerCount++;
- let entry: QueueItem | undefined;
+ let entry: QueueItem | undefined;
while ((entry = this.queue.shift())) {
const { reject, resolve, task } = entry;
diff --git a/src/utils/options/mergeOptions.ts b/src/utils/options/mergeOptions.ts
index 84674e98652..df7536d3cbf 100644
--- a/src/utils/options/mergeOptions.ts
+++ b/src/utils/options/mergeOptions.ts
@@ -120,6 +120,7 @@ function mergeInputOptions(
input: getOption('input') || [],
makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
manualChunks: getOption('manualChunks'),
+ maxParallelFileOps: getOption('maxParallelFileOps'),
maxParallelFileReads: getOption('maxParallelFileReads'),
moduleContext: getOption('moduleContext'),
onwarn: getOnWarn(config, defaultOnWarnHandler),
diff --git a/src/utils/options/normalizeInputOptions.ts b/src/utils/options/normalizeInputOptions.ts
index e3395651de9..11c88251878 100644
--- a/src/utils/options/normalizeInputOptions.ts
+++ b/src/utils/options/normalizeInputOptions.ts
@@ -38,6 +38,7 @@ export function normalizeInputOptions(config: InputOptions): {
const context = config.context ?? 'undefined';
const onwarn = getOnwarn(config);
const strictDeprecations = config.strictDeprecations || false;
+ const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
const options: NormalizedInputOptions & InputOptions = {
acorn: getAcorn(config) as unknown as NormalizedInputOptions['acorn'],
acornInjectPlugins: getAcornInjectPlugins(config),
@@ -49,7 +50,8 @@ export function normalizeInputOptions(config: InputOptions): {
input: getInput(config),
makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? true,
manualChunks: getManualChunks(config, onwarn, strictDeprecations),
- maxParallelFileReads: getMaxParallelFileReads(config),
+ maxParallelFileOps,
+ maxParallelFileReads: maxParallelFileOps,
moduleContext: getModuleContext(config, context),
onwarn,
perf: config.perf || false,
@@ -175,13 +177,24 @@ const getManualChunks = (
return configManualChunks;
};
-const getMaxParallelFileReads = (
- config: InputOptions
-): NormalizedInputOptions['maxParallelFileReads'] => {
+const getmaxParallelFileOps = (
+ config: InputOptions,
+ warn: WarningHandler,
+ strictDeprecations: boolean
+): NormalizedInputOptions['maxParallelFileOps'] => {
const maxParallelFileReads = config.maxParallelFileReads as unknown;
if (typeof maxParallelFileReads === 'number') {
- if (maxParallelFileReads <= 0) return Infinity;
- return maxParallelFileReads;
+ warnDeprecationWithOptions(
+ 'The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.',
+ false,
+ warn,
+ strictDeprecations
+ );
+ }
+ const maxParallelFileOps = (config.maxParallelFileOps as unknown) ?? maxParallelFileReads;
+ if (typeof maxParallelFileOps === 'number') {
+ if (maxParallelFileOps <= 0) return Infinity;
+ return maxParallelFileOps;
}
return 20;
};
diff --git a/test/chunking-form/index.js b/test/chunking-form/index.js
index 625025ec37e..ab9c6e1589a 100644
--- a/test/chunking-form/index.js
+++ b/test/chunking-form/index.js
@@ -11,6 +11,13 @@ runTestSuiteWithSamples('chunking form', resolve(__dirname, 'samples'), (dir, co
() => {
let bundle;
+ if (config.before) {
+ before(config.before);
+ }
+ if (config.after) {
+ after(config.after);
+ }
+
for (const format of FORMATS) {
it('generates ' + format, async () => {
chdir(dir);
diff --git a/test/function/samples/max-parallel-file-reads-default/1.js b/test/chunking-form/samples/max-parallel-file-operations/1.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-default/1.js
rename to test/chunking-form/samples/max-parallel-file-operations/1.js
diff --git a/test/function/samples/max-parallel-file-reads-default/2.js b/test/chunking-form/samples/max-parallel-file-operations/2.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-default/2.js
rename to test/chunking-form/samples/max-parallel-file-operations/2.js
diff --git a/test/function/samples/max-parallel-file-reads-default/3.js b/test/chunking-form/samples/max-parallel-file-operations/3.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-default/3.js
rename to test/chunking-form/samples/max-parallel-file-operations/3.js
diff --git a/test/function/samples/max-parallel-file-reads-default/4.js b/test/chunking-form/samples/max-parallel-file-operations/4.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-default/4.js
rename to test/chunking-form/samples/max-parallel-file-operations/4.js
diff --git a/test/function/samples/max-parallel-file-reads-default/5.js b/test/chunking-form/samples/max-parallel-file-operations/5.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-default/5.js
rename to test/chunking-form/samples/max-parallel-file-operations/5.js
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_config.js b/test/chunking-form/samples/max-parallel-file-operations/_config.js
new file mode 100644
index 00000000000..01a4274f82d
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_config.js
@@ -0,0 +1,28 @@
+const assert = require('assert');
+const { promises: fs } = require('fs');
+const { wait } = require('../../../utils');
+
+const fsWriteFile = fs.writeFile;
+let currentWrites = 0;
+let maxWrites = 0;
+
+module.exports = {
+ description: 'maxParallelFileOps limits write operations',
+ options: {
+ maxParallelFileOps: 3,
+ output: { preserveModules: true }
+ },
+ before() {
+ fs.writeFile = async (path, content) => {
+ currentWrites++;
+ maxWrites = Math.max(maxWrites, currentWrites);
+ await fsWriteFile(path, content);
+ await wait(50);
+ currentWrites--;
+ };
+ },
+ after() {
+ fs.writeFile = fsWriteFile;
+ assert.strictEqual(maxWrites, 3, 'Wrong number of parallel file writes: ' + maxWrites);
+ }
+};
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/1.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/1.js
new file mode 100644
index 00000000000..e22765045cc
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/1.js
@@ -0,0 +1,9 @@
+define(['exports'], (function (exports) { 'use strict';
+
+ const x1 = 1;
+
+ exports.x1 = x1;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/2.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/2.js
new file mode 100644
index 00000000000..0018c038f7b
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/2.js
@@ -0,0 +1,9 @@
+define(['exports'], (function (exports) { 'use strict';
+
+ const x2 = 2;
+
+ exports.x2 = x2;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/3.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/3.js
new file mode 100644
index 00000000000..6f9fd129364
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/3.js
@@ -0,0 +1,9 @@
+define(['exports'], (function (exports) { 'use strict';
+
+ const x3 = 3;
+
+ exports.x3 = x3;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/4.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/4.js
new file mode 100644
index 00000000000..53152abbb6b
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/4.js
@@ -0,0 +1,9 @@
+define(['exports'], (function (exports) { 'use strict';
+
+ const x4 = 4;
+
+ exports.x4 = x4;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/5.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/5.js
new file mode 100644
index 00000000000..23c4447f099
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/5.js
@@ -0,0 +1,9 @@
+define(['exports'], (function (exports) { 'use strict';
+
+ const x5 = 5;
+
+ exports.x5 = x5;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/main.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/main.js
new file mode 100644
index 00000000000..3c7ff656f2a
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/main.js
@@ -0,0 +1,13 @@
+define(['exports', './1', './2', './3', './4', './5'], (function (exports, _1, _2, _3, _4, _5) { 'use strict';
+
+
+
+ exports.x1 = _1.x1;
+ exports.x2 = _2.x2;
+ exports.x3 = _3.x3;
+ exports.x4 = _4.x4;
+ exports.x5 = _5.x5;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/1.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/1.js
new file mode 100644
index 00000000000..6f07f500e85
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/1.js
@@ -0,0 +1,7 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+const x1 = 1;
+
+exports.x1 = x1;
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/2.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/2.js
new file mode 100644
index 00000000000..b497b79cafa
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/2.js
@@ -0,0 +1,7 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+const x2 = 2;
+
+exports.x2 = x2;
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/3.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/3.js
new file mode 100644
index 00000000000..4e662215ed1
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/3.js
@@ -0,0 +1,7 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+const x3 = 3;
+
+exports.x3 = x3;
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/4.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/4.js
new file mode 100644
index 00000000000..fb8fcf8e9c7
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/4.js
@@ -0,0 +1,7 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+const x4 = 4;
+
+exports.x4 = x4;
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/5.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/5.js
new file mode 100644
index 00000000000..3000d97261f
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/5.js
@@ -0,0 +1,7 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+const x5 = 5;
+
+exports.x5 = x5;
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/main.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/main.js
new file mode 100644
index 00000000000..a1149dc2a55
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/main.js
@@ -0,0 +1,17 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+var _1 = require('./1.js');
+var _2 = require('./2.js');
+var _3 = require('./3.js');
+var _4 = require('./4.js');
+var _5 = require('./5.js');
+
+
+
+exports.x1 = _1.x1;
+exports.x2 = _2.x2;
+exports.x3 = _3.x3;
+exports.x4 = _4.x4;
+exports.x5 = _5.x5;
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/1.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/1.js
new file mode 100644
index 00000000000..12510eaeff9
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/1.js
@@ -0,0 +1,3 @@
+const x1 = 1;
+
+export { x1 };
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/2.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/2.js
new file mode 100644
index 00000000000..07506bd43c2
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/2.js
@@ -0,0 +1,3 @@
+const x2 = 2;
+
+export { x2 };
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/3.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/3.js
new file mode 100644
index 00000000000..b8d139147c2
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/3.js
@@ -0,0 +1,3 @@
+const x3 = 3;
+
+export { x3 };
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/4.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/4.js
new file mode 100644
index 00000000000..a5ad0e2c3ab
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/4.js
@@ -0,0 +1,3 @@
+const x4 = 4;
+
+export { x4 };
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/5.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/5.js
new file mode 100644
index 00000000000..7d8ab15e38a
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/5.js
@@ -0,0 +1,3 @@
+const x5 = 5;
+
+export { x5 };
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/main.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/main.js
new file mode 100644
index 00000000000..f09011e5458
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/main.js
@@ -0,0 +1,5 @@
+export { x1 } from './1.js';
+export { x2 } from './2.js';
+export { x3 } from './3.js';
+export { x4 } from './4.js';
+export { x5 } from './5.js';
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/1.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/1.js
new file mode 100644
index 00000000000..ea55e8b6543
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/1.js
@@ -0,0 +1,10 @@
+System.register([], (function (exports) {
+ 'use strict';
+ return {
+ execute: (function () {
+
+ const x1 = exports('x1', 1);
+
+ })
+ };
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/2.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/2.js
new file mode 100644
index 00000000000..d767f315b3d
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/2.js
@@ -0,0 +1,10 @@
+System.register([], (function (exports) {
+ 'use strict';
+ return {
+ execute: (function () {
+
+ const x2 = exports('x2', 2);
+
+ })
+ };
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/3.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/3.js
new file mode 100644
index 00000000000..646577e6cc6
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/3.js
@@ -0,0 +1,10 @@
+System.register([], (function (exports) {
+ 'use strict';
+ return {
+ execute: (function () {
+
+ const x3 = exports('x3', 3);
+
+ })
+ };
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/4.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/4.js
new file mode 100644
index 00000000000..a9c808201e3
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/4.js
@@ -0,0 +1,10 @@
+System.register([], (function (exports) {
+ 'use strict';
+ return {
+ execute: (function () {
+
+ const x4 = exports('x4', 4);
+
+ })
+ };
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/5.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/5.js
new file mode 100644
index 00000000000..078ad716f50
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/5.js
@@ -0,0 +1,10 @@
+System.register([], (function (exports) {
+ 'use strict';
+ return {
+ execute: (function () {
+
+ const x5 = exports('x5', 5);
+
+ })
+ };
+}));
diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/main.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/main.js
new file mode 100644
index 00000000000..b73aef46e7a
--- /dev/null
+++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/main.js
@@ -0,0 +1,21 @@
+System.register(['./1.js', './2.js', './3.js', './4.js', './5.js'], (function (exports) {
+ 'use strict';
+ return {
+ setters: [function (module) {
+ exports('x1', module.x1);
+ }, function (module) {
+ exports('x2', module.x2);
+ }, function (module) {
+ exports('x3', module.x3);
+ }, function (module) {
+ exports('x4', module.x4);
+ }, function (module) {
+ exports('x5', module.x5);
+ }],
+ execute: (function () {
+
+
+
+ })
+ };
+}));
diff --git a/test/function/samples/max-parallel-file-reads-default/main.js b/test/chunking-form/samples/max-parallel-file-operations/main.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-default/main.js
rename to test/chunking-form/samples/max-parallel-file-operations/main.js
diff --git a/test/function/index.js b/test/function/index.js
index 2651c87f226..ac8fb633d72 100644
--- a/test/function/index.js
+++ b/test/function/index.js
@@ -171,12 +171,12 @@ runTestSuiteWithSamples('function', path.join(__dirname, 'samples'), (dir, confi
});
})
.catch(err => {
- if (config.after) config.after();
if (config.error) {
compareError(err, config.error);
} else {
throw err;
}
+ if (config.after) config.after();
});
}
);
diff --git a/test/function/samples/max-parallel-file-reads-infinity/1.js b/test/function/samples/deprecated/max-parallel-file-reads/infinity/1.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-infinity/1.js
rename to test/function/samples/deprecated/max-parallel-file-reads/infinity/1.js
diff --git a/test/function/samples/max-parallel-file-reads-infinity/2.js b/test/function/samples/deprecated/max-parallel-file-reads/infinity/2.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-infinity/2.js
rename to test/function/samples/deprecated/max-parallel-file-reads/infinity/2.js
diff --git a/test/function/samples/max-parallel-file-reads-infinity/3.js b/test/function/samples/deprecated/max-parallel-file-reads/infinity/3.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-infinity/3.js
rename to test/function/samples/deprecated/max-parallel-file-reads/infinity/3.js
diff --git a/test/function/samples/max-parallel-file-reads-infinity/4.js b/test/function/samples/deprecated/max-parallel-file-reads/infinity/4.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-infinity/4.js
rename to test/function/samples/deprecated/max-parallel-file-reads/infinity/4.js
diff --git a/test/function/samples/max-parallel-file-reads-infinity/5.js b/test/function/samples/deprecated/max-parallel-file-reads/infinity/5.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-infinity/5.js
rename to test/function/samples/deprecated/max-parallel-file-reads/infinity/5.js
diff --git a/test/function/samples/max-parallel-file-reads-infinity/_config.js b/test/function/samples/deprecated/max-parallel-file-reads/infinity/_config.js
similarity index 88%
rename from test/function/samples/max-parallel-file-reads-infinity/_config.js
rename to test/function/samples/deprecated/max-parallel-file-reads/infinity/_config.js
index a694cacbfee..675b373f52d 100644
--- a/test/function/samples/max-parallel-file-reads-infinity/_config.js
+++ b/test/function/samples/deprecated/max-parallel-file-reads/infinity/_config.js
@@ -1,6 +1,6 @@
const assert = require('assert');
const { promises: fs } = require('fs');
-const { wait } = require('../../../utils');
+const { wait } = require('../../../../../utils');
const fsReadFile = fs.readFile;
let currentReads = 0;
@@ -9,6 +9,7 @@ let maxReads = 0;
module.exports = {
description: 'maxParallelFileReads set to infinity',
options: {
+ strictDeprecations: false,
maxParallelFileReads: 0
},
before() {
diff --git a/test/function/samples/max-parallel-file-reads-infinity/main.js b/test/function/samples/deprecated/max-parallel-file-reads/infinity/main.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-infinity/main.js
rename to test/function/samples/deprecated/max-parallel-file-reads/infinity/main.js
diff --git a/test/function/samples/max-parallel-file-reads-set/1.js b/test/function/samples/deprecated/max-parallel-file-reads/set/1.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-set/1.js
rename to test/function/samples/deprecated/max-parallel-file-reads/set/1.js
diff --git a/test/function/samples/max-parallel-file-reads-set/2.js b/test/function/samples/deprecated/max-parallel-file-reads/set/2.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-set/2.js
rename to test/function/samples/deprecated/max-parallel-file-reads/set/2.js
diff --git a/test/function/samples/max-parallel-file-reads-set/3.js b/test/function/samples/deprecated/max-parallel-file-reads/set/3.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-set/3.js
rename to test/function/samples/deprecated/max-parallel-file-reads/set/3.js
diff --git a/test/function/samples/max-parallel-file-reads-set/4.js b/test/function/samples/deprecated/max-parallel-file-reads/set/4.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-set/4.js
rename to test/function/samples/deprecated/max-parallel-file-reads/set/4.js
diff --git a/test/function/samples/max-parallel-file-reads-set/5.js b/test/function/samples/deprecated/max-parallel-file-reads/set/5.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-set/5.js
rename to test/function/samples/deprecated/max-parallel-file-reads/set/5.js
diff --git a/test/function/samples/max-parallel-file-reads-set/_config.js b/test/function/samples/deprecated/max-parallel-file-reads/set/_config.js
similarity index 88%
rename from test/function/samples/max-parallel-file-reads-set/_config.js
rename to test/function/samples/deprecated/max-parallel-file-reads/set/_config.js
index d56a36a76f0..b7e23dd4c46 100644
--- a/test/function/samples/max-parallel-file-reads-set/_config.js
+++ b/test/function/samples/deprecated/max-parallel-file-reads/set/_config.js
@@ -1,6 +1,6 @@
const assert = require('assert');
const { promises: fs } = require('fs');
-const { wait } = require('../../../utils');
+const { wait } = require('../../../../../utils');
const fsReadFile = fs.readFile;
let currentReads = 0;
@@ -9,6 +9,7 @@ let maxReads = 0;
module.exports = {
description: 'maxParallelFileReads set to 3',
options: {
+ strictDeprecations: false,
maxParallelFileReads: 3
},
before() {
diff --git a/test/function/samples/max-parallel-file-reads-set/main.js b/test/function/samples/deprecated/max-parallel-file-reads/set/main.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-set/main.js
rename to test/function/samples/deprecated/max-parallel-file-reads/set/main.js
diff --git a/test/function/samples/max-parallel-file-reads-with-plugin/1.js b/test/function/samples/deprecated/max-parallel-file-reads/with-plugin/1.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-with-plugin/1.js
rename to test/function/samples/deprecated/max-parallel-file-reads/with-plugin/1.js
diff --git a/test/function/samples/max-parallel-file-reads-with-plugin/2.js b/test/function/samples/deprecated/max-parallel-file-reads/with-plugin/2.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-with-plugin/2.js
rename to test/function/samples/deprecated/max-parallel-file-reads/with-plugin/2.js
diff --git a/test/function/samples/max-parallel-file-reads-with-plugin/3.js b/test/function/samples/deprecated/max-parallel-file-reads/with-plugin/3.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-with-plugin/3.js
rename to test/function/samples/deprecated/max-parallel-file-reads/with-plugin/3.js
diff --git a/test/function/samples/max-parallel-file-reads-with-plugin/4.js b/test/function/samples/deprecated/max-parallel-file-reads/with-plugin/4.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-with-plugin/4.js
rename to test/function/samples/deprecated/max-parallel-file-reads/with-plugin/4.js
diff --git a/test/function/samples/max-parallel-file-reads-with-plugin/5.js b/test/function/samples/deprecated/max-parallel-file-reads/with-plugin/5.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-with-plugin/5.js
rename to test/function/samples/deprecated/max-parallel-file-reads/with-plugin/5.js
diff --git a/test/function/samples/max-parallel-file-reads-with-plugin/_config.js b/test/function/samples/deprecated/max-parallel-file-reads/with-plugin/_config.js
similarity index 90%
rename from test/function/samples/max-parallel-file-reads-with-plugin/_config.js
rename to test/function/samples/deprecated/max-parallel-file-reads/with-plugin/_config.js
index e1a81d70409..23524bf811d 100644
--- a/test/function/samples/max-parallel-file-reads-with-plugin/_config.js
+++ b/test/function/samples/deprecated/max-parallel-file-reads/with-plugin/_config.js
@@ -1,6 +1,6 @@
const assert = require('assert');
const { promises: fs } = require('fs');
-const { wait } = require('../../../utils');
+const { wait } = require('../../../../../utils');
const fsReadFile = fs.readFile;
let currentReads = 0;
@@ -9,6 +9,7 @@ let maxReads = 0;
module.exports = {
description: 'maxParallelFileReads with plugin',
options: {
+ strictDeprecations: false,
maxParallelFileReads: 3,
plugins: [
{
diff --git a/test/function/samples/max-parallel-file-reads-with-plugin/main.js b/test/function/samples/deprecated/max-parallel-file-reads/with-plugin/main.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-with-plugin/main.js
rename to test/function/samples/deprecated/max-parallel-file-reads/with-plugin/main.js
diff --git a/test/function/samples/deprecations/maxParallelFileReads/_config.js b/test/function/samples/deprecations/maxParallelFileReads/_config.js
new file mode 100644
index 00000000000..5e17615f59b
--- /dev/null
+++ b/test/function/samples/deprecations/maxParallelFileReads/_config.js
@@ -0,0 +1,11 @@
+module.exports = {
+ description: 'marks the "maxParallelFileReads" option as deprecated',
+ options: {
+ maxParallelFileReads: 3
+ },
+ error: {
+ code: 'DEPRECATED_FEATURE',
+ message:
+ 'The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.'
+ }
+};
diff --git a/test/function/samples/deprecations/maxParallelFileReads/main.js b/test/function/samples/deprecations/maxParallelFileReads/main.js
new file mode 100644
index 00000000000..cc1d88a24fa
--- /dev/null
+++ b/test/function/samples/deprecations/maxParallelFileReads/main.js
@@ -0,0 +1 @@
+assert.ok(true);
diff --git a/test/function/samples/max-parallel-file-operations/default/1.js b/test/function/samples/max-parallel-file-operations/default/1.js
new file mode 100644
index 00000000000..877dd1fbb70
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/default/1.js
@@ -0,0 +1 @@
+export const x1 = 1;
diff --git a/test/function/samples/max-parallel-file-operations/default/2.js b/test/function/samples/max-parallel-file-operations/default/2.js
new file mode 100644
index 00000000000..c269ae0d246
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/default/2.js
@@ -0,0 +1 @@
+export const x2 = 2;
diff --git a/test/function/samples/max-parallel-file-operations/default/3.js b/test/function/samples/max-parallel-file-operations/default/3.js
new file mode 100644
index 00000000000..1c323539956
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/default/3.js
@@ -0,0 +1 @@
+export const x3 = 3;
diff --git a/test/function/samples/max-parallel-file-operations/default/4.js b/test/function/samples/max-parallel-file-operations/default/4.js
new file mode 100644
index 00000000000..1b01b419ace
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/default/4.js
@@ -0,0 +1 @@
+export const x4 = 4;
diff --git a/test/function/samples/max-parallel-file-operations/default/5.js b/test/function/samples/max-parallel-file-operations/default/5.js
new file mode 100644
index 00000000000..734bf3f6f04
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/default/5.js
@@ -0,0 +1 @@
+export const x5 = 5;
diff --git a/test/function/samples/max-parallel-file-reads-default/_config.js b/test/function/samples/max-parallel-file-operations/default/_config.js
similarity index 85%
rename from test/function/samples/max-parallel-file-reads-default/_config.js
rename to test/function/samples/max-parallel-file-operations/default/_config.js
index 321d86a1258..2cb90e7bb43 100644
--- a/test/function/samples/max-parallel-file-reads-default/_config.js
+++ b/test/function/samples/max-parallel-file-operations/default/_config.js
@@ -1,13 +1,13 @@
const assert = require('assert');
const { promises: fs } = require('fs');
-const { wait } = require('../../../utils');
+const { wait } = require('../../../../utils');
const fsReadFile = fs.readFile;
let currentReads = 0;
let maxReads = 0;
module.exports = {
- description: 'maxParallelFileReads not set',
+ description: 'maxParallelFileOps not set',
before() {
fs.readFile = async (path, options) => {
currentReads++;
diff --git a/test/function/samples/max-parallel-file-operations/default/main.js b/test/function/samples/max-parallel-file-operations/default/main.js
new file mode 100644
index 00000000000..5f0a705e464
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/default/main.js
@@ -0,0 +1,5 @@
+export * from './1';
+export * from './2';
+export * from './3';
+export * from './4';
+export * from './5';
diff --git a/test/function/samples/max-parallel-file-reads-error/_config.js b/test/function/samples/max-parallel-file-operations/error/_config.js
similarity index 83%
rename from test/function/samples/max-parallel-file-reads-error/_config.js
rename to test/function/samples/max-parallel-file-operations/error/_config.js
index f35d3d859d6..9fc291548ab 100644
--- a/test/function/samples/max-parallel-file-reads-error/_config.js
+++ b/test/function/samples/max-parallel-file-operations/error/_config.js
@@ -1,11 +1,11 @@
const { promises: fs } = require('fs');
const { join } = require('path');
-const { loader } = require('../../../utils.js');
+const { loader } = require('../../../../utils.js');
const fsReadFile = fs.readFile;
module.exports = {
- description: 'maxParallelFileReads: fileRead error is forwarded',
+ description: 'maxParallelFileOps: fileRead error is forwarded',
options: {
input: 'main',
plugins: loader({
diff --git a/test/function/samples/max-parallel-file-reads-error/dep.js b/test/function/samples/max-parallel-file-operations/error/dep.js
similarity index 100%
rename from test/function/samples/max-parallel-file-reads-error/dep.js
rename to test/function/samples/max-parallel-file-operations/error/dep.js
diff --git a/test/function/samples/max-parallel-file-operations/infinity/1.js b/test/function/samples/max-parallel-file-operations/infinity/1.js
new file mode 100644
index 00000000000..877dd1fbb70
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/infinity/1.js
@@ -0,0 +1 @@
+export const x1 = 1;
diff --git a/test/function/samples/max-parallel-file-operations/infinity/2.js b/test/function/samples/max-parallel-file-operations/infinity/2.js
new file mode 100644
index 00000000000..c269ae0d246
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/infinity/2.js
@@ -0,0 +1 @@
+export const x2 = 2;
diff --git a/test/function/samples/max-parallel-file-operations/infinity/3.js b/test/function/samples/max-parallel-file-operations/infinity/3.js
new file mode 100644
index 00000000000..1c323539956
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/infinity/3.js
@@ -0,0 +1 @@
+export const x3 = 3;
diff --git a/test/function/samples/max-parallel-file-operations/infinity/4.js b/test/function/samples/max-parallel-file-operations/infinity/4.js
new file mode 100644
index 00000000000..1b01b419ace
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/infinity/4.js
@@ -0,0 +1 @@
+export const x4 = 4;
diff --git a/test/function/samples/max-parallel-file-operations/infinity/5.js b/test/function/samples/max-parallel-file-operations/infinity/5.js
new file mode 100644
index 00000000000..734bf3f6f04
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/infinity/5.js
@@ -0,0 +1 @@
+export const x5 = 5;
diff --git a/test/function/samples/max-parallel-file-operations/infinity/_config.js b/test/function/samples/max-parallel-file-operations/infinity/_config.js
new file mode 100644
index 00000000000..ee8134f3204
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/infinity/_config.js
@@ -0,0 +1,28 @@
+const assert = require('assert');
+const { promises: fs } = require('fs');
+const { wait } = require('../../../../utils');
+
+const fsReadFile = fs.readFile;
+let currentReads = 0;
+let maxReads = 0;
+
+module.exports = {
+ description: 'maxParallelFileOps set to infinity',
+ options: {
+ maxParallelFileOps: 0
+ },
+ before() {
+ fs.readFile = async (path, options) => {
+ currentReads++;
+ maxReads = Math.max(maxReads, currentReads);
+ const content = await fsReadFile(path, options);
+ await wait(50);
+ currentReads--;
+ return content;
+ };
+ },
+ after() {
+ fs.readFile = fsReadFile;
+ assert.strictEqual(maxReads, 5, 'Wrong number of parallel file reads: ' + maxReads);
+ }
+};
diff --git a/test/function/samples/max-parallel-file-operations/infinity/main.js b/test/function/samples/max-parallel-file-operations/infinity/main.js
new file mode 100644
index 00000000000..5f0a705e464
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/infinity/main.js
@@ -0,0 +1,5 @@
+export * from './1';
+export * from './2';
+export * from './3';
+export * from './4';
+export * from './5';
diff --git a/test/function/samples/max-parallel-file-operations/set/1.js b/test/function/samples/max-parallel-file-operations/set/1.js
new file mode 100644
index 00000000000..877dd1fbb70
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/set/1.js
@@ -0,0 +1 @@
+export const x1 = 1;
diff --git a/test/function/samples/max-parallel-file-operations/set/2.js b/test/function/samples/max-parallel-file-operations/set/2.js
new file mode 100644
index 00000000000..c269ae0d246
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/set/2.js
@@ -0,0 +1 @@
+export const x2 = 2;
diff --git a/test/function/samples/max-parallel-file-operations/set/3.js b/test/function/samples/max-parallel-file-operations/set/3.js
new file mode 100644
index 00000000000..1c323539956
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/set/3.js
@@ -0,0 +1 @@
+export const x3 = 3;
diff --git a/test/function/samples/max-parallel-file-operations/set/4.js b/test/function/samples/max-parallel-file-operations/set/4.js
new file mode 100644
index 00000000000..1b01b419ace
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/set/4.js
@@ -0,0 +1 @@
+export const x4 = 4;
diff --git a/test/function/samples/max-parallel-file-operations/set/5.js b/test/function/samples/max-parallel-file-operations/set/5.js
new file mode 100644
index 00000000000..734bf3f6f04
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/set/5.js
@@ -0,0 +1 @@
+export const x5 = 5;
diff --git a/test/function/samples/max-parallel-file-operations/set/_config.js b/test/function/samples/max-parallel-file-operations/set/_config.js
new file mode 100644
index 00000000000..f4b5c46cefa
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/set/_config.js
@@ -0,0 +1,28 @@
+const assert = require('assert');
+const { promises: fs } = require('fs');
+const { wait } = require('../../../../utils');
+
+const fsReadFile = fs.readFile;
+let currentReads = 0;
+let maxReads = 0;
+
+module.exports = {
+ description: 'maxParallelFileOps set to 3',
+ options: {
+ maxParallelFileOps: 3
+ },
+ before() {
+ fs.readFile = async (path, options) => {
+ currentReads++;
+ maxReads = Math.max(maxReads, currentReads);
+ const content = await fsReadFile(path, options);
+ await wait(50);
+ currentReads--;
+ return content;
+ };
+ },
+ after() {
+ fs.readFile = fsReadFile;
+ assert.strictEqual(maxReads, 3, 'Wrong number of parallel file reads: ' + maxReads);
+ }
+};
diff --git a/test/function/samples/max-parallel-file-operations/set/main.js b/test/function/samples/max-parallel-file-operations/set/main.js
new file mode 100644
index 00000000000..5f0a705e464
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/set/main.js
@@ -0,0 +1,5 @@
+export * from './1';
+export * from './2';
+export * from './3';
+export * from './4';
+export * from './5';
diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/1.js b/test/function/samples/max-parallel-file-operations/with-plugin/1.js
new file mode 100644
index 00000000000..877dd1fbb70
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/with-plugin/1.js
@@ -0,0 +1 @@
+export const x1 = 1;
diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/2.js b/test/function/samples/max-parallel-file-operations/with-plugin/2.js
new file mode 100644
index 00000000000..c269ae0d246
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/with-plugin/2.js
@@ -0,0 +1 @@
+export const x2 = 2;
diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/3.js b/test/function/samples/max-parallel-file-operations/with-plugin/3.js
new file mode 100644
index 00000000000..1c323539956
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/with-plugin/3.js
@@ -0,0 +1 @@
+export const x3 = 3;
diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/4.js b/test/function/samples/max-parallel-file-operations/with-plugin/4.js
new file mode 100644
index 00000000000..1b01b419ace
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/with-plugin/4.js
@@ -0,0 +1 @@
+export const x4 = 4;
diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/5.js b/test/function/samples/max-parallel-file-operations/with-plugin/5.js
new file mode 100644
index 00000000000..734bf3f6f04
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/with-plugin/5.js
@@ -0,0 +1 @@
+export const x5 = 5;
diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/_config.js b/test/function/samples/max-parallel-file-operations/with-plugin/_config.js
new file mode 100644
index 00000000000..606cb4991a8
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/with-plugin/_config.js
@@ -0,0 +1,35 @@
+const assert = require('assert');
+const { promises: fs } = require('fs');
+const { wait } = require('../../../../utils');
+
+const fsReadFile = fs.readFile;
+let currentReads = 0;
+let maxReads = 0;
+
+module.exports = {
+ description: 'maxParallelFileOps with plugin',
+ options: {
+ maxParallelFileOps: 3,
+ plugins: [
+ {
+ load(id) {
+ return fs.readFile(id, 'utf-8');
+ }
+ }
+ ]
+ },
+ before() {
+ fs.readFile = async (path, options) => {
+ currentReads++;
+ maxReads = Math.max(maxReads, currentReads);
+ const content = await fsReadFile(path, options);
+ await wait(50);
+ currentReads--;
+ return content;
+ };
+ },
+ after() {
+ fs.readFile = fsReadFile;
+ assert.strictEqual(maxReads, 3, 'Wrong number of parallel file reads: ' + maxReads);
+ }
+};
diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/main.js b/test/function/samples/max-parallel-file-operations/with-plugin/main.js
new file mode 100644
index 00000000000..5f0a705e464
--- /dev/null
+++ b/test/function/samples/max-parallel-file-operations/with-plugin/main.js
@@ -0,0 +1,5 @@
+export * from './1';
+export * from './2';
+export * from './3';
+export * from './4';
+export * from './5';
diff --git a/test/function/samples/options-hook/_config.js b/test/function/samples/options-hook/_config.js
index 84e642d66e1..f739ee6252c 100644
--- a/test/function/samples/options-hook/_config.js
+++ b/test/function/samples/options-hook/_config.js
@@ -20,6 +20,7 @@ module.exports = {
experimentalCacheExpiry: 10,
input: ['used'],
makeAbsoluteExternalsRelative: true,
+ maxParallelFileOps: 20,
maxParallelFileReads: 20,
perf: false,
plugins: [
diff --git a/test/misc/optionList.js b/test/misc/optionList.js
index e0abbd63d5d..56c9e595332 100644
--- a/test/misc/optionList.js
+++ b/test/misc/optionList.js
@@ -1,6 +1,6 @@
exports.input =
- 'acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileReads, moduleContext, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch';
+ 'acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, maxParallelFileReads, moduleContext, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch';
exports.flags =
- 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, compact, config, configPlugin, context, d, dir, dynamicImportFunction, e, entryFileNames, environment, esModule, experimentalCacheExpiry, exports, extend, external, externalLiveBindings, f, failAfterWarnings, file, footer, format, freeze, g, generatedCode, globals, h, hoistTransitiveImports, i, indent, inlineDynamicImports, input, interop, intro, m, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileReads, minifyInternalExports, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, p, paths, perf, plugin, plugins, preferConst, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, sanitizeFileName, shimMissingExports, silent, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, w, waitForBundleInput, watch';
+ 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, compact, config, configPlugin, context, d, dir, dynamicImportFunction, e, entryFileNames, environment, esModule, experimentalCacheExpiry, exports, extend, external, externalLiveBindings, f, failAfterWarnings, file, footer, format, freeze, g, generatedCode, globals, h, hoistTransitiveImports, i, indent, inlineDynamicImports, input, interop, intro, m, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, maxParallelFileReads, minifyInternalExports, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, p, paths, perf, plugin, plugins, preferConst, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, sanitizeFileName, shimMissingExports, silent, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, w, waitForBundleInput, watch';
exports.output =
'amd, assetFileNames, banner, chunkFileNames, compact, dir, dynamicImportFunction, entryFileNames, esModule, exports, extend, externalLiveBindings, file, footer, format, freeze, generatedCode, globals, hoistTransitiveImports, indent, inlineDynamicImports, interop, intro, manualChunks, minifyInternalExports, name, namespaceToStringTag, noConflict, outro, paths, plugins, preferConst, preserveModules, preserveModulesRoot, sanitizeFileName, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapPathTransform, strict, systemNullSetters, validate';