MCPcopy
hub / github.com/webpack/webpack / getTaskForFile

Function getTaskForFile

lib/SourceMapDevToolPlugin.js:171–202  ·  view source on GitHub ↗
(
	file,
	asset,
	assetInfo,
	options,
	compilation,
	cacheItem,
	registry
)

Source from the content-addressed store, hash-verified

169 * @returns {SourceMapTask | undefined} created task instance or `undefined`
170 */
171const getTaskForFile = (
172 file,
173 asset,
174 assetInfo,
175 options,
176 compilation,
177 cacheItem,
178 registry
179) => {
180 const extracted = extractSourceAndMap(file, asset, options, registry);
181 if (!extracted) return;
182 const { source, sourceMap, mapSource } = extracted;
183 const context = compilation.options.context;
184 const root = compilation.compiler.root;
185 const cachedAbsolutify = makePathsAbsolute.bindContextCache(context, root);
186 const modules = sourceMap.sources.map((source) => {
187 if (!source.startsWith("webpack://")) return source;
188 source = cachedAbsolutify(source.slice(10));
189 const module = compilation.findModule(source);
190 return module || source;
191 });
192
193 return {
194 file,
195 source: /** @type {string} */ (source),
196 assetInfo,
197 sourceMap,
198 mapSource,
199 modules,
200 cacheItem
201 };
202};
203
204const PLUGIN_NAME = "SourceMapDevToolPlugin";
205

Callers 1

applyMethod · 0.85

Calls 3

extractSourceAndMapFunction · 0.85
sliceMethod · 0.80
findModuleMethod · 0.80

Tested by

no test coverage detected