| | |
| | | |
| | | /** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */ |
| | | /** @typedef {import("webpack-sources").Source} Source */ |
| | | /** @typedef {import("../declarations/WebpackOptions").DevtoolNamespace} DevtoolNamespace */ |
| | | /** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */ |
| | | /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */ |
| | | /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */ |
| | | /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ |
| | | /** @typedef {import("./Compiler")} Compiler */ |
| | | /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ |
| | | /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */ |
| | | |
| | | /** @type {WeakMap<Source, Source>} */ |
| | | const cache = new WeakMap(); |
| | |
| | | |
| | | class EvalSourceMapDevToolPlugin { |
| | | /** |
| | | * Creates an instance of EvalSourceMapDevToolPlugin. |
| | | * @param {SourceMapDevToolPluginOptions | string=} inputOptions Options object |
| | | */ |
| | | constructor(inputOptions = {}) { |
| | |
| | | } else { |
| | | options = inputOptions; |
| | | } |
| | | /** @type {string} */ |
| | | this.sourceMapComment = |
| | | options.append && typeof options.append !== "function" |
| | | ? options.append |
| | | : "//# sourceURL=[module]\n//# sourceMappingURL=[url]"; |
| | | /** @type {DevtoolModuleFilenameTemplate} */ |
| | | this.moduleFilenameTemplate = |
| | | options.moduleFilenameTemplate || |
| | | "webpack://[namespace]/[resource-path]?[hash]"; |
| | | /** @type {DevtoolNamespace} */ |
| | | this.namespace = options.namespace || ""; |
| | | /** @type {SourceMapDevToolPluginOptions} */ |
| | | this.options = options; |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns result. |
| | | * @param {Source} r result |
| | | * @returns {Source} result |
| | | */ |
| | |
| | | }); |
| | | /** @type {RawSourceMap} */ |
| | | let sourceMap; |
| | | /** @type {string | Buffer} */ |
| | | let content; |
| | | if (source.sourceAndMap) { |
| | | const sourceAndMap = source.sourceAndMap(options); |
| | |
| | | } |
| | | ); |
| | | sourceMap.sources = moduleFilenames; |
| | | sourceMap.ignoreList = options.ignoreList |
| | | ? sourceMap.sources.reduce( |
| | | /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ ( |
| | | (acc, sourceName, idx) => { |
| | | const rule = /** @type {Rules} */ (options.ignoreList); |
| | | if (ModuleFilenameHelpers.matchPart(sourceName, rule)) { |
| | | acc.push(idx); |
| | | } |
| | | return acc; |
| | | if (options.ignoreList) { |
| | | const ignoreList = sourceMap.sources.reduce( |
| | | /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ ( |
| | | (acc, sourceName, idx) => { |
| | | const rule = /** @type {Rules} */ (options.ignoreList); |
| | | if (ModuleFilenameHelpers.matchPart(sourceName, rule)) { |
| | | acc.push(idx); |
| | | } |
| | | ), |
| | | [] |
| | | ) |
| | | : []; |
| | | return acc; |
| | | } |
| | | ), |
| | | [] |
| | | ); |
| | | if (ignoreList.length > 0) { |
| | | sourceMap.ignoreList = ignoreList; |
| | | } |
| | | } |
| | | |
| | | if (options.noSources) { |
| | | sourceMap.sourcesContent = undefined; |