replace-and-update-source-map.d.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import { RawSourceMap } from 'source-map';
  2. /**
  3. * Adapted from https://github.com/nsams/sourcemap-aware-replace, with modern
  4. * JavaScript updates, along with additional properties copied from originalMap.
  5. *
  6. * @param {Object} options
  7. * @param {string} options.jsFilename The name for the file whose contents
  8. * correspond to originalSource.
  9. * @param {Object} options.originalMap The sourcemap for originalSource,
  10. * prior to any replacements.
  11. * @param {string} options.originalSource The source code, prior to any
  12. * replacements.
  13. * @param {string} options.replaceString A string to swap in for searchString.
  14. * @param {string} options.searchString A string in originalSource to replace.
  15. * Only the first occurrence will be replaced.
  16. * @return {{source: string, map: string}} An object containing both
  17. * originalSource with the replacement applied, and the modified originalMap.
  18. *
  19. * @private
  20. */
  21. export declare function replaceAndUpdateSourceMap({ jsFilename, originalMap, originalSource, replaceString, searchString, }: {
  22. jsFilename: string;
  23. originalMap: RawSourceMap;
  24. originalSource: string;
  25. replaceString: string;
  26. searchString: string;
  27. }): Promise<{
  28. map: string;
  29. source: string;
  30. }>;