* Whether the target is universal, i.e. its merged platform is neither * node- nor web-specific (the `"universal"` preset, or arrays like * `["web", "node"]`, `["web", "electron-main"]`, `["web", "node", "webworker"]`), * so the same bundle runs once per env. * @param {EXPECTED_ANY} webpackO
(webpackOptions)
| 116 | * @returns {boolean} whether target is universal |
| 117 | */ |
| 118 | static isUniversalTarget(webpackOptions) { |
| 119 | const outputModule = |
| 120 | (webpackOptions.output && webpackOptions.output.module) || |
| 121 | (webpackOptions.experiments && webpackOptions.experiments.outputModule); |
| 122 | const target = webpackOptions.target; |
| 123 | |
| 124 | const targetProperties = |
| 125 | target === false |
| 126 | ? /** @type {false} */ (false) |
| 127 | : typeof target === "string" |
| 128 | ? getTargetProperties( |
| 129 | target, |
| 130 | /** @type {string} */ (webpackOptions.context) |
| 131 | ) |
| 132 | : getTargetsProperties( |
| 133 | /** @type {string[]} */ (target), |
| 134 | /** @type {string} */ (webpackOptions.context) |
| 135 | ); |
| 136 | const props = |
| 137 | /** @type {import("../../../lib/config/target").TargetProperties} */ ( |
| 138 | targetProperties |
| 139 | ); |
| 140 | return outputModule && props.node === null && props.web === null; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * @param {object} options run options |
no test coverage detected