MCPcopy
hub / github.com/webpack/webpack / buildConfiguration

Function buildConfiguration

test/BenchmarkTestCases.benchmark.mjs:280–327  ·  view source on GitHub ↗

* @param {string} test test * @param {Baseline} baseline baseline * @param {Configuration} realConfig real configuration * @param {Scenario} scenario scenario * @param {string} testDirectory test directory * @returns {Configuration} built configuration

(
	test,
	baseline,
	realConfig,
	scenario,
	testDirectory
)

Source from the content-addressed store, hash-verified

278 * @returns {Configuration} built configuration
279 */
280function buildConfiguration(
281 test,
282 baseline,
283 realConfig,
284 scenario,
285 testDirectory
286) {
287 const { watch, ...rest } = scenario;
288 const config = structuredClone({ ...realConfig, ...rest });
289
290 config.entry =
291 typeof config.entry === "string"
292 ? path.resolve(
293 testDirectory,
294 config.entry
295 ? /\.(?:c|m)?js$/.test(config.entry)
296 ? config.entry
297 : `${config.entry}.js`
298 : "./index.js"
299 )
300 : config.entry;
301 config.devtool = config.devtool || false;
302 config.name = `${test}-${baseline.name}-${scenario.name}`;
303 config.context = testDirectory;
304 config.performance = false;
305 config.output = config.output || {};
306 config.output.path = path.join(
307 baseOutputPath,
308 test,
309 `scenario-${scenario.name}`,
310 `baseline-${baseline.name}`
311 );
312 config.plugins = config.plugins || [];
313 if (
314 config.cache &&
315 typeof config.cache !== "boolean" &&
316 config.cache.type === "filesystem"
317 ) {
318 config.cache.cacheDirectory = path.resolve(config.output.path, ".cache");
319 }
320 if (watch) {
321 config.cache = {
322 type: "memory",
323 maxGenerations: 1
324 };
325 }
326 return config;
327}
328
329/**
330 * @param {string} filename filename

Callers 1

registerSuiteFunction · 0.85

Calls 2

resolveMethod · 0.65
testMethod · 0.45

Tested by

no test coverage detected