static getModuleReplaceSource()

in packages/extract-svg-sprite-webpack-plugin/lib/utils/replacer.js [34:73]


  static getModuleReplaceSource(module, compilation) {
    const {
      dependencyTemplates,
      outputOptions,
      requestShortener,
      runtimeTemplate,
      moduleGraph,
      chunkGraph
    } = compilation;

    const args = [];

    // webpack 5
    if (moduleGraph && chunkGraph) {
      args.push({
        dependencyTemplates,
        runtimeTemplate,
        moduleGraph,
        chunkGraph
      });
    } else {
      args.push(dependencyTemplates);

      // webpack 3
      if (!runtimeTemplate) {
        args.push(outputOptions);
        args.push(requestShortener);
      }
      // webpack 4
      else {
        args.push(runtimeTemplate);
      }
    }

    const cachedSource = module.source(...args);

    return typeof cachedSource.replace === 'function'
      ? cachedSource
      : cachedSource._source;
  }