MCPcopy
hub / github.com/webpack/webpack / isUniversalTarget

Method isUniversalTarget

test/harness/runner/index.js:118–141  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 2

describeCasesFunction · 0.45
runBundlesMethod · 0.45

Calls 2

getTargetPropertiesFunction · 0.85
getTargetsPropertiesFunction · 0.85

Tested by

no test coverage detected