MCPcopy
hub / github.com/webpack/webpack / applyConfig

Function applyConfig

test/WatchTestCases.template.js:162–240  ·  view source on GitHub ↗
(
								/** @type {import("../").Configuration} */ options,
								/** @type {number} */ idx
							)

Source from the content-addressed store, hash-verified

160 });
161 }
162 const applyConfig = (
163 /** @type {import("../").Configuration} */ options,
164 /** @type {number} */ idx
165 ) => {
166 if (!options.mode) options.mode = "development";
167 if (!options.context) options.context = tempDirectory;
168 if (!options.entry) options.entry = "./index.js";
169 if (!options.target) options.target = "async-node";
170 if (!options.output) options.output = {};
171 if (!options.output.environment) {
172 options.output.environment = {};
173 }
174 if (
175 options.output.environment.optionalChaining === undefined &&
176 !supportsOptionalChaining()
177 ) {
178 // generated runtime runs in this Node.js process; avoid `?.` on Node < 14
179 options.output.environment.optionalChaining = false;
180 }
181 if (
182 options.output.environment.hasOwn === undefined &&
183 !supportsObjectHasOwn()
184 ) {
185 // generated runtime runs in this Node.js process; avoid `Object.hasOwn` on Node < 16.9
186 options.output.environment.hasOwn = false;
187 }
188 if (options.output.clean === undefined) {
189 options.output.clean = true;
190 }
191 if (!options.output.path) options.output.path = outputDirectory;
192 if (typeof options.output.pathinfo === "undefined") {
193 options.output.pathinfo = true;
194 }
195 if (!options.output.filename) {
196 options.output.filename = `bundle${
197 options.experiments && options.experiments.outputModule
198 ? ".mjs"
199 : ".js"
200 }`;
201 }
202 if (
203 options.cache &&
204 /** @type {import("../").FileCacheOptions} */ (options.cache)
205 .type === "filesystem"
206 ) {
207 const cacheDirectory = path.join(tempDirectory, ".cache");
208 /** @type {import("../").FileCacheOptions} */ (
209 options.cache
210 ).cacheDirectory = cacheDirectory;
211 /** @type {import("../").FileCacheOptions} */ (
212 options.cache
213 ).name = `config-${idx}`;
214 }
215 if (config.experiments) {
216 if (!options.experiments) options.experiments = {};
217 for (const key of Object.keys(config.experiments)) {
218 if (
219 /** @type {EXPECTED_ANY} */ (options.experiments)[key] ===

Callers 1

describeCasesFunction · 0.85

Calls 1

keysMethod · 0.65

Tested by

no test coverage detected