* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler compiler instance * @returns {void}
(compiler)
| 282 | * @returns {void} |
| 283 | */ |
| 284 | apply(compiler) { |
| 285 | compiler.hooks.validate.tap(PLUGIN_NAME, () => { |
| 286 | compiler.validate( |
| 287 | () => require(class="st">"../schemas/plugins/SourceMapDevToolPlugin.json"), |
| 288 | this.options, |
| 289 | { |
| 290 | name: class="st">"SourceMap DevTool Plugin", |
| 291 | baseDataPath: class="st">"options" |
| 292 | }, |
| 293 | (options) => |
| 294 | require(class="st">"../schemas/plugins/SourceMapDevToolPlugin.check")(options) |
| 295 | ); |
| 296 | }); |
| 297 | |
| 298 | const outputFs = |
| 299 | /** @type {OutputFileSystem} */ |
| 300 | (compiler.outputFileSystem); |
| 301 | const sourceMapFilename = this.sourceMapFilename; |
| 302 | const sourceMappingURLComment = this.sourceMappingURLComment; |
| 303 | const moduleFilenameTemplate = this.moduleFilenameTemplate; |
| 304 | const namespace = this.namespace; |
| 305 | const fallbackModuleFilenameTemplate = this.fallbackModuleFilenameTemplate; |
| 306 | const requestShortener = compiler.requestShortener; |
| 307 | const options = this.options; |
| 308 | options.test = options.test || CSS_AND_JS_MODULE_EXTENSIONS_REGEXP; |
| 309 | |
| 310 | /** @type {(filename: string) => boolean} */ |
| 311 | const matchObject = ModuleFilenameHelpers.matchObject.bind( |
| 312 | undefined, |
| 313 | options |
| 314 | ); |
| 315 | |
| 316 | compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { |
| 317 | new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation); |
| 318 | |
| 319 | class="cm">// All SourceMapDevToolPlugin instances on the same compilation share |
| 320 | class="cm">// a registry of pristine asset sources, so the second instance to |
| 321 | class="cm">// run can still recover the original map after the first instance |
| 322 | class="cm">// has replaced the asset with a `RawSource`. The registry lives on a |
| 323 | class="cm">// module-scoped `WeakMap` keyed by compilation so it is released |
| 324 | class="cm">// automatically and never pollutes the compilation object. |
| 325 | const originalSources = getOriginalSourceRegistry(compilation); |
| 326 | |
| 327 | compilation.hooks.processAssets.tapAsync( |
| 328 | { |
| 329 | name: PLUGIN_NAME, |
| 330 | stage: Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING, |
| 331 | additionalAssets: true |
| 332 | }, |
| 333 | (assets, callback) => { |
| 334 | const chunkGraph = compilation.chunkGraph; |
| 335 | const cache = compilation.getCache(PLUGIN_NAME); |
| 336 | /** @type {Map<string | Module, string>} */ |
| 337 | const moduleToSourceNameMapping = new Map(); |
| 338 | const reportProgress = |
| 339 | ProgressPlugin.getReporter(compilation.compiler) || (() => {}); |
| 340 | |
| 341 | /** @type {Map<string, Chunk>} */ |
nothing calls this directly
no test coverage detected