* Runtime condition expression. * @param {object} options options object * @param {ChunkGraph} options.chunkGraph the chunk graph * @param {RuntimeSpec=} options.runtime runtime for which this code will be generated * @param {RuntimeSpec | boolean=} options.runtimeCondition only execute the
({
chunkGraph,
runtimeCondition,
runtime,
runtimeRequirements
})
| 1002 | * @returns {string} expression |
| 1003 | */ |
| 1004 | runtimeConditionExpression({ |
| 1005 | chunkGraph, |
| 1006 | runtimeCondition, |
| 1007 | runtime, |
| 1008 | runtimeRequirements |
| 1009 | }) { |
| 1010 | if (runtimeCondition === undefined) return "true"; |
| 1011 | if (typeof runtimeCondition === "boolean") return `${runtimeCondition}`; |
| 1012 | /** @type {Set<string>} */ |
| 1013 | const positiveRuntimeIds = new Set(); |
| 1014 | forEachRuntime(runtimeCondition, (runtime) => |
| 1015 | positiveRuntimeIds.add( |
| 1016 | `${chunkGraph.getRuntimeId(/** @type {string} */ (runtime))}` |
| 1017 | ) |
| 1018 | ); |
| 1019 | /** @type {Set<string>} */ |
| 1020 | const negativeRuntimeIds = new Set(); |
| 1021 | forEachRuntime(subtractRuntime(runtime, runtimeCondition), (runtime) => |
| 1022 | negativeRuntimeIds.add( |
| 1023 | `${chunkGraph.getRuntimeId(/** @type {string} */ (runtime))}` |
| 1024 | ) |
| 1025 | ); |
| 1026 | runtimeRequirements.add(RuntimeGlobals.runtimeId); |
| 1027 | return compileBooleanMatcher.fromLists( |
| 1028 | [...positiveRuntimeIds], |
| 1029 | [...negativeRuntimeIds] |
| 1030 | )(RuntimeGlobals.runtimeId); |
| 1031 | } |
| 1032 | |
| 1033 | /** |
| 1034 | * Returns the import statement and the compat statement. |
no test coverage detected